| 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 <sstream> | 5 #include <sstream> |
| 6 | 6 |
| 7 #include "base/base_switches.h" | 7 #include "base/base_switches.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/metrics/histogram_base.h" | 9 #include "base/metrics/histogram_base.h" |
| 10 #include "base/metrics/histogram_samples.h" | 10 #include "base/metrics/histogram_samples.h" |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 submit_count_(0), | 139 submit_count_(0), |
| 140 on_esc_key_press_event_calls_(0), | 140 on_esc_key_press_event_calls_(0), |
| 141 on_focus_changed_calls_(0), | 141 on_focus_changed_calls_(0), |
| 142 is_focused_(false), | 142 is_focused_(false), |
| 143 on_toggle_voice_search_calls_(0) { | 143 on_toggle_voice_search_calls_(0) { |
| 144 } | 144 } |
| 145 protected: | 145 protected: |
| 146 void SetUpInProcessBrowserTestFixture() override { | 146 void SetUpInProcessBrowserTestFixture() override { |
| 147 search::EnableQueryExtractionForTesting(); | 147 search::EnableQueryExtractionForTesting(); |
| 148 ASSERT_TRUE(https_test_server().Start()); | 148 ASSERT_TRUE(https_test_server().Start()); |
| 149 GURL instant_url = https_test_server().GetURL( | 149 GURL instant_url = |
| 150 "files/instant_extended.html?strk=1&"); | 150 https_test_server().GetURL("/instant_extended.html?strk=1&"); |
| 151 GURL ntp_url = https_test_server().GetURL( | 151 GURL ntp_url = |
| 152 "files/instant_extended_ntp.html?strk=1&"); | 152 https_test_server().GetURL("/instant_extended_ntp.html?strk=1&"); |
| 153 InstantTestBase::Init(instant_url, ntp_url, false); | 153 InstantTestBase::Init(instant_url, ntp_url, false); |
| 154 } | 154 } |
| 155 | 155 |
| 156 int64 GetHistogramCount(const char* name) { | 156 int64 GetHistogramCount(const char* name) { |
| 157 base::HistogramBase* histogram = | 157 base::HistogramBase* histogram = |
| 158 base::StatisticsRecorder::FindHistogram(name); | 158 base::StatisticsRecorder::FindHistogram(name); |
| 159 if (!histogram) { | 159 if (!histogram) { |
| 160 // If no histogram is found, it's possible that no values have been | 160 // If no histogram is found, it's possible that no values have been |
| 161 // recorded yet. Assume that the value is zero. | 161 // recorded yet. Assume that the value is zero. |
| 162 return 0; | 162 return 0; |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 class InstantExtendedPrefetchTest : public InstantExtendedTest { | 254 class InstantExtendedPrefetchTest : public InstantExtendedTest { |
| 255 public: | 255 public: |
| 256 InstantExtendedPrefetchTest() | 256 InstantExtendedPrefetchTest() |
| 257 : factory_(new net::URLFetcherImplFactory()), | 257 : factory_(new net::URLFetcherImplFactory()), |
| 258 fake_factory_(new net::FakeURLFetcherFactory(factory_.get())) { | 258 fake_factory_(new net::FakeURLFetcherFactory(factory_.get())) { |
| 259 } | 259 } |
| 260 | 260 |
| 261 void SetUpInProcessBrowserTestFixture() override { | 261 void SetUpInProcessBrowserTestFixture() override { |
| 262 search::EnableQueryExtractionForTesting(); | 262 search::EnableQueryExtractionForTesting(); |
| 263 ASSERT_TRUE(https_test_server().Start()); | 263 ASSERT_TRUE(https_test_server().Start()); |
| 264 GURL instant_url = https_test_server().GetURL( | 264 GURL instant_url = |
| 265 "files/instant_extended.html?strk=1&"); | 265 https_test_server().GetURL("/instant_extended.html?strk=1&"); |
| 266 GURL ntp_url = https_test_server().GetURL( | 266 GURL ntp_url = |
| 267 "files/instant_extended_ntp.html?strk=1&"); | 267 https_test_server().GetURL("/instant_extended_ntp.html?strk=1&"); |
| 268 InstantTestBase::Init(instant_url, ntp_url, true); | 268 InstantTestBase::Init(instant_url, ntp_url, true); |
| 269 } | 269 } |
| 270 | 270 |
| 271 void SetUpCommandLine(base::CommandLine* command_line) override { | 271 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 272 command_line->AppendSwitchASCII( | 272 command_line->AppendSwitchASCII( |
| 273 switches::kForceFieldTrials, | 273 switches::kForceFieldTrials, |
| 274 "EmbeddedSearch/Group11 prefetch_results_srp:1/"); | 274 "EmbeddedSearch/Group11 prefetch_results_srp:1/"); |
| 275 } | 275 } |
| 276 | 276 |
| 277 net::FakeURLFetcherFactory* fake_factory() { return fake_factory_.get(); } | 277 net::FakeURLFetcherFactory* fake_factory() { return fake_factory_.get(); } |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 // Test class used to verify chrome-search: scheme and access policy from the | 312 // Test class used to verify chrome-search: scheme and access policy from the |
| 313 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it | 313 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it |
| 314 // loads a theme that provides a background image. | 314 // loads a theme that provides a background image. |
| 315 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { | 315 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { |
| 316 public: | 316 public: |
| 317 InstantPolicyTest() {} | 317 InstantPolicyTest() {} |
| 318 | 318 |
| 319 protected: | 319 protected: |
| 320 void SetUpInProcessBrowserTestFixture() override { | 320 void SetUpInProcessBrowserTestFixture() override { |
| 321 ASSERT_TRUE(https_test_server().Start()); | 321 ASSERT_TRUE(https_test_server().Start()); |
| 322 GURL instant_url = https_test_server().GetURL( | 322 GURL instant_url = |
| 323 "files/instant_extended.html?strk=1&"); | 323 https_test_server().GetURL("/instant_extended.html?strk=1&"); |
| 324 GURL ntp_url = https_test_server().GetURL( | 324 GURL ntp_url = |
| 325 "files/instant_extended_ntp.html?strk=1&"); | 325 https_test_server().GetURL("/instant_extended_ntp.html?strk=1&"); |
| 326 InstantTestBase::Init(instant_url, ntp_url, false); | 326 InstantTestBase::Init(instant_url, ntp_url, false); |
| 327 } | 327 } |
| 328 | 328 |
| 329 void InstallThemeSource() { | 329 void InstallThemeSource() { |
| 330 ThemeSource* theme = new ThemeSource(profile()); | 330 ThemeSource* theme = new ThemeSource(profile()); |
| 331 content::URLDataSource::Add(profile(), theme); | 331 content::URLDataSource::Add(profile(), theme); |
| 332 } | 332 } |
| 333 | 333 |
| 334 void InstallThemeAndVerify(const std::string& theme_dir, | 334 void InstallThemeAndVerify(const std::string& theme_dir, |
| 335 const std::string& theme_name) { | 335 const std::string& theme_name) { |
| (...skipping 644 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 980 omnibox()->ShowURL(); | 980 omnibox()->ShowURL(); |
| 981 EXPECT_FALSE(browser()->toolbar_model()->WouldPerformSearchTermReplacement( | 981 EXPECT_FALSE(browser()->toolbar_model()->WouldPerformSearchTermReplacement( |
| 982 false)); | 982 false)); |
| 983 // Don't bother looking for a specific URL; ensuring we're no longer showing | 983 // Don't bother looking for a specific URL; ensuring we're no longer showing |
| 984 // the search terms is sufficient. | 984 // the search terms is sufficient. |
| 985 EXPECT_NE(ASCIIToUTF16("foo"), omnibox()->GetText()); | 985 EXPECT_NE(ASCIIToUTF16("foo"), omnibox()->GetText()); |
| 986 } | 986 } |
| 987 | 987 |
| 988 // Check that clicking on a result sends the correct referrer. | 988 // Check that clicking on a result sends the correct referrer. |
| 989 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, Referrer) { | 989 IN_PROC_BROWSER_TEST_F(InstantExtendedTest, Referrer) { |
| 990 ASSERT_TRUE(test_server()->Start()); | 990 ASSERT_TRUE(embedded_test_server()->Start()); |
| 991 GURL result_url = | 991 GURL result_url = embedded_test_server()->GetURL( |
| 992 test_server()->GetURL("files/referrer_policy/referrer-policy-log.html"); | 992 "/referrer_policy/referrer-policy-log.html"); |
| 993 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); | 993 ASSERT_NO_FATAL_FAILURE(SetupInstant(browser())); |
| 994 FocusOmnibox(); | 994 FocusOmnibox(); |
| 995 | 995 |
| 996 // Type a query and press enter to get results. | 996 // Type a query and press enter to get results. |
| 997 SetOmniboxText("query"); | 997 SetOmniboxText("query"); |
| 998 PressEnterAndWaitForFrameLoad(); | 998 PressEnterAndWaitForFrameLoad(); |
| 999 | 999 |
| 1000 // Simulate going to a result. | 1000 // Simulate going to a result. |
| 1001 content::WebContents* contents = | 1001 content::WebContents* contents = |
| 1002 browser()->tab_strip_model()->GetActiveWebContents(); | 1002 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1003 std::ostringstream stream; | 1003 std::ostringstream stream; |
| 1004 stream << "var link = document.createElement('a');"; | 1004 stream << "var link = document.createElement('a');"; |
| 1005 stream << "link.href = \"" << result_url.spec() << "\";"; | 1005 stream << "link.href = \"" << result_url.spec() << "\";"; |
| 1006 stream << "document.body.appendChild(link);"; | 1006 stream << "document.body.appendChild(link);"; |
| 1007 stream << "link.click();"; | 1007 stream << "link.click();"; |
| 1008 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); | 1008 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); |
| 1009 | 1009 |
| 1010 content::WaitForLoadStop(contents); | 1010 content::WaitForLoadStop(contents); |
| 1011 std::string expected_title = | 1011 std::string expected_title = |
| 1012 "Referrer is " + instant_url().GetWithEmptyPath().spec(); | 1012 "Referrer is " + instant_url().GetWithEmptyPath().spec(); |
| 1013 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); | 1013 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); |
| 1014 } | 1014 } |
| OLD | NEW |