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

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

Issue 621823004: Simplifies the structure of app_list search a bit. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix Created 6 years, 2 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_list_view.h" 5 #include "ui/app_list/views/search_result_list_view.h"
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "ui/app_list/app_list_model.h" 10 #include "ui/app_list/app_list_model.h"
11 #include "ui/app_list/search_result.h"
12 #include "ui/app_list/test/app_list_test_view_delegate.h" 11 #include "ui/app_list/test/app_list_test_view_delegate.h"
12 #include "ui/app_list/test/test_search_result.h"
13 #include "ui/app_list/views/progress_bar_view.h" 13 #include "ui/app_list/views/progress_bar_view.h"
14 #include "ui/app_list/views/search_result_list_view_delegate.h" 14 #include "ui/app_list/views/search_result_list_view_delegate.h"
15 #include "ui/app_list/views/search_result_view.h" 15 #include "ui/app_list/views/search_result_view.h"
16 #include "ui/views/test/views_test_base.h" 16 #include "ui/views/test/views_test_base.h"
17 17
18 namespace app_list { 18 namespace app_list {
19 namespace test { 19 namespace test {
20 20
21 namespace { 21 namespace {
22 int kDefaultSearchItems = 5; 22 int kDefaultSearchItems = 5;
(...skipping 25 matching lines...) Expand all
48 view_delegate_.set_auto_launch_timeout(base::TimeDelta::FromDays(1)); 48 view_delegate_.set_auto_launch_timeout(base::TimeDelta::FromDays(1));
49 } 49 }
50 50
51 base::TimeDelta GetAutoLaunchTimeout() { 51 base::TimeDelta GetAutoLaunchTimeout() {
52 return view_delegate_.GetAutoLaunchTimeout(); 52 return view_delegate_.GetAutoLaunchTimeout();
53 } 53 }
54 54
55 void SetUpSearchResults() { 55 void SetUpSearchResults() {
56 AppListModel::SearchResults* results = GetResults(); 56 AppListModel::SearchResults* results = GetResults();
57 for (int i = 0; i < kDefaultSearchItems; ++i) 57 for (int i = 0; i < kDefaultSearchItems; ++i)
58 results->Add(new SearchResult()); 58 results->Add(new TestSearchResult());
59 59
60 // Adding results will schedule Update(). 60 // Adding results will schedule Update().
61 RunPendingMessages(); 61 RunPendingMessages();
62 } 62 }
63 63
64 int GetOpenResultCountAndReset(int ranking) { 64 int GetOpenResultCountAndReset(int ranking) {
65 int result = view_delegate_.open_search_result_counts()[ranking]; 65 int result = view_delegate_.open_search_result_counts()[ranking];
66 view_delegate_.open_search_result_counts().clear(); 66 view_delegate_.open_search_result_counts().clear();
67 return result; 67 return result;
68 } 68 }
69 69
70 int GetResultCount() { return view_->last_visible_index_ + 1; } 70 int GetResultCount() { return view_->last_visible_index_ + 1; }
71 71
72 int GetSelectedIndex() { 72 int GetSelectedIndex() {
73 return view_->selected_index_; 73 return view_->selected_index_;
74 } 74 }
75 75
76 void ResetSelectedIndex() { 76 void ResetSelectedIndex() {
77 view_->SetSelectedIndex(0); 77 view_->SetSelectedIndex(0);
78 } 78 }
79 79
80 void AddTestResultAtIndex(int index) { 80 void AddTestResultAtIndex(int index) {
81 GetResults()->Add(new SearchResult()); 81 GetResults()->Add(new TestSearchResult());
82 } 82 }
83 83
84 void DeleteResultAt(int index) { GetResults()->DeleteAt(index); } 84 void DeleteResultAt(int index) { GetResults()->DeleteAt(index); }
85 85
86 bool KeyPress(ui::KeyboardCode key_code) { 86 bool KeyPress(ui::KeyboardCode key_code) {
87 ui::KeyEvent event(ui::ET_KEY_PRESSED, key_code, ui::EF_NONE); 87 ui::KeyEvent event(ui::ET_KEY_PRESSED, key_code, ui::EF_NONE);
88 return view_->OnKeyPressed(event); 88 return view_->OnKeyPressed(event);
89 } 89 }
90 90
91 bool IsAutoLaunching() { 91 bool IsAutoLaunching() {
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 EXPECT_EQ(0.0f, GetProgressBarAt(0)->current_value()); 223 EXPECT_EQ(0.0f, GetProgressBarAt(0)->current_value());
224 GetResults()->GetItemAt(0)->SetPercentDownloaded(10); 224 GetResults()->GetItemAt(0)->SetPercentDownloaded(10);
225 225
226 DeleteResultAt(0); 226 DeleteResultAt(0);
227 RunPendingMessages(); 227 RunPendingMessages();
228 EXPECT_EQ(0.0f, GetProgressBarAt(0)->current_value()); 228 EXPECT_EQ(0.0f, GetProgressBarAt(0)->current_value());
229 } 229 }
230 230
231 } // namespace test 231 } // namespace test
232 } // namespace app_list 232 } // namespace app_list
OLDNEW
« ui/app_list/test/test_search_result.cc ('K') | « ui/app_list/views/app_list_view_unittest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698