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

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

Issue 627043002: replace OVERRIDE and FINAL with override and final in chrome/browser/ui/[a-s]* (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 "chrome/browser/ui/search/instant_search_prerenderer.h" 5 #include "chrome/browser/ui/search/instant_search_prerenderer.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/metrics/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 const GURL& url, 53 const GURL& url,
54 const Referrer& referrer, 54 const Referrer& referrer,
55 Origin origin, 55 Origin origin,
56 bool call_did_finish_load, 56 bool call_did_finish_load,
57 const content::SessionStorageNamespaceMap& session_storage_namespace_map); 57 const content::SessionStorageNamespaceMap& session_storage_namespace_map);
58 58
59 virtual void StartPrerendering( 59 virtual void StartPrerendering(
60 int ALLOW_UNUSED creator_child_id, 60 int ALLOW_UNUSED creator_child_id,
61 const gfx::Size& ALLOW_UNUSED size, 61 const gfx::Size& ALLOW_UNUSED size,
62 content::SessionStorageNamespace* session_storage_namespace, 62 content::SessionStorageNamespace* session_storage_namespace,
63 net::URLRequestContextGetter* request_context) OVERRIDE; 63 net::URLRequestContextGetter* request_context) override;
64 virtual bool GetChildId(int* child_id) const OVERRIDE; 64 virtual bool GetChildId(int* child_id) const override;
65 virtual bool GetRouteId(int* route_id) const OVERRIDE; 65 virtual bool GetRouteId(int* route_id) const override;
66 66
67 private: 67 private:
68 Profile* profile_; 68 Profile* profile_;
69 const GURL url_; 69 const GURL url_;
70 bool call_did_finish_load_; 70 bool call_did_finish_load_;
71 content::SessionStorageNamespaceMap session_storage_namespace_map_; 71 content::SessionStorageNamespaceMap session_storage_namespace_map_;
72 72
73 DISALLOW_COPY_AND_ASSIGN(DummyPrerenderContents); 73 DISALLOW_COPY_AND_ASSIGN(DummyPrerenderContents);
74 }; 74 };
75 75
76 class DummyPrerenderContentsFactory : public PrerenderContents::Factory { 76 class DummyPrerenderContentsFactory : public PrerenderContents::Factory {
77 public: 77 public:
78 DummyPrerenderContentsFactory( 78 DummyPrerenderContentsFactory(
79 bool call_did_finish_load, 79 bool call_did_finish_load,
80 const content::SessionStorageNamespaceMap& session_storage_namespace_map) 80 const content::SessionStorageNamespaceMap& session_storage_namespace_map)
81 : call_did_finish_load_(call_did_finish_load), 81 : call_did_finish_load_(call_did_finish_load),
82 session_storage_namespace_map_(session_storage_namespace_map) { 82 session_storage_namespace_map_(session_storage_namespace_map) {
83 } 83 }
84 84
85 virtual PrerenderContents* CreatePrerenderContents( 85 virtual PrerenderContents* CreatePrerenderContents(
86 PrerenderManager* prerender_manager, 86 PrerenderManager* prerender_manager,
87 Profile* profile, 87 Profile* profile,
88 const GURL& url, 88 const GURL& url,
89 const Referrer& referrer, 89 const Referrer& referrer,
90 Origin origin, 90 Origin origin,
91 uint8 experiment_id) OVERRIDE; 91 uint8 experiment_id) override;
92 92
93 private: 93 private:
94 bool call_did_finish_load_; 94 bool call_did_finish_load_;
95 content::SessionStorageNamespaceMap session_storage_namespace_map_; 95 content::SessionStorageNamespaceMap session_storage_namespace_map_;
96 96
97 DISALLOW_COPY_AND_ASSIGN(DummyPrerenderContentsFactory); 97 DISALLOW_COPY_AND_ASSIGN(DummyPrerenderContentsFactory);
98 }; 98 };
99 99
100 DummyPrerenderContents::DummyPrerenderContents( 100 DummyPrerenderContents::DummyPrerenderContents(
101 PrerenderManager* prerender_manager, 101 PrerenderManager* prerender_manager,
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 session_storage_namespace_map_); 158 session_storage_namespace_map_);
159 } 159 }
160 160
161 } // namespace 161 } // namespace
162 162
163 class InstantSearchPrerendererTest : public InstantUnitTestBase { 163 class InstantSearchPrerendererTest : public InstantUnitTestBase {
164 public: 164 public:
165 InstantSearchPrerendererTest() {} 165 InstantSearchPrerendererTest() {}
166 166
167 protected: 167 protected:
168 virtual void SetUp() OVERRIDE { 168 virtual void SetUp() override {
169 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch", 169 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch",
170 "Group1 strk:20")); 170 "Group1 strk:20"));
171 InstantUnitTestBase::SetUp(); 171 InstantUnitTestBase::SetUp();
172 } 172 }
173 173
174 void Init(bool prerender_search_results_base_page, 174 void Init(bool prerender_search_results_base_page,
175 bool call_did_finish_load) { 175 bool call_did_finish_load) {
176 AddTab(browser(), GURL(url::kAboutBlankURL)); 176 AddTab(browser(), GURL(url::kAboutBlankURL));
177 177
178 content::SessionStorageNamespaceMap session_storage_namespace_map; 178 content::SessionStorageNamespaceMap session_storage_namespace_map;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
423 EXPECT_NE(GetPrerenderURL(), new_tab->GetURL()); 423 EXPECT_NE(GetPrerenderURL(), new_tab->GetURL());
424 EXPECT_EQ(url, new_tab->GetURL()); 424 EXPECT_EQ(url, new_tab->GetURL());
425 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle()); 425 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
426 } 426 }
427 427
428 class ReuseInstantSearchBasePageTest : public InstantSearchPrerendererTest { 428 class ReuseInstantSearchBasePageTest : public InstantSearchPrerendererTest {
429 public: 429 public:
430 ReuseInstantSearchBasePageTest() {} 430 ReuseInstantSearchBasePageTest() {}
431 431
432 protected: 432 protected:
433 virtual void SetUp() OVERRIDE { 433 virtual void SetUp() override {
434 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch", 434 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial("EmbeddedSearch",
435 "Group1 strk:20")); 435 "Group1 strk:20"));
436 InstantUnitTestBase::SetUp(); 436 InstantUnitTestBase::SetUp();
437 } 437 }
438 }; 438 };
439 439
440 TEST_F(ReuseInstantSearchBasePageTest, CanCommitQuery) { 440 TEST_F(ReuseInstantSearchBasePageTest, CanCommitQuery) {
441 Init(true, true); 441 Init(true, true);
442 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer(); 442 InstantSearchPrerenderer* prerenderer = GetInstantSearchPrerenderer();
443 base::string16 query = ASCIIToUTF16("flowers"); 443 base::string16 query = ASCIIToUTF16("flowers");
(...skipping 20 matching lines...) Expand all
464 // When the Instant search base page hasn't finished loading, 464 // When the Instant search base page hasn't finished loading,
465 // InstantSearchPrerenderer cannot commit any search query to the base page. 465 // InstantSearchPrerenderer cannot commit any search query to the base page.
466 EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(), query)); 466 EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(), query));
467 EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(), 467 EXPECT_FALSE(prerenderer->CanCommitQuery(GetActiveWebContents(),
468 ASCIIToUTF16("joy"))); 468 ASCIIToUTF16("joy")));
469 } 469 }
470 470
471 #if !defined(OS_IOS) && !defined(OS_ANDROID) 471 #if !defined(OS_IOS) && !defined(OS_ANDROID)
472 class TestUsePrerenderPage : public InstantSearchPrerendererTest { 472 class TestUsePrerenderPage : public InstantSearchPrerendererTest {
473 protected: 473 protected:
474 virtual void SetUp() OVERRIDE { 474 virtual void SetUp() override {
475 // Disable query extraction flag in field trials. 475 // Disable query extraction flag in field trials.
476 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( 476 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial(
477 "EmbeddedSearch", "Group1 strk:20 query_extraction:0")); 477 "EmbeddedSearch", "Group1 strk:20 query_extraction:0"));
478 InstantUnitTestBase::SetUpWithoutQueryExtraction(); 478 InstantUnitTestBase::SetUpWithoutQueryExtraction();
479 } 479 }
480 }; 480 };
481 481
482 TEST_F(TestUsePrerenderPage, ExtractSearchTermsAndUsePrerenderPage) { 482 TEST_F(TestUsePrerenderPage, ExtractSearchTermsAndUsePrerenderPage) {
483 PrerenderSearchQuery(ASCIIToUTF16("foo")); 483 PrerenderSearchQuery(ASCIIToUTF16("foo"));
484 484
485 // Open a search results page. Query extraction flag is disabled in field 485 // Open a search results page. Query extraction flag is disabled in field
486 // trials. Search results page URL does not contain search terms replacement 486 // trials. Search results page URL does not contain search terms replacement
487 // key. Make sure UsePrerenderedPage() extracts the search terms from the URL 487 // key. Make sure UsePrerenderedPage() extracts the search terms from the URL
488 // and uses the prerendered page contents. 488 // and uses the prerendered page contents.
489 GURL url("https://www.google.com/alt#quux=foo"); 489 GURL url("https://www.google.com/alt#quux=foo");
490 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB, 490 browser()->OpenURL(content::OpenURLParams(url, Referrer(), CURRENT_TAB,
491 ui::PAGE_TRANSITION_TYPED, 491 ui::PAGE_TRANSITION_TYPED,
492 false)); 492 false));
493 EXPECT_EQ(GetPrerenderURL(), GetActiveWebContents()->GetURL()); 493 EXPECT_EQ(GetPrerenderURL(), GetActiveWebContents()->GetURL());
494 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle()); 494 EXPECT_EQ(static_cast<PrerenderHandle*>(NULL), prerender_handle());
495 } 495 }
496 #endif 496 #endif
OLDNEW
« no previous file with comments | « chrome/browser/ui/search/instant_page_unittest.cc ('k') | chrome/browser/ui/search/instant_tab.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698