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

Side by Side Diff: chrome/browser/android/ntp/most_visited_sites_unittest.cc

Issue 1919823002: Update MostVisitedSites observer interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: iMove move to .cc. Created 4 years, 8 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 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 "chrome/browser/android/ntp/most_visited_sites.h" 5 #include "chrome/browser/android/ntp/most_visited_sites.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <vector> 10 #include <vector>
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 // - Ensuring personal suggestions are not duplicated in popular suggestions. 46 // - Ensuring personal suggestions are not duplicated in popular suggestions.
47 class MostVisitedSitesTest : public testing::Test { 47 class MostVisitedSitesTest : public testing::Test {
48 protected: 48 protected:
49 void Check(const std::vector<TitleURL>& popular_sites, 49 void Check(const std::vector<TitleURL>& popular_sites,
50 const std::vector<TitleURL>& whitelist_entry_points, 50 const std::vector<TitleURL>& whitelist_entry_points,
51 const std::vector<TitleURL>& personal_sites, 51 const std::vector<TitleURL>& personal_sites,
52 const std::vector<std::string>& old_sites_url, 52 const std::vector<std::string>& old_sites_url,
53 const std::vector<bool>& old_sites_is_personal, 53 const std::vector<bool>& old_sites_is_personal,
54 const std::vector<bool>& expected_sites_is_personal, 54 const std::vector<bool>& expected_sites_is_personal,
55 const std::vector<TitleURL>& expected_sites) { 55 const std::vector<TitleURL>& expected_sites) {
56 MostVisitedSites::SuggestionsVector personal_suggestions; 56 MostVisitedSites::SuggestionsPtrVector personal_suggestions;
57 for (const TitleURL& site : personal_sites) 57 for (const TitleURL& site : personal_sites)
58 personal_suggestions.push_back(MakeSuggestionFrom(site, true, false)); 58 personal_suggestions.push_back(MakeSuggestionFrom(site, true, false));
59 MostVisitedSites::SuggestionsVector whitelist_suggestions; 59 MostVisitedSites::SuggestionsPtrVector whitelist_suggestions;
60 for (const TitleURL& site : whitelist_entry_points) 60 for (const TitleURL& site : whitelist_entry_points)
61 whitelist_suggestions.push_back(MakeSuggestionFrom(site, false, true)); 61 whitelist_suggestions.push_back(MakeSuggestionFrom(site, false, true));
62 MostVisitedSites::SuggestionsVector popular_suggestions; 62 MostVisitedSites::SuggestionsPtrVector popular_suggestions;
63 for (const TitleURL& site : popular_sites) 63 for (const TitleURL& site : popular_sites)
64 popular_suggestions.push_back(MakeSuggestionFrom(site, false, false)); 64 popular_suggestions.push_back(MakeSuggestionFrom(site, false, false));
65 MostVisitedSites::SuggestionsVector result_suggestions = 65 MostVisitedSites::SuggestionsPtrVector result_suggestions =
66 MostVisitedSites::MergeSuggestions( 66 MostVisitedSites::MergeSuggestions(
67 &personal_suggestions, &whitelist_suggestions, &popular_suggestions, 67 &personal_suggestions, &whitelist_suggestions, &popular_suggestions,
68 old_sites_url, old_sites_is_personal); 68 old_sites_url, old_sites_is_personal);
69 std::vector<TitleURL> result_sites; 69 std::vector<TitleURL> result_sites;
70 std::vector<bool> result_is_personal; 70 std::vector<bool> result_is_personal;
71 result_sites.reserve(result_suggestions.size()); 71 result_sites.reserve(result_suggestions.size());
72 result_is_personal.reserve(result_suggestions.size()); 72 result_is_personal.reserve(result_suggestions.size());
73 for (const auto& suggestion : result_suggestions) { 73 for (const auto& suggestion : result_suggestions) {
74 result_sites.push_back( 74 result_sites.push_back(
75 TitleURL(suggestion->title, suggestion->url.spec())); 75 TitleURL(suggestion->title, suggestion->url.spec()));
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 bool expected_source_is_personal[] = {false, true, true, false}; 232 bool expected_source_is_personal[] = {false, true, true, false};
233 Check(std::vector<TitleURL>(popular, popular + arraysize(popular)), 233 Check(std::vector<TitleURL>(popular, popular + arraysize(popular)),
234 std::vector<TitleURL>(), 234 std::vector<TitleURL>(),
235 std::vector<TitleURL>(personal, personal + arraysize(personal)), 235 std::vector<TitleURL>(personal, personal + arraysize(personal)),
236 std::vector<std::string>(old, old + arraysize(old)), old_sites_source, 236 std::vector<std::string>(old, old + arraysize(old)), old_sites_source,
237 std::vector<bool>(expected_source_is_personal, 237 std::vector<bool>(expected_source_is_personal,
238 expected_source_is_personal + 238 expected_source_is_personal +
239 arraysize(expected_source_is_personal)), 239 arraysize(expected_source_is_personal)),
240 std::vector<TitleURL>(expected, expected + arraysize(expected))); 240 std::vector<TitleURL>(expected, expected + arraysize(expected)));
241 } 241 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698