| 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" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 42 #include "chrome/browser/ui/browser_window.h" | 42 #include "chrome/browser/ui/browser_window.h" |
| 43 #include "chrome/browser/ui/extensions/application_launch.h" | 43 #include "chrome/browser/ui/extensions/application_launch.h" |
| 44 #include "chrome/browser/ui/host_desktop.h" | 44 #include "chrome/browser/ui/host_desktop.h" |
| 45 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 45 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 46 #include "chrome/common/chrome_switches.h" | 46 #include "chrome/common/chrome_switches.h" |
| 47 #include "chrome/common/extensions/extension_constants.h" | 47 #include "chrome/common/extensions/extension_constants.h" |
| 48 #include "chrome/test/base/ui_test_utils.h" | 48 #include "chrome/test/base/ui_test_utils.h" |
| 49 #include "content/public/browser/notification_service.h" | 49 #include "content/public/browser/notification_service.h" |
| 50 #include "content/public/browser/notification_source.h" | 50 #include "content/public/browser/notification_source.h" |
| 51 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
| 52 #include "content/public/test/browser_test_utils.h" |
| 52 #include "extensions/common/switches.h" | 53 #include "extensions/common/switches.h" |
| 53 #include "testing/gtest/include/gtest/gtest.h" | 54 #include "testing/gtest/include/gtest/gtest.h" |
| 54 #include "ui/app_list/views/apps_grid_view.h" | 55 #include "ui/app_list/views/apps_grid_view.h" |
| 55 #include "ui/aura/client/aura_constants.h" | 56 #include "ui/aura/client/aura_constants.h" |
| 56 #include "ui/aura/test/event_generator.h" | 57 #include "ui/aura/test/event_generator.h" |
| 57 #include "ui/aura/window.h" | 58 #include "ui/aura/window.h" |
| 58 #include "ui/events/event.h" | 59 #include "ui/events/event.h" |
| 59 | 60 |
| 60 using apps::ShellWindow; | 61 using apps::ShellWindow; |
| 61 using extensions::Extension; | 62 using extensions::Extension; |
| (...skipping 777 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 // Test that we can launch an app with a shortcut. | 840 // Test that we can launch an app with a shortcut. |
| 840 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) { | 841 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) { |
| 841 TabStripModel* tab_strip = browser()->tab_strip_model(); | 842 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 842 int tab_count = tab_strip->count(); | 843 int tab_count = tab_strip->count(); |
| 843 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 844 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
| 844 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); | 845 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); |
| 845 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); | 846 ActivateLauncherItem(model_->ItemIndexByID(shortcut_id)); |
| 846 EXPECT_EQ(++tab_count, tab_strip->count()); | 847 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 847 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); | 848 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); |
| 848 WebContents* tab = tab_strip->GetActiveWebContents(); | 849 WebContents* tab = tab_strip->GetActiveWebContents(); |
| 849 content::WindowedNotificationObserver close_observer( | 850 content::WebContentsDestroyedWatcher destroyed_watcher(tab); |
| 850 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | |
| 851 content::Source<WebContents>(tab)); | |
| 852 browser()->tab_strip_model()->CloseSelectedTabs(); | 851 browser()->tab_strip_model()->CloseSelectedTabs(); |
| 853 close_observer.Wait(); | 852 destroyed_watcher.Wait(); |
| 854 EXPECT_EQ(--tab_count, tab_strip->count()); | 853 EXPECT_EQ(--tab_count, tab_strip->count()); |
| 855 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); | 854 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); |
| 856 } | 855 } |
| 857 | 856 |
| 858 // Launch the app first and then create the shortcut. | 857 // Launch the app first and then create the shortcut. |
| 859 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchUnpinned) { | 858 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchUnpinned) { |
| 860 TabStripModel* tab_strip = browser()->tab_strip_model(); | 859 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 861 int tab_count = tab_strip->count(); | 860 int tab_count = tab_strip->count(); |
| 862 LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB, | 861 LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB, |
| 863 NEW_FOREGROUND_TAB); | 862 NEW_FOREGROUND_TAB); |
| 864 EXPECT_EQ(++tab_count, tab_strip->count()); | 863 EXPECT_EQ(++tab_count, tab_strip->count()); |
| 865 ash::LauncherID shortcut_id = CreateShortcut("app1"); | 864 ash::LauncherID shortcut_id = CreateShortcut("app1"); |
| 866 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); | 865 EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status); |
| 867 WebContents* tab = tab_strip->GetActiveWebContents(); | 866 WebContents* tab = tab_strip->GetActiveWebContents(); |
| 868 content::WindowedNotificationObserver close_observer( | 867 content::WebContentsDestroyedWatcher destroyed_watcher(tab); |
| 869 content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | |
| 870 content::Source<WebContents>(tab)); | |
| 871 browser()->tab_strip_model()->CloseSelectedTabs(); | 868 browser()->tab_strip_model()->CloseSelectedTabs(); |
| 872 close_observer.Wait(); | 869 destroyed_watcher.Wait(); |
| 873 EXPECT_EQ(--tab_count, tab_strip->count()); | 870 EXPECT_EQ(--tab_count, tab_strip->count()); |
| 874 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); | 871 EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status); |
| 875 } | 872 } |
| 876 | 873 |
| 877 // Launches an app in the background and then tries to open it. This is test for | 874 // Launches an app in the background and then tries to open it. This is test for |
| 878 // a crash we had. | 875 // a crash we had. |
| 879 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchInBackground) { | 876 IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchInBackground) { |
| 880 TabStripModel* tab_strip = browser()->tab_strip_model(); | 877 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 881 int tab_count = tab_strip->count(); | 878 int tab_count = tab_strip->count(); |
| 882 LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB, | 879 LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB, |
| (...skipping 995 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1878 // Now show overflow bubble. | 1875 // Now show overflow bubble. |
| 1879 test.ShowOverflowBubble(); | 1876 test.ShowOverflowBubble(); |
| 1880 EXPECT_TRUE(launcher_->IsShowingOverflowBubble()); | 1877 EXPECT_TRUE(launcher_->IsShowingOverflowBubble()); |
| 1881 | 1878 |
| 1882 // Unpin first pinned app and there should be no crash. | 1879 // Unpin first pinned app and there should be no crash. |
| 1883 controller_->UnpinAppWithID(std::string("fake_app_0")); | 1880 controller_->UnpinAppWithID(std::string("fake_app_0")); |
| 1884 | 1881 |
| 1885 test.RunMessageLoopUntilAnimationsDone(); | 1882 test.RunMessageLoopUntilAnimationsDone(); |
| 1886 EXPECT_FALSE(launcher_->IsShowingOverflowBubble()); | 1883 EXPECT_FALSE(launcher_->IsShowingOverflowBubble()); |
| 1887 } | 1884 } |
| OLD | NEW |