summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoriannucci@google.com <iannucci@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-21 01:12:03 +0000
committeriannucci@google.com <iannucci@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-21 01:12:03 +0000
commitecba86a383c555446661805e172350d36c5d1835 (patch)
tree7cc00ac26cc1f8535b3b0b58fd11a311e043c9c1
parentf2aafb5ab3ad59cdd39a00890458e0ba320756f3 (diff)
downloadchromium_src-ecba86a383c555446661805e172350d36c5d1835.zip
chromium_src-ecba86a383c555446661805e172350d36c5d1835.tar.gz
chromium_src-ecba86a383c555446661805e172350d36c5d1835.tar.bz2
Revert "Fixing activation states from the new launcher. Also adding a whole bunch of unit tests for the new launcher."
This reverts commit 0955b2b737aaf0e330d150f72bc39a127efff5b6 (aka r177840). This was failing RefocusFilterLaunch on chromeos: http://build.chromium.org/p/chromium.chromiumos/builders/Linux%20ChromiumOS%20Tests%20%28dbg%29%282%29/builds/6703 TBR=skuhne@chromium.org Review URL: https://codereview.chromium.org/11896005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@177882 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc7
-rw-r--r--chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h4
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller.h3
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc74
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h10
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_browsertest.cc800
-rw-r--r--chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_unittest.cc4
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc5
-rw-r--r--chrome/chrome_tests.gypi2
9 files changed, 34 insertions, 875 deletions
diff --git a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
index a92f53a..4a885cd 100644
--- a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
+++ b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.cc
@@ -33,9 +33,7 @@ AppShortcutLauncherItemController::AppShortcutLauncherItemController(
// used URL. This will also work with applications like Google Drive.
const Extension* extension =
launcher_controller()->GetExtensionForAppID(app_id);
- // Some unit tests have no real extension and will set their
- if (extension)
- refocus_url_ = GURL(extension->launch_web_url() + "*");
+ refocus_url_ = GURL(extension->launch_web_url() + "*");
}
AppShortcutLauncherItemController::~AppShortcutLauncherItemController() {
@@ -65,7 +63,8 @@ void AppShortcutLauncherItemController::Launch(int event_flags) {
}
void AppShortcutLauncherItemController::Activate() {
- std::vector<content::WebContents*> content = GetRunningApplications();
+ std::vector<content::WebContents*> content =
+ app_controller_->GetV1ApplicationsFromAppId(app_id());
if (content.empty()) {
Launch(ui::EF_NONE);
return;
diff --git a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
index 47b33f1..82bdaed 100644
--- a/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
+++ b/chrome/browser/ui/ash/launcher/app_shortcut_launcher_item_controller.h
@@ -41,10 +41,8 @@ class AppShortcutLauncherItemController : public LauncherItemController {
virtual ChromeLauncherAppMenuItems* GetApplicationList() OVERRIDE;
std::vector<content::WebContents*> GetRunningApplications();
- // Get the refocus url pattern, which can be used to identify this application
- // from a URL link.
+ // Stores the optional refocus url pattern for this item.
const GURL& refocus_url() const { return refocus_url_; }
- // Set the refocus url pattern. Used by unit tests.
void set_refocus_url(const GURL& refocus_url) { refocus_url_ = refocus_url; }
private:
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h
index 8dc043a..2a94486 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller.h
@@ -282,9 +282,6 @@ class ChromeLauncherController
friend class BrowserLauncherItemControllerTest;
friend class LauncherPlatformAppBrowserTest;
friend class LauncherAppBrowserTest;
- // TODO(skuhne): Remove these when the old launcher get removed.
- friend class LauncherPlatformPerAppAppBrowserTest;
- friend class LauncherPerAppAppBrowserTest;
// Creates a new app shortcut item and controller on the launcher at |index|.
// Use kInsertItemAtEnd to add a shortcut as the last item.
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc
index 6dcd78d..786707a 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.cc
@@ -164,7 +164,6 @@ ChromeLauncherControllerPerApp::ChromeLauncherControllerPerApp(
}
model_->AddObserver(this);
- BrowserList::AddObserver(this);
// TODO(stevenjb): Find a better owner for shell_window_controller_?
shell_window_controller_.reset(new ShellWindowLauncherController(this));
app_tab_helper_.reset(new LauncherAppTabHelper(profile_));
@@ -197,7 +196,6 @@ ChromeLauncherControllerPerApp::~ChromeLauncherControllerPerApp() {
shell_window_controller_.reset();
model_->RemoveObserver(this);
- BrowserList::RemoveObserver(this);
for (IDToItemControllerMap::iterator i = id_to_item_controller_map_.begin();
i != id_to_item_controller_map_.end(); ++i) {
i->second->OnRemoved();
@@ -286,7 +284,28 @@ void ChromeLauncherControllerPerApp::SetItemStatus(
if (model_->items()[index].type == ash::TYPE_BROWSER_SHORTCUT)
return;
}
- UpdateBrowserItemStatus();
+ // Determine the new browser's active state and change if necessary.
+ int browser_index = -1;
+ for (size_t index = 0; index < model_->items().size() && browser_index == -1;
+ index++) {
+ if (model_->items()[index].type == ash::TYPE_BROWSER_SHORTCUT)
+ browser_index = index;
+ }
+ DCHECK(browser_index >= 0);
+ ash::LauncherItem browser_item = model_->items()[browser_index];
+ ash::LauncherItemStatus browser_status = browser_item.status;
+ // See if the active window is a browser.
+ if (chrome::FindBrowserWithWindow(ash::wm::GetActiveWindow())) {
+ browser_status = ash::STATUS_ACTIVE;
+ } else if (!BrowserList::empty()) {
+ browser_status = ash::STATUS_RUNNING;
+ } else {
+ browser_status = ash::STATUS_CLOSED;
+ }
+ if (browser_status != browser_item.status) {
+ browser_item.status = browser_status;
+ model_->Set(browser_index, browser_item);
+ }
}
void ChromeLauncherControllerPerApp::SetItemController(
@@ -442,14 +461,8 @@ void ChromeLauncherControllerPerApp::ActivateApp(const std::string& app_id,
return;
}
- // Create a temporary application launcher item and use it to see if there are
- // running instances.
- scoped_ptr<AppShortcutLauncherItemController> app_controller(
- new AppShortcutLauncherItemController(app_id, this));
- if (!app_controller->GetRunningApplications().empty())
- app_controller->Activate();
- else
- LaunchApp(app_id, event_flags);
+ // Otherwise launch the app.
+ LaunchApp(app_id, event_flags);
}
extensions::ExtensionPrefs::LaunchType
@@ -685,12 +698,8 @@ void ChromeLauncherControllerPerApp::UpdateAppState(
RemoveTabFromRunningApp(contents, last_app_id);
}
- if (app_id.empty()) {
- // Even if there is no application running, we should update the activation
- // state of the associated browser.
- UpdateBrowserItemStatus();
+ if (app_id.empty())
return;
- }
web_contents_to_app_id_[contents] = app_id;
@@ -1003,13 +1012,6 @@ gfx::Image ChromeLauncherControllerPerApp::GetAppListIcon(
return favicon_tab_helper->GetFavicon();
}
-void ChromeLauncherControllerPerApp::OnBrowserRemoved(Browser* browser) {
- // When called by a unit test it is possible that there is no shell.
- // In that case, the following function should not get called.
- if (ash::Shell::HasInstance())
- UpdateBrowserItemStatus();
-}
-
ash::LauncherID ChromeLauncherControllerPerApp::CreateAppShortcutLauncherItem(
const std::string& app_id,
int index) {
@@ -1036,32 +1038,6 @@ ChromeLauncherControllerPerApp::GetAppIdFromLauncherIdForTest(
return id_to_item_controller_map_[id]->app_id();
}
-void ChromeLauncherControllerPerApp::UpdateBrowserItemStatus() {
- // Determine the new browser's active state and change if necessary.
- int browser_index = -1;
- for (size_t index = 0; index < model_->items().size() && browser_index == -1;
- index++) {
- if (model_->items()[index].type == ash::TYPE_BROWSER_SHORTCUT)
- browser_index = index;
- }
- DCHECK(browser_index >= 0);
- ash::LauncherItem browser_item = model_->items()[browser_index];
- ash::LauncherItemStatus browser_status = browser_item.status;
- // See if the active window is a browser.
- aura::Window* window = ash::wm::GetActiveWindow();
- if (window && chrome::FindBrowserWithWindow(window)) {
- browser_status = ash::STATUS_ACTIVE;
- } else if (!BrowserList::empty()) {
- browser_status = ash::STATUS_RUNNING;
- } else {
- browser_status = ash::STATUS_CLOSED;
- }
- if (browser_status != browser_item.status) {
- browser_item.status = browser_status;
- model_->Set(browser_index, browser_item);
- }
-}
-
Profile* ChromeLauncherControllerPerApp::GetProfileForNewWindows() {
return ProfileManager::GetDefaultProfileOrOffTheRecord();
}
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h
index b463bdb..bfae61f 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app.h
@@ -25,7 +25,6 @@
#include "chrome/browser/ui/ash/launcher/chrome_launcher_app_menu_item.h"
#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
#include "chrome/browser/ui/ash/launcher/shell_window_launcher_controller.h"
-#include "chrome/browser/ui/browser_list_observer.h"
#include "chrome/browser/ui/extensions/extension_enable_flow_delegate.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
@@ -66,8 +65,7 @@ class ChromeLauncherControllerPerApp : public ash::LauncherModelObserver,
public content::NotificationObserver,
public PrefServiceSyncableObserver,
public AppSyncUIStateObserver,
- public ExtensionEnableFlowDelegate,
- public chrome::BrowserListObserver {
+ public ExtensionEnableFlowDelegate {
public:
ChromeLauncherControllerPerApp(Profile* profile, ash::LauncherModel* model);
virtual ~ChromeLauncherControllerPerApp();
@@ -297,9 +295,6 @@ class ChromeLauncherControllerPerApp : public ash::LauncherModelObserver,
// Note that for incognito windows the incognito icon will be returned.
gfx::Image GetAppListIcon(content::WebContents* web_contents) const;
- // Overridden from chrome::BrowserListObserver.
- virtual void OnBrowserRemoved(Browser* browser) OVERRIDE;
-
protected:
// ChromeLauncherController overrides:
@@ -319,9 +314,6 @@ class ChromeLauncherControllerPerApp : public ash::LauncherModelObserver,
private:
friend class ChromeLauncherControllerPerAppTest;
- // Updates the activation state of the Broswer item.
- void UpdateBrowserItemStatus();
-
typedef std::map<ash::LauncherID, LauncherItemController*>
IDToItemControllerMap;
typedef std::list<content::WebContents*> WebContentsList;
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_browsertest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_browsertest.cc
deleted file mode 100644
index db55cb5..0000000
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_browsertest.cc
+++ /dev/null
@@ -1,800 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h"
-
-#include "ash/ash_switches.h"
-#include "ash/launcher/launcher.h"
-#include "ash/launcher/launcher_model.h"
-#include "ash/shell.h"
-#include "ash/test/shell_test_api.h"
-#include "ash/wm/window_util.h"
-#include "base/command_line.h"
-#include "base/utf_string_conversions.h"
-#include "chrome/browser/automation/automation_util.h"
-#include "chrome/browser/extensions/extension_apitest.h"
-#include "chrome/browser/extensions/extension_browsertest.h"
-#include "chrome/browser/extensions/extension_function_test_utils.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/extensions/extension_system.h"
-#include "chrome/browser/extensions/extension_test_message_listener.h"
-#include "chrome/browser/extensions/platform_app_browsertest_util.h"
-#include "chrome/browser/extensions/shell_window_registry.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/browser_commands.h"
-#include "chrome/browser/ui/browser_window.h"
-#include "chrome/browser/ui/extensions/application_launch.h"
-#include "chrome/browser/ui/extensions/shell_window.h"
-#include "chrome/browser/ui/tabs/tab_strip_model.h"
-#include "chrome/common/chrome_notification_types.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/extensions/extension_constants.h"
-#include "chrome/test/base/ui_test_utils.h"
-#include "content/public/browser/notification_service.h"
-#include "content/public/browser/notification_source.h"
-#include "content/public/browser/web_contents.h"
-#include "testing/gtest/include/gtest/gtest.h"
-#include "ui/aura/window.h"
-
-using extensions::Extension;
-using content::WebContents;
-
-// TODO(skuhne): Change name back to LauncherPlatformAppBrowserTest when the
-// old launcher gets ripped out.
-class LauncherPlatformPerAppAppBrowserTest
- : public extensions::PlatformAppBrowserTest {
- protected:
- LauncherPlatformPerAppAppBrowserTest()
- : launcher_(NULL),
- controller_(NULL) {
- }
-
- virtual ~LauncherPlatformPerAppAppBrowserTest() {}
- // TODO(skuhne): Remove when the old launcher gets removed.
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- PlatformAppBrowserTest::SetUpCommandLine(command_line);
- command_line->AppendSwitch(ash::switches::kAshEnablePerAppLauncher);
- }
-
- ash::LauncherModel* launcher_model() {
- return ash::test::ShellTestApi(ash::Shell::GetInstance()).launcher_model();
- }
-
- virtual void RunTestOnMainThreadLoop() {
- launcher_ = ash::Launcher::ForPrimaryDisplay();
- controller_ = static_cast<ChromeLauncherController*>(launcher_->delegate());
- return extensions::PlatformAppBrowserTest::RunTestOnMainThreadLoop();
- }
-
- ash::LauncherID CreateAppShortcutLauncherItem(const std::string& name) {
- return controller_->CreateAppShortcutLauncherItem(
- name, controller_->model()->item_count());
- }
-
- ash::Launcher* launcher_;
- ChromeLauncherController* controller_;
-};
-
-// TODO(skuhne): Change name back to LauncherAppBrowserTest when the
-// old launcher gets ripped out.
-class LauncherPerAppAppBrowserTest : public ExtensionBrowserTest {
- protected:
- LauncherPerAppAppBrowserTest()
- : launcher_(NULL),
- model_(NULL) {
- }
-
- virtual ~LauncherPerAppAppBrowserTest() {}
-
- // TODO(skuhne): Remove when the old launcher gets removed.
- virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
- ExtensionBrowserTest::SetUpCommandLine(command_line);
- command_line->AppendSwitch(ash::switches::kAshEnablePerAppLauncher);
- }
-
- virtual void RunTestOnMainThreadLoop() {
- launcher_ = ash::Launcher::ForPrimaryDisplay();
- model_ =
- ash::test::ShellTestApi(ash::Shell::GetInstance()).launcher_model();
- return ExtensionBrowserTest::RunTestOnMainThreadLoop();
- }
-
- const Extension* LoadAndLaunchExtension(
- const char* name,
- extension_misc::LaunchContainer container,
- WindowOpenDisposition disposition) {
- EXPECT_TRUE(LoadExtension(test_data_dir_.AppendASCII(name)));
-
- ExtensionService* service = extensions::ExtensionSystem::Get(
- browser()->profile())->extension_service();
- const Extension* extension =
- service->GetExtensionById(last_loaded_extension_id_, false);
- EXPECT_TRUE(extension);
-
- application_launch::OpenApplication(application_launch::LaunchParams(
- browser()->profile(), extension, container, disposition));
- return extension;
- }
-
- ash::LauncherID CreateShortcut(const char* name) {
- ExtensionService* service = extensions::ExtensionSystem::Get(
- browser()->profile())->extension_service();
- LoadExtension(test_data_dir_.AppendASCII(name));
-
- // First get app_id.
- const Extension* extension =
- service->GetExtensionById(last_loaded_extension_id_, false);
- 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();
- EXPECT_EQ(++item_count, model_->item_count());
- ash::LauncherItem item = *model_->ItemByID(shortcut_id);
- EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
- return item.id;
- }
-
- ash::Launcher* launcher_;
- ash::LauncherModel* model_;
-};
-
-// Test that we can launch a platform app and get a running item.
-IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest, LaunchUnpinned) {
- int item_count = launcher_model()->item_count();
- const Extension* extension = LoadAndLaunchPlatformApp("launch");
- ShellWindow* window = CreateShellWindow(extension);
- ++item_count;
- ASSERT_EQ(item_count, launcher_model()->item_count());
- ash::LauncherItem item =
- launcher_model()->items()[launcher_model()->item_count() - 2];
- EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type);
- EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
- CloseShellWindow(window);
- --item_count;
- EXPECT_EQ(item_count, launcher_model()->item_count());
-}
-
-// Test that we can launch a platform app that already has a shortcut.
-IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest, LaunchPinned) {
- int item_count = launcher_model()->item_count();
-
- // First get app_id.
- const Extension* extension = LoadAndLaunchPlatformApp("launch");
- const std::string app_id = extension->id();
-
- // Then create a shortcut.
- ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id);
- ++item_count;
- ASSERT_EQ(item_count, launcher_model()->item_count());
- ash::LauncherItem item = *launcher_model()->ItemByID(shortcut_id);
- EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
- EXPECT_EQ(ash::STATUS_CLOSED, item.status);
-
- // Open a window. Confirm the item is now running.
- ShellWindow* window = CreateShellWindow(extension);
- ash::wm::ActivateWindow(window->GetNativeWindow());
- ASSERT_EQ(item_count, launcher_model()->item_count());
- item = *launcher_model()->ItemByID(shortcut_id);
- EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
- EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
-
- // Then close it, make sure there's still an item.
- CloseShellWindow(window);
- ASSERT_EQ(item_count, launcher_model()->item_count());
- item = *launcher_model()->ItemByID(shortcut_id);
- EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
- EXPECT_EQ(ash::STATUS_CLOSED, item.status);
-}
-
-IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest, PinRunning) {
- // Run.
- int item_count = launcher_model()->item_count();
- const Extension* extension = LoadAndLaunchPlatformApp("launch");
- ShellWindow* window = CreateShellWindow(extension);
- ++item_count;
- ASSERT_EQ(item_count, launcher_model()->item_count());
- ash::LauncherItem item =
- launcher_model()->items()[launcher_model()->item_count() - 2];
- ash::LauncherID id = item.id;
- EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type);
- EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
-
- // Create a shortcut. The app item should be after it.
- ash::LauncherID foo_id = CreateAppShortcutLauncherItem("foo");
- ++item_count;
- ASSERT_EQ(item_count, launcher_model()->item_count());
- EXPECT_LT(launcher_model()->ItemIndexByID(foo_id),
- launcher_model()->ItemIndexByID(id));
-
- // Pin the app. The item should remain.
- controller_->Pin(id);
- ASSERT_EQ(item_count, launcher_model()->item_count());
- item = *launcher_model()->ItemByID(id);
- EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
- EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
-
- // New shortcuts should come after the item.
- ash::LauncherID bar_id = CreateAppShortcutLauncherItem("bar");
- ++item_count;
- ASSERT_EQ(item_count, launcher_model()->item_count());
- EXPECT_LT(launcher_model()->ItemIndexByID(id),
- launcher_model()->ItemIndexByID(bar_id));
-
- // Then close it, make sure the item remains.
- CloseShellWindow(window);
- ASSERT_EQ(item_count, launcher_model()->item_count());
-}
-
-IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest, UnpinRunning) {
- int item_count = launcher_model()->item_count();
-
- // First get app_id.
- const Extension* extension = LoadAndLaunchPlatformApp("launch");
- const std::string app_id = extension->id();
-
- // Then create a shortcut.
- ash::LauncherID shortcut_id = CreateAppShortcutLauncherItem(app_id);
- ++item_count;
- ASSERT_EQ(item_count, launcher_model()->item_count());
- ash::LauncherItem item = *launcher_model()->ItemByID(shortcut_id);
- EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
- EXPECT_EQ(ash::STATUS_CLOSED, item.status);
-
- // Create a second shortcut. This will be needed to force the first one to
- // move once it gets unpinned.
- ash::LauncherID foo_id = CreateAppShortcutLauncherItem("foo");
- ++item_count;
- ASSERT_EQ(item_count, launcher_model()->item_count());
- EXPECT_LT(launcher_model()->ItemIndexByID(shortcut_id),
- launcher_model()->ItemIndexByID(foo_id));
-
- // Open a window. Confirm the item is now running.
- ShellWindow* window = CreateShellWindow(extension);
- ash::wm::ActivateWindow(window->GetNativeWindow());
- ASSERT_EQ(item_count, launcher_model()->item_count());
- item = *launcher_model()->ItemByID(shortcut_id);
- EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
- EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
-
- // Unpin the app. The item should remain.
- controller_->Unpin(shortcut_id);
- ASSERT_EQ(item_count, launcher_model()->item_count());
- item = *launcher_model()->ItemByID(shortcut_id);
- EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type);
- EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
- // The item should have moved after the other shortcuts.
- EXPECT_GT(launcher_model()->ItemIndexByID(shortcut_id),
- launcher_model()->ItemIndexByID(foo_id));
-
- // Then close it, make sure the item's gone.
- CloseShellWindow(window);
- --item_count;
- ASSERT_EQ(item_count, launcher_model()->item_count());
-}
-
-// Test that we can launch a platform app with more than one window.
-IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest, MultipleWindows) {
- int item_count = launcher_model()->item_count();
-
- // First run app.
- const Extension* extension = LoadAndLaunchPlatformApp("launch");
- ShellWindow* window1 = CreateShellWindow(extension);
- ++item_count;
- ASSERT_EQ(item_count, launcher_model()->item_count());
- ash::LauncherItem item =
- launcher_model()->items()[launcher_model()->item_count() - 2];
- ash::LauncherID item_id = item.id;
- EXPECT_EQ(ash::TYPE_PLATFORM_APP, item.type);
- EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
-
- // Add second window.
- ShellWindow* window2 = CreateShellWindow(extension);
- // Confirm item stays.
- ASSERT_EQ(item_count, launcher_model()->item_count());
- item = *launcher_model()->ItemByID(item_id);
- EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
-
- // Close second window.
- CloseShellWindow(window2);
- // Confirm item stays.
- ASSERT_EQ(item_count, launcher_model()->item_count());
- item = *launcher_model()->ItemByID(item_id);
- EXPECT_EQ(ash::STATUS_ACTIVE, item.status);
-
- // Close first window.
- CloseShellWindow(window1);
- // Confirm item is removed.
- --item_count;
- ASSERT_EQ(item_count, launcher_model()->item_count());
-}
-
-IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest, MultipleApps) {
- 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;
- EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
- EXPECT_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;
- EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type);
- EXPECT_EQ(ash::STATUS_ACTIVE, item2.status);
-
- EXPECT_NE(item_id1, item_id2);
- EXPECT_EQ(ash::STATUS_RUNNING,
- launcher_model()->ItemByID(item_id1)->status);
-
- // Close second app.
- CloseShellWindow(window2);
- --item_count;
- ASSERT_EQ(item_count, launcher_model()->item_count());
- // First app should be active again.
- EXPECT_EQ(ash::STATUS_ACTIVE,
- launcher_model()->ItemByID(item_id1)->status);
-
- // Close first app.
- CloseShellWindow(window1);
- --item_count;
- 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(LauncherPlatformPerAppAppBrowserTest, WindowActivation) {
- 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;
- EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
- EXPECT_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;
- EXPECT_EQ(ash::TYPE_PLATFORM_APP, item2.type);
- EXPECT_EQ(ash::STATUS_ACTIVE, item2.status);
-
- EXPECT_NE(item_id1, item_id2);
- EXPECT_EQ(ash::STATUS_RUNNING,
- launcher_model()->ItemByID(item_id1)->status);
-
- // Activate first one.
- launcher_->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);
- EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
- EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
-
- // Activate second one.
- launcher_->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);
- EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
- EXPECT_TRUE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
-
- // Add window for app1. This will activate it.
- ShellWindow* window1b = CreateShellWindow(extension1);
- ash::wm::ActivateWindow(window1b->GetNativeWindow());
- EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
- EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
- EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
-
- // Activate launcher item for app1, this will cycle the active window.
- launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1));
- EXPECT_FALSE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
- EXPECT_TRUE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
- launcher_->ActivateLauncherItem(launcher_model()->ItemIndexByID(item_id1));
- EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
- EXPECT_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
-
- // Activate the second app again
- launcher_->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_FALSE(ash::wm::IsActiveWindow(window1->GetNativeWindow()));
- EXPECT_FALSE(ash::wm::IsActiveWindow(window2->GetNativeWindow()));
- EXPECT_TRUE(ash::wm::IsActiveWindow(window1b->GetNativeWindow()));
-
- // Close second app.
- CloseShellWindow(window2);
- --item_count;
- EXPECT_EQ(item_count, launcher_model()->item_count());
- // First app should be active again.
- EXPECT_EQ(ash::STATUS_ACTIVE, launcher_model()->ItemByID(item_id1)->status);
-
- // Close first app.
- CloseShellWindow(window1b);
- CloseShellWindow(window1);
- --item_count;
- EXPECT_EQ(item_count, launcher_model()->item_count());
-}
-
-IN_PROC_BROWSER_TEST_F(LauncherPlatformPerAppAppBrowserTest,
- BrowserActivation) {
- int item_count = launcher_model()->item_count();
-
- // First run app.
- const Extension* extension1 = LoadAndLaunchPlatformApp("launch");
- 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;
- EXPECT_EQ(ash::TYPE_PLATFORM_APP, item1.type);
- EXPECT_EQ(ash::STATUS_ACTIVE, item1.status);
-
- ash::wm::ActivateWindow(browser()->window()->GetNativeWindow());
- EXPECT_EQ(ash::STATUS_RUNNING,
- launcher_model()->ItemByID(item_id1)->status);
-}
-
-// Test that we can launch an app with a shortcut.
-IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, LaunchPinned) {
- TabStripModel* tab_strip = browser()->tab_strip_model();
- 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));
- EXPECT_EQ(++tab_count, tab_strip->count());
- EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status);
- WebContents* tab = tab_strip->GetActiveWebContents();
- content::WindowedNotificationObserver close_observer(
- content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
- content::Source<WebContents>(tab));
- browser()->tab_strip_model()->CloseSelectedTabs();
- close_observer.Wait();
- EXPECT_EQ(--tab_count, tab_strip->count());
- EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status);
-}
-
-// Launch the app first and then create the shortcut.
-IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, LaunchUnpinned) {
- TabStripModel* tab_strip = browser()->tab_strip_model();
- int tab_count = tab_strip->count();
- LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB,
- NEW_FOREGROUND_TAB);
- EXPECT_EQ(++tab_count, tab_strip->count());
- ash::LauncherID shortcut_id = CreateShortcut("app1");
- EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status);
- WebContents* tab = tab_strip->GetActiveWebContents();
- content::WindowedNotificationObserver close_observer(
- content::NOTIFICATION_WEB_CONTENTS_DESTROYED,
- content::Source<WebContents>(tab));
- browser()->tab_strip_model()->CloseSelectedTabs();
- close_observer.Wait();
- EXPECT_EQ(--tab_count, tab_strip->count());
- EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status);
-}
-
-// Launches an app in the background and then tries to open it. This is test for
-// a crash we had.
-IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, LaunchInBackground) {
- TabStripModel* tab_strip = browser()->tab_strip_model();
- int tab_count = tab_strip->count();
- LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB,
- NEW_BACKGROUND_TAB);
- EXPECT_EQ(++tab_count, tab_strip->count());
- ChromeLauncherController::instance()->LaunchApp(last_loaded_extension_id_, 0);
-}
-
-// Confirm that clicking a icon for an app running in one of 2 maxmized windows
-// activates the right window.
-IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, LaunchMaximized) {
- aura::Window* window1 = browser()->window()->GetNativeWindow();
- ash::wm::MaximizeWindow(window1);
- content::WindowedNotificationObserver open_observer(
- chrome::NOTIFICATION_BROWSER_WINDOW_READY,
- content::NotificationService::AllSources());
- chrome::NewEmptyWindow(browser()->profile());
- open_observer.Wait();
- Browser* browser2 = content::Source<Browser>(open_observer.source()).ptr();
- aura::Window* window2 = browser2->window()->GetNativeWindow();
- TabStripModel* tab_strip = browser2->tab_strip_model();
- int tab_count = tab_strip->count();
- ash::wm::MaximizeWindow(window2);
-
- ash::LauncherID shortcut_id = CreateShortcut("app1");
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
- EXPECT_EQ(++tab_count, tab_strip->count());
- EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status);
-
- window1->Show();
- ash::wm::ActivateWindow(window1);
- EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut_id)).status);
-
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
- EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status);
-}
-
-// Activating the same app multiple times should launch only a single copy.
-IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, ActivateApp) {
- TabStripModel* tab_strip = browser()->tab_strip_model();
- int tab_count = tab_strip->count();
- const Extension* extension =
- LoadExtension(test_data_dir_.AppendASCII("app1"));
-
- ChromeLauncherController::instance()->ActivateApp(extension->id(), 0);
- EXPECT_EQ(++tab_count, tab_strip->count());
- ChromeLauncherController::instance()->ActivateApp(extension->id(), 0);
- EXPECT_EQ(tab_count, tab_strip->count());
-}
-
-// Launching the same app multiple times should launch a copy for each call.
-IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, LaunchApp) {
- TabStripModel* tab_strip = browser()->tab_strip_model();
- int tab_count = tab_strip->count();
- const Extension* extension =
- LoadExtension(test_data_dir_.AppendASCII("app1"));
-
- ChromeLauncherController::instance()->LaunchApp(extension->id(), 0);
- EXPECT_EQ(++tab_count, tab_strip->count());
- ChromeLauncherController::instance()->LaunchApp(extension->id(), 0);
- EXPECT_EQ(++tab_count, tab_strip->count());
-}
-
-// Launch 2 apps and toggle which is active.
-IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, MultipleApps) {
- int item_count = model_->item_count();
- TabStripModel* tab_strip = browser()->tab_strip_model();
- int tab_count = tab_strip->count();
- ash::LauncherID shortcut1 = CreateShortcut("app1");
- EXPECT_EQ(++item_count, model_->item_count());
- ash::LauncherID shortcut2 = CreateShortcut("app2");
- EXPECT_EQ(++item_count, model_->item_count());
-
- // Launch first app.
- launcher_->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));
- EXPECT_EQ(++tab_count, tab_strip->count());
- WebContents* tab2 = tab_strip->GetActiveWebContents();
- ASSERT_NE(tab1, tab2);
- 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));
- 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);
-
- // Open second tab for second app. This should activate it.
- ui_test_utils::NavigateToURLWithDisposition(
- browser(),
- GURL("http://www.example.com/path3/foo.html"),
- NEW_FOREGROUND_TAB,
- 0);
- EXPECT_EQ(++tab_count, tab_strip->count());
- 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));
- 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));
- EXPECT_EQ(tab_count, tab_strip->count());
- EXPECT_EQ(tab_strip->GetActiveWebContents(), tab2);
- EXPECT_EQ(ash::STATUS_RUNNING, (*model_->ItemByID(shortcut1)).status);
- EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut2)).status);
-}
-
-// Confirm that a page can be navigated from and to while maintaining the
-// correct running state.
-IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, Navigation) {
- ash::LauncherID shortcut_id = CreateShortcut("app1");
- EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status);
- launcher_->ActivateLauncherItem(model_->ItemIndexByID(shortcut_id));
- EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status);
-
- // Navigate away.
- ui_test_utils::NavigateToURL(
- browser(), GURL("http://www.example.com/path0/bar.html"));
- EXPECT_EQ(ash::STATUS_CLOSED, (*model_->ItemByID(shortcut_id)).status);
-
- // Navigate back.
- ui_test_utils::NavigateToURL(
- browser(), GURL("http://www.example.com/path1/foo.html"));
- EXPECT_EQ(ash::STATUS_ACTIVE, (*model_->ItemByID(shortcut_id)).status);
-}
-
-IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, 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));
- 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(
- browser(),
- GURL("http://www.example.com/path2/bar.html"),
- NEW_FOREGROUND_TAB,
- ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
- EXPECT_EQ(++tab_count, tab_strip->count());
- // Confirm app is still active.
- EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
-
- // Create new tab not owned by app.
- ui_test_utils::NavigateToURLWithDisposition(
- browser(),
- GURL("http://www.example.com/path3/foo.html"),
- NEW_FOREGROUND_TAB,
- 0);
- EXPECT_EQ(++tab_count, tab_strip->count());
- // No longer active.
- EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status);
-
- // Activating app makes first tab active again.
- launcher_->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(LauncherPerAppAppBrowserTest, 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));
- 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(
- shortcut_id, GURL("http://www.example.com/path1/*"));
- // Create new tab owned by app.
- ui_test_utils::NavigateToURLWithDisposition(
- browser(),
- GURL("http://www.example.com/path2/bar.html"),
- NEW_FOREGROUND_TAB,
- ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION);
- EXPECT_EQ(++tab_count, tab_strip->count());
- // Confirm app is still active.
- EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
-
- // Create new tab not owned by app.
- ui_test_utils::NavigateToURLWithDisposition(
- browser(),
- GURL("http://www.example.com/path3/foo.html"),
- NEW_FOREGROUND_TAB,
- 0);
- EXPECT_EQ(++tab_count, tab_strip->count());
- // No longer active.
- EXPECT_EQ(ash::STATUS_RUNNING, model_->ItemByID(shortcut_id)->status);
-
- // Activating app makes first tab active again, because second tab isn't
- // in its refocus url path.
- launcher_->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(LauncherPerAppAppBrowserTest, 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(
- shortcut_id, GURL("http://www.example.com/path1/*"));
-
- // Create new tab owned by app.
- ui_test_utils::NavigateToURLWithDisposition(
- browser(),
- GURL("http://www.example.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);
-
- // Activating app should launch new tab, because second tab isn't
- // in its refocus url path.
- launcher_->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);
- EXPECT_NE(first_tab, second_tab);
- EXPECT_EQ(tab_strip->GetActiveWebContents(), second_tab);
-}
-
-// Check the launcher activation state for applications and browser.
-IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, ActivationStateCheck) {
- ChromeLauncherController* controller =
- static_cast<ChromeLauncherController*>(launcher_->delegate());
- TabStripModel* tab_strip = browser()->tab_strip_model();
- // Get the browser item index
- int browser_index = -1;
- for (size_t index = 0; index < model_->items().size() && browser_index == -1;
- index++) {
- if (model_->items()[index].type == ash::TYPE_BROWSER_SHORTCUT)
- browser_index = index;
- }
- 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);
-
- EXPECT_EQ(ash::STATUS_ACTIVE, model_->ItemByID(shortcut_id)->status);
- EXPECT_EQ(ash::STATUS_ACTIVE, 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);
-}
-
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_unittest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_unittest.cc
index 01f7792..e79136e 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_unittest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_unittest.cc
@@ -458,3 +458,7 @@ TEST_F(ChromeLauncherControllerPerAppTest, V1AppMenuExecution) {
// TODO(skuhne) Add tests for:
// - V2 apps: create through item in launcher or directly
+// - Tracking correct activation state (seems not to work from unit_test)
+// - Check that browser is always running or active when browser is active
+// - Check that v1 app active shows browser active and app.
+// ..
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 8c77984..e97ae4c 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -643,11 +643,6 @@ bool BrowserView::IsAlwaysOnTop() const {
}
gfx::NativeWindow BrowserView::GetNativeWindow() {
- // While the browser destruction is going on, the widget can already be gone,
- // but utility functions like FindBrowserWithWindow will come here and crash.
- // We short circuit therefore.
- if (!GetWidget())
- return NULL;
return GetWidget()->GetTopLevelWidget()->GetNativeWindow();
}
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 5092c9e..a867197 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -1199,7 +1199,6 @@
'browser/ui/ash/caps_lock_handler_browsertest.cc',
'browser/ui/ash/chrome_shell_delegate_browsertest.cc',
'browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc',
- 'browser/ui/ash/launcher/chrome_launcher_controller_per_app_browsertest.cc',
'browser/ui/ash/launcher/launcher_favicon_loader_browsertest.cc',
'browser/ui/ash/shelf_browsertest.cc',
'browser/ui/ash/volume_controller_browsertest_chromeos.cc',
@@ -1559,7 +1558,6 @@
# TODO: enable these for win_ash browser tests.
'browser/chromeos/system/tray_accessibility_browsertest.cc',
'browser/ui/ash/chrome_shell_delegate_browsertest.cc',
- 'browser/ui/ash/launcher/chrome_launcher_controller_per_app_browsertest.cc',
'browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc',
'browser/ui/ash/launcher/launcher_favicon_loader_browsertest.cc',
'browser/ui/ash/shelf_browsertest.cc',