OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/shelf/shelf.h" | 10 #include "ash/shelf/shelf.h" |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
370 void SetUpCommandLine(base::CommandLine* command_line) override { | 370 void SetUpCommandLine(base::CommandLine* command_line) override { |
371 ShelfAppBrowserTest::SetUpCommandLine(command_line); | 371 ShelfAppBrowserTest::SetUpCommandLine(command_line); |
372 command_line->AppendSwitch(switches::kNoStartupWindow); | 372 command_line->AppendSwitch(switches::kNoStartupWindow); |
373 } | 373 } |
374 | 374 |
375 private: | 375 private: |
376 | 376 |
377 DISALLOW_COPY_AND_ASSIGN(ShelfAppBrowserTestNoDefaultBrowser); | 377 DISALLOW_COPY_AND_ASSIGN(ShelfAppBrowserTestNoDefaultBrowser); |
378 }; | 378 }; |
379 | 379 |
380 // Since the default for minimizing on click might change, I added both classes | |
381 // to either get the minimize on click or not. | |
382 class ShelfAppBrowserNoMinimizeOnClick : public LauncherPlatformAppBrowserTest { | |
383 protected: | |
384 ShelfAppBrowserNoMinimizeOnClick() {} | |
385 ~ShelfAppBrowserNoMinimizeOnClick() override {} | |
386 | |
387 void SetUpCommandLine(base::CommandLine* command_line) override { | |
388 LauncherPlatformAppBrowserTest::SetUpCommandLine(command_line); | |
389 command_line->AppendSwitch( | |
390 switches::kDisableMinimizeOnSecondLauncherItemClick); | |
391 } | |
392 | |
393 private: | |
394 | |
395 DISALLOW_COPY_AND_ASSIGN(ShelfAppBrowserNoMinimizeOnClick); | |
396 }; | |
397 | |
398 typedef LauncherPlatformAppBrowserTest ShelfAppBrowserMinimizeOnClick; | |
399 | |
400 // Test that we can launch a platform app and get a running item. | 380 // Test that we can launch a platform app and get a running item. |
401 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchUnpinned) { | 381 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchUnpinned) { |
402 int item_count = shelf_model()->item_count(); | 382 int item_count = shelf_model()->item_count(); |
403 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); | 383 const Extension* extension = LoadAndLaunchPlatformApp("launch", "Launched"); |
404 AppWindow* window = CreateAppWindow(extension); | 384 AppWindow* window = CreateAppWindow(extension); |
405 ++item_count; | 385 ++item_count; |
406 ASSERT_EQ(item_count, shelf_model()->item_count()); | 386 ASSERT_EQ(item_count, shelf_model()->item_count()); |
407 const ash::ShelfItem& item = GetLastLauncherItem(); | 387 const ash::ShelfItem& item = GetLastLauncherItem(); |
408 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); | 388 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type); |
409 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); | 389 EXPECT_EQ(ash::STATUS_ACTIVE, item.status); |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
683 // First app should be active again. | 663 // First app should be active again. |
684 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id1)->status); | 664 EXPECT_EQ(ash::STATUS_ACTIVE, shelf_model()->ItemByID(item_id1)->status); |
685 | 665 |
686 // Close first app. | 666 // Close first app. |
687 CloseAppWindow(window1b); | 667 CloseAppWindow(window1b); |
688 CloseAppWindow(window1); | 668 CloseAppWindow(window1); |
689 --item_count; | 669 --item_count; |
690 EXPECT_EQ(item_count, shelf_model()->item_count()); | 670 EXPECT_EQ(item_count, shelf_model()->item_count()); |
691 } | 671 } |
692 | 672 |
693 // Confirm that Click behavior for app windows is correnct. | |
694 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserNoMinimizeOnClick, AppClickBehavior) { | |
695 // Launch a platform app and create a window for it. | |
696 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); | |
697 AppWindow* window1 = CreateAppWindow(extension1); | |
698 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | |
699 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | |
700 // Confirm that a controller item was created and is the correct state. | |
701 const ash::ShelfItem& item1 = GetLastLauncherItem(); | |
702 LauncherItemController* item1_controller = GetItemController(item1.id); | |
703 EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type); | |
704 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | |
705 EXPECT_EQ(LauncherItemController::TYPE_APP, item1_controller->type()); | |
706 // Clicking the item should have no effect. | |
707 TestEvent click_event(ui::ET_MOUSE_PRESSED); | |
708 item1_controller->ItemSelected(click_event); | |
709 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | |
710 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | |
711 // Minimize the window and confirm that the controller item is updated. | |
712 window1->GetBaseWindow()->Minimize(); | |
713 EXPECT_FALSE(window1->GetNativeWindow()->IsVisible()); | |
714 EXPECT_FALSE(window1->GetBaseWindow()->IsActive()); | |
715 EXPECT_EQ(ash::STATUS_RUNNING, item1.status); | |
716 // Clicking the item should activate the window. | |
717 item1_controller->ItemSelected(click_event); | |
718 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | |
719 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | |
720 EXPECT_EQ(ash::STATUS_ACTIVE, item1.status); | |
721 // Maximizing a window should preserve state after minimize + click. | |
722 window1->GetBaseWindow()->Maximize(); | |
723 window1->GetBaseWindow()->Minimize(); | |
724 item1_controller->ItemSelected(click_event); | |
725 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | |
726 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | |
727 EXPECT_TRUE(window1->GetBaseWindow()->IsMaximized()); | |
728 } | |
729 | |
730 // Confirm the minimizing click behavior for apps. | 673 // Confirm the minimizing click behavior for apps. |
731 IN_PROC_BROWSER_TEST_F(ShelfAppBrowserMinimizeOnClick, | 674 IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, |
732 PackagedAppClickBehaviorInMinimizeMode) { | 675 PackagedAppClickBehaviorInMinimizeMode) { |
733 // Launch one platform app and create a window for it. | 676 // Launch one platform app and create a window for it. |
734 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); | 677 const Extension* extension1 = LoadAndLaunchPlatformApp("launch", "Launched"); |
735 AppWindow* window1 = CreateAppWindow(extension1); | 678 AppWindow* window1 = CreateAppWindow(extension1); |
736 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); | 679 EXPECT_TRUE(window1->GetNativeWindow()->IsVisible()); |
737 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); | 680 EXPECT_TRUE(window1->GetBaseWindow()->IsActive()); |
738 | 681 |
739 // Confirm that a controller item was created and is the correct state. | 682 // Confirm that a controller item was created and is the correct state. |
740 const ash::ShelfItem& item1 = GetLastLauncherItem(); | 683 const ash::ShelfItem& item1 = GetLastLauncherItem(); |
741 LauncherItemController* item1_controller = GetItemController(item1.id); | 684 LauncherItemController* item1_controller = GetItemController(item1.id); |
(...skipping 1542 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2284 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); | 2227 controller_->ActivateApp(bookmark_app->id(), ash::LAUNCH_FROM_APP_LIST, 0); |
2285 | 2228 |
2286 // There should be two new browsers. | 2229 // There should be two new browsers. |
2287 EXPECT_EQ(3u, chrome::GetBrowserCount(browser()->profile())); | 2230 EXPECT_EQ(3u, chrome::GetBrowserCount(browser()->profile())); |
2288 | 2231 |
2289 // The apps should now be running, with the last opened app active. | 2232 // The apps should now be running, with the last opened app active. |
2290 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); | 2233 EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(hosted_app_shelf_id)->status); |
2291 EXPECT_EQ(ash::STATUS_ACTIVE, | 2234 EXPECT_EQ(ash::STATUS_ACTIVE, |
2292 model_->ItemByID(bookmark_app_shelf_id)->status); | 2235 model_->ItemByID(bookmark_app_shelf_id)->status); |
2293 } | 2236 } |
OLD | NEW |