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

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: fix compile 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
« no previous file with comments | « chrome/browser/ui/app_list/search/mixer.cc ('k') | ui/app_list/views/search_result_list_view.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 0ac4f48dda1029e484bb02009cd81d9617bf53f6..6d064cc5519aae93894bb96b49e894d7d4034247 100644
--- a/chrome/browser/ui/app_list/search/mixer_unittest.cc
+++ b/chrome/browser/ui/app_list/search/mixer_unittest.cc
@@ -201,6 +201,7 @@ TEST_F(MixerTest, Publish) {
scoped_ptr<ChromeSearchResult> result3(new TestSearchResult("app3", 0));
scoped_ptr<ChromeSearchResult> result3_copy = result3->Duplicate();
scoped_ptr<ChromeSearchResult> result4(new TestSearchResult("app4", 0));
+ scoped_ptr<ChromeSearchResult> result5(new TestSearchResult("app5", 0));
AppListModel::SearchResults ui_results;
@@ -256,6 +257,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(result5.get(), 1.0f);
+ 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
« no previous file with comments | « chrome/browser/ui/app_list/search/mixer.cc ('k') | ui/app_list/views/search_result_list_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698