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

Side by Side Diff: chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl_unittest.cc

Issue 2545923004: Remove LauncherItemController::type; use ShelfItems::type. (Closed)
Patch Set: Update tests; fix test item running status. Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <map> 10 #include <map>
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 TabToStringMap tab_id_map_; 243 TabToStringMap tab_id_map_;
244 244
245 DISALLOW_COPY_AND_ASSIGN(TestLauncherControllerHelper); 245 DISALLOW_COPY_AND_ASSIGN(TestLauncherControllerHelper);
246 }; 246 };
247 247
248 // Test implementation of a V2 app launcher item controller. 248 // Test implementation of a V2 app launcher item controller.
249 class TestV2AppLauncherItemController : public LauncherItemController { 249 class TestV2AppLauncherItemController : public LauncherItemController {
250 public: 250 public:
251 TestV2AppLauncherItemController(const std::string& app_id, 251 TestV2AppLauncherItemController(const std::string& app_id,
252 ChromeLauncherController* controller) 252 ChromeLauncherController* controller)
253 : LauncherItemController(LauncherItemController::TYPE_APP, 253 : LauncherItemController(app_id, "", controller) {}
254 app_id,
255 "",
256 controller) {}
257 254
258 ~TestV2AppLauncherItemController() override {} 255 ~TestV2AppLauncherItemController() override {}
259 256
260 // Override for LauncherItemController: 257 // Override for LauncherItemController:
261 bool IsVisible() const override { return true; } 258 bool IsVisible() const override { return true; }
262 void Launch(ash::LaunchSource source, int event_flags) override {} 259 void Launch(ash::LaunchSource source, int event_flags) override {}
263 ash::ShelfItemDelegate::PerformedAction Activate( 260 ash::ShelfItemDelegate::PerformedAction Activate(
264 ash::LaunchSource source) override { 261 ash::LaunchSource source) override {
265 return kExistingWindowActivated; 262 return kExistingWindowActivated;
266 } 263 }
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 ash::ShelfID id = 411 ash::ShelfID id =
415 launcher_controller_->CreateAppShortcutLauncherItemWithType( 412 launcher_controller_->CreateAppShortcutLauncherItemWithType(
416 ash::launcher::AppLauncherId(app_id), model_->item_count(), 413 ash::launcher::AppLauncherId(app_id), model_->item_count(),
417 ash::TYPE_APP); 414 ash::TYPE_APP);
418 DCHECK(id); 415 DCHECK(id);
419 // Change the created launcher controller into a V2 app controller. 416 // Change the created launcher controller into a V2 app controller.
420 test_controller_ = new TestV2AppLauncherItemController(app_id, 417 test_controller_ = new TestV2AppLauncherItemController(app_id,
421 launcher_controller_.get()); 418 launcher_controller_.get());
422 launcher_controller_->SetItemController(id, test_controller_); 419 launcher_controller_->SetItemController(id, test_controller_);
423 DCHECK(launcher_controller_->IsPlatformApp(id)); 420 DCHECK(launcher_controller_->IsPlatformApp(id));
421 launcher_controller_->SetItemStatus(id, ash::STATUS_RUNNING);
424 } 422 }
425 423
426 // Sets the stage for a multi user test. 424 // Sets the stage for a multi user test.
427 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a, 425 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a,
428 syncer::SyncChangeList* user_b) { 426 syncer::SyncChangeList* user_b) {
429 InitLauncherController(); 427 InitLauncherController();
430 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); 428 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus());
431 429
432 // Set an empty pinned pref to begin with. 430 // Set an empty pinned pref to begin with.
433 syncer::SyncChangeList sync_list; 431 syncer::SyncChangeList sync_list;
(...skipping 3074 matching lines...) Expand 10 before | Expand all | Expand 10 after
3508 // app_icon_loader1 and app_icon_loader2 are owned by 3506 // app_icon_loader1 and app_icon_loader2 are owned by
3509 // ChromeLauncherControllerImpl. 3507 // ChromeLauncherControllerImpl.
3510 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); 3508 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl();
3511 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); 3509 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl();
3512 app_icon_loader1->AddSupportedApp(app_id1); 3510 app_icon_loader1->AddSupportedApp(app_id1);
3513 app_icon_loader2->AddSupportedApp(app_id2); 3511 app_icon_loader2->AddSupportedApp(app_id2);
3514 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), 3512 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1),
3515 std::unique_ptr<AppIconLoader>(app_icon_loader2)); 3513 std::unique_ptr<AppIconLoader>(app_icon_loader2));
3516 3514
3517 AppWindowLauncherItemController* app_controller3 = 3515 AppWindowLauncherItemController* app_controller3 =
3518 new ExtensionAppWindowLauncherItemController( 3516 new ExtensionAppWindowLauncherItemController(app_id3, "id",
3519 LauncherItemController::TYPE_APP, app_id3, "id", 3517 launcher_controller_.get());
3520 launcher_controller_.get());
3521 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( 3518 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem(
3522 app_controller3, app_id3, ash::STATUS_RUNNING); 3519 app_controller3, app_id3, ash::STATUS_RUNNING);
3523 EXPECT_EQ(0, app_icon_loader1->fetch_count()); 3520 EXPECT_EQ(0, app_icon_loader1->fetch_count());
3524 EXPECT_EQ(0, app_icon_loader1->clear_count()); 3521 EXPECT_EQ(0, app_icon_loader1->clear_count());
3525 EXPECT_EQ(0, app_icon_loader2->fetch_count()); 3522 EXPECT_EQ(0, app_icon_loader2->fetch_count());
3526 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3523 EXPECT_EQ(0, app_icon_loader2->clear_count());
3527 3524
3528 AppWindowLauncherItemController* app_controller2 = 3525 AppWindowLauncherItemController* app_controller2 =
3529 new ExtensionAppWindowLauncherItemController( 3526 new ExtensionAppWindowLauncherItemController(app_id2, "id",
3530 LauncherItemController::TYPE_APP, app_id2, "id", 3527 launcher_controller_.get());
3531 launcher_controller_.get());
3532 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem( 3528 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem(
3533 app_controller2, app_id2, ash::STATUS_RUNNING); 3529 app_controller2, app_id2, ash::STATUS_RUNNING);
3534 EXPECT_EQ(0, app_icon_loader1->fetch_count()); 3530 EXPECT_EQ(0, app_icon_loader1->fetch_count());
3535 EXPECT_EQ(0, app_icon_loader1->clear_count()); 3531 EXPECT_EQ(0, app_icon_loader1->clear_count());
3536 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3532 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3537 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3533 EXPECT_EQ(0, app_icon_loader2->clear_count());
3538 3534
3539 AppWindowLauncherItemController* app_controller1 = 3535 AppWindowLauncherItemController* app_controller1 =
3540 new ExtensionAppWindowLauncherItemController( 3536 new ExtensionAppWindowLauncherItemController(app_id1, "id",
3541 LauncherItemController::TYPE_APP, app_id1, "id", 3537 launcher_controller_.get());
3542 launcher_controller_.get());
3543 3538
3544 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem( 3539 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem(
3545 app_controller1, app_id1, ash::STATUS_RUNNING); 3540 app_controller1, app_id1, ash::STATUS_RUNNING);
3546 EXPECT_EQ(1, app_icon_loader1->fetch_count()); 3541 EXPECT_EQ(1, app_icon_loader1->fetch_count());
3547 EXPECT_EQ(0, app_icon_loader1->clear_count()); 3542 EXPECT_EQ(0, app_icon_loader1->clear_count());
3548 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3543 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3549 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3544 EXPECT_EQ(0, app_icon_loader2->clear_count());
3550 3545
3551 launcher_controller_->CloseLauncherItem(shelfId1); 3546 launcher_controller_->CloseLauncherItem(shelfId1);
3552 EXPECT_EQ(1, app_icon_loader1->fetch_count()); 3547 EXPECT_EQ(1, app_icon_loader1->fetch_count());
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
4066 4061
4067 // Pinned state should not change. 4062 // Pinned state should not change.
4068 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 4063 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
4069 launcher_controller_->UnpinAppWithID(extension2_->id()); 4064 launcher_controller_->UnpinAppWithID(extension2_->id());
4070 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); 4065 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus());
4071 4066
4072 // Resume syncing and sync information overrides local copy. 4067 // Resume syncing and sync information overrides local copy.
4073 StartAppSyncService(copy_sync_list); 4068 StartAppSyncService(copy_sync_list);
4074 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 4069 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
4075 } 4070 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698