Chromium Code Reviews| 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 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/memory/scoped_vector.h" | 8 #include "base/memory/scoped_vector.h" |
| 9 #include "base/metrics/field_trial.h" | |
| 9 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/search/instant_service.h" | 11 #include "chrome/browser/search/instant_service.h" |
| 11 #include "chrome/browser/search/instant_service_observer.h" | 12 #include "chrome/browser/search/instant_service_observer.h" |
| 12 #include "chrome/browser/search/instant_unittest_base.h" | 13 #include "chrome/browser/search/instant_unittest_base.h" |
| 13 #include "chrome/browser/search/search.h" | 14 #include "chrome/browser/search/search.h" |
| 14 #include "chrome/browser/ui/browser_instant_controller.h" | 15 #include "chrome/browser/ui/browser_instant_controller.h" |
| 15 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 16 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 17 #include "chrome/common/url_constants.h" | 18 #include "chrome/common/url_constants.h" |
| 18 #include "content/public/browser/navigation_controller.h" | 19 #include "content/public/browser/navigation_controller.h" |
| 19 #include "content/public/browser/render_process_host.h" | 20 #include "content/public/browser/render_process_host.h" |
| 20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 21 #include "content/public/browser/web_contents_observer.h" | 22 #include "content/public/browser/web_contents_observer.h" |
| 22 | 23 |
| 23 namespace chrome { | 24 namespace chrome { |
| 24 | 25 |
| 25 namespace { | 26 namespace { |
| 26 | 27 |
| 27 class BrowserInstantControllerTest : public InstantUnitTestBase { | 28 class BrowserInstantControllerTest : public InstantUnitTestBase { |
| 28 protected: | 29 protected: |
| 29 friend class FakeWebContentsObserver; | 30 friend class FakeWebContentsObserver; |
| 30 }; | 31 }; |
| 31 | 32 |
| 33 class BrowserInstantControllerEmbeddedTest : public InstantUnitTestBase { | |
|
Peter Kasting
2014/05/06 19:49:00
Why not just do this on BrowserInstantControllerTe
Cait (Slow)
2014/05/06 20:10:53
I tried this and it broke GoogleBaseURLUpdated to
| |
| 34 public: | |
| 35 virtual void SetUp() OVERRIDE { | |
| 36 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | |
| 37 "EmbeddedSearch", "Group1 use_cacheable_ntp:1 prefetch_results:1")); | |
| 38 InstantUnitTestBase::SetUp(); | |
| 39 } | |
| 40 | |
| 41 protected: | |
| 42 friend class FakeWebContentsObserver; | |
| 43 }; | |
| 44 | |
| 32 const struct TabReloadTestCase { | 45 const struct TabReloadTestCase { |
| 33 const char* description; | 46 const char* description; |
| 34 const char* start_url; | 47 const char* start_url; |
| 35 bool start_in_instant_process; | 48 bool start_in_instant_process; |
| 36 bool should_reload; | 49 bool should_reload; |
| 37 bool end_in_instant_process; | 50 bool end_in_instant_process; |
| 38 } kTabReloadTestCases[] = { | 51 } kTabReloadTestCases[] = { |
| 39 {"Local Embedded NTP", chrome::kChromeSearchLocalNtpUrl, | 52 {"Local Embedded NTP", chrome::kChromeSearchLocalNtpUrl, |
| 40 true, true, true}, | 53 true, true, true}, |
| 41 {"Remote Embedded NTP", "https://www.google.com/instant?strk", | 54 {"Remote Embedded NTP", "https://www.google.com/instant?strk", |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 75 DefaultSearchProviderChanged); | 88 DefaultSearchProviderChanged); |
| 76 FRIEND_TEST_ALL_PREFIXES(BrowserInstantControllerTest, | 89 FRIEND_TEST_ALL_PREFIXES(BrowserInstantControllerTest, |
| 77 GoogleBaseURLUpdated); | 90 GoogleBaseURLUpdated); |
| 78 | 91 |
| 79 private: | 92 private: |
| 80 content::WebContents* contents_; | 93 content::WebContents* contents_; |
| 81 const GURL& url_; | 94 const GURL& url_; |
| 82 int num_reloads_; | 95 int num_reloads_; |
| 83 }; | 96 }; |
| 84 | 97 |
| 85 TEST_F(BrowserInstantControllerTest, DefaultSearchProviderChanged) { | 98 TEST_F(BrowserInstantControllerEmbeddedTest, DefaultSearchProviderChanged) { |
| 86 size_t num_tests = arraysize(kTabReloadTestCases); | 99 size_t num_tests = arraysize(kTabReloadTestCases); |
| 87 ScopedVector<FakeWebContentsObserver> observers; | 100 ScopedVector<FakeWebContentsObserver> observers; |
| 88 for (size_t i = 0; i < num_tests; ++i) { | 101 for (size_t i = 0; i < num_tests; ++i) { |
| 89 const TabReloadTestCase& test = kTabReloadTestCases[i]; | 102 const TabReloadTestCase& test = kTabReloadTestCases[i]; |
| 90 AddTab(browser(), GURL(test.start_url)); | 103 AddTab(browser(), GURL(test.start_url)); |
| 91 content::WebContents* contents = | 104 content::WebContents* contents = |
| 92 browser()->tab_strip_model()->GetActiveWebContents(); | 105 browser()->tab_strip_model()->GetActiveWebContents(); |
| 93 | 106 |
| 94 // Validate initial instant state. | 107 // Validate initial instant state. |
| 95 EXPECT_EQ(test.start_in_instant_process, | 108 EXPECT_EQ(test.start_in_instant_process, |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 172 | 185 |
| 173 browser.reset(NULL); | 186 browser.reset(NULL); |
| 174 window.reset(NULL); | 187 window.reset(NULL); |
| 175 EXPECT_FALSE(IsInstantServiceObserver(bic)) | 188 EXPECT_FALSE(IsInstantServiceObserver(bic)) |
| 176 << "New BrowserInstantController should register as InstantServiceObserver"; | 189 << "New BrowserInstantController should register as InstantServiceObserver"; |
| 177 } | 190 } |
| 178 | 191 |
| 179 } // namespace | 192 } // namespace |
| 180 | 193 |
| 181 } // namespace chrome | 194 } // namespace chrome |
| OLD | NEW |