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

Side by Side Diff: components/ntp_snippets/content_suggestions_service_unittest.cc

Issue 2463133002: 📰 Make the MORE button more configurable (Closed)
Patch Set: rebase Created 4 years, 1 month 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/content_suggestions_service.h" 5 #include "components/ntp_snippets/content_suggestions_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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 statuses_[category.id()] = CategoryStatus::AVAILABLE; 53 statuses_[category.id()] = CategoryStatus::AVAILABLE;
54 } 54 }
55 } 55 }
56 56
57 CategoryStatus GetCategoryStatus(Category category) override { 57 CategoryStatus GetCategoryStatus(Category category) override {
58 return statuses_[category.id()]; 58 return statuses_[category.id()];
59 } 59 }
60 60
61 CategoryInfo GetCategoryInfo(Category category) override { 61 CategoryInfo GetCategoryInfo(Category category) override {
62 return CategoryInfo(base::ASCIIToUTF16("Section title"), 62 return CategoryInfo(base::ASCIIToUTF16("Section title"),
63 ContentSuggestionsCardLayout::FULL_CARD, true, true, 63 ContentSuggestionsCardLayout::FULL_CARD, true, false,
64 true, false,
64 base::ASCIIToUTF16("No suggestions message")); 65 base::ASCIIToUTF16("No suggestions message"));
65 } 66 }
66 67
67 void FireSuggestionsChanged( 68 void FireSuggestionsChanged(
68 Category category, 69 Category category,
69 std::vector<ContentSuggestion> suggestions) { 70 std::vector<ContentSuggestion> suggestions) {
70 observer()->OnNewSuggestions(this, category, std::move(suggestions)); 71 observer()->OnNewSuggestions(this, category, std::move(suggestions));
71 } 72 }
72 73
73 void FireCategoryStatusChanged(Category category, CategoryStatus new_status) { 74 void FireCategoryStatusChanged(Category category, CategoryStatus new_status) {
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 TEST_F(ContentSuggestionsServiceTest, ShouldReturnCategoryInfo) { 471 TEST_F(ContentSuggestionsServiceTest, ShouldReturnCategoryInfo) {
471 Category category = FromKnownCategory(KnownCategories::DOWNLOADS); 472 Category category = FromKnownCategory(KnownCategories::DOWNLOADS);
472 MockProvider* provider = RegisterProvider(category); 473 MockProvider* provider = RegisterProvider(category);
473 provider->FireCategoryStatusChangedWithCurrentStatus(category); 474 provider->FireCategoryStatusChangedWithCurrentStatus(category);
474 base::Optional<CategoryInfo> result = service()->GetCategoryInfo(category); 475 base::Optional<CategoryInfo> result = service()->GetCategoryInfo(category);
475 ASSERT_TRUE(result.has_value()); 476 ASSERT_TRUE(result.has_value());
476 CategoryInfo expected = provider->GetCategoryInfo(category); 477 CategoryInfo expected = provider->GetCategoryInfo(category);
477 const CategoryInfo& actual = result.value(); 478 const CategoryInfo& actual = result.value();
478 EXPECT_THAT(expected.title(), Eq(actual.title())); 479 EXPECT_THAT(expected.title(), Eq(actual.title()));
479 EXPECT_THAT(expected.card_layout(), Eq(actual.card_layout())); 480 EXPECT_THAT(expected.card_layout(), Eq(actual.card_layout()));
480 EXPECT_THAT(expected.has_more_button(), Eq(actual.has_more_button())); 481 EXPECT_THAT(expected.has_more_action(), Eq(actual.has_more_action()));
482 EXPECT_THAT(expected.has_reload_action(), Eq(actual.has_reload_action()));
483 EXPECT_THAT(expected.has_view_all_action(), Eq(actual.has_view_all_action()));
481 } 484 }
482 485
483 TEST_F(ContentSuggestionsServiceTest, 486 TEST_F(ContentSuggestionsServiceTest,
484 ShouldRegisterNewCategoryOnNewSuggestions) { 487 ShouldRegisterNewCategoryOnNewSuggestions) {
485 Category category = FromKnownCategory(KnownCategories::DOWNLOADS); 488 Category category = FromKnownCategory(KnownCategories::DOWNLOADS);
486 MockProvider* provider = RegisterProvider(category); 489 MockProvider* provider = RegisterProvider(category);
487 provider->FireCategoryStatusChangedWithCurrentStatus(category); 490 provider->FireCategoryStatusChangedWithCurrentStatus(category);
488 MockServiceObserver observer; 491 MockServiceObserver observer;
489 service()->AddObserver(&observer); 492 service()->AddObserver(&observer);
490 493
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 provider = RegisterProvider(category); 686 provider = RegisterProvider(category);
684 provider->FireCategoryStatusChangedWithCurrentStatus(category); 687 provider->FireCategoryStatusChangedWithCurrentStatus(category);
685 EXPECT_TRUE(service()->IsCategoryDismissed(category)); 688 EXPECT_TRUE(service()->IsCategoryDismissed(category));
686 689
687 service()->RestoreDismissedCategories(); 690 service()->RestoreDismissedCategories();
688 EXPECT_FALSE(service()->IsCategoryDismissed(category)); 691 EXPECT_FALSE(service()->IsCategoryDismissed(category));
689 EXPECT_THAT(providers().find(category)->second, Eq(provider)); 692 EXPECT_THAT(providers().find(category)->second, Eq(provider));
690 } 693 }
691 694
692 } // namespace ntp_snippets 695 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/category_info.cc ('k') | components/ntp_snippets/offline_pages/recent_tab_suggestions_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698