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

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

Issue 2610553002: [NTP::SectionOrder] Make ClickBasedRanker move dismissed sections down. (Closed)
Patch Set: jkrcal@ comment. Created 3 years, 11 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
« no previous file with comments | « components/ntp_snippets/content_suggestions_service.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/message_loop/message_loop.h" 14 #include "base/message_loop/message_loop.h"
15 #include "base/run_loop.h" 15 #include "base/run_loop.h"
16 #include "base/strings/string_number_conversions.h" 16 #include "base/strings/string_number_conversions.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "components/ntp_snippets/category_info.h" 18 #include "components/ntp_snippets/category_info.h"
19 #include "components/ntp_snippets/category_rankers/constant_category_ranker.h" 19 #include "components/ntp_snippets/category_rankers/constant_category_ranker.h"
20 #include "components/ntp_snippets/category_rankers/fake_category_ranker.h" 20 #include "components/ntp_snippets/category_rankers/fake_category_ranker.h"
21 #include "components/ntp_snippets/category_rankers/mock_category_ranker.h"
21 #include "components/ntp_snippets/category_status.h" 22 #include "components/ntp_snippets/category_status.h"
22 #include "components/ntp_snippets/content_suggestion.h" 23 #include "components/ntp_snippets/content_suggestion.h"
23 #include "components/ntp_snippets/content_suggestions_provider.h" 24 #include "components/ntp_snippets/content_suggestions_provider.h"
24 #include "components/ntp_snippets/user_classifier.h" 25 #include "components/ntp_snippets/user_classifier.h"
25 #include "components/prefs/testing_pref_service.h" 26 #include "components/prefs/testing_pref_service.h"
26 #include "testing/gmock/include/gmock/gmock.h" 27 #include "testing/gmock/include/gmock/gmock.h"
27 #include "testing/gtest/include/gtest/gtest.h" 28 #include "testing/gtest/include/gtest/gtest.h"
28 #include "ui/gfx/image/image.h" 29 #include "ui/gfx/image/image.h"
29 30
30 using testing::_; 31 using testing::_;
(...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after
736 ElementsAre(first_category, second_category)); 737 ElementsAre(first_category, second_category));
737 738
738 // The order to display (in the ranker) changes. 739 // The order to display (in the ranker) changes.
739 raw_fake_ranker->SetOrder({second_category, first_category}); 740 raw_fake_ranker->SetOrder({second_category, first_category});
740 741
741 // Categories order should reflect the new order. 742 // Categories order should reflect the new order.
742 EXPECT_THAT(service()->GetCategories(), 743 EXPECT_THAT(service()->GetCategories(),
743 ElementsAre(second_category, first_category)); 744 ElementsAre(second_category, first_category));
744 } 745 }
745 746
747 TEST_F(ContentSuggestionsServiceTest,
748 ShouldForwardDismissedCategoryToCategoryRanker) {
749 auto mock_ranker = base::MakeUnique<MockCategoryRanker>();
750 MockCategoryRanker* raw_mock_ranker = mock_ranker.get();
751 SetCategoryRanker(std::move(mock_ranker));
752
753 // The service is recreated to pick up the new ranker.
754 ResetService();
755
756 Category category = Category::FromKnownCategory(KnownCategories::BOOKMARKS);
757 MockProvider* provider = RegisterProvider(category);
758 provider->FireCategoryStatusChangedWithCurrentStatus(category);
759
760 EXPECT_CALL(*raw_mock_ranker, OnCategoryDismissed(category));
761 service()->DismissCategory(category);
762 }
763
746 } // namespace ntp_snippets 764 } // namespace ntp_snippets
OLDNEW
« no previous file with comments | « components/ntp_snippets/content_suggestions_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698