| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/autocomplete/zero_suggest_provider.h" | 5 #include "chrome/browser/autocomplete/zero_suggest_provider.h" |
| 6 | 6 |
| 7 #include "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 base::ASCIIToUTF16("Foo")); | 268 base::ASCIIToUTF16("Foo")); |
| 269 urls.push_back(url); | 269 urls.push_back(url); |
| 270 | 270 |
| 271 provider_->Start(input, false, true); | 271 provider_->Start(input, false, true); |
| 272 EXPECT_TRUE(provider_->matches().empty()); | 272 EXPECT_TRUE(provider_->matches().empty()); |
| 273 scoped_refptr<history::TopSites> top_sites = | 273 scoped_refptr<history::TopSites> top_sites = |
| 274 TopSitesFactory::GetForProfile(&profile_); | 274 TopSitesFactory::GetForProfile(&profile_); |
| 275 static_cast<FakeEmptyTopSites*>(top_sites.get())->mv_callback.Run(urls); | 275 static_cast<FakeEmptyTopSites*>(top_sites.get())->mv_callback.Run(urls); |
| 276 // Should have verbatim match + most visited url match. | 276 // Should have verbatim match + most visited url match. |
| 277 EXPECT_EQ(2U, provider_->matches().size()); | 277 EXPECT_EQ(2U, provider_->matches().size()); |
| 278 provider_->Stop(false); | 278 provider_->Stop(false, false); |
| 279 | 279 |
| 280 provider_->Start(input, false, true); | 280 provider_->Start(input, false, true); |
| 281 provider_->Stop(false); | 281 provider_->Stop(false, false); |
| 282 EXPECT_TRUE(provider_->matches().empty()); | 282 EXPECT_TRUE(provider_->matches().empty()); |
| 283 // Most visited results arriving after Stop() has been called, ensure they | 283 // Most visited results arriving after Stop() has been called, ensure they |
| 284 // are not displayed. | 284 // are not displayed. |
| 285 static_cast<FakeEmptyTopSites*>(top_sites.get())->mv_callback.Run(urls); | 285 static_cast<FakeEmptyTopSites*>(top_sites.get())->mv_callback.Run(urls); |
| 286 EXPECT_TRUE(provider_->matches().empty()); | 286 EXPECT_TRUE(provider_->matches().empty()); |
| 287 } | 287 } |
| 288 | 288 |
| 289 TEST_F(ZeroSuggestProviderTest, TestMostVisitedNavigateToSearchPage) { | 289 TEST_F(ZeroSuggestProviderTest, TestMostVisitedNavigateToSearchPage) { |
| 290 CreateMostVisitedFieldTrial(); | 290 CreateMostVisitedFieldTrial(); |
| 291 | 291 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 443 | 443 |
| 444 base::RunLoop().RunUntilIdle(); | 444 base::RunLoop().RunUntilIdle(); |
| 445 | 445 |
| 446 // Expect that the matches have been cleared. | 446 // Expect that the matches have been cleared. |
| 447 ASSERT_TRUE(provider_->matches().empty()); | 447 ASSERT_TRUE(provider_->matches().empty()); |
| 448 | 448 |
| 449 // Expect the new results have been stored. | 449 // Expect the new results have been stored. |
| 450 EXPECT_EQ(empty_response, | 450 EXPECT_EQ(empty_response, |
| 451 prefs->GetString(prefs::kZeroSuggestCachedResults)); | 451 prefs->GetString(prefs::kZeroSuggestCachedResults)); |
| 452 } | 452 } |
| OLD | NEW |