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 <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 846 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
857 | 857 |
858 service->FetchSuggestionImage( | 858 service->FetchSuggestionImage( |
859 MakeUniqueID(*service, kSnippetUrl2), | 859 MakeUniqueID(*service, kSnippetUrl2), |
860 base::Bind(&MockFunction<void(const gfx::Image&)>::Call, | 860 base::Bind(&MockFunction<void(const gfx::Image&)>::Call, |
861 base::Unretained(&image_fetched))); | 861 base::Unretained(&image_fetched))); |
862 | 862 |
863 base::RunLoop().RunUntilIdle(); | 863 base::RunLoop().RunUntilIdle(); |
864 EXPECT_TRUE(image.IsEmpty()); | 864 EXPECT_TRUE(image.IsEmpty()); |
865 } | 865 } |
866 | 866 |
| 867 TEST_F(NTPSnippetsServiceTest, ClearHistoryRemovesAllSuggestions) { |
| 868 auto service = MakeSnippetsService(); |
| 869 |
| 870 std::string first_snippet = GetSnippetWithUrl("http://url1.com"); |
| 871 std::string second_snippet = GetSnippetWithUrl("http://url2.com"); |
| 872 std::string json_str = GetTestJson({first_snippet, second_snippet}); |
| 873 LoadFromJSONString(service.get(), json_str); |
| 874 ASSERT_THAT(service->GetSnippetsForTesting(), SizeIs(2)); |
| 875 |
| 876 service->DismissSuggestion(MakeUniqueID(*service, "http://url1.com")); |
| 877 ASSERT_THAT(service->GetSnippetsForTesting(), SizeIs(1)); |
| 878 ASSERT_THAT(service->GetDismissedSnippetsForTesting(), SizeIs(1)); |
| 879 |
| 880 base::Time begin = base::Time::FromTimeT(123), |
| 881 end = base::Time::FromTimeT(456); |
| 882 base::Callback<bool(const GURL& url)> filter; |
| 883 service->ClearHistory(begin, end, filter); |
| 884 |
| 885 EXPECT_THAT(service->GetSnippetsForTesting(), IsEmpty()); |
| 886 EXPECT_THAT(service->GetDismissedSnippetsForTesting(), IsEmpty()); |
| 887 } |
| 888 |
867 } // namespace ntp_snippets | 889 } // namespace ntp_snippets |
OLD | NEW |