| 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" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 app_list_view = service->shower().app_list(); | 81 app_list_view = service->shower().app_list(); |
| 82 #endif | 82 #endif |
| 83 return app_list_view; | 83 return app_list_view; |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Set the active page on the app list, according to |state|. Does not wait | 86 // Set the active page on the app list, according to |state|. Does not wait |
| 87 // for any animation or custom page to complete. | 87 // for any animation or custom page to complete. |
| 88 void SetActivePageAndVerify(app_list::AppListModel::State state) { | 88 void SetActivePageAndVerify(app_list::AppListModel::State state) { |
| 89 app_list::ContentsView* contents_view = | 89 app_list::ContentsView* contents_view = |
| 90 GetAppListView()->app_list_main_view()->contents_view(); | 90 GetAppListView()->app_list_main_view()->contents_view(); |
| 91 contents_view->SetActivePage(contents_view->GetPageIndexForState(state)); | 91 contents_view->SetActivePage(state); |
| 92 EXPECT_TRUE(contents_view->IsStateActive(state)); | 92 EXPECT_TRUE(contents_view->IsStateActive(state)); |
| 93 } | 93 } |
| 94 | 94 |
| 95 void SetCustomLauncherPageEnabled(bool enabled) { | 95 void SetCustomLauncherPageEnabled(bool enabled) { |
| 96 const base::string16 kLauncherPageDisableScript = | 96 const base::string16 kLauncherPageDisableScript = |
| 97 base::ASCIIToUTF16("disableCustomLauncherPage();"); | 97 base::ASCIIToUTF16("disableCustomLauncherPage();"); |
| 98 const base::string16 kLauncherPageEnableScript = | 98 const base::string16 kLauncherPageEnableScript = |
| 99 base::ASCIIToUTF16("enableCustomLauncherPage();"); | 99 base::ASCIIToUTF16("enableCustomLauncherPage();"); |
| 100 | 100 |
| 101 app_list::ContentsView* contents_view = | 101 app_list::ContentsView* contents_view = |
| (...skipping 21 matching lines...) Expand all Loading... |
| 123 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); | 123 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); |
| 124 app_list::AppListView* app_list_view = GetAppListView(); | 124 app_list::AppListView* app_list_view = GetAppListView(); |
| 125 app_list::ContentsView* contents_view = | 125 app_list::ContentsView* contents_view = |
| 126 app_list_view->app_list_main_view()->contents_view(); | 126 app_list_view->app_list_main_view()->contents_view(); |
| 127 | 127 |
| 128 ASSERT_TRUE( | 128 ASSERT_TRUE( |
| 129 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); | 129 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); |
| 130 | 130 |
| 131 { | 131 { |
| 132 ExtensionTestMessageListener listener("onPageProgressAt1", false); | 132 ExtensionTestMessageListener listener("onPageProgressAt1", false); |
| 133 contents_view->SetActivePage(contents_view->GetPageIndexForState( | 133 contents_view->SetActivePage( |
| 134 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); | 134 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE); |
| 135 | 135 |
| 136 listener.WaitUntilSatisfied(); | 136 listener.WaitUntilSatisfied(); |
| 137 } | 137 } |
| 138 { | 138 { |
| 139 ExtensionTestMessageListener listener("onPageProgressAt0", false); | 139 ExtensionTestMessageListener listener("onPageProgressAt0", false); |
| 140 contents_view->SetActivePage(contents_view->GetPageIndexForState( | 140 contents_view->SetActivePage(app_list::AppListModel::STATE_START); |
| 141 app_list::AppListModel::STATE_START)); | |
| 142 | 141 |
| 143 listener.WaitUntilSatisfied(); | 142 listener.WaitUntilSatisfied(); |
| 144 } | 143 } |
| 145 } | 144 } |
| 146 | 145 |
| 147 // Test that the app list will switch to the custom launcher page by sending a | 146 // Test that the app list will switch to the custom launcher page by sending a |
| 148 // click inside the clickzone, or a mouse scroll event. | 147 // click inside the clickzone, or a mouse scroll event. |
| 149 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, | 148 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, |
| 150 EventsActivateSwitchToCustomPage) { | 149 EventsActivateSwitchToCustomPage) { |
| 151 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); | 150 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 app_list::AppListView* app_list_view = GetAppListView(); | 267 app_list::AppListView* app_list_view = GetAppListView(); |
| 269 app_list::AppListModel* model = app_list_view->app_list_main_view()->model(); | 268 app_list::AppListModel* model = app_list_view->app_list_main_view()->model(); |
| 270 app_list::ContentsView* contents_view = | 269 app_list::ContentsView* contents_view = |
| 271 app_list_view->app_list_main_view()->contents_view(); | 270 app_list_view->app_list_main_view()->contents_view(); |
| 272 | 271 |
| 273 ASSERT_TRUE( | 272 ASSERT_TRUE( |
| 274 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); | 273 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); |
| 275 | 274 |
| 276 { | 275 { |
| 277 ExtensionTestMessageListener listener("onPageProgressAt1", false); | 276 ExtensionTestMessageListener listener("onPageProgressAt1", false); |
| 278 contents_view->SetActivePage(contents_view->GetPageIndexForState( | 277 contents_view->SetActivePage( |
| 279 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); | 278 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE); |
| 280 listener.WaitUntilSatisfied(); | 279 listener.WaitUntilSatisfied(); |
| 281 EXPECT_TRUE(contents_view->IsStateActive( | 280 EXPECT_TRUE(contents_view->IsStateActive( |
| 282 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); | 281 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); |
| 283 // The app pushes 2 subpages when the launcher page is shown. | 282 // The app pushes 2 subpages when the launcher page is shown. |
| 284 EXPECT_EQ(2, model->custom_launcher_page_subpage_depth()); | 283 EXPECT_EQ(2, model->custom_launcher_page_subpage_depth()); |
| 285 } | 284 } |
| 286 | 285 |
| 287 // Pop the subpages. | 286 // Pop the subpages. |
| 288 { | 287 { |
| 289 ExtensionTestMessageListener listener("onPopSubpage", false); | 288 ExtensionTestMessageListener listener("onPopSubpage", false); |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 EXPECT_TRUE(custom_page_view->visible()); | 375 EXPECT_TRUE(custom_page_view->visible()); |
| 377 | 376 |
| 378 SetCustomLauncherPageEnabled(false); | 377 SetCustomLauncherPageEnabled(false); |
| 379 EXPECT_FALSE(model->custom_launcher_page_enabled()); | 378 EXPECT_FALSE(model->custom_launcher_page_enabled()); |
| 380 EXPECT_FALSE(custom_page_view->visible()); | 379 EXPECT_FALSE(custom_page_view->visible()); |
| 381 | 380 |
| 382 SetCustomLauncherPageEnabled(true); | 381 SetCustomLauncherPageEnabled(true); |
| 383 EXPECT_TRUE(model->custom_launcher_page_enabled()); | 382 EXPECT_TRUE(model->custom_launcher_page_enabled()); |
| 384 EXPECT_TRUE(custom_page_view->visible()); | 383 EXPECT_TRUE(custom_page_view->visible()); |
| 385 } | 384 } |
| OLD | NEW |