| 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 <stdint.h> | 5 #include <stdint.h> |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "base/base_switches.h" | 9 #include "base/base_switches.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 221 } | 221 } |
| 222 | 222 |
| 223 void BlockUntilHistoryProcessesPendingRequests() { | 223 void BlockUntilHistoryProcessesPendingRequests() { |
| 224 history::HistoryService* history = HistoryServiceFactory::GetForProfile( | 224 history::HistoryService* history = HistoryServiceFactory::GetForProfile( |
| 225 browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS); | 225 browser()->profile(), ServiceAccessType::EXPLICIT_ACCESS); |
| 226 DCHECK(history); | 226 DCHECK(history); |
| 227 DCHECK(base::MessageLoop::current()); | 227 DCHECK(base::MessageLoop::current()); |
| 228 | 228 |
| 229 base::CancelableTaskTracker tracker; | 229 base::CancelableTaskTracker tracker; |
| 230 history->ScheduleDBTask( | 230 history->ScheduleDBTask( |
| 231 scoped_ptr<history::HistoryDBTask>( | 231 std::unique_ptr<history::HistoryDBTask>(new QuittingHistoryDBTask()), |
| 232 new QuittingHistoryDBTask()), | |
| 233 &tracker); | 232 &tracker); |
| 234 base::MessageLoop::current()->Run(); | 233 base::MessageLoop::current()->Run(); |
| 235 } | 234 } |
| 236 | 235 |
| 237 int CountSearchProviderSuggestions() { | 236 int CountSearchProviderSuggestions() { |
| 238 return omnibox()->model()->autocomplete_controller()->search_provider()-> | 237 return omnibox()->model()->autocomplete_controller()->search_provider()-> |
| 239 matches().size(); | 238 matches().size(); |
| 240 } | 239 } |
| 241 | 240 |
| 242 int on_most_visited_change_calls_; | 241 int on_most_visited_change_calls_; |
| (...skipping 29 matching lines...) Expand all Loading... |
| 272 void SetUpCommandLine(base::CommandLine* command_line) override { | 271 void SetUpCommandLine(base::CommandLine* command_line) override { |
| 273 command_line->AppendSwitchASCII( | 272 command_line->AppendSwitchASCII( |
| 274 switches::kForceFieldTrials, | 273 switches::kForceFieldTrials, |
| 275 "EmbeddedSearch/Group11 prefetch_results_srp:1/"); | 274 "EmbeddedSearch/Group11 prefetch_results_srp:1/"); |
| 276 } | 275 } |
| 277 | 276 |
| 278 net::FakeURLFetcherFactory* fake_factory() { return fake_factory_.get(); } | 277 net::FakeURLFetcherFactory* fake_factory() { return fake_factory_.get(); } |
| 279 | 278 |
| 280 private: | 279 private: |
| 281 // Used to instantiate FakeURLFetcherFactory. | 280 // Used to instantiate FakeURLFetcherFactory. |
| 282 scoped_ptr<net::URLFetcherImplFactory> factory_; | 281 std::unique_ptr<net::URLFetcherImplFactory> factory_; |
| 283 | 282 |
| 284 // Used to mock default search provider suggest response. | 283 // Used to mock default search provider suggest response. |
| 285 scoped_ptr<net::FakeURLFetcherFactory> fake_factory_; | 284 std::unique_ptr<net::FakeURLFetcherFactory> fake_factory_; |
| 286 | 285 |
| 287 DISALLOW_COPY_AND_ASSIGN(InstantExtendedPrefetchTest); | 286 DISALLOW_COPY_AND_ASSIGN(InstantExtendedPrefetchTest); |
| 288 }; | 287 }; |
| 289 | 288 |
| 290 class InstantExtendedNetworkTest : public InstantExtendedTest { | 289 class InstantExtendedNetworkTest : public InstantExtendedTest { |
| 291 protected: | 290 protected: |
| 292 void SetUpOnMainThread() override { | 291 void SetUpOnMainThread() override { |
| 293 disable_for_test_.reset(new net::NetworkChangeNotifier::DisableForTest); | 292 disable_for_test_.reset(new net::NetworkChangeNotifier::DisableForTest); |
| 294 fake_network_change_notifier_.reset(new FakeNetworkChangeNotifier); | 293 fake_network_change_notifier_.reset(new FakeNetworkChangeNotifier); |
| 295 InstantExtendedTest::SetUpOnMainThread(); | 294 InstantExtendedTest::SetUpOnMainThread(); |
| 296 } | 295 } |
| 297 | 296 |
| 298 void TearDownOnMainThread() override { | 297 void TearDownOnMainThread() override { |
| 299 InstantExtendedTest::TearDownOnMainThread(); | 298 InstantExtendedTest::TearDownOnMainThread(); |
| 300 fake_network_change_notifier_.reset(); | 299 fake_network_change_notifier_.reset(); |
| 301 disable_for_test_.reset(); | 300 disable_for_test_.reset(); |
| 302 } | 301 } |
| 303 | 302 |
| 304 void SetConnectionType(net::NetworkChangeNotifier::ConnectionType type) { | 303 void SetConnectionType(net::NetworkChangeNotifier::ConnectionType type) { |
| 305 fake_network_change_notifier_->SetConnectionType(type); | 304 fake_network_change_notifier_->SetConnectionType(type); |
| 306 } | 305 } |
| 307 | 306 |
| 308 private: | 307 private: |
| 309 scoped_ptr<net::NetworkChangeNotifier::DisableForTest> disable_for_test_; | 308 std::unique_ptr<net::NetworkChangeNotifier::DisableForTest> disable_for_test_; |
| 310 scoped_ptr<FakeNetworkChangeNotifier> fake_network_change_notifier_; | 309 std::unique_ptr<FakeNetworkChangeNotifier> fake_network_change_notifier_; |
| 311 }; | 310 }; |
| 312 | 311 |
| 313 // 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 |
| 314 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it | 313 // Instant overlay. This is a subclass of |ExtensionBrowserTest| because it |
| 315 // loads a theme that provides a background image. | 314 // loads a theme that provides a background image. |
| 316 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { | 315 class InstantPolicyTest : public ExtensionBrowserTest, public InstantTestBase { |
| 317 public: | 316 public: |
| 318 InstantPolicyTest() {} | 317 InstantPolicyTest() {} |
| 319 | 318 |
| 320 protected: | 319 protected: |
| (...skipping 652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 973 stream << "link.href = \"" << result_url.spec() << "\";"; | 972 stream << "link.href = \"" << result_url.spec() << "\";"; |
| 974 stream << "document.body.appendChild(link);"; | 973 stream << "document.body.appendChild(link);"; |
| 975 stream << "link.click();"; | 974 stream << "link.click();"; |
| 976 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); | 975 EXPECT_TRUE(content::ExecuteScript(contents, stream.str())); |
| 977 | 976 |
| 978 content::WaitForLoadStop(contents); | 977 content::WaitForLoadStop(contents); |
| 979 std::string expected_title = | 978 std::string expected_title = |
| 980 "Referrer is " + instant_url().GetWithEmptyPath().spec(); | 979 "Referrer is " + instant_url().GetWithEmptyPath().spec(); |
| 981 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); | 980 EXPECT_EQ(ASCIIToUTF16(expected_title), contents->GetTitle()); |
| 982 } | 981 } |
| OLD | NEW |