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

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

Issue 369693004: Make app list search result mixer more resilient to reordering. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rework algorithm, rebase onto https://codereview.chromium.org/372843003/ 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 2627a6dec54c6ed67e715c9b23e02dc9ec7945f1..f606b0094a37ea8ca34c8184726e77045f9dbda4 100644
--- a/chrome/browser/ui/app_list/search/mixer_unittest.cc
+++ b/chrome/browser/ui/app_list/search/mixer_unittest.cc
@@ -250,6 +250,30 @@ TEST_F(MixerTest, Publish) {
// The third result will use the original object as the ID did not change.
EXPECT_EQ(old_ui_result_ids[2],
TestSearchResult::GetInstanceId(ui_results.GetItemAt(2)));
+
+ // Save the current |ui_results| order which should is app4, app2, app3.
+ old_ui_result_ids.clear();
+ for (size_t i = 0; i < ui_results.item_count(); ++i) {
+ old_ui_result_ids.push_back(
+ TestSearchResult::GetInstanceId(ui_results.GetItemAt(i)));
+ }
+
+ // Reorder the existing results and add a new one in the second place.
+ new_results[0] = Mixer::SortData(result2.get(), 1.0f);
+ new_results[1] = Mixer::SortData(result1.get(), 1.0f);
Matt Giuca 2014/07/09 01:30:54 I think this is the "new one", correct? (Because r
calamity 2014/07/09 03:03:48 Done.
+ new_results[2] = Mixer::SortData(result3.get(), 1.0f);
+ new_results.push_back(Mixer::SortData(result4.get(), 1.0f));
+
+ Mixer::Publish(new_results, &ui_results);
+ EXPECT_EQ(4u, ui_results.item_count());
+
+ // The reordered results should use the original objects.
+ EXPECT_EQ(old_ui_result_ids[0],
+ TestSearchResult::GetInstanceId(ui_results.GetItemAt(3)));
+ EXPECT_EQ(old_ui_result_ids[1],
+ TestSearchResult::GetInstanceId(ui_results.GetItemAt(0)));
+ EXPECT_EQ(old_ui_result_ids[2],
+ TestSearchResult::GetInstanceId(ui_results.GetItemAt(2)));
}
} // namespace test

Powered by Google App Engine
This is Rietveld 408576698