Chromium Code Reviews| 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 801538a448ea1efd99fc80c858a48aa3210b15f5..ac14d264c0cd95f3c8c4c2b1f66e1bc24aeb178a 100644 |
| --- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc |
| +++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_browsertest.cc |
| @@ -63,7 +63,8 @@ class LauncherPlatformAppBrowserTest |
| virtual void RunTestOnMainThreadLoop() OVERRIDE { |
| launcher_ = ash::Launcher::ForPrimaryDisplay(); |
| - controller_ = static_cast<ChromeLauncherController*>(launcher_->delegate()); |
| + controller_ = ChromeLauncherController::instance(); |
| + DCHECK(controller_); |
| return extensions::PlatformAppBrowserTest::RunTestOnMainThreadLoop(); |
| } |
| @@ -106,6 +107,8 @@ class LauncherAppBrowserTest : public ExtensionBrowserTest { |
| launcher_ = ash::Launcher::ForPrimaryDisplay(); |
| model_ = |
| ash::test::ShellTestApi(ash::Shell::GetInstance()).launcher_model(); |
| + controller_ = ChromeLauncherController::instance(); |
| + DCHECK(controller_); |
|
Mr4D (OOO till 08-26)
2013/08/13 18:18:24
Isn't there a DCHECK already in the instance funct
simonhong_
2013/08/13 19:54:56
Yes, it is already checked.
Removed.
|
| return ExtensionBrowserTest::RunTestOnMainThreadLoop(); |
| } |
| @@ -142,12 +145,10 @@ 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( |
| + ash::LauncherID shortcut_id = controller_->CreateAppShortcutLauncherItem( |
| app_id, item_count); |
| - controller->PersistPinnedState(); |
| + controller_->PersistPinnedState(); |
| EXPECT_EQ(++item_count, model_->item_count()); |
| ash::LauncherItem item = *model_->ItemByID(shortcut_id); |
| EXPECT_EQ(ash::TYPE_APP_SHORTCUT, item.type); |
| @@ -155,14 +156,13 @@ class LauncherAppBrowserTest : public ExtensionBrowserTest { |
| } |
| 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_; |
| }; |
| // Test that we can launch a platform app and get a running item. |
| @@ -566,7 +566,7 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, 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 |
| @@ -605,9 +605,9 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, 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()); |
| } |
| @@ -618,9 +618,9 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, 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()); |
| } |
| @@ -736,8 +736,6 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, MultipleOwnedTabs) { |
| } |
| 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"); |
| @@ -746,7 +744,7 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, 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( |
| @@ -776,12 +774,10 @@ IN_PROC_BROWSER_TEST_F(LauncherAppBrowserTest, RefocusFilter) { |
| } |
| 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. |
| @@ -828,9 +824,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()); |