| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 | 308 |
| 309 // Once all subpages are popped, the start page should show. | 309 // Once all subpages are popped, the start page should show. |
| 310 EXPECT_TRUE(contents_view->Back()); | 310 EXPECT_TRUE(contents_view->Back()); |
| 311 | 311 |
| 312 // Immediately finish the animation. | 312 // Immediately finish the animation. |
| 313 contents_view->Layout(); | 313 contents_view->Layout(); |
| 314 EXPECT_TRUE( | 314 EXPECT_TRUE( |
| 315 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); | 315 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); |
| 316 } | 316 } |
| 317 | 317 |
| 318 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, | 318 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, LauncherPageShowAndHide) { |
| 319 LauncherPageShow) { | |
| 320 const base::string16 kLauncherPageShowScript = | 319 const base::string16 kLauncherPageShowScript = |
| 321 base::ASCIIToUTF16("chrome.launcherPage.show();"); | 320 base::ASCIIToUTF16("chrome.launcherPage.show();"); |
| 321 const base::string16 kLauncherPageHideScript = |
| 322 base::ASCIIToUTF16("hideCustomLauncherPage()"); |
| 322 | 323 |
| 323 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); | 324 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); |
| 324 app_list::AppListView* app_list_view = GetAppListView(); | 325 app_list::AppListView* app_list_view = GetAppListView(); |
| 325 app_list::ContentsView* contents_view = | 326 app_list::ContentsView* contents_view = |
| 326 app_list_view->app_list_main_view()->contents_view(); | 327 app_list_view->app_list_main_view()->contents_view(); |
| 327 | 328 |
| 328 views::WebView* custom_page_view = static_cast<views::WebView*>( | 329 views::WebView* custom_page_view = static_cast<views::WebView*>( |
| 329 contents_view->custom_page_view()->custom_launcher_page_contents()); | 330 contents_view->custom_page_view()->custom_launcher_page_contents()); |
| 330 | 331 |
| 331 content::RenderFrameHost* custom_page_frame = | 332 content::RenderFrameHost* custom_page_frame = |
| (...skipping 23 matching lines...) Expand all Loading... |
| 355 custom_page_frame->ExecuteJavaScript(kLauncherPageShowScript); | 356 custom_page_frame->ExecuteJavaScript(kLauncherPageShowScript); |
| 356 | 357 |
| 357 listener.WaitUntilSatisfied(); | 358 listener.WaitUntilSatisfied(); |
| 358 | 359 |
| 359 // The app list view will have changed on ChromeOS. | 360 // The app list view will have changed on ChromeOS. |
| 360 app_list_view = GetAppListView(); | 361 app_list_view = GetAppListView(); |
| 361 contents_view = app_list_view->app_list_main_view()->contents_view(); | 362 contents_view = app_list_view->app_list_main_view()->contents_view(); |
| 362 EXPECT_TRUE(contents_view->IsStateActive( | 363 EXPECT_TRUE(contents_view->IsStateActive( |
| 363 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); | 364 app_list::AppListModel::STATE_CUSTOM_LAUNCHER_PAGE)); |
| 364 } | 365 } |
| 366 |
| 367 // Ensure launcherPage.hide() hides the launcher page when it's showing. |
| 368 { |
| 369 ExtensionTestMessageListener listener("onPageProgressAt0", false); |
| 370 custom_page_frame->ExecuteJavaScript(kLauncherPageHideScript); |
| 371 |
| 372 listener.WaitUntilSatisfied(); |
| 373 |
| 374 EXPECT_TRUE( |
| 375 contents_view->IsStateActive(app_list::AppListModel::STATE_START)); |
| 376 } |
| 377 |
| 378 // Nothing should happen if hide() is called from the apps page. |
| 379 { |
| 380 contents_view->SetActiveState(app_list::AppListModel::STATE_APPS, false); |
| 381 |
| 382 ExtensionTestMessageListener listener("launcherPageHidden", false); |
| 383 custom_page_frame->ExecuteJavaScript(kLauncherPageHideScript); |
| 384 listener.WaitUntilSatisfied(); |
| 385 |
| 386 EXPECT_TRUE( |
| 387 contents_view->IsStateActive(app_list::AppListModel::STATE_APPS)); |
| 388 } |
| 365 } | 389 } |
| 366 | 390 |
| 367 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, LauncherPageSetEnabled) { | 391 IN_PROC_BROWSER_TEST_F(CustomLauncherPageBrowserTest, LauncherPageSetEnabled) { |
| 368 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); | 392 LoadAndLaunchPlatformApp(kCustomLauncherPagePath, "Launched"); |
| 369 app_list::AppListView* app_list_view = GetAppListView(); | 393 app_list::AppListView* app_list_view = GetAppListView(); |
| 370 app_list::AppListModel* model = app_list_view->app_list_main_view()->model(); | 394 app_list::AppListModel* model = app_list_view->app_list_main_view()->model(); |
| 371 app_list::ContentsView* contents_view = | 395 app_list::ContentsView* contents_view = |
| 372 app_list_view->app_list_main_view()->contents_view(); | 396 app_list_view->app_list_main_view()->contents_view(); |
| 373 | 397 |
| 374 views::View* custom_page_view = contents_view->custom_page_view(); | 398 views::View* custom_page_view = contents_view->custom_page_view(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 // And in reverse. | 448 // And in reverse. |
| 425 EXPECT_EQ( | 449 EXPECT_EQ( |
| 426 search_box_textfield, | 450 search_box_textfield, |
| 427 app_list_view->GetFocusManager()->GetNextFocusableView( | 451 app_list_view->GetFocusManager()->GetNextFocusableView( |
| 428 custom_page_webview, custom_page_webview->GetWidget(), true, false)); | 452 custom_page_webview, custom_page_webview->GetWidget(), true, false)); |
| 429 EXPECT_EQ(custom_page_webview, | 453 EXPECT_EQ(custom_page_webview, |
| 430 app_list_view->GetFocusManager()->GetNextFocusableView( | 454 app_list_view->GetFocusManager()->GetNextFocusableView( |
| 431 search_box_textfield, search_box_textfield->GetWidget(), true, | 455 search_box_textfield, search_box_textfield->GetWidget(), true, |
| 432 false)); | 456 false)); |
| 433 } | 457 } |
| OLD | NEW |