OLD | NEW |
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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 TabToStringMap tab_id_map_; | 244 TabToStringMap tab_id_map_; |
245 | 245 |
246 DISALLOW_COPY_AND_ASSIGN(TestLauncherControllerHelper); | 246 DISALLOW_COPY_AND_ASSIGN(TestLauncherControllerHelper); |
247 }; | 247 }; |
248 | 248 |
249 // Test implementation of a V2 app launcher item controller. | 249 // Test implementation of a V2 app launcher item controller. |
250 class TestV2AppLauncherItemController : public LauncherItemController { | 250 class TestV2AppLauncherItemController : public LauncherItemController { |
251 public: | 251 public: |
252 TestV2AppLauncherItemController(const std::string& app_id, | 252 TestV2AppLauncherItemController(const std::string& app_id, |
253 ChromeLauncherController* controller) | 253 ChromeLauncherController* controller) |
254 : LauncherItemController(LauncherItemController::TYPE_APP, | 254 : LauncherItemController(app_id, "", controller) {} |
255 app_id, | |
256 "", | |
257 controller) {} | |
258 | 255 |
259 ~TestV2AppLauncherItemController() override {} | 256 ~TestV2AppLauncherItemController() override {} |
260 | 257 |
261 // Override for LauncherItemController: | 258 // Override for LauncherItemController: |
262 bool IsVisible() const override { return true; } | 259 bool IsVisible() const override { return true; } |
263 void Launch(ash::LaunchSource source, int event_flags) override {} | 260 void Launch(ash::LaunchSource source, int event_flags) override {} |
264 ash::ShelfItemDelegate::PerformedAction Activate( | 261 ash::ShelfItemDelegate::PerformedAction Activate( |
265 ash::LaunchSource source) override { | 262 ash::LaunchSource source) override { |
266 return kExistingWindowActivated; | 263 return kExistingWindowActivated; |
267 } | 264 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 ash::ShelfID id = | 412 ash::ShelfID id = |
416 launcher_controller_->CreateAppShortcutLauncherItemWithType( | 413 launcher_controller_->CreateAppShortcutLauncherItemWithType( |
417 ash::launcher::AppLauncherId(app_id), model_->item_count(), | 414 ash::launcher::AppLauncherId(app_id), model_->item_count(), |
418 ash::TYPE_APP); | 415 ash::TYPE_APP); |
419 DCHECK(id); | 416 DCHECK(id); |
420 // Change the created launcher controller into a V2 app controller. | 417 // Change the created launcher controller into a V2 app controller. |
421 test_controller_ = new TestV2AppLauncherItemController(app_id, | 418 test_controller_ = new TestV2AppLauncherItemController(app_id, |
422 launcher_controller_.get()); | 419 launcher_controller_.get()); |
423 launcher_controller_->SetItemController(id, test_controller_); | 420 launcher_controller_->SetItemController(id, test_controller_); |
424 DCHECK(launcher_controller_->IsPlatformApp(id)); | 421 DCHECK(launcher_controller_->IsPlatformApp(id)); |
| 422 launcher_controller_->SetItemStatus(id, ash::STATUS_RUNNING); |
425 } | 423 } |
426 | 424 |
427 // Sets the stage for a multi user test. | 425 // Sets the stage for a multi user test. |
428 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a, | 426 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a, |
429 syncer::SyncChangeList* user_b) { | 427 syncer::SyncChangeList* user_b) { |
430 InitLauncherController(); | 428 InitLauncherController(); |
431 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); | 429 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); |
432 | 430 |
433 // Set an empty pinned pref to begin with. | 431 // Set an empty pinned pref to begin with. |
434 syncer::SyncChangeList sync_list; | 432 syncer::SyncChangeList sync_list; |
(...skipping 3083 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3518 // app_icon_loader1 and app_icon_loader2 are owned by | 3516 // app_icon_loader1 and app_icon_loader2 are owned by |
3519 // ChromeLauncherControllerImpl. | 3517 // ChromeLauncherControllerImpl. |
3520 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); | 3518 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); |
3521 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); | 3519 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); |
3522 app_icon_loader1->AddSupportedApp(app_id1); | 3520 app_icon_loader1->AddSupportedApp(app_id1); |
3523 app_icon_loader2->AddSupportedApp(app_id2); | 3521 app_icon_loader2->AddSupportedApp(app_id2); |
3524 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), | 3522 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), |
3525 std::unique_ptr<AppIconLoader>(app_icon_loader2)); | 3523 std::unique_ptr<AppIconLoader>(app_icon_loader2)); |
3526 | 3524 |
3527 AppWindowLauncherItemController* app_controller3 = | 3525 AppWindowLauncherItemController* app_controller3 = |
3528 new ExtensionAppWindowLauncherItemController( | 3526 new ExtensionAppWindowLauncherItemController(app_id3, "id", |
3529 LauncherItemController::TYPE_APP, app_id3, "id", | 3527 launcher_controller_.get()); |
3530 launcher_controller_.get()); | |
3531 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( | 3528 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( |
3532 app_controller3, app_id3, ash::STATUS_RUNNING); | 3529 app_controller3, app_id3, ash::STATUS_RUNNING); |
3533 EXPECT_EQ(0, app_icon_loader1->fetch_count()); | 3530 EXPECT_EQ(0, app_icon_loader1->fetch_count()); |
3534 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3531 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
3535 EXPECT_EQ(0, app_icon_loader2->fetch_count()); | 3532 EXPECT_EQ(0, app_icon_loader2->fetch_count()); |
3536 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3533 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
3537 | 3534 |
3538 AppWindowLauncherItemController* app_controller2 = | 3535 AppWindowLauncherItemController* app_controller2 = |
3539 new ExtensionAppWindowLauncherItemController( | 3536 new ExtensionAppWindowLauncherItemController(app_id2, "id", |
3540 LauncherItemController::TYPE_APP, app_id2, "id", | 3537 launcher_controller_.get()); |
3541 launcher_controller_.get()); | |
3542 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem( | 3538 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem( |
3543 app_controller2, app_id2, ash::STATUS_RUNNING); | 3539 app_controller2, app_id2, ash::STATUS_RUNNING); |
3544 EXPECT_EQ(0, app_icon_loader1->fetch_count()); | 3540 EXPECT_EQ(0, app_icon_loader1->fetch_count()); |
3545 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3541 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
3546 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3542 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
3547 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3543 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
3548 | 3544 |
3549 AppWindowLauncherItemController* app_controller1 = | 3545 AppWindowLauncherItemController* app_controller1 = |
3550 new ExtensionAppWindowLauncherItemController( | 3546 new ExtensionAppWindowLauncherItemController(app_id1, "id", |
3551 LauncherItemController::TYPE_APP, app_id1, "id", | 3547 launcher_controller_.get()); |
3552 launcher_controller_.get()); | |
3553 | 3548 |
3554 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem( | 3549 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem( |
3555 app_controller1, app_id1, ash::STATUS_RUNNING); | 3550 app_controller1, app_id1, ash::STATUS_RUNNING); |
3556 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3551 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
3557 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3552 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
3558 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3553 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
3559 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3554 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
3560 | 3555 |
3561 launcher_controller_->CloseLauncherItem(shelfId1); | 3556 launcher_controller_->CloseLauncherItem(shelfId1); |
3562 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3557 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4076 | 4071 |
4077 // Pinned state should not change. | 4072 // Pinned state should not change. |
4078 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 4073 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
4079 launcher_controller_->UnpinAppWithID(extension2_->id()); | 4074 launcher_controller_->UnpinAppWithID(extension2_->id()); |
4080 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); | 4075 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); |
4081 | 4076 |
4082 // Resume syncing and sync information overrides local copy. | 4077 // Resume syncing and sync information overrides local copy. |
4083 StartAppSyncService(copy_sync_list); | 4078 StartAppSyncService(copy_sync_list); |
4084 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 4079 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
4085 } | 4080 } |
OLD | NEW |