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

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

Issue 2800263002: Revert of mash: Remove ChromeLauncherController's |id_to_item_controller_map_|. (Closed)
Patch Set: Created 3 years, 8 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_impl_unittest.cc
diff --git a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc
index af15a5061257e43f5c672be1ad4e875acd2f8134..cc29bfd0d18ebb1eb9d7e788b96a3275fa6a6454 100644
--- a/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc
+++ b/chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc
@@ -161,6 +161,9 @@
last_index_ = target_index;
}
+ void OnSetShelfItemDelegate(ash::ShelfID id,
+ ash::ShelfItemDelegate* item_delegate) override {}
+
void clear_counts() {
added_ = 0;
removed_ = 0;
@@ -713,13 +716,18 @@
app_service_->ProcessSyncChanges(FROM_HERE, sync_list);
}
- // Gets the IDs of the currently pinned app items.
- void GetPinnedAppIds(ChromeLauncherControllerImpl* controller,
- std::vector<std::string>* app_ids) {
- app_ids->clear();
- for (const auto& item : model_->items()) {
- if (item.type == ash::TYPE_PINNED_APP)
- app_ids->push_back(item.app_launch_id.app_id());
+ // Gets the currently configured app launchers from the controller.
+ void GetAppLaunchers(ChromeLauncherControllerImpl* controller,
+ std::vector<std::string>* launchers) {
+ launchers->clear();
+ for (ash::ShelfItems::const_iterator iter(model_->items().begin());
+ iter != model_->items().end(); ++iter) {
+ ChromeLauncherControllerImpl::IDToItemControllerMap::const_iterator entry(
+ controller->id_to_item_controller_map_.find(iter->id));
+ if (iter->type == ash::TYPE_PINNED_APP &&
+ entry != controller->id_to_item_controller_map_.end()) {
+ launchers->push_back(entry->second->app_id());
+ }
}
}
@@ -1866,7 +1874,7 @@
// We activated arc_app_id1 twice but expect one close for item controller
// stops launching request.
ash::ShelfItemDelegate* item_delegate =
- model_->GetShelfItemDelegate(shelf_id_app_1);
+ launcher_controller_->GetShelfItemDelegate(shelf_id_app_1);
ASSERT_NE(nullptr, item_delegate);
item_delegate->Close();
base::RunLoop().RunUntilIdle();
@@ -1930,7 +1938,7 @@
// Play Store app is ARC app that might be represented by native Chrome
// platform app.
- model_->SetShelfItemDelegate(
+ launcher_controller_->SetShelfItemDelegate(
shelf_id, base::MakeUnique<ExtensionAppWindowLauncherItemController>(
ash::AppLaunchId(app_id)));
launcher_controller_->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
@@ -2408,8 +2416,9 @@
multi_user_util::GetAccountIdFromProfile(profile());
// Create a browser window with a native window for the current user.
+ Browser::CreateParams params(profile(), true);
std::unique_ptr<Browser> browser(
- CreateBrowserWithTestWindowForProfile(profile()));
+ chrome::CreateBrowserWithAuraTestWindowForParams(nullptr, &params));
BrowserWindow* browser_window = browser->window();
aura::Window* window = browser_window->GetNativeWindow();
manager->SetWindowOwner(window, current_user);
@@ -2685,10 +2694,10 @@
InsertAddPinChange(&sync_list, 10, extension_misc::kChromeAppId);
SendPinChanges(sync_list, true);
- std::vector<std::string> expected_pinned_apps;
- std::vector<std::string> actual_pinned_apps;
- GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
- EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
+ std::vector<std::string> expected_launchers;
+ std::vector<std::string> actual_launchers;
+ GetAppLaunchers(launcher_controller_, &actual_launchers);
+ EXPECT_EQ(expected_launchers, actual_launchers);
// Unavailable extensions don't create launcher items.
sync_list.clear();
@@ -2697,49 +2706,48 @@
InsertAddPinChange(&sync_list, 3, extension4_->id());
SendPinChanges(sync_list, false);
- expected_pinned_apps.push_back(extension2_->id());
- expected_pinned_apps.push_back(extension4_->id());
- GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
- EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
+ expected_launchers.push_back(extension2_->id());
+ expected_launchers.push_back(extension4_->id());
+ GetAppLaunchers(launcher_controller_, &actual_launchers);
+ EXPECT_EQ(expected_launchers, actual_launchers);
sync_list.clear();
InsertAddPinChange(&sync_list, 2, extension3_->id());
SendPinChanges(sync_list, false);
- expected_pinned_apps.insert(expected_pinned_apps.begin() + 1,
- extension3_->id());
- GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
- EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
+ expected_launchers.insert(expected_launchers.begin() + 1, extension3_->id());
+ GetAppLaunchers(launcher_controller_, &actual_launchers);
+ EXPECT_EQ(expected_launchers, actual_launchers);
sync_list.clear();
InsertUpdatePinChange(&sync_list, 0, extension4_->id());
InsertUpdatePinChange(&sync_list, 1, extension3_->id());
InsertUpdatePinChange(&sync_list, 2, extension2_->id());
SendPinChanges(sync_list, false);
- std::reverse(expected_pinned_apps.begin(), expected_pinned_apps.end());
- GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
- EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
+ std::reverse(expected_launchers.begin(), expected_launchers.end());
+ GetAppLaunchers(launcher_controller_, &actual_launchers);
+ EXPECT_EQ(expected_launchers, actual_launchers);
// Sending legacy sync change without pin info should not affect pin model.
sync_list.clear();
InsertLegacyPinChange(&sync_list, extension4_->id());
SendPinChanges(sync_list, false);
- GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
- EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
+ GetAppLaunchers(launcher_controller_, &actual_launchers);
+ EXPECT_EQ(expected_launchers, actual_launchers);
sync_list.clear();
InsertRemovePinChange(&sync_list, extension4_->id());
SendPinChanges(sync_list, false);
- expected_pinned_apps.erase(expected_pinned_apps.begin());
- GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
- EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
+ expected_launchers.erase(expected_launchers.begin());
+ GetAppLaunchers(launcher_controller_, &actual_launchers);
+ EXPECT_EQ(expected_launchers, actual_launchers);
sync_list.clear();
InsertRemovePinChange(&sync_list, extension3_->id());
InsertRemovePinChange(&sync_list, extension2_->id());
SendPinChanges(sync_list, false);
- expected_pinned_apps.clear();
- GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
- EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
+ expected_launchers.clear();
+ GetAppLaunchers(launcher_controller_, &actual_launchers);
+ EXPECT_EQ(expected_launchers, actual_launchers);
}
TEST_F(ChromeLauncherControllerImplTest, ImportLegacyPin) {
@@ -2801,20 +2809,19 @@
InsertAddPinChange(&sync_list, 2, extension3_->id());
SendPinChanges(sync_list, true);
- std::vector<std::string> expected_pinned_apps;
- expected_pinned_apps.push_back(extension1_->id());
- expected_pinned_apps.push_back(extension3_->id());
- std::vector<std::string> actual_pinned_apps;
-
- GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
- EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
+ std::vector<std::string> expected_launchers;
+ expected_launchers.push_back(extension1_->id());
+ expected_launchers.push_back(extension3_->id());
+ std::vector<std::string> actual_launchers;
+
+ GetAppLaunchers(launcher_controller_, &actual_launchers);
+ EXPECT_EQ(expected_launchers, actual_launchers);
// Install |extension2| and verify it shows up between the other two.
extension_service_->AddExtension(extension2_.get());
- expected_pinned_apps.insert(expected_pinned_apps.begin() + 1,
- extension2_->id());
- GetPinnedAppIds(launcher_controller_, &actual_pinned_apps);
- EXPECT_EQ(expected_pinned_apps, actual_pinned_apps);
+ expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id());
+ GetAppLaunchers(launcher_controller_, &actual_launchers);
+ EXPECT_EQ(expected_launchers, actual_launchers);
}
// Ensure |controller| creates the expected menu items for the given shelf item.
@@ -3274,7 +3281,7 @@
base::string16 two_menu_items[] = {title1, title2};
CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items);
ash::ShelfItemDelegate* item_delegate =
- model_->GetShelfItemDelegate(gmail_id);
+ launcher_controller_->GetShelfItemDelegate(gmail_id);
ASSERT_TRUE(item_delegate);
EXPECT_EQ(1, browser()->tab_strip_model()->active_index());
// Execute the second item in the menu, after the title and two separators,
@@ -3323,7 +3330,7 @@
CheckAppMenu(launcher_controller_, item_gmail, 2, two_menu_items);
ash::ShelfItemDelegate* item_delegate =
- model_->GetShelfItemDelegate(gmail_id);
+ launcher_controller_->GetShelfItemDelegate(gmail_id);
ASSERT_TRUE(item_delegate);
int tabs = browser()->tab_strip_model()->count();
// Activate the proper tab through the menu item.
@@ -3708,7 +3715,7 @@
const ash::ShelfID shelf_id =
launcher_controller_->GetShelfIDForAppID(app_id);
ash::ShelfItemDelegate* item_delegate =
- model_->GetShelfItemDelegate(shelf_id);
+ launcher_controller_->GetShelfItemDelegate(shelf_id);
ASSERT_TRUE(item_delegate);
// Selecting the item will show its application menu. It does not change the
@@ -4054,8 +4061,9 @@
arc::kPlayStoreAppId));
// Simulate click. This should schedule Play Store for deferred launch.
- ash::ShelfItemDelegate* item_delegate = model_->GetShelfItemDelegate(
- launcher_controller_->GetShelfIDForAppID(arc::kPlayStoreAppId));
+ ash::ShelfItemDelegate* item_delegate =
+ launcher_controller_->GetShelfItemDelegate(
+ launcher_controller_->GetShelfIDForAppID(arc::kPlayStoreAppId));
EXPECT_TRUE(item_delegate);
SelectItem(item_delegate);
EXPECT_TRUE(launcher_controller_->IsAppPinned(arc::kPlayStoreAppId));

Powered by Google App Engine
This is Rietveld 408576698