| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/remote/remote_suggestions_fetcher.h" | 5 #include "components/ntp_snippets/remote/remote_suggestions_fetcher.h" |
| 6 | 6 |
| 7 #include <deque> | 7 #include <deque> |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 669 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 680 | 680 |
| 681 ASSERT_TRUE(fetched_categories); | 681 ASSERT_TRUE(fetched_categories); |
| 682 ASSERT_THAT(fetched_categories->size(), Eq(1u)); | 682 ASSERT_THAT(fetched_categories->size(), Eq(1u)); |
| 683 const auto& category = (*fetched_categories)[0]; | 683 const auto& category = (*fetched_categories)[0]; |
| 684 EXPECT_THAT(category.category.id(), Eq(Category::FromRemoteCategory(2).id())); | 684 EXPECT_THAT(category.category.id(), Eq(Category::FromRemoteCategory(2).id())); |
| 685 ASSERT_THAT(category.suggestions.size(), Eq(1u)); | 685 ASSERT_THAT(category.suggestions.size(), Eq(1u)); |
| 686 EXPECT_THAT(category.suggestions[0]->url().spec(), | 686 EXPECT_THAT(category.suggestions[0]->url().spec(), |
| 687 Eq("http://localhost/foo2")); | 687 Eq("http://localhost/foo2")); |
| 688 } | 688 } |
| 689 | 689 |
| 690 // TODO(fhorschig): Check for behavioral changes instead of state. | |
| 691 TEST_F(ChromeReaderSnippetsFetcherTest, PersonalizesDependingOnVariations) { | |
| 692 // Default setting should be both personalization options. | |
| 693 EXPECT_THAT(snippets_fetcher().personalization(), Eq(Personalization::kBoth)); | |
| 694 | |
| 695 SetVariationParam("fetching_personalization", "personal"); | |
| 696 ResetSnippetsFetcher(); | |
| 697 EXPECT_THAT(snippets_fetcher().personalization(), | |
| 698 Eq(Personalization::kPersonal)); | |
| 699 | |
| 700 SetVariationParam("fetching_personalization", "non_personal"); | |
| 701 ResetSnippetsFetcher(); | |
| 702 EXPECT_THAT(snippets_fetcher().personalization(), | |
| 703 Eq(Personalization::kNonPersonal)); | |
| 704 | |
| 705 SetVariationParam("fetching_personalization", "both"); | |
| 706 ResetSnippetsFetcher(); | |
| 707 EXPECT_THAT(snippets_fetcher().personalization(), Eq(Personalization::kBoth)); | |
| 708 } | |
| 709 | |
| 710 TEST_F(ChromeReaderSnippetsFetcherTest, ShouldFetchSuccessfullyEmptyList) { | 690 TEST_F(ChromeReaderSnippetsFetcherTest, ShouldFetchSuccessfullyEmptyList) { |
| 711 const std::string kJsonStr = "{\"recos\": []}"; | 691 const std::string kJsonStr = "{\"recos\": []}"; |
| 712 SetFakeResponse(/*response_data=*/kJsonStr, net::HTTP_OK, | 692 SetFakeResponse(/*response_data=*/kJsonStr, net::HTTP_OK, |
| 713 net::URLRequestStatus::SUCCESS); | 693 net::URLRequestStatus::SUCCESS); |
| 714 EXPECT_CALL(mock_callback(), Run(IsSuccess(), IsEmptyArticleList())); | 694 EXPECT_CALL(mock_callback(), Run(IsSuccess(), IsEmptyArticleList())); |
| 715 snippets_fetcher().FetchSnippets( | 695 snippets_fetcher().FetchSnippets( |
| 716 test_params(), ToSnippetsAvailableCallback(&mock_callback())); | 696 test_params(), ToSnippetsAvailableCallback(&mock_callback())); |
| 717 FastForwardUntilNoTasksRemain(); | 697 FastForwardUntilNoTasksRemain(); |
| 718 EXPECT_THAT(snippets_fetcher().last_status(), Eq("OK")); | 698 EXPECT_THAT(snippets_fetcher().last_status(), Eq("OK")); |
| 719 EXPECT_THAT(snippets_fetcher().last_json(), Eq(kJsonStr)); | 699 EXPECT_THAT(snippets_fetcher().last_json(), Eq(kJsonStr)); |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 922 fetched_categories) { | 902 fetched_categories) { |
| 923 if (fetched_categories) { | 903 if (fetched_categories) { |
| 924 // Matchers above aren't any more precise than this, so this is sufficient | 904 // Matchers above aren't any more precise than this, so this is sufficient |
| 925 // for test-failure diagnostics. | 905 // for test-failure diagnostics. |
| 926 return os << "list with " << fetched_categories->size() << " elements"; | 906 return os << "list with " << fetched_categories->size() << " elements"; |
| 927 } | 907 } |
| 928 return os << "null"; | 908 return os << "null"; |
| 929 } | 909 } |
| 930 | 910 |
| 931 } // namespace ntp_snippets | 911 } // namespace ntp_snippets |
| OLD | NEW |