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

Unified Diff: chrome/browser/ui/app_list/search/mixer_unittest.cc

Issue 372843003: Add unit test for Mixer::Publish. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/app_list/search/mixer_unittest.cc
diff --git a/chrome/browser/ui/app_list/search/mixer_unittest.cc b/chrome/browser/ui/app_list/search/mixer_unittest.cc
index ddcf3a9f31cd40eac20ee2e79bc78c5d4f1173b3..7eb52f6ed6d3c6f5e222b880ba79da3ad3e20df5 100644
--- a/chrome/browser/ui/app_list/search/mixer_unittest.cc
+++ b/chrome/browser/ui/app_list/search/mixer_unittest.cc
@@ -182,5 +182,44 @@ TEST_F(MixerTest, RemoveDuplicates) {
EXPECT_EQ("dup0,dup1,dup2", GetResults());
}
+TEST_F(MixerTest, PublishReusesExisting) {
Matt Giuca 2014/07/08 01:48:23 I think should just call this "Publish" (as it is
calamity 2014/07/08 04:23:00 Done.
+ ScopedVector<TestSearchResult> test_results;
Matt Giuca 2014/07/08 01:48:24 I don't think you should use a vector here. It imp
calamity 2014/07/08 04:23:00 Done.
+ test_results.push_back(new TestSearchResult("app1", 0));
+ test_results.push_back(new TestSearchResult("app2", 0));
+ test_results.push_back(new TestSearchResult("app3", 0));
+ test_results.push_back(new TestSearchResult("app4", 0));
+
+ AppListModel::SearchResults ui_results;
Matt Giuca 2014/07/08 01:48:23 // Publish the first three results to |ui_results|
calamity 2014/07/08 04:23:01 Done.
+ std::vector<Mixer::SortData> new_results;
+
+ new_results.push_back(Mixer::SortData(test_results[0], 1.0f));
+ new_results.push_back(Mixer::SortData(test_results[1], 1.0f));
+ new_results.push_back(Mixer::SortData(test_results[2], 1.0f));
+
+ Mixer::Publish(new_results, &ui_results);
+ EXPECT_EQ(3u, ui_results.item_count());
Matt Giuca 2014/07/08 01:48:23 EXPECT_EQ(new_results[0], ui_results.GetItemAt(0))
calamity 2014/07/08 04:23:00 As discussed, this isn't true since new copies get
+
+ // Ensure old results are reused if the ID is the same.
Matt Giuca 2014/07/08 01:48:23 Save the "ensures" for the EXPECT section. Here ju
calamity 2014/07/08 04:23:00 Done.
+ std::vector<const SearchResult*> old_ui_results;
+ for (size_t i = 0; i < ui_results.item_count(); ++i)
+ old_ui_results.push_back(ui_results.GetItemAt(i));
+
+ // The first result will be different as the ID has changed.
Matt Giuca 2014/07/08 01:48:23 // Change the first result to a totally new object
calamity 2014/07/08 04:23:00 Done.
+ new_results[0] = Mixer::SortData(test_results[3], 1.0f);
Matt Giuca 2014/07/08 01:48:23 Shouldn't you have: new_results[1] = Mixer::SortDa
calamity 2014/07/08 04:23:00 As discussed, copies are always made because the i
Matt Giuca 2014/07/08 05:31:45 As discussed, do the duplication on 2, not 3 (to t
+
+ // The second result will have a different title but still use the original
+ // object.
Matt Giuca 2014/07/08 01:48:23 This is VERY CONFUSING since without reading TestS
calamity 2014/07/08 04:23:00 Done.
+ const base::string16 kApp2AltName = base::UTF8ToUTF16("app2altname");
+ new_results[1].result->set_title(kApp2AltName);
+
+ Mixer::Publish(new_results, &ui_results);
+ EXPECT_EQ(3u, ui_results.item_count());
+
+ EXPECT_NE(old_ui_results[0], ui_results.GetItemAt(0));
Matt Giuca 2014/07/08 01:48:23 // The first result will be a new object, as the I
calamity 2014/07/08 04:23:00 Done. Second check does not apply.
+ EXPECT_EQ(old_ui_results[1], ui_results.GetItemAt(1));
Matt Giuca 2014/07/08 01:48:23 // The second result will still use the original o
calamity 2014/07/08 04:23:00 Done.
+ EXPECT_EQ(kApp2AltName, new_results[1].result->title());
Matt Giuca 2014/07/08 01:48:23 This isn't testing anything. Should be: EXPECT_EQ(
calamity 2014/07/08 04:23:00 Done.
+ EXPECT_EQ(old_ui_results[2], ui_results.GetItemAt(2));
+}
+
} // namespace test
} // namespace app_list
« chrome/browser/ui/app_list/search/mixer.h ('K') | « chrome/browser/ui/app_list/search/mixer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698