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 "apps/native_app_window.h" | 7 #include "apps/native_app_window.h" |
8 #include "apps/shell_window.h" | 8 #include "apps/shell_window.h" |
9 #include "apps/shell_window_registry.h" | 9 #include "apps/shell_window_registry.h" |
10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" |
11 #include "ash/display/display_controller.h" | 11 #include "ash/display/display_controller.h" |
12 #include "ash/launcher/launcher.h" | 12 #include "ash/launcher/launcher.h" |
13 #include "ash/launcher/launcher_button.h" | 13 #include "ash/launcher/launcher_button.h" |
14 #include "ash/launcher/launcher_model.h" | 14 #include "ash/launcher/launcher_model.h" |
15 #include "ash/launcher/launcher_util.h" | 15 #include "ash/launcher/launcher_util.h" |
16 #include "ash/launcher/launcher_view.h" | 16 #include "ash/launcher/launcher_view.h" |
17 #include "ash/shell.h" | 17 #include "ash/shell.h" |
18 #include "ash/test/launcher_test_api.h" | 18 #include "ash/test/launcher_test_api.h" |
19 #include "ash/test/launcher_view_test_api.h" | 19 #include "ash/test/launcher_view_test_api.h" |
20 #include "ash/test/shell_test_api.h" | 20 #include "ash/test/shell_test_api.h" |
| 21 #include "ash/wm/window_state.h" |
21 #include "ash/wm/window_util.h" | 22 #include "ash/wm/window_util.h" |
22 #include "base/strings/stringprintf.h" | 23 #include "base/strings/stringprintf.h" |
23 #include "base/strings/utf_string_conversions.h" | 24 #include "base/strings/utf_string_conversions.h" |
24 #include "chrome/browser/apps/app_browsertest_util.h" | 25 #include "chrome/browser/apps/app_browsertest_util.h" |
25 #include "chrome/browser/automation/automation_util.h" | 26 #include "chrome/browser/automation/automation_util.h" |
26 #include "chrome/browser/chrome_notification_types.h" | 27 #include "chrome/browser/chrome_notification_types.h" |
27 #include "chrome/browser/extensions/extension_apitest.h" | 28 #include "chrome/browser/extensions/extension_apitest.h" |
28 #include "chrome/browser/extensions/extension_browsertest.h" | 29 #include "chrome/browser/extensions/extension_browsertest.h" |
29 #include "chrome/browser/extensions/extension_function_test_utils.h" | 30 #include "chrome/browser/extensions/extension_function_test_utils.h" |
30 #include "chrome/browser/extensions/extension_service.h" | 31 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
881 LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB, | 882 LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB, |
882 NEW_BACKGROUND_TAB); | 883 NEW_BACKGROUND_TAB); |
883 EXPECT_EQ(++tab_count, tab_strip->count()); | 884 EXPECT_EQ(++tab_count, tab_strip->count()); |
884 ChromeLauncherController::instance()->LaunchApp(last_loaded_extension_id_, 0); | 885 ChromeLauncherController::instance()->LaunchApp(last_loaded_extension_id_, 0); |
885 } | 886 } |
886 | 887 |
887 // Confirm that clicking a icon for an app running in one of 2 maxmized windows | 888 // Confirm that clicking a icon for an app running in one of 2 maxmized windows |
888 // activates the right window. | 889 // activates the right window. |
889 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchMaximized) { | 890 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchMaximized) { |
890 aura::Window* window1 = browser()->window()->GetNativeWindow(); | 891 aura::Window* window1 = browser()->window()->GetNativeWindow(); |
891 ash::wm::MaximizeWindow(window1); | 892 ash::wm::WindowState* window1_state = ash::wm::GetWindowState(window1); |
| 893 window1_state->Maximize(); |
892 content::WindowedNotificationObserver open_observer( | 894 content::WindowedNotificationObserver open_observer( |
893 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 895 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
894 content::NotificationService::AllSources()); | 896 content::NotificationService::AllSources()); |
895 chrome::NewEmptyWindow(browser()->profile(), chrome::HOST_DESKTOP_TYPE_ASH); | 897 chrome::NewEmptyWindow(browser()->profile(), chrome::HOST_DESKTOP_TYPE_ASH); |
896 open_observer.Wait(); | 898 open_observer.Wait(); |
897 Browser* browser2 = content::Source<Browser>(open_observer.source()).ptr(); | 899 Browser* browser2 = content::Source<Browser>(open_observer.source()).ptr(); |
898 aura::Window* window2 = browser2->window()->GetNativeWindow(); | 900 aura::Window* window2 = browser2->window()->GetNativeWindow(); |
899 TabStripModel* tab_strip = browser2->tab_strip_model(); | 901 TabStripModel* tab_strip = browser2->tab_strip_model(); |
900 int tab_count = tab_strip->count(); | 902 int tab_count = tab_strip->count(); |
901 ash::wm::MaximizeWindow(window2); | 903 ash::wm::GetWindowState(window2)->Maximize(); |
902 | 904 |
903 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 905 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
904 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 906 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); |
905 EXPECT_EQ(++tab_count, tab_strip->count()); | 907 EXPECT_EQ(++tab_count, tab_strip->count()); |
906 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); | 908 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); |
907 | 909 |
908 window1->Show(); | 910 window1->Show(); |
909 ash::wm::ActivateWindow(window1); | 911 window1_state->Activate(); |
910 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut_id)).status); | 912 EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut_id)).status); |
911 | 913 |
912 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 914 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); |
913 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); | 915 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); |
914 } | 916 } |
915 | 917 |
916 // Activating the same app multiple times should launch only a single copy. | 918 // Activating the same app multiple times should launch only a single copy. |
917 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ActivateApp) { | 919 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ActivateApp) { |
918 TabStripModel* tab_strip = browser()->tab_strip_model(); | 920 TabStripModel* tab_strip = browser()->tab_strip_model(); |
919 int tab_count = tab_strip->count(); | 921 int tab_count = tab_strip->count(); |
(...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 EXPECT_FALSE(item_controller->IsOpen()); | 1706 EXPECT_FALSE(item_controller->IsOpen()); |
1705 | 1707 |
1706 // Activate. This creates new browser | 1708 // Activate. This creates new browser |
1707 item_controller->Activate(); | 1709 item_controller->Activate(); |
1708 // New Window is created. | 1710 // New Window is created. |
1709 running_browser = chrome::GetTotalBrowserCount(); | 1711 running_browser = chrome::GetTotalBrowserCount(); |
1710 EXPECT_EQ(1u, running_browser); | 1712 EXPECT_EQ(1u, running_browser); |
1711 EXPECT_TRUE(item_controller->IsOpen()); | 1713 EXPECT_TRUE(item_controller->IsOpen()); |
1712 | 1714 |
1713 // Minimize Window. | 1715 // Minimize Window. |
1714 aura::Window* window = ash::wm::GetActiveWindow(); | 1716 ash::wm::WindowState* window_state = ash::wm::GetActiveWindowState(); |
1715 ash::wm::MinimizeWindow(window); | 1717 window_state->Minimize(); |
1716 EXPECT_TRUE(ash::wm::IsWindowMinimized(window)); | 1718 EXPECT_TRUE(window_state->IsMinimized()); |
1717 | 1719 |
1718 // Activate again. This doesn't create new browser. | 1720 // Activate again. This doesn't create new browser. |
1719 // It activates window. | 1721 // It activates window. |
1720 item_controller->Activate(); | 1722 item_controller->Activate(); |
1721 running_browser = chrome::GetTotalBrowserCount(); | 1723 running_browser = chrome::GetTotalBrowserCount(); |
1722 EXPECT_EQ(1u, running_browser); | 1724 EXPECT_EQ(1u, running_browser); |
1723 EXPECT_TRUE(item_controller->IsOpen()); | 1725 EXPECT_TRUE(item_controller->IsOpen()); |
1724 EXPECT_FALSE(ash::wm::IsWindowMinimized(window)); | 1726 EXPECT_FALSE(window_state->IsMinimized()); |
1725 } | 1727 } |
1726 | 1728 |
1727 // Check that GetIDByWindow() returns |LauncherID| of the active tab. | 1729 // Check that GetIDByWindow() returns |LauncherID| of the active tab. |
1728 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MatchingLauncherIDandActiveTab) { | 1730 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MatchingLauncherIDandActiveTab) { |
1729 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); | 1731 EXPECT_EQ(1u, chrome::GetTotalBrowserCount()); |
1730 EXPECT_EQ(1, browser()->tab_strip_model()->count()); | 1732 EXPECT_EQ(1, browser()->tab_strip_model()->count()); |
1731 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); | 1733 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); |
1732 EXPECT_EQ(2, model_->item_count()); | 1734 EXPECT_EQ(2, model_->item_count()); |
1733 | 1735 |
1734 aura::Window* window = browser()->window()->GetNativeWindow(); | 1736 aura::Window* window = browser()->window()->GetNativeWindow(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1776 // Now show overflow bubble. | 1778 // Now show overflow bubble. |
1777 test.ShowOverflowBubble(); | 1779 test.ShowOverflowBubble(); |
1778 EXPECT_TRUE(launcher_->IsShowingOverflowBubble()); | 1780 EXPECT_TRUE(launcher_->IsShowingOverflowBubble()); |
1779 | 1781 |
1780 // Unpin first pinned app and there should be no crash. | 1782 // Unpin first pinned app and there should be no crash. |
1781 controller_->UnpinAppWithID(std::string("fake_app_0")); | 1783 controller_->UnpinAppWithID(std::string("fake_app_0")); |
1782 | 1784 |
1783 test.RunMessageLoopUntilAnimationsDone(); | 1785 test.RunMessageLoopUntilAnimationsDone(); |
1784 EXPECT_FALSE(launcher_->IsShowingOverflowBubble()); | 1786 EXPECT_FALSE(launcher_->IsShowingOverflowBubble()); |
1785 } | 1787 } |
OLD | NEW |