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

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

Issue 23606016: Refactor LauncherItemController and LauncherItemDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix for LauncherTest and observing LauncherModel in DelegateManager Created 7 years, 3 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_unittest.cc
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc
index 8cf80760f19d8658b95a25ce4f19d2487981e58d..69cf1dd17b75ed505214416755e3cf7fea7c501d 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_unittest.cc
@@ -9,8 +9,10 @@
#include <vector>
#include "ash/ash_switches.h"
+#include "ash/launcher/launcher_item_delegate_manager.h"
#include "ash/launcher/launcher_model.h"
#include "ash/launcher/launcher_model_observer.h"
+#include "ash/shell.h"
#include "base/command_line.h"
#include "base/compiler_specific.h"
#include "base/files/file_path.h"
@@ -21,6 +23,7 @@
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/test_extension_system.h"
#include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
+#include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h"
#include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
#include "chrome/browser/ui/ash/launcher/shell_window_launcher_item_controller.h"
#include "chrome/browser/ui/browser.h"
@@ -1099,7 +1102,8 @@ bool CheckMenuCreation(ChromeLauncherController* controller,
}
scoped_ptr<ash::LauncherMenuModel> menu(
- controller->CreateApplicationMenu(item, 0));
+ new LauncherApplicationMenuItemModel(
+ controller->GetApplicationList(item, 0)));
// The first element in the menu is a spacing separator. On some systems
// (e.g. Windows) such things do not exist. As such we check the existence
// and adjust dynamically.
@@ -1263,7 +1267,8 @@ TEST_F(ChromeLauncherControllerTest, V1AppMenuExecution) {
// item is per definition already the active tab).
{
scoped_ptr<ash::LauncherMenuModel> menu(
- launcher_controller_->CreateApplicationMenu(item_gmail, 0));
+ new LauncherApplicationMenuItemModel(
+ launcher_controller_->GetApplicationList(item_gmail, 0)));
// The first element in the menu is a spacing separator. On some systems
// (e.g. Windows) such things do not exist. As such we check the existence
// and adjust dynamically.
@@ -1276,7 +1281,8 @@ TEST_F(ChromeLauncherControllerTest, V1AppMenuExecution) {
// Execute the first item.
{
scoped_ptr<ash::LauncherMenuModel> menu(
- launcher_controller_->CreateApplicationMenu(item_gmail, 0));
+ new LauncherApplicationMenuItemModel(
+ launcher_controller_->GetApplicationList(item_gmail, 0)));
int first_item =
(menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0;
menu->ActivatedAt(first_item + 2);
@@ -1337,11 +1343,14 @@ TEST_F(ChromeLauncherControllerTest, AppPanels) {
// Test adding an app panel
std::string app_id = extension1_->id();
- ShellWindowLauncherItemController app_panel_controller(
- LauncherItemController::TYPE_APP_PANEL, "id", app_id,
- launcher_controller_.get());
+ ShellWindowLauncherItemController* app_panel_controller =
+ new ShellWindowLauncherItemController(
+ LauncherItemController::TYPE_APP_PANEL,
+ "id",
+ app_id,
+ launcher_controller_.get());
ash::LauncherID launcher_id1 = launcher_controller_->CreateAppLauncherItem(
- &app_panel_controller, app_id, ash::STATUS_RUNNING);
+ app_panel_controller, app_id, ash::STATUS_RUNNING);
int panel_index = model_observer_->last_index();
EXPECT_EQ(2, model_observer_->added());
EXPECT_EQ(0, model_observer_->changed());
@@ -1352,7 +1361,7 @@ TEST_F(ChromeLauncherControllerTest, AppPanels) {
EXPECT_EQ(0, launcher_controller_->GetLauncherIDForAppID(app_id));
// Setting the app image image should not change the panel if it set its icon
- app_panel_controller.set_image_set_by_controller(true);
+ app_panel_controller->set_image_set_by_controller(true);
gfx::ImageSkia image;
launcher_controller_->SetAppImage(app_id, image);
EXPECT_EQ(0, model_observer_->changed());
@@ -1360,8 +1369,15 @@ TEST_F(ChromeLauncherControllerTest, AppPanels) {
// Add a second app panel and verify that it get the same index as the first
// one had, being added to the left of the existing panel.
+ ShellWindowLauncherItemController* app_panel_controller2 =
+ new ShellWindowLauncherItemController(
+ LauncherItemController::TYPE_APP_PANEL,
+ "id",
+ app_id,
+ launcher_controller_.get());
+
ash::LauncherID launcher_id2 = launcher_controller_->CreateAppLauncherItem(
- &app_panel_controller, app_id, ash::STATUS_RUNNING);
+ app_panel_controller2, app_id, ash::STATUS_RUNNING);
EXPECT_EQ(panel_index, model_observer_->last_index());
EXPECT_EQ(1, model_observer_->added());
model_observer_->clear_counts();
@@ -1369,6 +1385,11 @@ TEST_F(ChromeLauncherControllerTest, AppPanels) {
launcher_controller_->CloseLauncherItem(launcher_id2);
launcher_controller_->CloseLauncherItem(launcher_id1);
EXPECT_EQ(2, model_observer_->removed());
+
+ if (!ash::Shell::HasInstance()) {
+ delete app_panel_controller;
+ delete app_panel_controller2;
+ }
}
// Tests that the Gmail extension matches more then the app itself claims with
@@ -1466,6 +1487,13 @@ TEST_F(ChromeLauncherControllerTest, PersistLauncherItemPositions) {
launcher_controller_.reset();
model_.reset(new ash::LauncherModel);
+
+ // Clear already registered LauncherItemDelegate.
+ if (ash::Shell::HasInstance()) {
+ ash::Shell::GetInstance()->launcher_item_delegate_manager()->
+ UnregisterAllLauncherItemDelegateForTest();
+ }
+
launcher_controller_.reset(
ChromeLauncherController::CreateInstance(profile(), model_.get()));
app_tab_helper = new TestAppTabHelperImpl;
@@ -1509,6 +1537,13 @@ TEST_F(ChromeLauncherControllerTest, PersistPinned) {
launcher_controller_.reset();
model_.reset(new ash::LauncherModel);
+
+ // Clear already registered LauncherItemDelegate.
+ if (ash::Shell::HasInstance()) {
+ ash::Shell::GetInstance()->launcher_item_delegate_manager()->
+ UnregisterAllLauncherItemDelegateForTest();
+ }
+
launcher_controller_.reset(
ChromeLauncherController::CreateInstance(profile(), model_.get()));
app_tab_helper = new TestAppTabHelperImpl;

Powered by Google App Engine
This is Rietveld 408576698