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 "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" |
11 #include "chrome/browser/ui/app_list/app_list_service.h" | 11 #include "chrome/browser/ui/app_list/app_list_service.h" |
12 #include "chrome/browser/ui/app_list/app_list_service_views.h" | 12 #include "chrome/browser/ui/app_list/app_list_service_views.h" |
13 #include "chrome/browser/ui/app_list/app_list_shower_views.h" | 13 #include "chrome/browser/ui/app_list/app_list_shower_views.h" |
14 #include "content/public/browser/render_frame_host.h" | 14 #include "content/public/browser/render_frame_host.h" |
15 #include "content/public/browser/web_contents.h" | 15 #include "content/public/browser/web_contents.h" |
16 #include "extensions/common/extension.h" | 16 #include "extensions/common/extension.h" |
17 #include "extensions/common/switches.h" | 17 #include "extensions/common/switches.h" |
18 #include "extensions/test/extension_test_message_listener.h" | 18 #include "extensions/test/extension_test_message_listener.h" |
19 #include "ui/app_list/app_list_switches.h" | 19 #include "ui/app_list/app_list_switches.h" |
20 #include "ui/app_list/views/app_list_main_view.h" | 20 #include "ui/app_list/views/app_list_main_view.h" |
21 #include "ui/app_list/views/app_list_view.h" | 21 #include "ui/app_list/views/app_list_view.h" |
22 #include "ui/app_list/views/contents_view.h" | 22 #include "ui/app_list/views/contents_view.h" |
| 23 #include "ui/app_list/views/search_box_view.h" |
23 #include "ui/events/test/event_generator.h" | 24 #include "ui/events/test/event_generator.h" |
| 25 #include "ui/views/controls/textfield/textfield.h" |
24 #include "ui/views/controls/webview/webview.h" | 26 #include "ui/views/controls/webview/webview.h" |
| 27 #include "ui/views/focus/focus_manager.h" |
25 | 28 |
26 namespace { | 29 namespace { |
27 | 30 |
28 // The path of the test application within the "platform_apps" directory. | 31 // The path of the test application within the "platform_apps" directory. |
29 const char kCustomLauncherPagePath[] = "custom_launcher_page"; | 32 const char kCustomLauncherPagePath[] = "custom_launcher_page"; |
30 | 33 |
31 // The app ID of the test application. | 34 // The app ID of the test application. |
32 const char kCustomLauncherPageID[] = "lmadimbbgapmngbiclpjjngmdickadpl"; | 35 const char kCustomLauncherPageID[] = "lmadimbbgapmngbiclpjjngmdickadpl"; |
33 | 36 |
34 } // namespace | 37 } // namespace |
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 EXPECT_TRUE(custom_page_view->visible()); | 379 EXPECT_TRUE(custom_page_view->visible()); |
377 | 380 |
378 SetCustomLauncherPageEnabled(false); | 381 SetCustomLauncherPageEnabled(false); |
379 EXPECT_FALSE(model->custom_launcher_page_enabled()); | 382 EXPECT_FALSE(model->custom_launcher_page_enabled()); |
380 EXPECT_FALSE(custom_page_view->visible()); | 383 EXPECT_FALSE(custom_page_view->visible()); |
381 | 384 |
382 SetCustomLauncherPageEnabled(true); | 385 SetCustomLauncherPageEnabled(true); |
383 EXPECT_TRUE(model->custom_launcher_page_enabled()); | 386 EXPECT_TRUE(model->custom_launcher_page_enabled()); |
384 EXPECT_TRUE(custom_page_view->visible()); | 387 EXPECT_TRUE(custom_page_view->visible()); |
385 } | 388 } |
| 389 |
| 390 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, |
| 391 LauncherPageFocusTraversal) { |
| 392 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); |
| 393 app_list::AppListView* app_list_view = GetAppListView(); |
| 394 app_list::ContentsView* contents_view = |
| 395 app_list_view->app_list_main_view()->contents_view(); |
| 396 app_list::SearchBoxView* search_box_view = |
| 397 app_list_view->app_list_main_view()->search_box_view(); |
| 398 |
| 399 ASSERT_TRUE( |
| 400 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); |
| 401 EXPECT_EQ(app_list_view->GetFocusManager()->GetFocusedView(), |
| 402 search_box_view->search_box()); |
| 403 |
| 404 { |
| 405 ExtensionTestMessageListener listener("onPageProgressAt1", false); |
| 406 contents_view->SetActivePage(contents_view->GetPageIndexForState( |
| 407 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); |
| 408 listener.WaitUntilSatisfied(); |
| 409 EXPECT_TRUE(contents_view->IsStateActive( |
| 410 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); |
| 411 EXPECT_EQ(app_list_view->GetFocusManager()->GetFocusedView(), |
| 412 search_box_view->search_box()); |
| 413 } |
| 414 { |
| 415 ExtensionTestMessageListener listener("textfieldFocused", false); |
| 416 app_list_view->GetFocusManager()->AdvanceFocus(false); |
| 417 listener.WaitUntilSatisfied(); |
| 418 EXPECT_NE(app_list_view->GetFocusManager()->GetFocusedView(), |
| 419 search_box_view->search_box()); |
| 420 } |
| 421 { |
| 422 ExtensionTestMessageListener listener("textfieldBlurred", false); |
| 423 app_list_view->GetFocusManager()->AdvanceFocus(false); |
| 424 listener.WaitUntilSatisfied(); |
| 425 EXPECT_EQ(app_list_view->GetFocusManager()->GetFocusedView(), |
| 426 search_box_view->search_box()); |
| 427 } |
| 428 } |
OLD | NEW |