Index: ui/app_list/views/search_result_page_view_unittest.cc |
diff --git a/ui/app_list/views/search_result_page_view_unittest.cc b/ui/app_list/views/search_result_page_view_unittest.cc |
index c9087b737a789094af97bf9052c9c3d3cb2e8487..6878a58c1d237ed3ed14a55941c05f3960a97a1f 100644 |
--- a/ui/app_list/views/search_result_page_view_unittest.cc |
+++ b/ui/app_list/views/search_result_page_view_unittest.cc |
@@ -52,7 +52,7 @@ class SearchResultPageViewTest : public views::ViewsTestBase, |
for (const auto& data : result_types) { |
for (int i = 0; i < data.second; ++i) { |
TestSearchResult* result = new TestSearchResult(); |
- result->SetDisplayType(data.first); |
+ result->set_display_type(data.first); |
results->Add(result); |
} |
} |
@@ -124,5 +124,44 @@ TEST_F(SearchResultPageViewTest, Basic) { |
EXPECT_EQ(0, GetSelectedIndex()); |
} |
+TEST_F(SearchResultPageViewTest, ResultsSorted) { |
+ AppListModel::SearchResults* results = GetResults(); |
+ |
+ // Add 3 results and expect the tile list view to be the first result |
+ // container view. |
+ TestSearchResult* tile_result = new TestSearchResult(); |
+ tile_result->set_display_type(SearchResult::DISPLAY_TILE); |
+ tile_result->set_relevance(1.0); |
Matt Giuca
2015/02/17 08:24:20
Can you make this 0.4 (so the TILE comes in betwee
calamity
2015/02/18 01:28:30
Done.
|
+ results->Add(tile_result); |
+ { |
+ TestSearchResult* list_result = new TestSearchResult(); |
+ list_result->set_display_type(SearchResult::DISPLAY_LIST); |
+ list_result->set_relevance(0.5); |
+ results->Add(list_result); |
+ } |
+ { |
+ TestSearchResult* list_result = new TestSearchResult(); |
+ list_result->set_display_type(SearchResult::DISPLAY_LIST); |
+ list_result->set_relevance(0.3); |
+ results->Add(list_result); |
+ } |
+ |
+ // Adding results will schedule Update(). |
+ RunPendingMessages(); |
+ |
+ EXPECT_EQ(tile_list_view(), view()->result_container_views()[0]); |
+ EXPECT_EQ(list_view(), view()->result_container_views()[1]); |
+ |
+ // Change the relevance of the tile result and expect the list results to be |
+ // displayed first. |
+ tile_result->set_relevance(0.1); |
+ |
+ results->NotifyItemsChanged(0, 1); |
+ RunPendingMessages(); |
+ |
+ EXPECT_EQ(list_view(), view()->result_container_views()[0]); |
+ EXPECT_EQ(tile_list_view(), view()->result_container_views()[1]); |
+} |
+ |
} // namespace test |
} // namespace app_list |