Index: chrome/browser/ui/views/ash/launcher/launcher_platform_app_browsertest.cc |
diff --git a/chrome/browser/ui/views/ash/launcher/launcher_platform_app_browsertest.cc b/chrome/browser/ui/views/ash/launcher/launcher_platform_app_browsertest.cc |
index 60c5939770f28d21fcf5f0f63605edcd941ccb4a..3f2f994cc4cd88c2cf9e63885887708a15f92c28 100644 |
--- a/chrome/browser/ui/views/ash/launcher/launcher_platform_app_browsertest.cc |
+++ b/chrome/browser/ui/views/ash/launcher/launcher_platform_app_browsertest.cc |
@@ -168,3 +168,82 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleApps) { |
ASSERT_EQ(item_count, launcher->model()->item_count()); |
} |
+ |
+// Confirm that app windows can be reactivated by clicking their icons and that |
+// the correct activation order is maintained. |
+IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowActivation) { |
+ ash::Launcher* launcher = ash::Shell::GetInstance()->launcher(); |
+ int item_count = launcher->model()->item_count(); |
+ |
+ // First run app. |
+ const Extension* extension1 = LoadAndLaunchPlatformApp("launch"); |
+ ShellWindow* window1 = CreateShellWindow(extension1); |
+ ++item_count; |
+ ASSERT_EQ(item_count, launcher->model()->item_count()); |
+ ash::LauncherItem item1 = |
+ launcher->model()->items()[launcher->model()->item_count() - 2]; |
+ ash::LauncherID item_id1 = item1.id; |
+ ASSERT_EQ(ash::TYPE_PLATFORM_APP, item1.type); |
sky
2012/06/12 04:32:11
EXPECT_EQ is fine here and almost all of these. Us
|
+ ASSERT_EQ(ash::STATUS_ACTIVE, item1.status); |
+ |
+ // Then run second app. |
+ const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2"); |
+ ShellWindow* window2 = CreateShellWindow(extension2); |
+ ++item_count; |
+ ASSERT_EQ(item_count, launcher->model()->item_count()); |
+ ash::LauncherItem item2 = |
+ launcher->model()->items()[launcher->model()->item_count() - 2]; |
+ ash::LauncherID item_id2 = item2.id; |
+ ASSERT_EQ(ash::TYPE_PLATFORM_APP, item2.type); |
+ ASSERT_EQ(ash::STATUS_ACTIVE, item2.status); |
+ |
+ ASSERT_NE(item_id1, item_id2); |
+ ASSERT_EQ(ash::STATUS_RUNNING, launcher->model()->ItemByID(item_id1)->status); |
+ |
+ // Activate first one. |
+ launcher->ActivateLauncherItem(launcher->model()->ItemIndexByID(item_id1)); |
+ ASSERT_EQ(ash::STATUS_ACTIVE, launcher->model()->ItemByID(item_id1)->status); |
+ ASSERT_EQ(ash::STATUS_RUNNING, launcher->model()->ItemByID(item_id2)->status); |
+ ASSERT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); |
+ ASSERT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); |
+ |
+ // Activate second one. |
+ launcher->ActivateLauncherItem(launcher->model()->ItemIndexByID(item_id2)); |
+ ASSERT_EQ(ash::STATUS_RUNNING, launcher->model()->ItemByID(item_id1)->status); |
+ ASSERT_EQ(ash::STATUS_ACTIVE, launcher->model()->ItemByID(item_id2)->status); |
+ ASSERT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); |
+ ASSERT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); |
+ |
+ // Add window for app1. This will activate it. |
+ ShellWindow* window3 = CreateShellWindow(extension1); |
+ ash::wm::ActivateWindow(window3->GetNativeWindow()); |
+ ASSERT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); |
+ ASSERT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); |
+ ASSERT_TRUE(ash::wm::IsActiveWindow(window3->GetNativeWindow())); |
+ |
+ // Activate the second app again |
+ launcher->ActivateLauncherItem(launcher->model()->ItemIndexByID(item_id2)); |
+ ASSERT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); |
+ ASSERT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); |
+ ASSERT_FALSE(ash::wm::IsActiveWindow(window3->GetNativeWindow())); |
+ |
+ // Activate the first app app |
+ launcher->ActivateLauncherItem(launcher->model()->ItemIndexByID(item_id1)); |
+ ASSERT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow())); |
+ ASSERT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow())); |
+ ASSERT_TRUE(ash::wm::IsActiveWindow(window3->GetNativeWindow())); |
+ |
+ // Close second app. |
+ CloseShellWindow(window2); |
+ --item_count; |
+ ASSERT_EQ(item_count, launcher->model()->item_count()); |
+ // First app should be active again. |
+ ASSERT_EQ(ash::STATUS_ACTIVE, launcher->model()->ItemByID(item_id1)->status); |
+ |
+ // Close first app. |
+ CloseShellWindow(window3); |
+ CloseShellWindow(window1); |
+ --item_count; |
+ ASSERT_EQ(item_count, launcher->model()->item_count()); |
+ |
+} |