[email protected] | c8a118e | 2013-09-24 21:33:40 | [diff] [blame] | 1 | // 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] | 1ddfd9a | 2013-11-15 00:12:20 | [diff] [blame] | 10 | #include "base/metrics/field_trial.h" |
avi | b896c71 | 2015-12-26 02:10:43 | [diff] [blame] | 11 | #include "build/build_config.h" |
[email protected] | c8a118e | 2013-09-24 21:33:40 | [diff] [blame] | 12 | #include "chrome/browser/search/instant_service.h" |
[email protected] | c8a118e | 2013-09-24 21:33:40 | [diff] [blame] | 13 | #include "chrome/test/base/browser_with_test_window_test.h" |
[email protected] | bf5c532d | 2014-07-05 00:29:53 | [diff] [blame] | 14 | #include "components/search_engines/template_url_service.h" |
[email protected] | c8a118e | 2013-09-24 21:33:40 | [diff] [blame] | 15 | |
16 | class InstantServiceObserver; | ||||
17 | |||||
18 | // This class provides an extension on top of BrowserWithTestWindowTest, and | ||||
19 | // adds some utility methods which can be useful for various unit tests for | ||||
20 | // Embedded Search / Instant implementation classes. | ||||
21 | class InstantUnitTestBase : public BrowserWithTestWindowTest { | ||||
22 | protected: | ||||
[email protected] | 1ddfd9a | 2013-11-15 00:12:20 | [diff] [blame] | 23 | InstantUnitTestBase(); |
dcheng | e1bc798 | 2014-10-30 00:32:40 | [diff] [blame] | 24 | ~InstantUnitTestBase() override; |
[email protected] | 1ddfd9a | 2013-11-15 00:12:20 | [diff] [blame] | 25 | |
dcheng | e1bc798 | 2014-10-30 00:32:40 | [diff] [blame] | 26 | void SetUp() override; |
27 | void TearDown() override; | ||||
[email protected] | c8a118e | 2013-09-24 21:33:40 | [diff] [blame] | 28 | |
jam | 1c5a9149 | 2016-02-24 20:47:53 | [diff] [blame] | 29 | #if !defined(OS_ANDROID) |
[email protected] | 50da190 | 2014-02-14 02:40:19 | [diff] [blame] | 30 | // Query extraction is always enabled on Android and iOS. |
31 | void SetUpWithoutQueryExtraction(); | ||||
32 | #endif | ||||
[email protected] | 1ddfd9a | 2013-11-15 00:12:20 | [diff] [blame] | 33 | |
[email protected] | c8a118e | 2013-09-24 21:33:40 | [diff] [blame] | 34 | // Adds and sets the default search provider using the base_url. |
35 | // The base_url should have the http[s]:// prefix and a trailing / after the | ||||
36 | // TLD. | ||||
37 | // It will always use an instant-enabled configuration using a | ||||
38 | // search_terms_replacement_key. | ||||
[email protected] | f1cb558 | 2014-04-25 07:35:26 | [diff] [blame] | 39 | void SetUserSelectedDefaultSearchProvider(const std::string& base_url); |
[email protected] | c8a118e | 2013-09-24 21:33:40 | [diff] [blame] | 40 | |
41 | // Simulates a Google Base URL change as would happen in event of | ||||
42 | // search-domain-check. Note that the GoogleURLTrackerFactory is disabled for | ||||
43 | // tests, so this is required. | ||||
44 | void NotifyGoogleBaseURLUpdate(const std::string& new_google_base_url); | ||||
45 | |||||
mgiuca | 64ccf236 | 2014-11-10 06:44:23 | [diff] [blame] | 46 | bool IsInstantServiceObserver(const InstantServiceObserver* observer) const; |
[email protected] | c8a118e | 2013-09-24 21:33:40 | [diff] [blame] | 47 | |
48 | InstantService* instant_service_; | ||||
49 | TemplateURLService* template_url_service_; | ||||
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame^] | 50 | std::unique_ptr<base::FieldTrialList> field_trial_list_; |
[email protected] | 50da190 | 2014-02-14 02:40:19 | [diff] [blame] | 51 | |
52 | private: | ||||
[email protected] | c4b2af2 | 2014-05-11 19:48:53 | [diff] [blame] | 53 | // BrowserWithTestWindowTest override: |
Daniel Cheng | a542fca | 2014-10-21 09:51:29 | [diff] [blame] | 54 | TestingProfile* CreateProfile() override; |
[email protected] | c4b2af2 | 2014-05-11 19:48:53 | [diff] [blame] | 55 | |
[email protected] | 50da190 | 2014-02-14 02:40:19 | [diff] [blame] | 56 | void SetUpHelper(); |
[email protected] | c8a118e | 2013-09-24 21:33:40 | [diff] [blame] | 57 | }; |
58 | |||||
59 | #endif // CHROME_BROWSER_SEARCH_INSTANT_UNITTEST_BASE_H_ |