OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_SEARCH_INSTANT_UNITTEST_BASE_H_ | 5 #ifndef CHROME_BROWSER_SEARCH_INSTANT_UNITTEST_BASE_H_ |
6 #define CHROME_BROWSER_SEARCH_INSTANT_UNITTEST_BASE_H_ | 6 #define CHROME_BROWSER_SEARCH_INSTANT_UNITTEST_BASE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/metrics/field_trial.h" | 10 #include "base/metrics/field_trial.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "chrome/browser/search/instant_service.h" | 12 #include "chrome/browser/search/instant_service.h" |
13 #include "chrome/test/base/browser_with_test_window_test.h" | 13 #include "chrome/test/base/browser_with_test_window_test.h" |
14 #include "components/search_engines/template_url_service.h" | 14 #include "components/search_engines/template_url_service.h" |
15 | 15 |
16 class InstantServiceObserver; | 16 class InstantServiceObserver; |
17 | 17 |
18 // This class provides an extension on top of BrowserWithTestWindowTest, and | 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 | 19 // adds some utility methods which can be useful for various unit tests for |
20 // Embedded Search / Instant implementation classes. | 20 // Embedded Search / Instant implementation classes. |
21 class InstantUnitTestBase : public BrowserWithTestWindowTest { | 21 class InstantUnitTestBase : public BrowserWithTestWindowTest { |
22 protected: | 22 protected: |
23 InstantUnitTestBase(); | 23 InstantUnitTestBase(); |
24 ~InstantUnitTestBase() override; | 24 ~InstantUnitTestBase() override; |
25 | 25 |
26 void SetUp() override; | 26 void SetUp() override; |
27 void TearDown() override; | 27 void TearDown() override; |
28 | 28 |
29 #if !defined(OS_ANDROID) | |
30 // Query extraction is always enabled on Android and iOS. | |
31 void SetUpWithoutQueryExtraction(); | |
32 #endif | |
33 | |
34 // Adds and sets the default search provider using the base_url. | 29 // 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 | 30 // The base_url should have the http[s]:// prefix and a trailing / after the |
36 // TLD. | 31 // TLD. |
37 // It will always use an instant-enabled configuration using a | 32 // It will always use an instant-enabled configuration using a |
38 // search_terms_replacement_key. | 33 // search_terms_replacement_key. |
39 void SetUserSelectedDefaultSearchProvider(const std::string& base_url); | 34 void SetUserSelectedDefaultSearchProvider(const std::string& base_url); |
40 | 35 |
41 // Simulates a Google Base URL change as would happen in event of | 36 // Simulates a Google Base URL change as would happen in event of |
42 // search-domain-check. Note that the GoogleURLTrackerFactory is disabled for | 37 // search-domain-check. Note that the GoogleURLTrackerFactory is disabled for |
43 // tests, so this is required. | 38 // tests, so this is required. |
44 void NotifyGoogleBaseURLUpdate(const std::string& new_google_base_url); | 39 void NotifyGoogleBaseURLUpdate(const std::string& new_google_base_url); |
45 | 40 |
46 bool IsInstantServiceObserver(const InstantServiceObserver* observer) const; | 41 bool IsInstantServiceObserver(const InstantServiceObserver* observer) const; |
47 | 42 |
48 InstantService* instant_service_; | 43 InstantService* instant_service_; |
49 TemplateURLService* template_url_service_; | 44 TemplateURLService* template_url_service_; |
50 std::unique_ptr<base::FieldTrialList> field_trial_list_; | 45 std::unique_ptr<base::FieldTrialList> field_trial_list_; |
51 | 46 |
52 private: | 47 private: |
53 // BrowserWithTestWindowTest override: | 48 // BrowserWithTestWindowTest override: |
54 TestingProfile* CreateProfile() override; | 49 TestingProfile* CreateProfile() override; |
55 | |
56 void SetUpHelper(); | |
57 }; | 50 }; |
58 | 51 |
59 #endif // CHROME_BROWSER_SEARCH_INSTANT_UNITTEST_BASE_H_ | 52 #endif // CHROME_BROWSER_SEARCH_INSTANT_UNITTEST_BASE_H_ |
OLD | NEW |