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

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

Issue 683703002: Notify launcher page with onTransitionChanged event (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@launcher_page_api_show_state_notify
Patch Set: fix mac compile Created 6 years, 1 month 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 <string> 5 #include <string>
6 6
7 #include "ash/shell.h"
7 #include "base/command_line.h" 8 #include "base/command_line.h"
8 #include "chrome/browser/apps/app_browsertest_util.h" 9 #include "chrome/browser/apps/app_browsertest_util.h"
9 #include "chrome/browser/ui/app_list/app_list_service.h" 10 #include "chrome/browser/ui/app_list/app_list_service.h"
11 #include "chrome/browser/ui/app_list/app_list_service_views.h"
12 #include "chrome/browser/ui/app_list/app_list_shower_views.h"
10 #include "extensions/common/extension.h" 13 #include "extensions/common/extension.h"
11 #include "extensions/common/switches.h" 14 #include "extensions/common/switches.h"
15 #include "extensions/test/extension_test_message_listener.h"
12 #include "ui/app_list/app_list_switches.h" 16 #include "ui/app_list/app_list_switches.h"
17 #include "ui/app_list/views/app_list_main_view.h"
18 #include "ui/app_list/views/app_list_view.h"
19 #include "ui/app_list/views/contents_view.h"
13 20
14 namespace { 21 namespace {
15 22
16 // The path of the test application within the "platform_apps" directory. 23 // The path of the test application within the "platform_apps" directory.
17 const char kCustomLauncherPagePath[] = "custom_launcher_page"; 24 const char kCustomLauncherPagePath[] = "custom_launcher_page";
18 25
19 // The app ID of the test application. 26 // The app ID of the test application.
20 const char kCustomLauncherPageID[] = "lmadimbbgapmngbiclpjjngmdickadpl"; 27 const char kCustomLauncherPageID[] = "lmadimbbgapmngbiclpjjngmdickadpl";
21 28
22 } // namespace 29 } // namespace
23 30
24 // Browser tests for custom launcher pages, platform apps that run as a page in 31 // Browser tests for custom launcher pages, platform apps that run as a page in
25 // the app launcher. Within this test class, LoadAndLaunchPlatformApp runs the 32 // the app launcher. Within this test class, LoadAndLaunchPlatformApp runs the
26 // app inside the launcher, not as a standalone background page. 33 // app inside the launcher, not as a standalone background page.
27 // the app launcher. 34 // the app launcher.
28 class CustomLauncherPageBrowserTest 35 class CustomLauncherPageBrowserTest
29 : public extensions::PlatformAppBrowserTest { 36 : public extensions::PlatformAppBrowserTest {
30 public: 37 public:
31 CustomLauncherPageBrowserTest() {} 38 CustomLauncherPageBrowserTest() {}
32 39
33 void SetUpCommandLine(base::CommandLine* command_line) override { 40 void SetUpCommandLine(base::CommandLine* command_line) override {
34 PlatformAppBrowserTest::SetUpCommandLine(command_line); 41 PlatformAppBrowserTest::SetUpCommandLine(command_line);
35 42
36 // Custom launcher pages only work in the experimental app list. 43 // Custom launcher pages only work in the experimental app list.
37 command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList); 44 command_line->AppendSwitch(app_list::switches::kEnableExperimentalAppList);
38 45
46 // Ensure the app list does not close during the test.
47 command_line->AppendSwitch(
48 app_list::switches::kDisableAppListDismissOnBlur);
49
39 // The test app must be whitelisted to use launcher_page. 50 // The test app must be whitelisted to use launcher_page.
40 command_line->AppendSwitchASCII( 51 command_line->AppendSwitchASCII(
41 extensions::switches::kWhitelistedExtensionID, kCustomLauncherPageID); 52 extensions::switches::kWhitelistedExtensionID, kCustomLauncherPageID);
42 } 53 }
43 54
44 // Open the launcher. Ignores the Extension argument (this will simply 55 // Open the launcher. Ignores the Extension argument (this will simply
45 // activate any loaded launcher pages). 56 // activate any loaded launcher pages).
46 void LaunchPlatformApp(const extensions::Extension* /*unused*/) override { 57 void LaunchPlatformApp(const extensions::Extension* /*unused*/) override {
47 AppListService* service = 58 AppListService* service =
48 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE); 59 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE);
49 DCHECK(service); 60 DCHECK(service);
50 service->ShowForProfile(browser()->profile()); 61 service->ShowForProfile(browser()->profile());
51 } 62 }
52 63
53 private: 64 private:
54 DISALLOW_COPY_AND_ASSIGN(CustomLauncherPageBrowserTest); 65 DISALLOW_COPY_AND_ASSIGN(CustomLauncherPageBrowserTest);
55 }; 66 };
56 67
57 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, LoadPageAndOpenLauncher) { 68 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest,
69 OpenLauncherAndSwitchToCustomPage) {
58 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); 70 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched");
71
72 app_list::AppListView* app_list_view = nullptr;
73 #if defined(OS_CHROMEOS)
74 ash::Shell* shell = ash::Shell::GetInstance();
75 app_list_view = shell->GetAppListView();
76 EXPECT_TRUE(shell->GetAppListTargetVisibility());
77 #else
78 AppListServiceViews* service = static_cast<AppListServiceViews*>(
79 AppListService::Get(chrome::HOST_DESKTOP_TYPE_NATIVE));
80 // The app list should have loaded instantly since the profile is already
81 // loaded.
82 EXPECT_TRUE(service->IsAppListVisible());
83 app_list_view = service->shower().app_list();
84 #endif
85
86 ASSERT_NE(nullptr, app_list_view);
87 app_list::ContentsView* contents_view =
88 app_list_view->app_list_main_view()->contents_view();
89
90 ASSERT_TRUE(
91 contents_view->IsStateActive(app_list::AppListModel::STATE_START));
92
93 {
94 ExtensionTestMessageListener listener("onPageProgressAt1", false);
95 contents_view->SetActivePage(contents_view->GetPageIndexForState(
96 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE));
97
98 listener.WaitUntilSatisfied();
99 }
100 {
101 ExtensionTestMessageListener listener("onPageProgressAt0", false);
102 contents_view->SetActivePage(contents_view->GetPageIndexForState(
103 app_list::AppListModel::STATE_START));
104
105 listener.WaitUntilSatisfied();
106 }
59 } 107 }
OLDNEW
« no previous file with comments | « athena/home/app_list_view_delegate.cc ('k') | chrome/browser/ui/app_list/app_list_view_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698