blob: 6dd420b4afefe23a1b1e5faebe649310bac58e40 [file] [log] [blame]
[email protected]c8a118e2013-09-24 21:33:401// Copyright 2013 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_SEARCH_INSTANT_UNITTEST_BASE_H_
6#define CHROME_BROWSER_SEARCH_INSTANT_UNITTEST_BASE_H_
7
8#include <string>
9
[email protected]1ddfd9a2013-11-15 00:12:2010#include "base/metrics/field_trial.h"
[email protected]c8a118e2013-09-24 21:33:4011#include "chrome/browser/search/instant_service.h"
[email protected]c8a118e2013-09-24 21:33:4012#include "chrome/test/base/browser_with_test_window_test.h"
[email protected]bf5c532d2014-07-05 00:29:5313#include "components/search_engines/template_url_service.h"
[email protected]c8a118e2013-09-24 21:33:4014
15class InstantServiceObserver;
16
17// This class provides an extension on top of BrowserWithTestWindowTest, and
18// adds some utility methods which can be useful for various unit tests for
19// Embedded Search / Instant implementation classes.
20class InstantUnitTestBase : public BrowserWithTestWindowTest {
21 protected:
[email protected]1ddfd9a2013-11-15 00:12:2022 InstantUnitTestBase();
23 virtual ~InstantUnitTestBase();
24
[email protected]c8a118e2013-09-24 21:33:4025 virtual void SetUp() OVERRIDE;
26 virtual void TearDown() OVERRIDE;
27
[email protected]50da1902014-02-14 02:40:1928#if !defined(OS_IOS) && !defined(OS_ANDROID)
29 // Query extraction is always enabled on Android and iOS.
30 void SetUpWithoutQueryExtraction();
31#endif
[email protected]1ddfd9a2013-11-15 00:12:2032
[email protected]c8a118e2013-09-24 21:33:4033 // Adds and sets the default search provider using the base_url.
34 // The base_url should have the http[s]:// prefix and a trailing / after the
35 // TLD.
36 // It will always use an instant-enabled configuration using a
37 // search_terms_replacement_key.
[email protected]f1cb5582014-04-25 07:35:2638 void SetUserSelectedDefaultSearchProvider(const std::string& base_url);
[email protected]c8a118e2013-09-24 21:33:4039
40 // Simulates a Google Base URL change as would happen in event of
41 // search-domain-check. Note that the GoogleURLTrackerFactory is disabled for
42 // tests, so this is required.
43 void NotifyGoogleBaseURLUpdate(const std::string& new_google_base_url);
44
45 bool IsInstantServiceObserver(InstantServiceObserver* observer);
46
47 InstantService* instant_service_;
48 TemplateURLService* template_url_service_;
[email protected]1ddfd9a2013-11-15 00:12:2049 scoped_ptr<base::FieldTrialList> field_trial_list_;
[email protected]50da1902014-02-14 02:40:1950
51 private:
[email protected]c4b2af22014-05-11 19:48:5352 // BrowserWithTestWindowTest override:
53 virtual TestingProfile* CreateProfile() OVERRIDE;
54
[email protected]50da1902014-02-14 02:40:1955 void SetUpHelper();
[email protected]c8a118e2013-09-24 21:33:4056};
57
58#endif // CHROME_BROWSER_SEARCH_INSTANT_UNITTEST_BASE_H_