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

Side by Side Diff: ui/app_list/views/search_result_page_view_unittest.cc

Issue 922063003: Sort experimental app list search result groups. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@fix_search_results_not_being_there
Patch Set: rebase Created 5 years, 10 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ui/app_list/views/search_result_page_view.h" 5 #include "ui/app_list/views/search_result_page_view.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "ui/app_list/app_list_model.h" 9 #include "ui/app_list/app_list_model.h"
10 #include "ui/app_list/test/app_list_test_view_delegate.h" 10 #include "ui/app_list/test/app_list_test_view_delegate.h"
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 AppListModel::SearchResults* GetResults() { 45 AppListModel::SearchResults* GetResults() {
46 return view_delegate_.GetModel()->results(); 46 return view_delegate_.GetModel()->results();
47 } 47 }
48 48
49 void SetUpSearchResults( 49 void SetUpSearchResults(
50 const std::map<SearchResult::DisplayType, int> result_types) { 50 const std::map<SearchResult::DisplayType, int> result_types) {
51 AppListModel::SearchResults* results = GetResults(); 51 AppListModel::SearchResults* results = GetResults();
52 for (const auto& data : result_types) { 52 for (const auto& data : result_types) {
53 for (int i = 0; i < data.second; ++i) { 53 for (int i = 0; i < data.second; ++i) {
54 TestSearchResult* result = new TestSearchResult(); 54 TestSearchResult* result = new TestSearchResult();
55 result->SetDisplayType(data.first); 55 result->set_display_type(data.first);
56 results->Add(result); 56 results->Add(result);
57 } 57 }
58 } 58 }
59 59
60 // Adding results will schedule Update(). 60 // Adding results will schedule Update().
61 RunPendingMessages(); 61 RunPendingMessages();
62 } 62 }
63 63
64 int GetSelectedIndex() { return view_->selected_index(); } 64 int GetSelectedIndex() { return view_->selected_index(); }
65 65
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 EXPECT_EQ(-1, tile_list_view()->selected_index()); 117 EXPECT_EQ(-1, tile_list_view()->selected_index());
118 118
119 // Navigate off top of list. 119 // Navigate off top of list.
120 EXPECT_TRUE(KeyPress(ui::VKEY_UP)); 120 EXPECT_TRUE(KeyPress(ui::VKEY_UP));
121 EXPECT_EQ(0, list_view()->selected_index()); 121 EXPECT_EQ(0, list_view()->selected_index());
122 EXPECT_FALSE(KeyPress(ui::VKEY_UP)); 122 EXPECT_FALSE(KeyPress(ui::VKEY_UP));
123 EXPECT_EQ(0, list_view()->selected_index()); 123 EXPECT_EQ(0, list_view()->selected_index());
124 EXPECT_EQ(0, GetSelectedIndex()); 124 EXPECT_EQ(0, GetSelectedIndex());
125 } 125 }
126 126
127 TEST_F(SearchResultPageViewTest, ResultsSorted) {
128 AppListModel::SearchResults* results = GetResults();
129
130 // Add 3 results and expect the tile list view to be the first result
131 // container view.
132 TestSearchResult* tile_result = new TestSearchResult();
133 tile_result->set_display_type(SearchResult::DISPLAY_TILE);
134 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.
135 results->Add(tile_result);
136 {
137 TestSearchResult* list_result = new TestSearchResult();
138 list_result->set_display_type(SearchResult::DISPLAY_LIST);
139 list_result->set_relevance(0.5);
140 results->Add(list_result);
141 }
142 {
143 TestSearchResult* list_result = new TestSearchResult();
144 list_result->set_display_type(SearchResult::DISPLAY_LIST);
145 list_result->set_relevance(0.3);
146 results->Add(list_result);
147 }
148
149 // Adding results will schedule Update().
150 RunPendingMessages();
151
152 EXPECT_EQ(tile_list_view(), view()->result_container_views()[0]);
153 EXPECT_EQ(list_view(), view()->result_container_views()[1]);
154
155 // Change the relevance of the tile result and expect the list results to be
156 // displayed first.
157 tile_result->set_relevance(0.1);
158
159 results->NotifyItemsChanged(0, 1);
160 RunPendingMessages();
161
162 EXPECT_EQ(list_view(), view()->result_container_views()[0]);
163 EXPECT_EQ(tile_list_view(), view()->result_container_views()[1]);
164 }
165
127 } // namespace test 166 } // namespace test
128 } // namespace app_list 167 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698