| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/ntp_snippets/ntp_snippets_service.h" | 5 #include "components/ntp_snippets/ntp_snippets_service.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 | 228 |
| 229 class MockProviderObserver : public ContentSuggestionsProvider::Observer { | 229 class MockProviderObserver : public ContentSuggestionsProvider::Observer { |
| 230 public: | 230 public: |
| 231 void OnNewSuggestions(ContentSuggestionsProvider* provider, | 231 void OnNewSuggestions(ContentSuggestionsProvider* provider, |
| 232 Category category, | 232 Category category, |
| 233 std::vector<ContentSuggestion> suggestions) override {} | 233 std::vector<ContentSuggestion> suggestions) override {} |
| 234 MOCK_METHOD3(OnCategoryStatusChanged, | 234 MOCK_METHOD3(OnCategoryStatusChanged, |
| 235 void(ContentSuggestionsProvider* provider, | 235 void(ContentSuggestionsProvider* provider, |
| 236 Category category, | 236 Category category, |
| 237 CategoryStatus new_status)); | 237 CategoryStatus new_status)); |
| 238 MOCK_METHOD3(OnSuggestionInvalidated, |
| 239 void(ContentSuggestionsProvider* provider, |
| 240 Category category, |
| 241 const std::string& suggestion_id)); |
| 238 }; | 242 }; |
| 239 | 243 |
| 240 class WaitForDBLoad { | 244 class WaitForDBLoad { |
| 241 public: | 245 public: |
| 242 WaitForDBLoad(MockProviderObserver* observer, NTPSnippetsService* service) | 246 WaitForDBLoad(MockProviderObserver* observer, NTPSnippetsService* service) |
| 243 : observer_(observer) { | 247 : observer_(observer) { |
| 244 EXPECT_CALL(*observer_, OnCategoryStatusChanged(_, _, _)) | 248 EXPECT_CALL(*observer_, OnCategoryStatusChanged(_, _, _)) |
| 245 .WillOnce(Invoke(this, &WaitForDBLoad::OnCategoryStatusChanged)); | 249 .WillOnce(Invoke(this, &WaitForDBLoad::OnCategoryStatusChanged)); |
| 246 if (!service->ready()) | 250 if (!service->ready()) |
| 247 run_loop_.Run(); | 251 run_loop_.Run(); |
| (...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 880 EXPECT_CALL(mock_scheduler(), Schedule(_, _, _, _)).Times(1); | 884 EXPECT_CALL(mock_scheduler(), Schedule(_, _, _, _)).Times(1); |
| 881 service()->OnDisabledReasonChanged(DisabledReason::NONE); | 885 service()->OnDisabledReasonChanged(DisabledReason::NONE); |
| 882 EXPECT_CALL(observer(), | 886 EXPECT_CALL(observer(), |
| 883 OnCategoryStatusChanged(_, _, CategoryStatus::AVAILABLE)); | 887 OnCategoryStatusChanged(_, _, CategoryStatus::AVAILABLE)); |
| 884 base::RunLoop().RunUntilIdle(); | 888 base::RunLoop().RunUntilIdle(); |
| 885 EXPECT_EQ(NTPSnippetsService::State::READY, service()->state_); | 889 EXPECT_EQ(NTPSnippetsService::State::READY, service()->state_); |
| 886 EXPECT_FALSE(service()->GetSnippetsForTesting().empty()); | 890 EXPECT_FALSE(service()->GetSnippetsForTesting().empty()); |
| 887 } | 891 } |
| 888 | 892 |
| 889 } // namespace ntp_snippets | 893 } // namespace ntp_snippets |
| OLD | NEW |