| Index: chrome/browser/ui/ash/launcher/chrome_launcher_controller_per_app_browsertest.cc
|
| 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
|
| index 248b19a46179fcebf9a7aa012e4b470f64b3b9d7..9bc5cd126905227fbe29f6abcbe1b03f2461ba99 100644
|
| --- 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
|
| @@ -118,8 +118,9 @@ class LauncherPlatformPerAppAppBrowserTest
|
|
|
| virtual void RunTestOnMainThreadLoop() OVERRIDE {
|
| launcher_ = ash::Launcher::ForPrimaryDisplay();
|
| - controller_ =
|
| - static_cast<ChromeLauncherControllerPerApp*>(launcher_->delegate());
|
| + controller_ = static_cast<ChromeLauncherControllerPerApp*>
|
| + (ChromeLauncherController::instance());
|
| + DCHECK(controller_);
|
| return extensions::PlatformAppBrowserTest::RunTestOnMainThreadLoop();
|
| }
|
|
|
| @@ -189,14 +190,16 @@ class LauncherPerAppAppBrowserTest : public ExtensionBrowserTest {
|
| launcher_ = ash::Launcher::ForPrimaryDisplay();
|
| model_ =
|
| ash::test::ShellTestApi(ash::Shell::GetInstance()).launcher_model();
|
| + controller_ = static_cast<ChromeLauncherControllerPerApp*>
|
| + (ChromeLauncherController::instance());
|
| + DCHECK(controller_);
|
| +
|
| return ExtensionBrowserTest::RunTestOnMainThreadLoop();
|
| }
|
|
|
| size_t NumberOfDetectedLauncherBrowsers(bool show_all_tabs) {
|
| - ChromeLauncherControllerPerApp* controller =
|
| - static_cast<ChromeLauncherControllerPerApp*>(launcher_->delegate());
|
| LauncherItemController* item_controller =
|
| - controller->GetBrowserShortcutLauncherItemController();
|
| + 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.
|
| @@ -233,13 +236,11 @@ class LauncherPerAppAppBrowserTest : 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(
|
| + ash::LauncherID shortcut_id = controller_->CreateAppShortcutLauncherItem(
|
| app_id,
|
| item_count);
|
| - controller->PersistPinnedState();
|
| + controller_->PersistPinnedState();
|
| EXPECT_EQ(++item_count, model_->item_count());
|
| const ash::LauncherItem& item = *model_->ItemByID(shortcut_id);
|
| EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type);
|
| @@ -253,6 +254,7 @@ class LauncherPerAppAppBrowserTest : public ExtensionBrowserTest {
|
|
|
| ash::Launcher* launcher_;
|
| ash::LauncherModel* model_;
|
| + ChromeLauncherControllerPerApp* controller_;
|
|
|
| private:
|
|
|
| @@ -839,7 +841,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, LaunchInBackground) {
|
| LoadAndLaunchExtension("app1", extension_misc::LAUNCH_TAB,
|
| NEW_BACKGROUND_TAB);
|
| EXPECT_EQ(++tab_count, tab_strip->count());
|
| - ChromeLauncherController::instance()->LaunchApp(last_loaded_extension_id_, 0);
|
| + controller_->LaunchApp(last_loaded_extension_id_, 0);
|
| }
|
|
|
| // Confirm that clicking a icon for an app running in one of 2 maxmized windows
|
| @@ -878,9 +880,9 @@ IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, ActivateApp) {
|
| const Extension* extension =
|
| LoadExtension(test_data_dir_.AppendASCII("app1"));
|
|
|
| - ChromeLauncherController::instance()->ActivateApp(extension->id(), 0);
|
| + controller_->ActivateApp(extension->id(), 0);
|
| EXPECT_EQ(++tab_count, tab_strip->count());
|
| - ChromeLauncherController::instance()->ActivateApp(extension->id(), 0);
|
| + controller_->ActivateApp(extension->id(), 0);
|
| EXPECT_EQ(tab_count, tab_strip->count());
|
| }
|
|
|
| @@ -891,9 +893,9 @@ IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, LaunchApp) {
|
| const Extension* extension =
|
| LoadExtension(test_data_dir_.AppendASCII("app1"));
|
|
|
| - ChromeLauncherController::instance()->LaunchApp(extension->id(), 0);
|
| + controller_->LaunchApp(extension->id(), 0);
|
| EXPECT_EQ(++tab_count, tab_strip->count());
|
| - ChromeLauncherController::instance()->LaunchApp(extension->id(), 0);
|
| + controller_->LaunchApp(extension->id(), 0);
|
| EXPECT_EQ(++tab_count, tab_strip->count());
|
| }
|
|
|
| @@ -1008,8 +1010,6 @@ IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, MultipleOwnedTabs) {
|
| }
|
|
|
| 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");
|
| @@ -1018,7 +1018,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, RefocusFilter) {
|
| 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(
|
| @@ -1048,12 +1048,10 @@ IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, RefocusFilter) {
|
| }
|
|
|
| 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(
|
| + controller_->SetRefocusURLPatternForTest(
|
| shortcut_id, GURL("http://www.example.com/path1/*"));
|
|
|
| // Create new tab.
|
| @@ -1079,18 +1077,16 @@ IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, RefocusFilterLaunch) {
|
|
|
| // 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 = ash::launcher::GetBrowserItemIndex(*controller->model());
|
| + 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(
|
| + controller_->SetRefocusURLPatternForTest(
|
| shortcut_id, GURL("http://www.example.com/path1/*"));
|
|
|
| EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status);
|
| @@ -1125,12 +1121,10 @@ IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, ActivationStateCheck) {
|
| // destroyed.
|
| IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest,
|
| AsyncActivationStateCheck) {
|
| - ChromeLauncherController* controller =
|
| - static_cast<ChromeLauncherController*>(launcher_->delegate());
|
| TabStripModel* tab_strip = browser()->tab_strip_model();
|
|
|
| ash::LauncherID shortcut_id = CreateShortcut("app1");
|
| - controller->SetRefocusURLPatternForTest(
|
| + controller_->SetRefocusURLPatternForTest(
|
| shortcut_id, GURL("http://www.example.com/path1/*"));
|
|
|
| EXPECT_EQ(ash::STATUS_CLOSED, model_->ItemByID(shortcut_id)->status);
|
| @@ -1203,11 +1197,9 @@ IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTestNoDefaultBrowser,
|
| // the items at hand.
|
| IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, AltNumberTabsTabbing) {
|
| TabStripModel* tab_strip = browser()->tab_strip_model();
|
| - ChromeLauncherController* controller =
|
| - static_cast<ChromeLauncherController*>(launcher_->delegate());
|
|
|
| ash::LauncherID shortcut_id = CreateShortcut("app");
|
| - controller->SetRefocusURLPatternForTest(
|
| + controller_->SetRefocusURLPatternForTest(
|
| shortcut_id, GURL("http://www.example.com/path/*"));
|
| std::string url = "http://www.example.com/path/bla";
|
|
|
| @@ -1352,8 +1344,6 @@ IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest,
|
| EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
|
|
|
| // Create a known application.
|
| - ChromeLauncherController* controller =
|
| - static_cast<ChromeLauncherController*>(launcher_->delegate());
|
| ash::LauncherID shortcut_id = CreateShortcut("app1");
|
|
|
| // Create a new browser - without activating it - and load an "app" into it.
|
| @@ -1361,7 +1351,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest,
|
| Browser::CreateParams(profile(), chrome::GetActiveDesktop());
|
| params.initial_show_state = ui::SHOW_STATE_INACTIVE;
|
| Browser* browser2 = new Browser(params);
|
| - controller->SetRefocusURLPatternForTest(
|
| + controller_->SetRefocusURLPatternForTest(
|
| shortcut_id, GURL("http://www.example.com/path/*"));
|
| std::string url = "http://www.example.com/path/bla";
|
| ui_test_utils::NavigateToURLWithDisposition(
|
| @@ -1390,7 +1380,7 @@ IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest,
|
| 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),
|
| + controller_->ItemSelected(*model_->ItemByID(shortcut_id),
|
| ui::KeyEvent(ui::ET_KEY_RELEASED,
|
| ui::VKEY_RETURN,
|
| 0,
|
| @@ -1547,13 +1537,12 @@ IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTest, ClickItem) {
|
| EXPECT_EQ(tab_count + 1, tab_strip->count());
|
| }
|
|
|
| -// Check LauncherItemController of Browser Shortcut functionality.
|
| +// Check LauncherItemController of Browser Shortcut functionality and its
|
| +// status.
|
| IN_PROC_BROWSER_TEST_F(LauncherPerAppAppBrowserTestNoDefaultBrowser,
|
| - BrowserShortcutLauncherItemController) {
|
| - ChromeLauncherControllerPerApp* controller =
|
| - static_cast<ChromeLauncherControllerPerApp*>(launcher_->delegate());
|
| + BrowserShortcutLauncherItemTest) {
|
| LauncherItemController* item_controller =
|
| - controller->GetBrowserShortcutLauncherItemController();
|
| + controller_->GetBrowserShortcutLauncherItemController();
|
|
|
| // Get the number of browsers.
|
| size_t running_browser = chrome::GetTotalBrowserCount();
|
|
|