| 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 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 } | 92 } |
| 93 // content::NotificationObserver: | 93 // content::NotificationObserver: |
| 94 void Observe(int type, | 94 void Observe(int type, |
| 95 const content::NotificationSource& source, | 95 const content::NotificationSource& source, |
| 96 const content::NotificationDetails& details) override {} | 96 const content::NotificationDetails& details) override {} |
| 97 | 97 |
| 98 // A test-specific field for controlling when most visited callback is run | 98 // A test-specific field for controlling when most visited callback is run |
| 99 // after top sites have been requested. | 99 // after top sites have been requested. |
| 100 GetMostVisitedURLsCallback mv_callback; | 100 GetMostVisitedURLsCallback mv_callback; |
| 101 protected: | 101 protected: |
| 102 virtual ~FakeEmptyTopSites() { | 102 ~FakeEmptyTopSites() override {} |
| 103 } | |
| 104 }; | 103 }; |
| 105 | 104 |
| 106 void FakeEmptyTopSites::GetMostVisitedURLs( | 105 void FakeEmptyTopSites::GetMostVisitedURLs( |
| 107 const GetMostVisitedURLsCallback& callback, | 106 const GetMostVisitedURLsCallback& callback, |
| 108 bool include_forced_urls) { | 107 bool include_forced_urls) { |
| 109 mv_callback = callback; | 108 mv_callback = callback; |
| 110 } | 109 } |
| 111 | 110 |
| 112 } // namespace | 111 } // namespace |
| 113 | 112 |
| 114 | 113 |
| 115 class ZeroSuggestProviderTest : public testing::Test, | 114 class ZeroSuggestProviderTest : public testing::Test, |
| 116 public AutocompleteProviderListener { | 115 public AutocompleteProviderListener { |
| 117 public: | 116 public: |
| 118 ZeroSuggestProviderTest(); | 117 ZeroSuggestProviderTest(); |
| 119 | 118 |
| 120 virtual void SetUp() override; | 119 void SetUp() override; |
| 121 virtual void TearDown() override; | 120 void TearDown() override; |
| 122 | 121 |
| 123 protected: | 122 protected: |
| 124 // AutocompleteProviderListener: | 123 // AutocompleteProviderListener: |
| 125 void OnProviderUpdate(bool updated_matches) override; | 124 void OnProviderUpdate(bool updated_matches) override; |
| 126 | 125 |
| 127 void ResetFieldTrialList(); | 126 void ResetFieldTrialList(); |
| 128 | 127 |
| 129 void CreatePersonalizedFieldTrial(); | 128 void CreatePersonalizedFieldTrial(); |
| 130 void CreateMostVisitedFieldTrial(); | 129 void CreateMostVisitedFieldTrial(); |
| 131 | 130 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 | 407 |
| 409 base::RunLoop().RunUntilIdle(); | 408 base::RunLoop().RunUntilIdle(); |
| 410 | 409 |
| 411 // Expect that the matches have been cleared. | 410 // Expect that the matches have been cleared. |
| 412 ASSERT_TRUE(provider_->matches().empty()); | 411 ASSERT_TRUE(provider_->matches().empty()); |
| 413 | 412 |
| 414 // Expect the new results have been stored. | 413 // Expect the new results have been stored. |
| 415 EXPECT_EQ(empty_response, | 414 EXPECT_EQ(empty_response, |
| 416 prefs->GetString(prefs::kZeroSuggestCachedResults)); | 415 prefs->GetString(prefs::kZeroSuggestCachedResults)); |
| 417 } | 416 } |
| OLD | NEW |