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

Side by Side Diff: chrome/browser/apps/custom_launcher_page_browsertest_views.cc

Issue 947903002: Change ContentsView::SetActivePage to use States rather than indexes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more_rebase Created 5 years, 9 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 | chrome/browser/ui/app_list/app_list_service_views.cc » ('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 <string> 5 #include <string>
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/apps/app_browsertest_util.h" 10 #include "chrome/browser/apps/app_browsertest_util.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 // The app list should have loaded instantly since the profile is already 81 // The app list should have loaded instantly since the profile is already
82 // loaded. 82 // loaded.
83 EXPECT_TRUE(service->IsAppListVisible()); 83 EXPECT_TRUE(service->IsAppListVisible());
84 app_list_view = service->shower().app_list(); 84 app_list_view = service->shower().app_list();
85 #endif 85 #endif
86 return app_list_view; 86 return app_list_view;
87 } 87 }
88 88
89 // Set the active page on the app list, according to |state|. Does not wait 89 // Set the active page on the app list, according to |state|. Does not wait
90 // for any animation or custom page to complete. 90 // for any animation or custom page to complete.
91 void SetActivePageAndVerify(app_list::AppListModel::State state) { 91 void SetActiveStateAndVerify(app_list::AppListModel::State state) {
92 app_list::ContentsView* contents_view = 92 app_list::ContentsView* contents_view =
93 GetAppListView()->app_list_main_view()->contents_view(); 93 GetAppListView()->app_list_main_view()->contents_view();
94 contents_view->SetActivePage(contents_view->GetPageIndexForState(state)); 94 contents_view->SetActiveState(state);
95 EXPECT_TRUE(contents_view->IsStateActive(state)); 95 EXPECT_TRUE(contents_view->IsStateActive(state));
96 } 96 }
97 97
98 void SetCustomLauncherPageEnabled(bool enabled) { 98 void SetCustomLauncherPageEnabled(bool enabled) {
99 const base::string16 kLauncherPageDisableScript = 99 const base::string16 kLauncherPageDisableScript =
100 base::ASCIIToUTF16("disableCustomLauncherPage();"); 100 base::ASCIIToUTF16("disableCustomLauncherPage();");
101 const base::string16 kLauncherPageEnableScript = 101 const base::string16 kLauncherPageEnableScript =
102 base::ASCIIToUTF16("enableCustomLauncherPage();"); 102 base::ASCIIToUTF16("enableCustomLauncherPage();");
103 103
104 app_list::ContentsView* contents_view = 104 app_list::ContentsView* contents_view =
(...skipping 21 matching lines...) Expand all
126 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); 126 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched");
127 app_list::AppListView* app_list_view = GetAppListView(); 127 app_list::AppListView* app_list_view = GetAppListView();
128 app_list::ContentsView* contents_view = 128 app_list::ContentsView* contents_view =
129 app_list_view->app_list_main_view()->contents_view(); 129 app_list_view->app_list_main_view()->contents_view();
130 130
131 ASSERT_TRUE( 131 ASSERT_TRUE(
132 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); 132 contents_view->IsStateActive(app_list::AppListModel::STATE_START));
133 133
134 { 134 {
135 ExtensionTestMessageListener listener("onPageProgressAt1", false); 135 ExtensionTestMessageListener listener("onPageProgressAt1", false);
136 contents_view->SetActivePage(contents_view->GetPageIndexForState( 136 contents_view->SetActiveState(
137 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); 137 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE);
138 138
139 listener.WaitUntilSatisfied(); 139 listener.WaitUntilSatisfied();
140 } 140 }
141 { 141 {
142 ExtensionTestMessageListener listener("onPageProgressAt0", false); 142 ExtensionTestMessageListener listener("onPageProgressAt0", false);
143 contents_view->SetActivePage(contents_view->GetPageIndexForState( 143 contents_view->SetActiveState(app_list::AppListModel::STATE_START);
144 app_list::AppListModel::STATE_START));
145 144
146 listener.WaitUntilSatisfied(); 145 listener.WaitUntilSatisfied();
147 } 146 }
148 } 147 }
149 148
150 // Test that the app list will switch to the custom launcher page by sending a 149 // Test that the app list will switch to the custom launcher page by sending a
151 // click inside the clickzone, or a mouse scroll event. 150 // click inside the clickzone, or a mouse scroll event.
152 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, 151 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest,
153 EventsActivateSwitchToCustomPage) { 152 EventsActivateSwitchToCustomPage) {
154 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); 153 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched");
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 event_generator.ClickLeftButton(); 185 event_generator.ClickLeftButton();
187 EXPECT_TRUE( 186 EXPECT_TRUE(
188 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); 187 contents_view->IsStateActive(app_list::AppListModel::STATE_START));
189 // Click again with it enabled. The active state should update immediately. 188 // Click again with it enabled. The active state should update immediately.
190 SetCustomLauncherPageEnabled(true); 189 SetCustomLauncherPageEnabled(true);
191 event_generator.ClickLeftButton(); 190 event_generator.ClickLeftButton();
192 EXPECT_TRUE(contents_view->IsStateActive( 191 EXPECT_TRUE(contents_view->IsStateActive(
193 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); 192 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE));
194 193
195 // Back to the start page. And send a mouse wheel event. 194 // Back to the start page. And send a mouse wheel event.
196 SetActivePageAndVerify(app_list::AppListModel::STATE_START); 195 SetActiveStateAndVerify(app_list::AppListModel::STATE_START);
197 // Generate wheel events above the clickzone. 196 // Generate wheel events above the clickzone.
198 event_generator.MoveMouseRelativeTo(window, point_above_clickzone); 197 event_generator.MoveMouseRelativeTo(window, point_above_clickzone);
199 // Scrolling left, right or up should do nothing. 198 // Scrolling left, right or up should do nothing.
200 event_generator.MoveMouseWheel(-5, 0); 199 event_generator.MoveMouseWheel(-5, 0);
201 event_generator.MoveMouseWheel(5, 0); 200 event_generator.MoveMouseWheel(5, 0);
202 event_generator.MoveMouseWheel(0, 5); 201 event_generator.MoveMouseWheel(0, 5);
203 EXPECT_TRUE( 202 EXPECT_TRUE(
204 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); 203 contents_view->IsStateActive(app_list::AppListModel::STATE_START));
205 // Scroll down to open launcher page. 204 // Scroll down to open launcher page.
206 event_generator.MoveMouseWheel(0, -5); 205 event_generator.MoveMouseWheel(0, -5);
(...skipping 10 matching lines...) Expand all
217 // Widget is the host, so nothing needs to be done. On ChromeOS, the points 216 // Widget is the host, so nothing needs to be done. On ChromeOS, the points
218 // need to be put into screen coordinates. This works because the root window 217 // need to be put into screen coordinates. This works because the root window
219 // assumes it fills the screen. 218 // assumes it fills the screen.
220 point_in_clickzone = bounds.CenterPoint(); 219 point_in_clickzone = bounds.CenterPoint();
221 point_above_clickzone.SetPoint(point_in_clickzone.x(), bounds.y() - 10); 220 point_above_clickzone.SetPoint(point_in_clickzone.x(), bounds.y() - 10);
222 views::View::ConvertPointToScreen(contents_view, &point_above_clickzone); 221 views::View::ConvertPointToScreen(contents_view, &point_above_clickzone);
223 views::View::ConvertPointToScreen(contents_view, &point_in_clickzone); 222 views::View::ConvertPointToScreen(contents_view, &point_in_clickzone);
224 #endif 223 #endif
225 224
226 // Back to the start page. And send a scroll gesture. 225 // Back to the start page. And send a scroll gesture.
227 SetActivePageAndVerify(app_list::AppListModel::STATE_START); 226 SetActiveStateAndVerify(app_list::AppListModel::STATE_START);
228 // Going down should do nothing. 227 // Going down should do nothing.
229 event_generator.GestureScrollSequence( 228 event_generator.GestureScrollSequence(
230 point_above_clickzone, point_in_clickzone, step_delay, num_steps); 229 point_above_clickzone, point_in_clickzone, step_delay, num_steps);
231 EXPECT_TRUE( 230 EXPECT_TRUE(
232 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); 231 contents_view->IsStateActive(app_list::AppListModel::STATE_START));
233 // Now go up - should change state. 232 // Now go up - should change state.
234 event_generator.GestureScrollSequence( 233 event_generator.GestureScrollSequence(
235 point_in_clickzone, point_above_clickzone, step_delay, num_steps); 234 point_in_clickzone, point_above_clickzone, step_delay, num_steps);
236 EXPECT_TRUE(contents_view->IsStateActive( 235 EXPECT_TRUE(contents_view->IsStateActive(
237 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); 236 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE));
238 237
239 // Back to the start page. And send a trackpad scroll event. 238 // Back to the start page. And send a trackpad scroll event.
240 SetActivePageAndVerify(app_list::AppListModel::STATE_START); 239 SetActiveStateAndVerify(app_list::AppListModel::STATE_START);
241 // Going down left, right or up should do nothing. 240 // Going down left, right or up should do nothing.
242 event_generator.ScrollSequence(point_in_clickzone, step_delay, -5, 0, 241 event_generator.ScrollSequence(point_in_clickzone, step_delay, -5, 0,
243 num_steps, num_fingers); 242 num_steps, num_fingers);
244 event_generator.ScrollSequence(point_in_clickzone, step_delay, 5, 0, 243 event_generator.ScrollSequence(point_in_clickzone, step_delay, 5, 0,
245 num_steps, num_fingers); 244 num_steps, num_fingers);
246 event_generator.ScrollSequence(point_in_clickzone, step_delay, 0, 5, 245 event_generator.ScrollSequence(point_in_clickzone, step_delay, 0, 5,
247 num_steps, num_fingers); 246 num_steps, num_fingers);
248 EXPECT_TRUE( 247 EXPECT_TRUE(
249 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); 248 contents_view->IsStateActive(app_list::AppListModel::STATE_START));
250 // Scroll up to open launcher page. 249 // Scroll up to open launcher page.
251 event_generator.ScrollSequence(point_in_clickzone, step_delay, 0, -5, 250 event_generator.ScrollSequence(point_in_clickzone, step_delay, 0, -5,
252 num_steps, num_fingers); 251 num_steps, num_fingers);
253 EXPECT_TRUE(contents_view->IsStateActive( 252 EXPECT_TRUE(contents_view->IsStateActive(
254 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); 253 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE));
255 254
256 // Back to the start page. And send a tap gesture. 255 // Back to the start page. And send a tap gesture.
257 SetActivePageAndVerify(app_list::AppListModel::STATE_START); 256 SetActiveStateAndVerify(app_list::AppListModel::STATE_START);
258 // Tapping outside the clickzone should do nothing. 257 // Tapping outside the clickzone should do nothing.
259 event_generator.GestureTapAt(point_above_clickzone); 258 event_generator.GestureTapAt(point_above_clickzone);
260 EXPECT_TRUE( 259 EXPECT_TRUE(
261 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); 260 contents_view->IsStateActive(app_list::AppListModel::STATE_START));
262 // Now tap in the clickzone. 261 // Now tap in the clickzone.
263 event_generator.GestureTapAt(point_in_clickzone); 262 event_generator.GestureTapAt(point_in_clickzone);
264 EXPECT_TRUE(contents_view->IsStateActive( 263 EXPECT_TRUE(contents_view->IsStateActive(
265 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); 264 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE));
266 } 265 }
267 266
268 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, LauncherPageSubpages) { 267 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, LauncherPageSubpages) {
269 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); 268 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched");
270 269
271 app_list::AppListView* app_list_view = GetAppListView(); 270 app_list::AppListView* app_list_view = GetAppListView();
272 app_list::AppListModel* model = app_list_view->app_list_main_view()->model(); 271 app_list::AppListModel* model = app_list_view->app_list_main_view()->model();
273 app_list::ContentsView* contents_view = 272 app_list::ContentsView* contents_view =
274 app_list_view->app_list_main_view()->contents_view(); 273 app_list_view->app_list_main_view()->contents_view();
275 274
276 ASSERT_TRUE( 275 ASSERT_TRUE(
277 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); 276 contents_view->IsStateActive(app_list::AppListModel::STATE_START));
278 277
279 { 278 {
280 ExtensionTestMessageListener listener("onPageProgressAt1", false); 279 ExtensionTestMessageListener listener("onPageProgressAt1", false);
281 contents_view->SetActivePage(contents_view->GetPageIndexForState( 280 contents_view->SetActiveState(
282 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); 281 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE);
283 listener.WaitUntilSatisfied(); 282 listener.WaitUntilSatisfied();
284 EXPECT_TRUE(contents_view->IsStateActive( 283 EXPECT_TRUE(contents_view->IsStateActive(
285 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); 284 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE));
286 // The app pushes 2 subpages when the launcher page is shown. 285 // The app pushes 2 subpages when the launcher page is shown.
287 EXPECT_EQ(2, model->custom_launcher_page_subpage_depth()); 286 EXPECT_EQ(2, model->custom_launcher_page_subpage_depth());
288 } 287 }
289 288
290 // Pop the subpages. 289 // Pop the subpages.
291 { 290 {
292 ExtensionTestMessageListener listener("onPopSubpage", false); 291 ExtensionTestMessageListener listener("onPopSubpage", false);
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 app_list::SearchBoxView* search_box_view = 397 app_list::SearchBoxView* search_box_view =
399 app_list_view->app_list_main_view()->search_box_view(); 398 app_list_view->app_list_main_view()->search_box_view();
400 399
401 ASSERT_TRUE( 400 ASSERT_TRUE(
402 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); 401 contents_view->IsStateActive(app_list::AppListModel::STATE_START));
403 EXPECT_EQ(app_list_view->GetFocusManager()->GetFocusedView(), 402 EXPECT_EQ(app_list_view->GetFocusManager()->GetFocusedView(),
404 search_box_view->search_box()); 403 search_box_view->search_box());
405 404
406 { 405 {
407 ExtensionTestMessageListener listener("onPageProgressAt1", false); 406 ExtensionTestMessageListener listener("onPageProgressAt1", false);
408 contents_view->SetActivePage(contents_view->GetPageIndexForState( 407 contents_view->SetActiveState(
409 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); 408 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE);
410 listener.WaitUntilSatisfied(); 409 listener.WaitUntilSatisfied();
411 EXPECT_TRUE(contents_view->IsStateActive( 410 EXPECT_TRUE(contents_view->IsStateActive(
412 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); 411 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE));
413 EXPECT_EQ(app_list_view->GetFocusManager()->GetFocusedView(), 412 EXPECT_EQ(app_list_view->GetFocusManager()->GetFocusedView(),
414 search_box_view->search_box()); 413 search_box_view->search_box());
415 } 414 }
416 { 415 {
417 ExtensionTestMessageListener listener("textfieldFocused", false); 416 ExtensionTestMessageListener listener("textfieldFocused", false);
418 app_list_view->GetFocusManager()->AdvanceFocus(false); 417 app_list_view->GetFocusManager()->AdvanceFocus(false);
419 listener.WaitUntilSatisfied(); 418 listener.WaitUntilSatisfied();
420 EXPECT_NE(app_list_view->GetFocusManager()->GetFocusedView(), 419 EXPECT_NE(app_list_view->GetFocusManager()->GetFocusedView(),
421 search_box_view->search_box()); 420 search_box_view->search_box());
422 } 421 }
423 { 422 {
424 ExtensionTestMessageListener listener("textfieldBlurred", false); 423 ExtensionTestMessageListener listener("textfieldBlurred", false);
425 app_list_view->GetFocusManager()->AdvanceFocus(false); 424 app_list_view->GetFocusManager()->AdvanceFocus(false);
426 listener.WaitUntilSatisfied(); 425 listener.WaitUntilSatisfied();
427 EXPECT_EQ(app_list_view->GetFocusManager()->GetFocusedView(), 426 EXPECT_EQ(app_list_view->GetFocusManager()->GetFocusedView(),
428 search_box_view->search_box()); 427 search_box_view->search_box());
429 } 428 }
430 } 429 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/app_list_service_views.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698