| 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 "chrome/browser/ui/search/search_tab_helper.h" | 5 #include "chrome/browser/ui/search/search_tab_helper.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/metrics/field_trial.h" | 9 #include "base/metrics/field_trial.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 346 | 346 |
| 347 TEST_F(SearchTabHelperTest, TitleIsSetForNTP) { | 347 TEST_F(SearchTabHelperTest, TitleIsSetForNTP) { |
| 348 TabTitleObserver title_observer(web_contents()); | 348 TabTitleObserver title_observer(web_contents()); |
| 349 NavigateAndCommit(GURL(chrome::kChromeUINewTabURL)); | 349 NavigateAndCommit(GURL(chrome::kChromeUINewTabURL)); |
| 350 const base::string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); | 350 const base::string16 title = l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE); |
| 351 EXPECT_EQ(title, title_observer.title_on_start()); | 351 EXPECT_EQ(title, title_observer.title_on_start()); |
| 352 EXPECT_EQ(title, title_observer.title_on_commit()); | 352 EXPECT_EQ(title, title_observer.title_on_commit()); |
| 353 EXPECT_EQ(title, web_contents()->GetTitle()); | 353 EXPECT_EQ(title, web_contents()->GetTitle()); |
| 354 } | 354 } |
| 355 | 355 |
| 356 class SearchTabHelperWindowTest : public BrowserWithTestWindowTest { | |
| 357 protected: | |
| 358 void SetUp() override { | |
| 359 BrowserWithTestWindowTest::SetUp(); | |
| 360 TemplateURLServiceFactory::GetInstance()->SetTestingFactoryAndUse( | |
| 361 profile(), &TemplateURLServiceFactory::BuildInstanceFor); | |
| 362 TemplateURLService* template_url_service = | |
| 363 TemplateURLServiceFactory::GetForProfile(profile()); | |
| 364 ui_test_utils::WaitForTemplateURLServiceToLoad(template_url_service); | |
| 365 | |
| 366 TemplateURLData data; | |
| 367 data.SetURL("http://foo.com/url?bar={searchTerms}"); | |
| 368 data.instant_url = "http://foo.com/instant?" | |
| 369 "{google:omniboxStartMarginParameter}{google:forceInstantResults}" | |
| 370 "foo=foo#foo=foo&strk"; | |
| 371 data.new_tab_url = std::string("https://foo.com/newtab?strk"); | |
| 372 data.alternate_urls.push_back("http://foo.com/alt#quux={searchTerms}"); | |
| 373 data.search_terms_replacement_key = "strk"; | |
| 374 | |
| 375 TemplateURL* template_url = new TemplateURL(data); | |
| 376 template_url_service->Add(template_url); | |
| 377 template_url_service->SetUserSelectedDefaultSearchProvider(template_url); | |
| 378 } | |
| 379 }; | |
| 380 | |
| 381 class SearchTabHelperPrerenderTest : public InstantUnitTestBase { | 356 class SearchTabHelperPrerenderTest : public InstantUnitTestBase { |
| 382 public: | 357 public: |
| 383 ~SearchTabHelperPrerenderTest() override {} | 358 ~SearchTabHelperPrerenderTest() override {} |
| 384 | 359 |
| 385 protected: | 360 protected: |
| 386 void SetUp() override { | 361 void SetUp() override { |
| 387 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( | 362 ASSERT_TRUE(base::FieldTrialList::CreateFieldTrial( |
| 388 "EmbeddedSearch", | 363 "EmbeddedSearch", |
| 389 "Group1 espv:89 prefetch_results:1 " | 364 "Group1 espv:89 prefetch_results:1 " |
| 390 "prerender_instant_url_on_omnibox_focus:1")); | 365 "prerender_instant_url_on_omnibox_focus:1")); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 } | 410 } |
| 436 | 411 |
| 437 TEST_F(SearchTabHelperPrerenderTest, | 412 TEST_F(SearchTabHelperPrerenderTest, |
| 438 OnTabActivatedNoPrerenderIfOmniboxBlurred) { | 413 OnTabActivatedNoPrerenderIfOmniboxBlurred) { |
| 439 SearchTabHelperPrerenderTest::omnibox_has_focus_ = false; | 414 SearchTabHelperPrerenderTest::omnibox_has_focus_ = false; |
| 440 SearchTabHelper* search_tab_helper = | 415 SearchTabHelper* search_tab_helper = |
| 441 SearchTabHelper::FromWebContents(web_contents()); | 416 SearchTabHelper::FromWebContents(web_contents()); |
| 442 search_tab_helper->OnTabActivated(); | 417 search_tab_helper->OnTabActivated(); |
| 443 ASSERT_FALSE(IsInstantURLMarkedForPrerendering()); | 418 ASSERT_FALSE(IsInstantURLMarkedForPrerendering()); |
| 444 } | 419 } |
| OLD | NEW |