Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(351)

Side by Side Diff: components/ntp_snippets/remote/remote_suggestions_fetcher_unittest.cc

Issue 2665743002: [Remote suggestions] Clean up variation params in the fetcher. (Closed)
Patch Set: Further changes & unit-test fixes Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 664 matching lines...) Expand 10 before | Expand all | Expand 10 after
675 675
676 ASSERT_TRUE(fetched_categories); 676 ASSERT_TRUE(fetched_categories);
677 ASSERT_THAT(fetched_categories->size(), Eq(1u)); 677 ASSERT_THAT(fetched_categories->size(), Eq(1u));
678 const auto& category = (*fetched_categories)[0]; 678 const auto& category = (*fetched_categories)[0];
679 EXPECT_THAT(category.category.id(), Eq(Category::FromRemoteCategory(2).id())); 679 EXPECT_THAT(category.category.id(), Eq(Category::FromRemoteCategory(2).id()));
680 ASSERT_THAT(category.suggestions.size(), Eq(1u)); 680 ASSERT_THAT(category.suggestions.size(), Eq(1u));
681 EXPECT_THAT(category.suggestions[0]->url().spec(), 681 EXPECT_THAT(category.suggestions[0]->url().spec(),
682 Eq("http://localhost/foo2")); 682 Eq("http://localhost/foo2"));
683 } 683 }
684 684
685 // TODO(fhorschig): Check for behavioral changes instead of state.
686 TEST_F(ChromeReaderSnippetsFetcherTest, PersonalizesDependingOnVariations) {
687 // Default setting should be both personalization options.
688 EXPECT_THAT(snippets_fetcher().personalization(), Eq(Personalization::kBoth));
689
690 SetVariationParam("fetching_personalization", "personal");
691 ResetSnippetsFetcher();
692 EXPECT_THAT(snippets_fetcher().personalization(),
693 Eq(Personalization::kPersonal));
694
695 SetVariationParam("fetching_personalization", "non_personal");
696 ResetSnippetsFetcher();
697 EXPECT_THAT(snippets_fetcher().personalization(),
698 Eq(Personalization::kNonPersonal));
699
700 SetVariationParam("fetching_personalization", "both");
701 ResetSnippetsFetcher();
702 EXPECT_THAT(snippets_fetcher().personalization(), Eq(Personalization::kBoth));
703 }
704
705 TEST_F(ChromeReaderSnippetsFetcherTest, ShouldFetchSuccessfullyEmptyList) { 685 TEST_F(ChromeReaderSnippetsFetcherTest, ShouldFetchSuccessfullyEmptyList) {
706 const std::string kJsonStr = "{\"recos\": []}"; 686 const std::string kJsonStr = "{\"recos\": []}";
707 SetFakeResponse(/*response_data=*/kJsonStr, net::HTTP_OK, 687 SetFakeResponse(/*response_data=*/kJsonStr, net::HTTP_OK,
708 net::URLRequestStatus::SUCCESS); 688 net::URLRequestStatus::SUCCESS);
709 EXPECT_CALL(mock_callback(), Run(IsSuccess(), IsEmptyArticleList())); 689 EXPECT_CALL(mock_callback(), Run(IsSuccess(), IsEmptyArticleList()));
710 snippets_fetcher().FetchSnippets( 690 snippets_fetcher().FetchSnippets(
711 test_params(), ToSnippetsAvailableCallback(&mock_callback())); 691 test_params(), ToSnippetsAvailableCallback(&mock_callback()));
712 FastForwardUntilNoTasksRemain(); 692 FastForwardUntilNoTasksRemain();
713 EXPECT_THAT(snippets_fetcher().last_status(), Eq("OK")); 693 EXPECT_THAT(snippets_fetcher().last_status(), Eq("OK"));
714 EXPECT_THAT(snippets_fetcher().last_json(), Eq(kJsonStr)); 694 EXPECT_THAT(snippets_fetcher().last_json(), Eq(kJsonStr));
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after
917 fetched_categories) { 897 fetched_categories) {
918 if (fetched_categories) { 898 if (fetched_categories) {
919 // Matchers above aren't any more precise than this, so this is sufficient 899 // Matchers above aren't any more precise than this, so this is sufficient
920 // for test-failure diagnostics. 900 // for test-failure diagnostics.
921 return os << "list with " << fetched_categories->size() << " elements"; 901 return os << "list with " << fetched_categories->size() << " elements";
922 } 902 }
923 return os << "null"; 903 return os << "null";
924 } 904 }
925 905
926 } // namespace ntp_snippets 906 } // namespace ntp_snippets
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698