OLD | NEW |
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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
10 #include "build/build_config.h" | 10 #include "build/build_config.h" |
11 #include "chrome/browser/apps/app_browsertest_util.h" | 11 #include "chrome/browser/apps/app_browsertest_util.h" |
12 #include "chrome/browser/ui/app_list/app_list_service.h" | 12 #include "chrome/browser/ui/app_list/app_list_service.h" |
13 #include "chrome/browser/ui/app_list/app_list_service_views.h" | 13 #include "chrome/browser/ui/ash/app_list/test/app_list_service_ash_test_api.h" |
14 #include "chrome/browser/ui/app_list/app_list_shower_views.h" | |
15 #include "content/public/browser/render_frame_host.h" | 14 #include "content/public/browser/render_frame_host.h" |
16 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
17 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
18 #include "extensions/common/switches.h" | 17 #include "extensions/common/switches.h" |
19 #include "extensions/test/extension_test_message_listener.h" | 18 #include "extensions/test/extension_test_message_listener.h" |
20 #include "ui/app_list/app_list_switches.h" | 19 #include "ui/app_list/app_list_switches.h" |
| 20 #include "ui/app_list/presenter/app_list_presenter_impl.h" |
21 #include "ui/app_list/views/app_list_main_view.h" | 21 #include "ui/app_list/views/app_list_main_view.h" |
22 #include "ui/app_list/views/app_list_view.h" | 22 #include "ui/app_list/views/app_list_view.h" |
23 #include "ui/app_list/views/contents_view.h" | 23 #include "ui/app_list/views/contents_view.h" |
24 #include "ui/app_list/views/custom_launcher_page_view.h" | 24 #include "ui/app_list/views/custom_launcher_page_view.h" |
25 #include "ui/app_list/views/search_box_view.h" | 25 #include "ui/app_list/views/search_box_view.h" |
26 #include "ui/aura/window.h" | 26 #include "ui/aura/window.h" |
27 #include "ui/events/test/event_generator.h" | 27 #include "ui/events/test/event_generator.h" |
28 #include "ui/views/controls/textfield/textfield.h" | 28 #include "ui/views/controls/textfield/textfield.h" |
29 #include "ui/views/controls/webview/webview.h" | 29 #include "ui/views/controls/webview/webview.h" |
30 #include "ui/views/focus/focus_manager.h" | 30 #include "ui/views/focus/focus_manager.h" |
31 | 31 |
32 #if defined(OS_CHROMEOS) | |
33 #include "chrome/browser/ui/ash/app_list/test/app_list_service_ash_test_api.h" | |
34 #include "ui/app_list/presenter/app_list_presenter_impl.h" | |
35 #endif | |
36 | |
37 namespace { | 32 namespace { |
38 | 33 |
39 // The path of the test application within the "platform_apps" directory. | 34 // The path of the test application within the "platform_apps" directory. |
40 const char kCustomLauncherPagePath[] = "custom_launcher_page"; | 35 const char kCustomLauncherPagePath[] = "custom_launcher_page"; |
41 | 36 |
42 // The app ID of the test application. | 37 // The app ID of the test application. |
43 const char kCustomLauncherPageID[] = "lmadimbbgapmngbiclpjjngmdickadpl"; | 38 const char kCustomLauncherPageID[] = "lmadimbbgapmngbiclpjjngmdickadpl"; |
44 | 39 |
45 } // namespace | 40 } // namespace |
46 | 41 |
(...skipping 21 matching lines...) Expand all Loading... |
68 // Open the launcher. Ignores the Extension argument (this will simply | 63 // Open the launcher. Ignores the Extension argument (this will simply |
69 // activate any loaded launcher pages). | 64 // activate any loaded launcher pages). |
70 void LaunchPlatformApp(const extensions::Extension* /*unused*/) override { | 65 void LaunchPlatformApp(const extensions::Extension* /*unused*/) override { |
71 AppListService* service = AppListService::Get(); | 66 AppListService* service = AppListService::Get(); |
72 DCHECK(service); | 67 DCHECK(service); |
73 service->ShowForProfile(browser()->profile()); | 68 service->ShowForProfile(browser()->profile()); |
74 } | 69 } |
75 | 70 |
76 app_list::AppListView* GetAppListView() { | 71 app_list::AppListView* GetAppListView() { |
77 app_list::AppListView* app_list_view = nullptr; | 72 app_list::AppListView* app_list_view = nullptr; |
78 #if defined(OS_CHROMEOS) | |
79 AppListServiceAshTestApi service_test; | 73 AppListServiceAshTestApi service_test; |
80 app_list_view = service_test.GetAppListView(); | 74 app_list_view = service_test.GetAppListView(); |
81 EXPECT_TRUE(service_test.GetAppListPresenter()->GetTargetVisibility()); | 75 EXPECT_TRUE(service_test.GetAppListPresenter()->GetTargetVisibility()); |
82 #else | |
83 AppListServiceViews* service = | |
84 static_cast<AppListServiceViews*>(AppListService::Get()); | |
85 // The app list should have loaded instantly since the profile is already | |
86 // loaded. | |
87 EXPECT_TRUE(service->IsAppListVisible()); | |
88 app_list_view = service->shower().app_list(); | |
89 #endif | |
90 return app_list_view; | 76 return app_list_view; |
91 } | 77 } |
92 | 78 |
93 // Set the active page on the app list, according to |state|. Does not wait | 79 // Set the active page on the app list, according to |state|. Does not wait |
94 // for any animation or custom page to complete. | 80 // for any animation or custom page to complete. |
95 void SetActiveStateAndVerify(app_list::AppListModel::State state) { | 81 void SetActiveStateAndVerify(app_list::AppListModel::State state) { |
96 app_list::ContentsView* contents_view = | 82 app_list::ContentsView* contents_view = |
97 GetAppListView()->app_list_main_view()->contents_view(); | 83 GetAppListView()->app_list_main_view()->contents_view(); |
98 contents_view->SetActiveState(state); | 84 contents_view->SetActiveState(state); |
99 EXPECT_TRUE(contents_view->IsStateActive(state)); | 85 EXPECT_TRUE(contents_view->IsStateActive(state)); |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // Scroll down to open launcher page. | 201 // Scroll down to open launcher page. |
216 event_generator.MoveMouseWheel(0, -5); | 202 event_generator.MoveMouseWheel(0, -5); |
217 EXPECT_TRUE(contents_view->IsStateActive( | 203 EXPECT_TRUE(contents_view->IsStateActive( |
218 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); | 204 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); |
219 | 205 |
220 // Constants for gesture/trackpad events. | 206 // Constants for gesture/trackpad events. |
221 const base::TimeDelta step_delay = base::TimeDelta::FromMilliseconds(300); | 207 const base::TimeDelta step_delay = base::TimeDelta::FromMilliseconds(300); |
222 const int num_steps = 5; | 208 const int num_steps = 5; |
223 const int num_fingers = 2; | 209 const int num_fingers = 2; |
224 | 210 |
225 #if defined(OS_CHROMEOS) | 211 // Gesture events need to be in host coordinates. The points need to be put |
226 // Gesture events need to be in host coordinates. On Desktop platforms, the | 212 // into screen coordinates. This works because the root window assumes it |
227 // Widget is the host, so nothing needs to be done. On ChromeOS, the points | 213 // fills the screen. |
228 // need to be put into screen coordinates. This works because the root window | |
229 // assumes it fills the screen. | |
230 point_in_clickzone = bounds.CenterPoint(); | 214 point_in_clickzone = bounds.CenterPoint(); |
231 point_above_clickzone.SetPoint(point_in_clickzone.x(), bounds.y() - 10); | 215 point_above_clickzone.SetPoint(point_in_clickzone.x(), bounds.y() - 10); |
232 views::View::ConvertPointToScreen(contents_view, &point_above_clickzone); | 216 views::View::ConvertPointToScreen(contents_view, &point_above_clickzone); |
233 views::View::ConvertPointToScreen(contents_view, &point_in_clickzone); | 217 views::View::ConvertPointToScreen(contents_view, &point_in_clickzone); |
234 #endif | |
235 | 218 |
236 // Back to the start page. And send a scroll gesture. | 219 // Back to the start page. And send a scroll gesture. |
237 SetActiveStateAndVerify(app_list::AppListModel::STATE_START); | 220 SetActiveStateAndVerify(app_list::AppListModel::STATE_START); |
238 // Going down should do nothing. | 221 // Going down should do nothing. |
239 event_generator.GestureScrollSequence( | 222 event_generator.GestureScrollSequence( |
240 point_above_clickzone, point_in_clickzone, step_delay, num_steps); | 223 point_above_clickzone, point_in_clickzone, step_delay, num_steps); |
241 EXPECT_TRUE( | 224 EXPECT_TRUE( |
242 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); | 225 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); |
243 // Now go up - should change state. | 226 // Now go up - should change state. |
244 event_generator.GestureScrollSequence( | 227 event_generator.GestureScrollSequence( |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
457 // And in reverse. | 440 // And in reverse. |
458 EXPECT_EQ( | 441 EXPECT_EQ( |
459 search_box_textfield, | 442 search_box_textfield, |
460 app_list_view->GetFocusManager()->GetNextFocusableView( | 443 app_list_view->GetFocusManager()->GetNextFocusableView( |
461 custom_page_webview, custom_page_webview->GetWidget(), true, false)); | 444 custom_page_webview, custom_page_webview->GetWidget(), true, false)); |
462 EXPECT_EQ(custom_page_webview, | 445 EXPECT_EQ(custom_page_webview, |
463 app_list_view->GetFocusManager()->GetNextFocusableView( | 446 app_list_view->GetFocusManager()->GetNextFocusableView( |
464 search_box_textfield, search_box_textfield->GetWidget(), true, | 447 search_box_textfield, search_box_textfield->GetWidget(), true, |
465 false)); | 448 false)); |
466 } | 449 } |
OLD | NEW |