Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(591)

Side by Side Diff: chrome/browser/ui/search/instant_extended_interactive_uitest.cc

Issue 671653002: Standardize usage of virtual/override/final in chrome/browser/ui/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <sstream> 5 #include <sstream>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/metrics/histogram_base.h" 8 #include "base/metrics/histogram_base.h"
9 #include "base/metrics/histogram_samples.h" 9 #include "base/metrics/histogram_samples.h"
10 #include "base/metrics/statistics_recorder.h" 10 #include "base/metrics/statistics_recorder.h"
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 using testing::HasSubstr; 83 using testing::HasSubstr;
84 84
85 namespace { 85 namespace {
86 86
87 // Task used to make sure history has finished processing a request. Intended 87 // Task used to make sure history has finished processing a request. Intended
88 // for use with BlockUntilHistoryProcessesPendingRequests. 88 // for use with BlockUntilHistoryProcessesPendingRequests.
89 class QuittingHistoryDBTask : public history::HistoryDBTask { 89 class QuittingHistoryDBTask : public history::HistoryDBTask {
90 public: 90 public:
91 QuittingHistoryDBTask() {} 91 QuittingHistoryDBTask() {}
92 92
93 virtual bool RunOnDBThread(history::HistoryBackend* backend, 93 bool RunOnDBThread(history::HistoryBackend* backend,
94 history::HistoryDatabase* db) override { 94 history::HistoryDatabase* db) override {
95 return true; 95 return true;
96 } 96 }
97 97
98 virtual void DoneRunOnMainThread() override { 98 void DoneRunOnMainThread() override { base::MessageLoop::current()->Quit(); }
99 base::MessageLoop::current()->Quit();
100 }
101 99
102 private: 100 private:
103 virtual ~QuittingHistoryDBTask() {} 101 ~QuittingHistoryDBTask() override {}
104 102
105 DISALLOW_COPY_AND_ASSIGN(QuittingHistoryDBTask); 103 DISALLOW_COPY_AND_ASSIGN(QuittingHistoryDBTask);
106 }; 104 };
107 105
108 class FakeNetworkChangeNotifier : public net::NetworkChangeNotifier { 106 class FakeNetworkChangeNotifier : public net::NetworkChangeNotifier {
109 public: 107 public:
110 FakeNetworkChangeNotifier() : connection_type_(CONNECTION_NONE) {} 108 FakeNetworkChangeNotifier() : connection_type_(CONNECTION_NONE) {}
111 109
112 virtual ConnectionType GetCurrentConnectionType() const override { 110 ConnectionType GetCurrentConnectionType() const override {
113 return connection_type_; 111 return connection_type_;
114 } 112 }
115 113
116 void SetConnectionType(ConnectionType type) { 114 void SetConnectionType(ConnectionType type) {
117 connection_type_ = type; 115 connection_type_ = type;
118 NotifyObserversOfNetworkChange(type); 116 NotifyObserversOfNetworkChange(type);
119 base::RunLoop().RunUntilIdle(); 117 base::RunLoop().RunUntilIdle();
120 } 118 }
121 119
122 virtual ~FakeNetworkChangeNotifier() {} 120 ~FakeNetworkChangeNotifier() override {}
123 121
124 private: 122 private:
125 ConnectionType connection_type_; 123 ConnectionType connection_type_;
126 DISALLOW_COPY_AND_ASSIGN(FakeNetworkChangeNotifier); 124 DISALLOW_COPY_AND_ASSIGN(FakeNetworkChangeNotifier);
127 }; 125 };
128 } // namespace 126 } // namespace
129 127
130 class InstantExtendedTest : public InProcessBrowserTest, 128 class InstantExtendedTest : public InProcessBrowserTest,
131 public InstantTestBase { 129 public InstantTestBase {
132 public: 130 public:
133 InstantExtendedTest() 131 InstantExtendedTest()
134 : on_most_visited_change_calls_(0), 132 : on_most_visited_change_calls_(0),
135 most_visited_items_count_(0), 133 most_visited_items_count_(0),
136 first_most_visited_item_id_(0), 134 first_most_visited_item_id_(0),
137 on_native_suggestions_calls_(0), 135 on_native_suggestions_calls_(0),
138 on_change_calls_(0), 136 on_change_calls_(0),
139 submit_count_(0), 137 submit_count_(0),
140 on_esc_key_press_event_calls_(0), 138 on_esc_key_press_event_calls_(0),
141 on_focus_changed_calls_(0), 139 on_focus_changed_calls_(0),
142 is_focused_(false), 140 is_focused_(false),
143 on_toggle_voice_search_calls_(0) { 141 on_toggle_voice_search_calls_(0) {
144 } 142 }
145 protected: 143 protected:
146 virtual void SetUpInProcessBrowserTestFixture() override { 144 void SetUpInProcessBrowserTestFixture() override {
147 chrome::EnableQueryExtractionForTesting(); 145 chrome::EnableQueryExtractionForTesting();
148 ASSERT_TRUE(https_test_server().Start()); 146 ASSERT_TRUE(https_test_server().Start());
149 GURL instant_url = https_test_server().GetURL( 147 GURL instant_url = https_test_server().GetURL(
150 "files/instant_extended.html?strk=1&"); 148 "files/instant_extended.html?strk=1&");
151 GURL ntp_url = https_test_server().GetURL( 149 GURL ntp_url = https_test_server().GetURL(
152 "files/instant_extended_ntp.html?strk=1&"); 150 "files/instant_extended_ntp.html?strk=1&");
153 InstantTestBase::Init(instant_url, ntp_url, false); 151 InstantTestBase::Init(instant_url, ntp_url, false);
154 } 152 }
155 153
156 int64 GetHistogramCount(const char* name) { 154 int64 GetHistogramCount(const char* name) {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 std::string prefetch_query_value_; 249 std::string prefetch_query_value_;
252 }; 250 };
253 251
254 class InstantExtendedPrefetchTest : public InstantExtendedTest { 252 class InstantExtendedPrefetchTest : public InstantExtendedTest {
255 public: 253 public:
256 InstantExtendedPrefetchTest() 254 InstantExtendedPrefetchTest()
257 : factory_(new net::URLFetcherImplFactory()), 255 : factory_(new net::URLFetcherImplFactory()),
258 fake_factory_(new net::FakeURLFetcherFactory(factory_.get())) { 256 fake_factory_(new net::FakeURLFetcherFactory(factory_.get())) {
259 } 257 }
260 258
261 virtual void SetUpInProcessBrowserTestFixture() override { 259 void SetUpInProcessBrowserTestFixture() override {
262 chrome::EnableQueryExtractionForTesting(); 260 chrome::EnableQueryExtractionForTesting();
263 ASSERT_TRUE(https_test_server().Start()); 261 ASSERT_TRUE(https_test_server().Start());
264 GURL instant_url = https_test_server().GetURL( 262 GURL instant_url = https_test_server().GetURL(
265 "files/instant_extended.html?strk=1&"); 263 "files/instant_extended.html?strk=1&");
266 GURL ntp_url = https_test_server().GetURL( 264 GURL ntp_url = https_test_server().GetURL(
267 "files/instant_extended_ntp.html?strk=1&"); 265 "files/instant_extended_ntp.html?strk=1&");
268 InstantTestBase::Init(instant_url, ntp_url, true); 266 InstantTestBase::Init(instant_url, ntp_url, true);
269 } 267 }
270 268
271 virtual void SetUpCommandLine(CommandLine* command_line) override { 269 void SetUpCommandLine(CommandLine* command_line) override {
272 command_line->AppendSwitchASCII( 270 command_line->AppendSwitchASCII(
273 switches::kForceFieldTrials, 271 switches::kForceFieldTrials,
274 "EmbeddedSearch/Group11 prefetch_results_srp:1/"); 272 "EmbeddedSearch/Group11 prefetch_results_srp:1/");
275 } 273 }
276 274
277 net::FakeURLFetcherFactory* fake_factory() { return fake_factory_.get(); } 275 net::FakeURLFetcherFactory* fake_factory() { return fake_factory_.get(); }
278 276
279 private: 277 private:
280 // Used to instantiate FakeURLFetcherFactory. 278 // Used to instantiate FakeURLFetcherFactory.
281 scoped_ptr<net::URLFetcherImplFactory> factory_; 279 scoped_ptr<net::URLFetcherImplFactory> factory_;
282 280
283 // Used to mock default search provider suggest response. 281 // Used to mock default search provider suggest response.
284 scoped_ptr<net::FakeURLFetcherFactory> fake_factory_; 282 scoped_ptr<net::FakeURLFetcherFactory> fake_factory_;
285 283
286 DISALLOW_COPY_AND_ASSIGN(InstantExtendedPrefetchTest); 284 DISALLOW_COPY_AND_ASSIGN(InstantExtendedPrefetchTest);
287 }; 285 };
288 286
289 class InstantExtendedNetworkTest : public InstantExtendedTest { 287 class InstantExtendedNetworkTest : public InstantExtendedTest {
290 protected: 288 protected:
291 virtual void SetUpOnMainThread() override { 289 void SetUpOnMainThread() override {
292 disable_for_test_.reset(new net::NetworkChangeNotifier::DisableForTest); 290 disable_for_test_.reset(new net::NetworkChangeNotifier::DisableForTest);
293 fake_network_change_notifier_.reset(new FakeNetworkChangeNotifier); 291 fake_network_change_notifier_.reset(new FakeNetworkChangeNotifier);
294 InstantExtendedTest::SetUpOnMainThread(); 292 InstantExtendedTest::SetUpOnMainThread();
295 } 293 }
296 294
297 virtual void TearDownOnMainThread() override { 295 void TearDownOnMainThread() override {
298 InstantExtendedTest::TearDownOnMainThread(); 296 InstantExtendedTest::TearDownOnMainThread();
299 fake_network_change_notifier_.reset(); 297 fake_network_change_notifier_.reset();
300 disable_for_test_.reset(); 298 disable_for_test_.reset();
301 } 299 }
302 300
303 void SetConnectionType(net::NetworkChangeNotifier::ConnectionType type) { 301 void SetConnectionType(net::NetworkChangeNotifier::ConnectionType type) {
304 fake_network_change_notifier_->SetConnectionType(type); 302 fake_network_change_notifier_->SetConnectionType(type);
305 } 303 }
306 304
307 private: 305 private:
308 scoped_ptr<net::NetworkChangeNotifier::DisableForTest> disable_for_test_; 306 scoped_ptr<net::NetworkChangeNotifier::DisableForTest> disable_for_test_;
309 scoped_ptr<FakeNetworkChangeNotifier> fake_network_change_notifier_; 307 scoped_ptr<FakeNetworkChangeNotifier> fake_network_change_notifier_;
310 }; 308 };
311 309
312 // Test class used to verify chrome-search: scheme and access policy from the 310 // Test class used to verify chrome-search: scheme and access policy from the
313 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it 311 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it
314 // loads a theme that provides a background image. 312 // loads a theme that provides a background image.
315 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { 313 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase {
316 public: 314 public:
317 InstantPolicyTest() {} 315 InstantPolicyTest() {}
318 316
319 protected: 317 protected:
320 virtual void SetUpInProcessBrowserTestFixture() override { 318 void SetUpInProcessBrowserTestFixture() override {
321 ASSERT_TRUE(https_test_server().Start()); 319 ASSERT_TRUE(https_test_server().Start());
322 GURL instant_url = https_test_server().GetURL( 320 GURL instant_url = https_test_server().GetURL(
323 "files/instant_extended.html?strk=1&"); 321 "files/instant_extended.html?strk=1&");
324 GURL ntp_url = https_test_server().GetURL( 322 GURL ntp_url = https_test_server().GetURL(
325 "files/instant_extended_ntp.html?strk=1&"); 323 "files/instant_extended_ntp.html?strk=1&");
326 InstantTestBase::Init(instant_url, ntp_url, false); 324 InstantTestBase::Init(instant_url, ntp_url, false);
327 } 325 }
328 326
329 void InstallThemeSource() { 327 void InstallThemeSource() {
330 ThemeSource* theme = new ThemeSource(profile()); 328 ThemeSource* theme = new ThemeSource(profile());
(...skipping 642 matching lines...) Expand 10 before | Expand all | Expand 10 after
973 stream << "link.href = \"" << result_url.spec() << "\";"; 971 stream << "link.href = \"" << result_url.spec() << "\";";
974 stream << "document.body.appendChild(link);"; 972 stream << "document.body.appendChild(link);";
975 stream << "link.click();"; 973 stream << "link.click();";
976 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); 974 EXPECT_TRUE(content::ExecuteScript(contents, stream.str()));
977 975
978 content::WaitForLoadStop(contents); 976 content::WaitForLoadStop(contents);
979 std::string expected_title = 977 std::string expected_title =
980 "Referrer is " + instant_url().GetWithEmptyPath().spec(); 978 "Referrer is " + instant_url().GetWithEmptyPath().spec();
981 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); 979 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle());
982 } 980 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698