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

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

Issue 935523002: App launcher: Spoken feedback reads out details of search results. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added NON_EXPORTED_BASE to fix Windows compile. 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
« no previous file with comments | « no previous file | ui/app_list/views/search_result_view.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/stringprintf.h"
9 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
10 #include "ui/app_list/app_list_model.h" 11 #include "ui/app_list/app_list_model.h"
11 #include "ui/app_list/test/app_list_test_view_delegate.h" 12 #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/test/test_search_result.h"
13 #include "ui/app_list/views/progress_bar_view.h" 14 #include "ui/app_list/views/progress_bar_view.h"
14 #include "ui/app_list/views/search_result_list_view_delegate.h" 15 #include "ui/app_list/views/search_result_list_view_delegate.h"
15 #include "ui/app_list/views/search_result_view.h" 16 #include "ui/app_list/views/search_result_view.h"
16 #include "ui/views/test/views_test_base.h" 17 #include "ui/views/test/views_test_base.h"
17 18
18 namespace app_list { 19 namespace app_list {
(...skipping 12 matching lines...) Expand all
31 // Overridden from testing::Test: 32 // Overridden from testing::Test:
32 void SetUp() override { 33 void SetUp() override {
33 views::ViewsTestBase::SetUp(); 34 views::ViewsTestBase::SetUp();
34 view_.reset(new SearchResultListView(this, &view_delegate_)); 35 view_.reset(new SearchResultListView(this, &view_delegate_));
35 view_->SetResults(view_delegate_.GetModel()->results()); 36 view_->SetResults(view_delegate_.GetModel()->results());
36 } 37 }
37 38
38 protected: 39 protected:
39 SearchResultListView* view() { return view_.get(); } 40 SearchResultListView* view() { return view_.get(); }
40 41
42 SearchResultView* GetResultViewAt(int index) {
43 return view_->GetResultViewAt(index);
44 }
45
41 AppListModel::SearchResults* GetResults() { 46 AppListModel::SearchResults* GetResults() {
42 return view_delegate_.GetModel()->results(); 47 return view_delegate_.GetModel()->results();
43 } 48 }
44 49
45 void SetLongAutoLaunchTimeout() { 50 void SetLongAutoLaunchTimeout() {
46 // Sets a long timeout that lasts longer than the test run. 51 // Sets a long timeout that lasts longer than the test run.
47 view_delegate_.set_auto_launch_timeout(base::TimeDelta::FromDays(1)); 52 view_delegate_.set_auto_launch_timeout(base::TimeDelta::FromDays(1));
48 } 53 }
49 54
50 base::TimeDelta GetAutoLaunchTimeout() { 55 base::TimeDelta GetAutoLaunchTimeout() {
51 return view_delegate_.GetAutoLaunchTimeout(); 56 return view_delegate_.GetAutoLaunchTimeout();
52 } 57 }
53 58
54 void SetUpSearchResults() { 59 void SetUpSearchResults() {
55 AppListModel::SearchResults* results = GetResults(); 60 AppListModel::SearchResults* results = GetResults();
56 for (int i = 0; i < kDefaultSearchItems; ++i) { 61 for (int i = 0; i < kDefaultSearchItems; ++i) {
57 TestSearchResult* result = new TestSearchResult(); 62 TestSearchResult* result = new TestSearchResult();
58 result->set_display_type(SearchResult::DISPLAY_LIST); 63 result->set_display_type(SearchResult::DISPLAY_LIST);
64 result->set_title(base::UTF8ToUTF16(base::StringPrintf("Result %d", i)));
65 if (i < 2)
66 result->set_details(base::ASCIIToUTF16("Detail"));
59 results->Add(result); 67 results->Add(result);
60 } 68 }
61 69
62 // Adding results will schedule Update(). 70 // Adding results will schedule Update().
63 RunPendingMessages(); 71 RunPendingMessages();
64 view_->OnContainerSelected(false); 72 view_->OnContainerSelected(false);
65 } 73 }
66 74
67 int GetOpenResultCountAndReset(int ranking) { 75 int GetOpenResultCountAndReset(int ranking) {
68 int result = view_delegate_.open_search_result_counts()[ranking]; 76 int result = view_delegate_.open_search_result_counts()[ranking];
(...skipping 27 matching lines...) Expand all
96 void ForceAutoLaunch() { 104 void ForceAutoLaunch() {
97 view_->ForceAutoLaunchForTest(); 105 view_->ForceAutoLaunchForTest();
98 } 106 }
99 107
100 void ExpectConsistent() { 108 void ExpectConsistent() {
101 // Adding results will schedule Update(). 109 // Adding results will schedule Update().
102 RunPendingMessages(); 110 RunPendingMessages();
103 111
104 AppListModel::SearchResults* results = GetResults(); 112 AppListModel::SearchResults* results = GetResults();
105 for (size_t i = 0; i < results->item_count(); ++i) { 113 for (size_t i = 0; i < results->item_count(); ++i) {
106 EXPECT_EQ(results->GetItemAt(i), view_->GetResultViewAt(i)->result()); 114 EXPECT_EQ(results->GetItemAt(i), GetResultViewAt(i)->result());
107 } 115 }
108 } 116 }
109 117
110 ProgressBarView* GetProgressBarAt(size_t index) { 118 ProgressBarView* GetProgressBarAt(size_t index) {
111 return view()->GetResultViewAt(index)->progress_bar_; 119 return GetResultViewAt(index)->progress_bar_;
112 } 120 }
113 121
114 private: 122 private:
115 void OnResultInstalled(SearchResult* result) override {} 123 void OnResultInstalled(SearchResult* result) override {}
116 124
117 AppListTestViewDelegate view_delegate_; 125 AppListTestViewDelegate view_delegate_;
118 scoped_ptr<SearchResultListView> view_; 126 scoped_ptr<SearchResultListView> view_;
119 127
120 DISALLOW_COPY_AND_ASSIGN(SearchResultListViewTest); 128 DISALLOW_COPY_AND_ASSIGN(SearchResultListViewTest);
121 }; 129 };
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 EXPECT_TRUE(IsAutoLaunching()); 195 EXPECT_TRUE(IsAutoLaunching());
188 196
189 view()->SetVisible(false); 197 view()->SetVisible(false);
190 EXPECT_FALSE(IsAutoLaunching()); 198 EXPECT_FALSE(IsAutoLaunching());
191 199
192 SetLongAutoLaunchTimeout(); 200 SetLongAutoLaunchTimeout();
193 view()->SetVisible(true); 201 view()->SetVisible(true);
194 EXPECT_TRUE(IsAutoLaunching()); 202 EXPECT_TRUE(IsAutoLaunching());
195 } 203 }
196 204
205 TEST_F(SearchResultListViewTest, SpokenFeedback) {
206 SetUpSearchResults();
207
208 // Result 0 has a detail text. Expect that the detail is appended to the
209 // accessibility name.
210 EXPECT_EQ(base::ASCIIToUTF16("Result 0, Detail"),
211 GetResultViewAt(0)->ComputeAccessibleName());
212
213 // Result 2 has no detail text.
214 EXPECT_EQ(base::ASCIIToUTF16("Result 2"),
215 GetResultViewAt(2)->ComputeAccessibleName());
216 }
217
197 TEST_F(SearchResultListViewTest, ModelObservers) { 218 TEST_F(SearchResultListViewTest, ModelObservers) {
198 SetUpSearchResults(); 219 SetUpSearchResults();
199 ExpectConsistent(); 220 ExpectConsistent();
200 221
201 // Insert at start. 222 // Insert at start.
202 AddTestResultAtIndex(0); 223 AddTestResultAtIndex(0);
203 ExpectConsistent(); 224 ExpectConsistent();
204 225
205 // Remove from end. 226 // Remove from end.
206 DeleteResultAt(kDefaultSearchItems); 227 DeleteResultAt(kDefaultSearchItems);
(...skipping 17 matching lines...) Expand all
224 EXPECT_EQ(0.0f, GetProgressBarAt(0)->current_value()); 245 EXPECT_EQ(0.0f, GetProgressBarAt(0)->current_value());
225 GetResults()->GetItemAt(0)->SetPercentDownloaded(10); 246 GetResults()->GetItemAt(0)->SetPercentDownloaded(10);
226 247
227 DeleteResultAt(0); 248 DeleteResultAt(0);
228 RunPendingMessages(); 249 RunPendingMessages();
229 EXPECT_EQ(0.0f, GetProgressBarAt(0)->current_value()); 250 EXPECT_EQ(0.0f, GetProgressBarAt(0)->current_value());
230 } 251 }
231 252
232 } // namespace test 253 } // namespace test
233 } // namespace app_list 254 } // namespace app_list
OLDNEW
« no previous file with comments | « no previous file | ui/app_list/views/search_result_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698