Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1753)

Unified Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc

Issue 22887015: Remove PerBrowser launcher (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix nit Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
index c68476c8f8b0b28670504e3e0cd50dea1a96e2f9..abf040837cc10db67c11db67aa0b7316660a3141 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc
@@ -8,13 +8,15 @@
#include "apps/shell_window.h"
#include "apps/shell_window_registry.h"
#include "ash/ash_switches.h"
+#include "ash/display/display_controller.h"
#include "ash/launcher/launcher.h"
#include "ash/launcher/launcher_model.h"
+#include "ash/launcher/launcher_util.h"
+#include "ash/launcher/launcher_view.h"
#include "ash/shell.h"
#include "ash/test/launcher_view_test_api.h"
#include "ash/test/shell_test_api.h"
#include "ash/wm/window_util.h"
-#include "base/command_line.h"
#include "base/strings/stringprintf.h"
#include "base/strings/utf_string_conversions.h"
#include "chrome/browser/apps/app_browsertest_util.h"
@@ -27,8 +29,13 @@
#include "chrome/browser/extensions/extension_system.h"
#include "chrome/browser/extensions/extension_test_message_listener.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/app_list/app_list_service.h"
+#include "chrome/browser/ui/ash/launcher/browser_shortcut_launcher_item_controller.h"
+#include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_commands.h"
+#include "chrome/browser/ui/browser_finder.h"
+#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/extensions/application_launch.h"
#include "chrome/browser/ui/host_desktop.h"
@@ -39,37 +46,81 @@
#include "content/public/browser/notification_service.h"
#include "content/public/browser/notification_source.h"
#include "content/public/browser/web_contents.h"
+#include "extensions/common/switches.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "ui/app_list/views/apps_grid_view.h"
#include "ui/aura/client/aura_constants.h"
+#include "ui/aura/test/event_generator.h"
#include "ui/aura/window.h"
+#include "ui/base/events/event.h"
using apps::ShellWindow;
using extensions::Extension;
using content::WebContents;
+namespace {
+
+class TestEvent : public ui::Event {
+ public:
+ explicit TestEvent(ui::EventType type)
+ : ui::Event(type, base::TimeDelta(), 0) {
+ }
+ virtual ~TestEvent() {
+ }
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TestEvent);
+};
+
+class TestShellWindowRegistryObserver
+ : public apps::ShellWindowRegistry::Observer {
+ public:
+ explicit TestShellWindowRegistryObserver(Profile* profile)
+ : profile_(profile),
+ icon_updates_(0) {
+ apps::ShellWindowRegistry::Get(profile_)->AddObserver(this);
+ }
+
+ virtual ~TestShellWindowRegistryObserver() {
+ apps::ShellWindowRegistry::Get(profile_)->RemoveObserver(this);
+ }
+
+ // Overridden from ShellWindowRegistry::Observer:
+ virtual void OnShellWindowAdded(ShellWindow* shell_window) OVERRIDE {}
+
+ virtual void OnShellWindowIconChanged(ShellWindow* shell_window) OVERRIDE {
+ ++icon_updates_;
+ }
+
+ virtual void OnShellWindowRemoved(ShellWindow* shell_window) OVERRIDE {}
+
+ int icon_updates() { return icon_updates_; }
+
+ private:
+ Profile* profile_;
+ int icon_updates_;
+
+ DISALLOW_COPY_AND_ASSIGN(TestShellWindowRegistryObserver);
+};
+
+} // namespace
+
class LauncherPlatformAppBrowserTest
: public extensions::PlatformAppBrowserTest {
protected:
- LauncherPlatformAppBrowserTest()
- : launcher_(NULL),
- controller_(NULL) {
+ LauncherPlatformAppBrowserTest() : launcher_(NULL), controller_(NULL) {
}
virtual ~LauncherPlatformAppBrowserTest() {}
- ash::LauncherModel* launcher_model() {
- return ash::test::ShellTestApi(ash::Shell::GetInstance()).launcher_model();
- }
-
virtual void RunTestOnMainThreadLoop() OVERRIDE {
launcher_ = ash::Launcher::ForPrimaryDisplay();
- controller_ = static_cast<ChromeLauncherController*>(launcher_->delegate());
+ controller_ = ChromeLauncherController::instance();
return extensions::PlatformAppBrowserTest::RunTestOnMainThreadLoop();
}
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- PlatformAppBrowserTest::SetUpCommandLine(command_line);
- command_line->AppendSwitch(ash::switches::kAshDisablePerAppLauncher);
+ ash::LauncherModel* launcher_model() {
+ return ash::test::ShellTestApi(ash::Shell::GetInstance()).launcher_model();
}
ash::LauncherID CreateAppShortcutLauncherItem(const std::string& name) {
@@ -79,7 +130,7 @@ class LauncherPlatformAppBrowserTest
const ash::LauncherItem& GetLastLauncherItem() {
// Unless there are any panels, the item at index [count - 1] will be
- // the app list, and the item at [count - 2] will be the desited item.
+ // the app list, and the item at [count - 2] will be the desired item.
return launcher_model()->items()[launcher_model()->item_count() - 2];
}
@@ -89,15 +140,39 @@ class LauncherPlatformAppBrowserTest
return launcher_model()->items()[launcher_model()->item_count() - 1];
}
+ LauncherItemController* GetItemController(ash::LauncherID id) {
+ return controller_->id_to_item_controller_map_[id];
+ }
+
+ // Returns the number of menu items, ignoring separators.
+ int GetNumApplicationMenuItems(const ash::LauncherItem& item) {
+ const int event_flags = 0;
+ scoped_ptr<ash::LauncherMenuModel> menu(
+ controller_->CreateApplicationMenu(item, event_flags));
+ int num_items = 0;
+ for (int i = 0; i < menu->GetItemCount(); ++i) {
+ if (menu->GetTypeAt(i) != ui::MenuModel::TYPE_SEPARATOR)
+ ++num_items;
+ }
+ return num_items;
+ }
+
+ // Activate the launcher item with the given |id|.
+ void ActivateLauncherItem(int id) {
+ launcher_->ActivateLauncherItem(id);
+ }
+
ash::Launcher* launcher_;
ChromeLauncherController* controller_;
+
+ private:
+
+ DISALLOW_COPY_AND_ASSIGN(LauncherPlatformAppBrowserTest);
};
class LauncherAppBrowserTest : public ExtensionBrowserTest {
protected:
- LauncherAppBrowserTest()
- : launcher_(NULL),
- model_(NULL) {
+ LauncherAppBrowserTest() : launcher_(NULL), model_(NULL), controller_(NULL) {
}
virtual ~LauncherAppBrowserTest() {}
@@ -106,12 +181,17 @@ class LauncherAppBrowserTest : public ExtensionBrowserTest {
launcher_ = ash::Launcher::ForPrimaryDisplay();
model_ =
ash::test::ShellTestApi(ash::Shell::GetInstance()).launcher_model();
+ controller_ = ChromeLauncherController::instance();
return ExtensionBrowserTest::RunTestOnMainThreadLoop();
}
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- ExtensionBrowserTest::SetUpCommandLine(command_line);
- command_line->AppendSwitch(ash::switches::kAshDisablePerAppLauncher);
+ size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) {
+ LauncherItemController* item_controller =
+ controller_->GetBrowserShortcutLauncherItemController();
+ int items = item_controller->GetApplicationList(
+ show_all_tabs ? ui::EF_SHIFT_DOWN : 0).size();
+ // If we have at least one item, we have also a title which we remove here.
+ return items ? (items - 1) : 0;
}
const Extension* LoadAndLaunchExtension(
@@ -121,19 +201,21 @@ class LauncherAppBrowserTest : public ExtensionBrowserTest {
EXPECT_TRUE(LoadExtension(test_data_dir_.AppendASCII(name)));
ExtensionService* service = extensions::ExtensionSystem::Get(
- browser()->profile())->extension_service();
+ profile())->extension_service();
const Extension* extension =
service->GetExtensionById(last_loaded_extension_id_, false);
EXPECT_TRUE(extension);
- chrome::OpenApplication(chrome::AppLaunchParams(
- browser()->profile(), extension, container, disposition));
+ chrome::OpenApplication(chrome::AppLaunchParams(profile(),
+ extension,
+ container,
+ disposition));
return extension;
}
ash::LauncherID CreateShortcut(const char* name) {
ExtensionService* service = extensions::ExtensionSystem::Get(
- browser()->profile())->extension_service();
+ profile())->extension_service();
LoadExtension(test_data_dir_.AppendASCII(name));
// First get app_id.
@@ -142,29 +224,72 @@ class LauncherAppBrowserTest : public ExtensionBrowserTest {
const std::string app_id = extension->id();
// Then create a shortcut.
- ChromeLauncherController* controller =
- static_cast<ChromeLauncherController*>(launcher_->delegate());
int item_count = model_->item_count();
- ash::LauncherID shortcut_id = controller->CreateAppShortcutLauncherItem(
- app_id, item_count);
- controller->PersistPinnedState();
+ ash::LauncherID shortcut_id = controller_->CreateAppShortcutLauncherItem(
+ app_id,
+ item_count);
+ controller_->PersistPinnedState();
EXPECT_EQ(++item_count, model_->item_count());
- ash::LauncherItem item = *model_->ItemByID(shortcut_id);
+ const ash::LauncherItem& item = *model_->ItemByID(shortcut_id);
EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
return item.id;
}
+ // Activate the launcher item with the given |id|.
+ void ActivateLauncherItem(int id) {
+ launcher_->ActivateLauncherItem(id);
+ }
+
ash::LauncherID PinFakeApp(const std::string& name) {
- ChromeLauncherController* controller =
- static_cast<ChromeLauncherController*>(launcher_->delegate());
- return controller->CreateAppShortcutLauncherItem(
+ return controller_->CreateAppShortcutLauncherItem(
name, model_->item_count());
}
ash::Launcher* launcher_;
ash::LauncherModel* model_;
+ ChromeLauncherController* controller_;
+
+ private:
+
+ DISALLOW_COPY_AND_ASSIGN(LauncherAppBrowserTest);
};
+class LauncherAppBrowserTestNoDefaultBrowser : public LauncherAppBrowserTest {
+ protected:
+ LauncherAppBrowserTestNoDefaultBrowser() {}
+ virtual ~LauncherAppBrowserTestNoDefaultBrowser() {}
+
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ LauncherAppBrowserTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitch(switches::kNoStartupWindow);
+ }
+
+ private:
+
+ DISALLOW_COPY_AND_ASSIGN(LauncherAppBrowserTestNoDefaultBrowser);
+};
+
+// Since the default for minimizing on click might change, I added both classes
+// to either get the minimize on click or not.
+class LauncherAppBrowserNoMinimizeOnClick
+ : public LauncherPlatformAppBrowserTest {
+ protected:
+ LauncherAppBrowserNoMinimizeOnClick() {}
+ virtual ~LauncherAppBrowserNoMinimizeOnClick() {}
+
+ virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ LauncherPlatformAppBrowserTest::SetUpCommandLine(command_line);
+ command_line->AppendSwitch(
+ switches::kDisableMinimizeOnSecondLauncherItemClick);
+ }
+
+ private:
+
+ DISALLOW_COPY_AND_ASSIGN(LauncherAppBrowserNoMinimizeOnClick);
+};
+
+typedef LauncherPlatformAppBrowserTest LauncherAppBrowserMinimizeOnClick;
+
// Test that we can launch a platform app and get a running item.
IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchUnpinned) {
int item_count = launcher_model()->item_count();
@@ -310,6 +435,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) {
ash::LauncherID item_id = item1.id;
EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
+ EXPECT_EQ(2, GetNumApplicationMenuItems(item1)); // Title + 1 window
// Add second window.
ShellWindow* window2 = CreateShellWindow(extension);
@@ -317,6 +443,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) {
ASSERT_EQ(item_count, launcher_model()->item_count());
const ash::LauncherItem& item2 = *launcher_model()->ItemByID(item_id);
EXPECT_EQ(ash::STATUS_ACTIVE, item2.status);
+ EXPECT_EQ(3, GetNumApplicationMenuItems(item2)); // Title + 2 windows
// Close second window.
CloseShellWindow(window2);
@@ -324,6 +451,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleWindows) {
ASSERT_EQ(item_count, launcher_model()->item_count());
const ash::LauncherItem& item3 = *launcher_model()->ItemByID(item_id);
EXPECT_EQ(ash::STATUS_ACTIVE, item3.status);
+ EXPECT_EQ(2, GetNumApplicationMenuItems(item3)); // Title + 1 window
// Close first window.
CloseShellWindow(window1);
@@ -373,33 +501,9 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MultipleApps) {
ASSERT_EQ(item_count, launcher_model()->item_count());
}
-// Test that we can launch a platform app panel and get a running item.
-IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, LaunchPanelWindow) {
- int item_count = launcher_model()->item_count();
- const Extension* extension = LoadAndLaunchPlatformApp("launch");
- ShellWindow::CreateParams params;
- params.window_type = ShellWindow::WINDOW_TYPE_PANEL;
- params.focused = false;
- ShellWindow* window = CreateShellWindowFromParams(extension, params);
- ++item_count;
- ASSERT_EQ(item_count, launcher_model()->item_count());
- const ash::LauncherItem& item = GetLastLauncherPanelItem();
- EXPECT_EQ(ash::TYPE_APP_PANEL, item.type);
- // Opening a panel does not activate it.
- EXPECT_EQ(ash::STATUS_RUNNING, item.status);
- CloseShellWindow(window);
- --item_count;
- EXPECT_EQ(item_count, launcher_model()->item_count());
-}
-
-#if defined(OS_CHROMEOS)
-#define MAYBE_WindowActivation DISABLED_WindowActivation
-#else
-#define MAYBE_WindowActivation WindowActivation
-#endif
// 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, MAYBE_WindowActivation) {
+IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowActivation) {
int item_count = launcher_model()->item_count();
// First run app.
@@ -427,7 +531,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_WindowActivation) {
launcher_model()->ItemByID(item_id1)->status);
// Activate first one.
- launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1));
+ ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1));
EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model()->ItemByID(item_id1)->status);
EXPECT_EQ(ash::STATUS_RUNNING,
launcher_model()->ItemByID(item_id2)->status);
@@ -435,7 +539,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_WindowActivation) {
EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
// Activate second one.
- launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id2));
+ ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id2));
EXPECT_EQ(ash::STATUS_RUNNING,
launcher_model()->ItemByID(item_id1)->status);
EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model()->ItemByID(item_id2)->status);
@@ -450,23 +554,23 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_WindowActivation) {
EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
// Activate launcher item for app1, this will activate the first app window.
- launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1));
+ ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1));
EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
- launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1));
- EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
+ ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1));
+ EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
// Activate the second app again
- launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id2));
+ ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id2));
EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
// Activate the first app again
- launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1));
- EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
+ ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1));
+ EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
- EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
+ EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
// Close second app.
CloseShellWindow(window2);
@@ -482,6 +586,138 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, MAYBE_WindowActivation) {
EXPECT_EQ(item_count, launcher_model()->item_count());
}
+// Confirm that Click behavior for app windows is correnct.
+IN_PROC_BROWSER_TEST_F(LauncherAppBrowserNoMinimizeOnClick,
+ AppClickBehavior) {
+ // Launch a platform app and create a window for it.
+ const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
+ ShellWindow* window1 = CreateShellWindow(extension1);
+ EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
+ EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
+ // Confirm that a controller item was created and is the correct state.
+ const ash::LauncherItem& item1 = GetLastLauncherItem();
+ LauncherItemController* item1_controller = GetItemController(item1.id);
+ EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
+ EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
+ EXPECT_EQ(LauncherItemController::TYPE_APP, item1_controller->type());
+ // Clicking the item should have no effect.
+ TestEvent click_event(ui::ET_MOUSE_PRESSED);
+ item1_controller->Clicked(click_event);
+ EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
+ EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
+ // Minimize the window and confirm that the controller item is updated.
+ window1->GetBaseWindow()->Minimize();
+ EXPECT_FALSE(window1->GetNativeWindow()->IsVisible());
+ EXPECT_FALSE(window1->GetBaseWindow()->IsActive());
+ EXPECT_EQ(ash::STATUS_RUNNING, item1.status);
+ // Clicking the item should activate the window.
+ item1_controller->Clicked(click_event);
+ EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
+ EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
+ EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
+ // Maximizing a window should preserve state after minimize + click.
+ window1->GetBaseWindow()->Maximize();
+ window1->GetBaseWindow()->Minimize();
+ item1_controller->Clicked(click_event);
+ EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
+ EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
+ EXPECT_TRUE(window1->GetBaseWindow()->IsMaximized());
+}
+
+// Confirm the minimizing click behavior for apps.
+IN_PROC_BROWSER_TEST_F(LauncherAppBrowserMinimizeOnClick,
+ PackagedAppClickBehaviorInMinimizeMode) {
+ // Launch one platform app and create a window for it.
+ const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
+ ShellWindow* window1 = CreateShellWindow(extension1);
+ EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
+ EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
+
+ // Confirm that a controller item was created and is the correct state.
+ const ash::LauncherItem& item1 = GetLastLauncherItem();
+ LauncherItemController* item1_controller = GetItemController(item1.id);
+ EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
+ EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
+ EXPECT_EQ(LauncherItemController::TYPE_APP, item1_controller->type());
+ // Since it is already active, clicking it should minimize.
+ TestEvent click_event(ui::ET_MOUSE_PRESSED);
+ item1_controller->Clicked(click_event);
+ EXPECT_FALSE(window1->GetNativeWindow()->IsVisible());
+ EXPECT_FALSE(window1->GetBaseWindow()->IsActive());
+ EXPECT_TRUE(window1->GetBaseWindow()->IsMinimized());
+ EXPECT_EQ(ash::STATUS_RUNNING, item1.status);
+ // Clicking the item again should activate the window again.
+ item1_controller->Clicked(click_event);
+ EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
+ EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
+ EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
+ // Maximizing a window should preserve state after minimize + click.
+ window1->GetBaseWindow()->Maximize();
+ window1->GetBaseWindow()->Minimize();
+ item1_controller->Clicked(click_event);
+ EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
+ EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
+ EXPECT_TRUE(window1->GetBaseWindow()->IsMaximized());
+ window1->GetBaseWindow()->Restore();
+ EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
+ EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
+ EXPECT_FALSE(window1->GetBaseWindow()->IsMaximized());
+
+ // Creating a second window of the same type should change the behavior so
+ // that a click does not change the activation state.
+ ShellWindow* window1a = CreateShellWindow(extension1);
+ EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible());
+ EXPECT_TRUE(window1a->GetBaseWindow()->IsActive());
+ // The first click does nothing.
+ item1_controller->Clicked(click_event);
+ EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
+ EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible());
+ EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
+ EXPECT_FALSE(window1a->GetBaseWindow()->IsActive());
+ // The second neither.
+ item1_controller->Clicked(click_event);
+ EXPECT_TRUE(window1->GetNativeWindow()->IsVisible());
+ EXPECT_TRUE(window1a->GetNativeWindow()->IsVisible());
+ EXPECT_TRUE(window1->GetBaseWindow()->IsActive());
+ EXPECT_FALSE(window1a->GetBaseWindow()->IsActive());
+}
+
+// Confirm that click behavior for app panels is correct.
+IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, AppPanelClickBehavior) {
+ // Enable experimental APIs to allow panel creation.
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ extensions::switches::kEnableExperimentalExtensionApis);
+ // Launch a platform app and create a panel window for it.
+ const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
+ ShellWindow::CreateParams params;
+ params.window_type = ShellWindow::WINDOW_TYPE_PANEL;
+ params.focused = false;
+ ShellWindow* panel = CreateShellWindowFromParams(extension1, params);
+ EXPECT_TRUE(panel->GetNativeWindow()->IsVisible());
+ // Panels should not be active by default.
+ EXPECT_FALSE(panel->GetBaseWindow()->IsActive());
+ // Confirm that a controller item was created and is the correct state.
+ const ash::LauncherItem& item1 = GetLastLauncherPanelItem();
+ LauncherItemController* item1_controller = GetItemController(item1.id);
+ EXPECT_EQ(ash::TYPE_APP_PANEL, item1.type);
+ EXPECT_EQ(ash::STATUS_RUNNING, item1.status);
+ EXPECT_EQ(LauncherItemController::TYPE_APP_PANEL, item1_controller->type());
+ // Click the item and confirm that the panel is activated.
+ TestEvent click_event(ui::ET_MOUSE_PRESSED);
+ item1_controller->Clicked(click_event);
+ EXPECT_TRUE(panel->GetBaseWindow()->IsActive());
+ EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
+ // Click the item again and confirm that the panel is minimized.
+ item1_controller->Clicked(click_event);
+ EXPECT_TRUE(panel->GetBaseWindow()->IsMinimized());
+ EXPECT_EQ(ash::STATUS_RUNNING, item1.status);
+ // Click the item again and confirm that the panel is activated.
+ item1_controller->Clicked(click_event);
+ EXPECT_TRUE(panel->GetNativeWindow()->IsVisible());
+ EXPECT_TRUE(panel->GetBaseWindow()->IsActive());
+ EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
+}
+
IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) {
int item_count = launcher_model()->item_count();
@@ -500,24 +736,49 @@ IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, BrowserActivation) {
launcher_model()->ItemByID(item_id1)->status);
}
-// Test that draw attention sets the launcher item status.
-IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, DrawAttention) {
- const Extension* extension = LoadAndLaunchPlatformApp("launch");
- ShellWindow* shell_window = CreateShellWindow(extension);
- const ash::LauncherItem& item = GetLastLauncherItem();
- EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
- // Set Minimize window to deactivate the launcher item.
- shell_window->GetBaseWindow()->Minimize();
- EXPECT_EQ(ash::STATUS_RUNNING, item.status);
- // Set DrawAttention property.
- shell_window->GetNativeWindow()->SetProperty(
- aura::client::kDrawAttentionKey, true);
- EXPECT_EQ(ash::STATUS_ATTENTION, item.status);
- // Activate window, should clear DrawAttention.
- shell_window->GetBaseWindow()->Activate();
- EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
- EXPECT_FALSE(shell_window->GetNativeWindow()->GetProperty(
- aura::client::kDrawAttentionKey));
+// Test that opening an app sets the correct icon
+IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, SetIcon) {
+ TestShellWindowRegistryObserver test_observer(browser()->profile());
+
+ // Enable experimental APIs to allow panel creation.
+ CommandLine::ForCurrentProcess()->AppendSwitch(
+ extensions::switches::kEnableExperimentalExtensionApis);
+
+ int base_launcher_item_count = launcher_model()->item_count();
+ ExtensionTestMessageListener launched_listener("Launched", false);
+ ExtensionTestMessageListener completed_listener("Completed", false);
+ LoadAndLaunchPlatformApp("app_icon");
+ ASSERT_TRUE(launched_listener.WaitUntilSatisfied());
+ ASSERT_TRUE(completed_listener.WaitUntilSatisfied());
+
+ // Now wait until the WebContent has decoded the icons and chrome has
+ // processed it. This needs to be in a loop since the renderer runs in a
+ // different process.
+ while (test_observer.icon_updates() < 3) {
+ base::RunLoop run_loop;
+ run_loop.RunUntilIdle();
+ }
+
+ // This test creates one shell window and one panel window.
+ int launcher_item_count = launcher_model()->item_count();
+ ASSERT_EQ(base_launcher_item_count + 2, launcher_item_count);
+ // The Panel will be the last item, the app list second-to-last, the app
+ // third from last.
+ const ash::LauncherItem& app_item =
+ launcher_model()->items()[launcher_item_count - 3];
+ const ash::LauncherItem& panel_item =
+ launcher_model()->items()[launcher_item_count - 1];
+ const LauncherItemController* app_item_controller =
+ GetItemController(app_item.id);
+ const LauncherItemController* panel_item_controller =
+ GetItemController(panel_item.id);
+ // Icons for Apps are set by the ShellWindowLauncherController, so
+ // image_set_by_controller() should be set.
+ EXPECT_TRUE(app_item_controller->image_set_by_controller());
+ EXPECT_TRUE(panel_item_controller->image_set_by_controller());
+ // Ensure icon heights are correct (see test.js in app_icon/ test directory)
+ EXPECT_EQ(48, app_item.image.height());
+ EXPECT_EQ(64, panel_item.image.height());
}
// Test that we can launch an app with a shortcut.
@@ -526,7 +787,7 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchPinned) {
int tab_count = tab_strip->count();
ash::LauncherID shortcut_id = CreateShortcut("app1");
EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status);
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
+ ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
EXPECT_EQ(++tab_count, tab_strip->count());
EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status);
WebContents* tab = tab_strip->GetActiveWebContents();
@@ -586,7 +847,7 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchMaximized) {
ash::wm::MaximizeWindow(window2);
ash::LauncherID shortcut_id = CreateShortcut("app1");
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
+ ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
EXPECT_EQ(++tab_count, tab_strip->count());
EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status);
@@ -594,7 +855,7 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, LaunchMaximized) {
ash::wm::ActivateWindow(window1);
EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut_id)).status);
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
+ ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status);
}
@@ -635,13 +896,13 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MultipleApps) {
EXPECT_EQ(++item_count, model_->item_count());
// Launch first app.
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut1));
+ ActivateLauncherItem(model_->ItemIndexByID(shortcut1));
EXPECT_EQ(++tab_count, tab_strip->count());
WebContents* tab1 = tab_strip->GetActiveWebContents();
EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status);
// Launch second app.
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut2));
+ ActivateLauncherItem(model_->ItemIndexByID(shortcut2));
EXPECT_EQ(++tab_count, tab_strip->count());
WebContents* tab2 = tab_strip->GetActiveWebContents();
ASSERT_NE(tab1, tab2);
@@ -649,7 +910,7 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MultipleApps) {
EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status);
// Reactivate first app.
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut1));
+ ActivateLauncherItem(model_->ItemIndexByID(shortcut1));
EXPECT_EQ(tab_count, tab_strip->count());
EXPECT_EQ(tab_strip->GetActiveWebContents(), tab1);
EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status);
@@ -662,21 +923,20 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MultipleApps) {
NEW_FOREGROUND_TAB,
0);
EXPECT_EQ(++tab_count, tab_strip->count());
- WebContents* tab3 = tab_strip->GetActiveWebContents();
EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status);
EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status);
// Reactivate first app.
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut1));
+ ActivateLauncherItem(model_->ItemIndexByID(shortcut1));
EXPECT_EQ(tab_count, tab_strip->count());
EXPECT_EQ(tab_strip->GetActiveWebContents(), tab1);
EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut1)).status);
EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut2)).status);
// And second again. This time the second tab should become active.
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut2));
+ ActivateLauncherItem(model_->ItemIndexByID(shortcut2));
EXPECT_EQ(tab_count, tab_strip->count());
- EXPECT_EQ(tab_strip->GetActiveWebContents(), tab3);
+ EXPECT_EQ(tab_strip->GetActiveWebContents(), tab2);
EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status);
EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status);
}
@@ -686,7 +946,7 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MultipleApps) {
IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, Navigation) {
ash::LauncherID shortcut_id = CreateShortcut("app1");
EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status);
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
+ ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status);
// Navigate away.
@@ -704,9 +964,10 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MultipleOwnedTabs) {
TabStripModel* tab_strip = browser()->tab_strip_model();
int tab_count = tab_strip->count();
ash::LauncherID shortcut_id = CreateShortcut("app1");
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
+ ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
EXPECT_EQ(++tab_count, tab_strip->count());
EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
+ WebContents* first_tab = tab_strip->GetActiveWebContents();
// Create new tab owned by app.
ui_test_utils::NavigateToURLWithDisposition(
@@ -717,7 +978,6 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MultipleOwnedTabs) {
EXPECT_EQ(++tab_count, tab_strip->count());
// Confirm app is still active.
EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
- WebContents* second_tab = tab_strip->GetActiveWebContents();
// Create new tab not owned by app.
ui_test_utils::NavigateToURLWithDisposition(
@@ -729,24 +989,22 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MultipleOwnedTabs) {
// No longer active.
EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status);
- // Activating app makes second tab active again.
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
+ // Activating app makes first tab active again.
+ ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
- EXPECT_EQ(tab_strip->GetActiveWebContents(), second_tab);
+ EXPECT_EQ(tab_strip->GetActiveWebContents(), first_tab);
}
IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, RefocusFilter) {
- ChromeLauncherController* controller =
- static_cast<ChromeLauncherController*>(launcher_->delegate());
TabStripModel* tab_strip = browser()->tab_strip_model();
int tab_count = tab_strip->count();
ash::LauncherID shortcut_id = CreateShortcut("app1");
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
+ ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
EXPECT_EQ(++tab_count, tab_strip->count());
EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
WebContents* first_tab = tab_strip->GetActiveWebContents();
- controller->SetRefocusURLPatternForTest(
+ controller_->SetRefocusURLPatternForTest(
shortcut_id, GURL("http://www.example.com/path1/*"));
// Create new tab owned by app.
ui_test_utils::NavigateToURLWithDisposition(
@@ -770,34 +1028,32 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, RefocusFilter) {
// Activating app makes first tab active again, because second tab isn't
// in its refocus url path.
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
+ ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
EXPECT_EQ(tab_strip->GetActiveWebContents(), first_tab);
}
IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, RefocusFilterLaunch) {
- ChromeLauncherController* controller =
- static_cast<ChromeLauncherController*>(launcher_->delegate());
TabStripModel* tab_strip = browser()->tab_strip_model();
int tab_count = tab_strip->count();
ash::LauncherID shortcut_id = CreateShortcut("app1");
- controller->SetRefocusURLPatternForTest(
+ controller_->SetRefocusURLPatternForTest(
shortcut_id, GURL("http://www.example.com/path1/*"));
- // Create new tab owned by app.
+ // Create new tab.
ui_test_utils::NavigateToURLWithDisposition(
browser(),
- GURL("http://www.example.com/path2/bar.html"),
+ GURL("http://www.example2.com/path2/bar.html"),
NEW_FOREGROUND_TAB,
ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
EXPECT_EQ(++tab_count, tab_strip->count());
WebContents* first_tab = tab_strip->GetActiveWebContents();
- // Confirm app is active.
- EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
+ // Confirm app is not active.
+ EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status);
// Activating app should launch new tab, because second tab isn't
// in its refocus url path.
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
+ ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
EXPECT_EQ(++tab_count, tab_strip->count());
WebContents* second_tab = tab_strip->GetActiveWebContents();
EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
@@ -805,6 +1061,580 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, RefocusFilterLaunch) {
EXPECT_EQ(tab_strip->GetActiveWebContents(), second_tab);
}
+// Check the launcher activation state for applications and browser.
+IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ActivationStateCheck) {
+ TabStripModel* tab_strip = browser()->tab_strip_model();
+ // Get the browser item index
+ int browser_index = ash::launcher::GetBrowserItemIndex(*controller_->model());
+ EXPECT_TRUE(browser_index >= 0);
+
+ // Even though we are just comming up, the browser should be active.
+ EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status);
+
+ ash::LauncherID shortcut_id = CreateShortcut("app1");
+ controller_->SetRefocusURLPatternForTest(
+ shortcut_id, GURL("http://www.example.com/path1/*"));
+
+ EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status);
+ EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status);
+
+ // Create new tab which would be the running app.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(),
+ GURL("http://www.example.com/path1/bar.html"),
+ NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+
+ // There should never be two items active at the same time.
+ EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
+ EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[browser_index].status);
+
+ tab_strip->ActivateTabAt(0, false);
+ EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status);
+ EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status);
+
+ tab_strip->CloseWebContentsAt(1, TabStripModel::CLOSE_NONE);
+ EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status);
+ EXPECT_EQ(ash::STATUS_ACTIVE, model_->items()[browser_index].status);
+
+ ash::wm::DeactivateWindow(browser()->window()->GetNativeWindow());
+ EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status);
+ EXPECT_EQ(ash::STATUS_RUNNING, model_->items()[browser_index].status);
+}
+
+// Check that the launcher activation state for a V1 application stays closed
+// even after an asynchronous browser event comes in after the tab got
+// destroyed.
+IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, AsyncActivationStateCheck) {
+ TabStripModel* tab_strip = browser()->tab_strip_model();
+
+ ash::LauncherID shortcut_id = CreateShortcut("app1");
+ controller_->SetRefocusURLPatternForTest(
+ shortcut_id, GURL("http://www.example.com/path1/*"));
+
+ EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status);
+
+ // Create new tab which would be the running app.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(),
+ GURL("http://www.example.com/path1/bar.html"),
+ NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+
+ EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
+ // To address the issue of crbug.com/174050, the tab we are about to close
+ // has to be active.
+ tab_strip->ActivateTabAt(1, false);
+ EXPECT_EQ(1, tab_strip->active_index());
+
+ // Close the web contents.
+ tab_strip->CloseWebContentsAt(1, TabStripModel::CLOSE_NONE);
+ // The status should now be set to closed.
+ EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status);
+}
+
+// Checks that a windowed application does not add an item to the browser list.
+IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTestNoDefaultBrowser,
+ WindowedAppDoesNotAddToBrowser) {
+ // Get the number of items in the browser menu.
+ size_t items = NumberOfDetectedLauncherBrowsers(false);
+ size_t running_browser = chrome::GetTotalBrowserCount();
+ EXPECT_EQ(0u, items);
+ EXPECT_EQ(0u, running_browser);
+
+ LoadAndLaunchExtension("app1", extension_misc::LAUNCH_WINDOW, NEW_WINDOW);
+
+ // No new browser should get detected, even though one more is running.
+ EXPECT_EQ(0u, NumberOfDetectedLauncherBrowsers(false));
+ EXPECT_EQ(++running_browser, chrome::GetTotalBrowserCount());
+
+ LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB, NEW_WINDOW);
+
+ // A new browser should get detected and one more should be running.
+ EXPECT_EQ(NumberOfDetectedLauncherBrowsers(false), 1u);
+ EXPECT_EQ(++running_browser, chrome::GetTotalBrowserCount());
+}
+
+// Checks the functionality to enumerate all browsers vs. all tabs.
+IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTestNoDefaultBrowser,
+ EnumerateALlBrowsersAndTabs) {
+ // Create at least one browser.
+ LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB, NEW_WINDOW);
+ size_t browsers = NumberOfDetectedLauncherBrowsers(false);
+ size_t tabs = NumberOfDetectedLauncherBrowsers(true);
+
+ // Create a second browser.
+ LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB, NEW_WINDOW);
+
+ EXPECT_EQ(++browsers, NumberOfDetectedLauncherBrowsers(false));
+ EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true));
+
+ // Create only a tab.
+ LoadAndLaunchExtension("app1",
+ extension_misc::LAUNCH_TAB,
+ NEW_FOREGROUND_TAB);
+
+ EXPECT_EQ(browsers, NumberOfDetectedLauncherBrowsers(false));
+ EXPECT_EQ(++tabs, NumberOfDetectedLauncherBrowsers(true));
+}
+
+// Check that the keyboard activation of a launcher item tabs properly through
+// the items at hand.
+IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, AltNumberTabsTabbing) {
+ TabStripModel* tab_strip = browser()->tab_strip_model();
+
+ ash::LauncherID shortcut_id = CreateShortcut("app");
+ controller_->SetRefocusURLPatternForTest(
+ shortcut_id, GURL("http://www.example.com/path/*"));
+ std::string url = "http://www.example.com/path/bla";
+
+ int shortcut_index = model_->ItemIndexByID(shortcut_id);
+
+ // Create an application handled browser tab.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(),
+ GURL(url),
+ NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+
+ content::WebContents* content1 = tab_strip->GetActiveWebContents();
+
+ // Create some other browser tab.
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(),
+ GURL("http://www.test.com"),
+ NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ content::WebContents* content1a = tab_strip->GetActiveWebContents();
+
+ // Make sure that the active tab is now our handled tab.
+ EXPECT_NE(content1a, content1);
+
+ // The active tab should still be the unnamed tab. Then we switch and reach
+ // the first app and stay there.
+ EXPECT_EQ(content1a, tab_strip->GetActiveWebContents());
+ ActivateLauncherItem(shortcut_index);
+ EXPECT_EQ(content1, tab_strip->GetActiveWebContents());
+ ActivateLauncherItem(shortcut_index);
+ EXPECT_EQ(content1, tab_strip->GetActiveWebContents());
+
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser(),
+ GURL(url),
+ NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+ content::WebContents* content2 = tab_strip->GetActiveWebContents();
+
+ EXPECT_EQ(content2, browser()->tab_strip_model()->GetActiveWebContents());
+ ActivateLauncherItem(shortcut_index);
+ EXPECT_EQ(content1, browser()->tab_strip_model()->GetActiveWebContents());
+ ActivateLauncherItem(shortcut_index);
+ EXPECT_EQ(content2, browser()->tab_strip_model()->GetActiveWebContents());
+}
+
+// Check that the keyboard activation of a launcher item tabs properly through
+// the items at hand.
+IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest,
+ AltNumberAppsTabbing) {
+ // First run app.
+ const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
+ ui::BaseWindow* window1 = CreateShellWindow(extension1)->GetBaseWindow();
+ const ash::LauncherItem& item1 = GetLastLauncherItem();
+ ash::LauncherID app_id = item1.id;
+ int app_index = launcher_model()->ItemIndexByID(app_id);
+
+ EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
+ EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
+
+ const Extension* extension2 = LoadAndLaunchPlatformApp("launch_2");
+ ui::BaseWindow* window2 = CreateShellWindow(extension2)->GetBaseWindow();
+
+ // By now the browser should be active. Issue Alt keystrokes several times to
+ // see that we stay on that application.
+ EXPECT_TRUE(window2->IsActive());
+ ActivateLauncherItem(app_index);
+ EXPECT_TRUE(window1->IsActive());
+ ActivateLauncherItem(app_index);
+ EXPECT_TRUE(window1->IsActive());
+
+ ui::BaseWindow* window1a = CreateShellWindow(extension1)->GetBaseWindow();
+
+ EXPECT_TRUE(window1a->IsActive());
+ EXPECT_FALSE(window1->IsActive());
+ ActivateLauncherItem(app_index);
+ EXPECT_TRUE(window1->IsActive());
+ ActivateLauncherItem(app_index);
+ EXPECT_TRUE(window1a->IsActive());
+}
+
+// Test that we can launch a platform app panel and get a running item.
+IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest,
+ LaunchPanelWindow) {
+ int item_count = launcher_model()->item_count();
+ const Extension* extension = LoadAndLaunchPlatformApp("launch");
+ ShellWindow::CreateParams params;
+ params.window_type = ShellWindow::WINDOW_TYPE_PANEL;
+ params.focused = false;
+ ShellWindow* window = CreateShellWindowFromParams(extension, params);
+ ++item_count;
+ ASSERT_EQ(item_count, launcher_model()->item_count());
+ const ash::LauncherItem& item = GetLastLauncherPanelItem();
+ EXPECT_EQ(ash::TYPE_APP_PANEL, item.type);
+ // Opening a panel does not activate it.
+ EXPECT_EQ(ash::STATUS_RUNNING, item.status);
+ CloseShellWindow(window);
+ --item_count;
+ EXPECT_EQ(item_count, launcher_model()->item_count());
+}
+
+// Test attention states of windows.
+IN_PROC_BROWSER_TEST_F(LauncherPlatformAppBrowserTest, WindowAttentionStatus) {
+ const Extension* extension = LoadAndLaunchPlatformApp("launch");
+ ShellWindow::CreateParams params;
+ params.window_type = ShellWindow::WINDOW_TYPE_PANEL;
+ params.focused = false;
+ ShellWindow* panel = CreateShellWindowFromParams(extension, params);
+ EXPECT_TRUE(panel->GetNativeWindow()->IsVisible());
+ // Panels should not be active by default.
+ EXPECT_FALSE(panel->GetBaseWindow()->IsActive());
+ // Confirm that a controller item was created and is the correct state.
+ const ash::LauncherItem& item = GetLastLauncherPanelItem();
+ LauncherItemController* item_controller = GetItemController(item.id);
+ EXPECT_EQ(ash::TYPE_APP_PANEL, item.type);
+ EXPECT_EQ(ash::STATUS_RUNNING, item.status);
+ EXPECT_EQ(LauncherItemController::TYPE_APP_PANEL, item_controller->type());
+
+ // App windows should go to attention state.
+ panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true);
+ EXPECT_EQ(ash::STATUS_ATTENTION, item.status);
+
+ // Click the item and confirm that the panel is activated.
+ TestEvent click_event(ui::ET_MOUSE_PRESSED);
+ item_controller->Clicked(click_event);
+ EXPECT_TRUE(panel->GetBaseWindow()->IsActive());
+ EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
+
+ // Active windows don't show attention.
+ panel->GetNativeWindow()->SetProperty(aura::client::kDrawAttentionKey, true);
+ EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
+}
+
+// Checks that the browser Alt "tabbing" is properly done.
+IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTestNoDefaultBrowser,
+ AltNumberBrowserTabbing) {
+ // Get the number of items in the browser menu.
+ EXPECT_EQ(0u, chrome::GetTotalBrowserCount());
+ // The first activation should create a browser.
+ launcher_->ActivateLauncherItem(0);
+ EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
+ // A second activation should not create a new instance.
+ launcher_->ActivateLauncherItem(0);
+ Browser* browser1 = chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow());
+ EXPECT_TRUE(browser1);
+ aura::Window* window1 = browser1->window()->GetNativeWindow();
+ Browser* browser2 = CreateBrowser(profile());
+ aura::Window* window2 = browser2->window()->GetNativeWindow();
+
+ EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
+ EXPECT_NE(window1, window2);
+ EXPECT_EQ(window2, ash::wm::GetActiveWindow());
+
+ // Activate multiple times the switcher to see that the windows get activated.
+ launcher_->ActivateLauncherItem(0);
+ EXPECT_EQ(window1, ash::wm::GetActiveWindow());
+ launcher_->ActivateLauncherItem(0);
+ EXPECT_EQ(window2, ash::wm::GetActiveWindow());
+
+ // Create a third browser - make sure that we do not toggle simply between
+ // two windows.
+ Browser* browser3 = CreateBrowser(profile());
+ aura::Window* window3 = browser3->window()->GetNativeWindow();
+
+ EXPECT_EQ(3u, chrome::GetTotalBrowserCount());
+ EXPECT_NE(window1, window3);
+ EXPECT_NE(window2, window3);
+ EXPECT_EQ(window3, ash::wm::GetActiveWindow());
+
+ launcher_->ActivateLauncherItem(0);
+ EXPECT_EQ(window1, ash::wm::GetActiveWindow());
+ launcher_->ActivateLauncherItem(0);
+ EXPECT_EQ(window2, ash::wm::GetActiveWindow());
+ launcher_->ActivateLauncherItem(0);
+ EXPECT_EQ(window3, ash::wm::GetActiveWindow());
+ launcher_->ActivateLauncherItem(0);
+ EXPECT_EQ(window1, ash::wm::GetActiveWindow());
+
+ // Create anther app and make sure that none of our browsers is active.
+ LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB, NEW_WINDOW);
+ EXPECT_NE(window1, ash::wm::GetActiveWindow());
+ EXPECT_NE(window2, ash::wm::GetActiveWindow());
+
+ // After activation our browser should be active again.
+ launcher_->ActivateLauncherItem(0);
+ EXPECT_EQ(window1, ash::wm::GetActiveWindow());
+}
+
+// Checks that after a session restore, we do not start applications on an
+// activation.
+IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ActivateAfterSessionRestore) {
+ EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
+
+ // Create a known application.
+ ash::LauncherID shortcut_id = CreateShortcut("app1");
+
+ // Create a new browser - without activating it - and load an "app" into it.
+ Browser::CreateParams params =
+ Browser::CreateParams(profile(), chrome::GetActiveDesktop());
+ params.initial_show_state = ui::SHOW_STATE_INACTIVE;
+ Browser* browser2 = new Browser(params);
+ controller_->SetRefocusURLPatternForTest(
+ shortcut_id, GURL("http://www.example.com/path/*"));
+ std::string url = "http://www.example.com/path/bla";
+ ui_test_utils::NavigateToURLWithDisposition(
+ browser2,
+ GURL(url),
+ NEW_FOREGROUND_TAB,
+ ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
+
+ // Remember the number of tabs for each browser.
+ TabStripModel* tab_strip = browser()->tab_strip_model();
+ int tab_count1 = tab_strip->count();
+ TabStripModel* tab_strip2 = browser2->tab_strip_model();
+ int tab_count2 = tab_strip2->count();
+
+ // Check that we have two browsers and the inactive browser remained inactive.
+ EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
+ EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()),
+ browser());
+ // Check that the LRU browser list does only contain the original browser.
+ BrowserList* ash_browser_list =
+ BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH);
+ BrowserList::const_reverse_iterator it =
+ ash_browser_list->begin_last_active();
+ EXPECT_EQ(*it, browser());
+ ++it;
+ EXPECT_EQ(it, ash_browser_list->end_last_active());
+
+ // Now request to either activate an existing app or create a new one.
+ controller_->ItemSelected(*model_->ItemByID(shortcut_id),
+ ui::KeyEvent(ui::ET_KEY_RELEASED,
+ ui::VKEY_RETURN,
+ 0,
+ false));
+
+ // Check that we have set focus on the existing application and nothing new
+ // was created.
+ EXPECT_EQ(2u, chrome::GetTotalBrowserCount());
+ EXPECT_EQ(tab_count1, tab_strip->count());
+ EXPECT_EQ(tab_count2, tab_strip2->count());
+ EXPECT_EQ(chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow()),
+ browser2);
+}
+
+// Do various drag and drop interaction tests between the application list and
+// the launcher.
+IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, DragAndDrop) {
+ // Get a number of interfaces we need.
+ aura::test::EventGenerator generator(
+ ash::Shell::GetPrimaryRootWindow(), gfx::Point());
+ ash::test::LauncherViewTestAPI test(launcher_->GetLauncherViewForTest());
+ AppListService* service = AppListService::Get();
+
+ // There should be two items in our launcher by this time.
+ EXPECT_EQ(2, model_->item_count());
+ EXPECT_FALSE(service->IsAppListVisible());
+
+ // Open the app list menu and check that the drag and drop host was set.
+ gfx::Rect app_list_bounds =
+ test.launcher_view()->GetAppListButtonView()->GetBoundsInScreen();
+ generator.MoveMouseTo(app_list_bounds.CenterPoint().x(),
+ app_list_bounds.CenterPoint().y());
+ base::MessageLoop::current()->RunUntilIdle();
+ generator.ClickLeftButton();
+
+ EXPECT_TRUE(service->IsAppListVisible());
+ app_list::AppsGridView* grid_view =
+ app_list::AppsGridView::GetLastGridViewForTest();
+ ASSERT_TRUE(grid_view);
+ ASSERT_TRUE(grid_view->has_drag_and_drop_host_for_test());
+
+ // There should be 2 items in our application list.
+ const views::ViewModel* vm_grid = grid_view->view_model_for_test();
+ EXPECT_EQ(2, vm_grid->view_size());
+
+ // Test #1: Drag an app list which does not exist yet item into the
+ // launcher. Keeping it dragged, see that a new item gets created. Continuing
+ // to drag it out should remove it again.
+
+ // Get over item #1 of the application list and press the mouse button.
+ views::View* item1 = vm_grid->view_at(1);
+ gfx::Rect bounds_grid_1 = item1->GetBoundsInScreen();
+ generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(),
+ bounds_grid_1.CenterPoint().y());
+ base::MessageLoop::current()->RunUntilIdle();
+ generator.PressLeftButton();
+
+ EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test());
+
+ // Drag the item into the launcher and check that a new item gets created.
+ const views::ViewModel* vm_launcher =
+ test.launcher_view()->view_model_for_test();
+ views::View* launcher1 = vm_launcher->view_at(1);
+ gfx::Rect bounds_launcher_1 = launcher1->GetBoundsInScreen();
+ generator.MoveMouseTo(bounds_launcher_1.CenterPoint().x(),
+ bounds_launcher_1.CenterPoint().y());
+ base::MessageLoop::current()->RunUntilIdle();
+
+ // Check that a new item got created.
+ EXPECT_EQ(3, model_->item_count());
+ EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test());
+
+ // Move it where the item originally was and check that it disappears again.
+ generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(),
+ bounds_grid_1.CenterPoint().y());
+ base::MessageLoop::current()->RunUntilIdle();
+ EXPECT_EQ(2, model_->item_count());
+ EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test());
+
+ // Dropping it should keep the launcher as it originally was.
+ generator.ReleaseLeftButton();
+ base::MessageLoop::current()->RunUntilIdle();
+ EXPECT_EQ(2, model_->item_count());
+ // There are a few animations which need finishing before we can continue.
+ test.RunMessageLoopUntilAnimationsDone();
+ // Move the mouse outside of the launcher.
+ generator.MoveMouseTo(0, 0);
+
+ // Test #2: Check that the unknown item dropped into the launcher will
+ // create a new item.
+ generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(),
+ bounds_grid_1.CenterPoint().y());
+ generator.PressLeftButton();
+ generator.MoveMouseTo(bounds_launcher_1.CenterPoint().x(),
+ bounds_launcher_1.CenterPoint().y());
+ base::MessageLoop::current()->RunUntilIdle();
+ EXPECT_EQ(3, model_->item_count());
+ EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test());
+ generator.ReleaseLeftButton();
+ base::MessageLoop::current()->RunUntilIdle();
+ EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test());
+ EXPECT_EQ(3, model_->item_count()); // It should be still there.
+ test.RunMessageLoopUntilAnimationsDone();
+
+ // Test #3: Check that the now known item dropped into the launcher will
+ // not create a new item.
+ generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(),
+ bounds_grid_1.CenterPoint().y());
+ generator.PressLeftButton();
+ generator.MoveMouseTo(bounds_launcher_1.CenterPoint().x(),
+ bounds_launcher_1.CenterPoint().y());
+ base::MessageLoop::current()->RunUntilIdle();
+ EXPECT_EQ(3, model_->item_count()); // No new item got added.
+ EXPECT_TRUE(grid_view->forward_events_to_drag_and_drop_host_for_test());
+ generator.ReleaseLeftButton();
+ base::MessageLoop::current()->RunUntilIdle();
+ EXPECT_FALSE(grid_view->forward_events_to_drag_and_drop_host_for_test());
+ EXPECT_EQ(3, model_->item_count()); // And it remains that way.
+}
+
+// Check that clicking on an app launcher item launches a new browser.
+IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, ClickItem) {
+ // Get a number of interfaces we need.
+ aura::test::EventGenerator generator(
+ ash::Shell::GetPrimaryRootWindow(), gfx::Point());
+ ash::test::LauncherViewTestAPI test(launcher_->GetLauncherViewForTest());
+ AppListService* service = AppListService::Get();
+ // There should be two items in our launcher by this time.
+ EXPECT_EQ(2, model_->item_count());
+ EXPECT_FALSE(service->IsAppListVisible());
+
+ // Open the app list menu and check that the drag and drop host was set.
+ gfx::Rect app_list_bounds =
+ test.launcher_view()->GetAppListButtonView()->GetBoundsInScreen();
+ generator.MoveMouseTo(app_list_bounds.CenterPoint().x(),
+ app_list_bounds.CenterPoint().y());
+ generator.ClickLeftButton();
+ base::MessageLoop::current()->RunUntilIdle();
+
+ EXPECT_TRUE(service->IsAppListVisible());
+ app_list::AppsGridView* grid_view =
+ app_list::AppsGridView::GetLastGridViewForTest();
+ ASSERT_TRUE(grid_view);
+ const views::ViewModel* vm_grid = grid_view->view_model_for_test();
+ EXPECT_EQ(2, vm_grid->view_size());
+ gfx::Rect bounds_grid_1 = vm_grid->view_at(1)->GetBoundsInScreen();
+ // Test now that a click does create a new application tab.
+ TabStripModel* tab_strip = browser()->tab_strip_model();
+ int tab_count = tab_strip->count();
+ generator.MoveMouseTo(bounds_grid_1.CenterPoint().x(),
+ bounds_grid_1.CenterPoint().y());
+ generator.ClickLeftButton();
+ base::MessageLoop::current()->RunUntilIdle();
+ EXPECT_EQ(tab_count + 1, tab_strip->count());
+}
+
+// Check LauncherItemController of Browser Shortcut functionality.
+IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTestNoDefaultBrowser,
+ BrowserShortcutLauncherItemController) {
+ LauncherItemController* item_controller =
+ controller_->GetBrowserShortcutLauncherItemController();
+
+ // Get the number of browsers.
+ size_t running_browser = chrome::GetTotalBrowserCount();
+ EXPECT_EQ(0u, running_browser);
+ EXPECT_FALSE(item_controller->IsOpen());
+
+ // Activate. This creates new browser
+ item_controller->Activate();
+ // New Window is created.
+ running_browser = chrome::GetTotalBrowserCount();
+ EXPECT_EQ(1u, running_browser);
+ EXPECT_TRUE(item_controller->IsOpen());
+
+ // Minimize Window.
+ aura::Window* window = ash::wm::GetActiveWindow();
+ ash::wm::MinimizeWindow(window);
+ EXPECT_TRUE(ash::wm::IsWindowMinimized(window));
+
+ // Activate again. This doesn't create new browser.
+ // It activates window.
+ item_controller->Activate();
+ running_browser = chrome::GetTotalBrowserCount();
+ EXPECT_EQ(1u, running_browser);
+ EXPECT_TRUE(item_controller->IsOpen());
+ EXPECT_FALSE(ash::wm::IsWindowMinimized(window));
+}
+
+// Check that GetIDByWindow() returns |LauncherID| of the active tab.
+IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MatchingLauncherIDandActiveTab) {
+ EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
+ EXPECT_EQ(1, browser()->tab_strip_model()->count());
+ EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
+ EXPECT_EQ(2, model_->item_count());
+
+ aura::Window* window = browser()->window()->GetNativeWindow();
+
+ int browser_index = ash::launcher::GetBrowserItemIndex(*model_);
+ ash::LauncherID browser_id = model_->items()[browser_index].id;
+ EXPECT_EQ(browser_id, controller_->GetIDByWindow(window));
+
+ ash::LauncherID app_id = CreateShortcut("app1");
+ EXPECT_EQ(3, model_->item_count());
+
+ // Creates a new tab for "app1" and checks that GetIDByWindow() returns
+ // |LauncherID| of "app1".
+ ActivateLauncherItem(model_->ItemIndexByID(app_id));
+ EXPECT_EQ(2, browser()->tab_strip_model()->count());
+ EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
+ EXPECT_EQ(app_id, controller_->GetIDByWindow(window));
+
+ // Makes tab at index 0(NTP) as an active tab and checks that GetIDByWindow()
+ // returns |LauncherID| of browser shortcut.
+ browser()->tab_strip_model()->ActivateTabAt(0, false);
+ EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
+ EXPECT_EQ(browser_id, controller_->GetIDByWindow(window));
+}
+
IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, OverflowBubble) {
// Make sure to have a browser window
chrome::NewTab(browser());
@@ -828,9 +1658,7 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, OverflowBubble) {
EXPECT_TRUE(launcher_->IsShowingOverflowBubble());
// Unpin first pinned app and there should be no crash.
- ChromeLauncherController* controller =
- static_cast<ChromeLauncherController*>(launcher_->delegate());
- controller->UnpinAppsWithID(std::string("fake_app_0"));
+ controller_->UnpinAppsWithID(std::string("fake_app_0"));
test.RunMessageLoopUntilAnimationsDone();
EXPECT_FALSE(launcher_->IsShowingOverflowBubble());

Powered by Google App Engine
This is Rietveld 408576698