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 }; | 244 }; |
245 | 245 |
246 // Test implementation of a V2 app launcher item controller. | 246 // Test implementation of a V2 app launcher item controller. |
247 class TestV2AppLauncherItemController : public LauncherItemController { | 247 class TestV2AppLauncherItemController : public LauncherItemController { |
248 public: | 248 public: |
249 TestV2AppLauncherItemController(const std::string& app_id, | 249 TestV2AppLauncherItemController(const std::string& app_id, |
250 ChromeLauncherController* controller) | 250 ChromeLauncherController* controller) |
251 : LauncherItemController(LauncherItemController::TYPE_APP, | 251 : LauncherItemController(LauncherItemController::TYPE_APP, |
252 app_id, | 252 app_id, |
253 "", | 253 "", |
| 254 "", |
254 controller) {} | 255 controller) {} |
255 | 256 |
256 ~TestV2AppLauncherItemController() override {} | 257 ~TestV2AppLauncherItemController() override {} |
257 | 258 |
258 // Override for LauncherItemController: | 259 // Override for LauncherItemController: |
259 bool IsVisible() const override { return true; } | 260 bool IsVisible() const override { return true; } |
260 void Launch(ash::LaunchSource source, int event_flags) override {} | 261 void Launch(ash::LaunchSource source, int event_flags) override {} |
261 ash::ShelfItemDelegate::PerformedAction Activate( | 262 ash::ShelfItemDelegate::PerformedAction Activate( |
262 ash::LaunchSource source) override { | 263 ash::LaunchSource source) override { |
263 return kExistingWindowActivated; | 264 return kExistingWindowActivated; |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
403 arc_support_host_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 404 arc_support_host_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
404 manifest, Extension::NO_FLAGS, | 405 manifest, Extension::NO_FLAGS, |
405 ArcSupportHost::kHostAppId, &error); | 406 ArcSupportHost::kHostAppId, &error); |
406 } | 407 } |
407 | 408 |
408 // Creates a running V2 app (not pinned) of type |app_id|. | 409 // Creates a running V2 app (not pinned) of type |app_id|. |
409 virtual void CreateRunningV2App(const std::string& app_id) { | 410 virtual void CreateRunningV2App(const std::string& app_id) { |
410 DCHECK(!test_controller_); | 411 DCHECK(!test_controller_); |
411 ash::ShelfID id = | 412 ash::ShelfID id = |
412 launcher_controller_->CreateAppShortcutLauncherItemWithType( | 413 launcher_controller_->CreateAppShortcutLauncherItemWithType( |
413 ash::launcher::AppLauncherId(app_id), model_->item_count(), | 414 ash::launcher::AppLauncherId(app_id), "", model_->item_count(), |
414 ash::TYPE_PLATFORM_APP); | 415 ash::TYPE_PLATFORM_APP); |
415 DCHECK(id); | 416 DCHECK(id); |
416 // Change the created launcher controller into a V2 app controller. | 417 // Change the created launcher controller into a V2 app controller. |
417 test_controller_ = new TestV2AppLauncherItemController(app_id, | 418 test_controller_ = new TestV2AppLauncherItemController(app_id, |
418 launcher_controller_.get()); | 419 launcher_controller_.get()); |
419 launcher_controller_->SetItemController(id, test_controller_); | 420 launcher_controller_->SetItemController(id, test_controller_); |
420 } | 421 } |
421 | 422 |
422 // Sets the stage for a multi user test. | 423 // Sets the stage for a multi user test. |
423 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a, | 424 virtual void SetUpMultiUserScenario(syncer::SyncChangeList* user_a, |
(...skipping 3054 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3478 // ChromeLauncherControllerImpl. | 3479 // ChromeLauncherControllerImpl. |
3479 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); | 3480 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); |
3480 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); | 3481 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); |
3481 app_icon_loader1->AddSupportedApp(app_id1); | 3482 app_icon_loader1->AddSupportedApp(app_id1); |
3482 app_icon_loader2->AddSupportedApp(app_id2); | 3483 app_icon_loader2->AddSupportedApp(app_id2); |
3483 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), | 3484 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), |
3484 std::unique_ptr<AppIconLoader>(app_icon_loader2)); | 3485 std::unique_ptr<AppIconLoader>(app_icon_loader2)); |
3485 | 3486 |
3486 AppWindowLauncherItemController* app_controller3 = | 3487 AppWindowLauncherItemController* app_controller3 = |
3487 new ExtensionAppWindowLauncherItemController( | 3488 new ExtensionAppWindowLauncherItemController( |
3488 LauncherItemController::TYPE_APP, app_id3, "id", | 3489 LauncherItemController::TYPE_APP, app_id3, "id", "", |
3489 launcher_controller_.get()); | 3490 launcher_controller_.get()); |
3490 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( | 3491 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( |
3491 app_controller3, app_id3, ash::STATUS_RUNNING); | 3492 app_controller3, app_id3, ash::STATUS_RUNNING); |
3492 EXPECT_EQ(0, app_icon_loader1->fetch_count()); | 3493 EXPECT_EQ(0, app_icon_loader1->fetch_count()); |
3493 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3494 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
3494 EXPECT_EQ(0, app_icon_loader2->fetch_count()); | 3495 EXPECT_EQ(0, app_icon_loader2->fetch_count()); |
3495 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3496 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
3496 | 3497 |
3497 AppWindowLauncherItemController* app_controller2 = | 3498 AppWindowLauncherItemController* app_controller2 = |
3498 new ExtensionAppWindowLauncherItemController( | 3499 new ExtensionAppWindowLauncherItemController( |
3499 LauncherItemController::TYPE_APP, app_id2, "id", | 3500 LauncherItemController::TYPE_APP, app_id2, "id", "", |
3500 launcher_controller_.get()); | 3501 launcher_controller_.get()); |
3501 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem( | 3502 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem( |
3502 app_controller2, app_id2, ash::STATUS_RUNNING); | 3503 app_controller2, app_id2, ash::STATUS_RUNNING); |
3503 EXPECT_EQ(0, app_icon_loader1->fetch_count()); | 3504 EXPECT_EQ(0, app_icon_loader1->fetch_count()); |
3504 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3505 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
3505 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3506 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
3506 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3507 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
3507 | 3508 |
3508 AppWindowLauncherItemController* app_controller1 = | 3509 AppWindowLauncherItemController* app_controller1 = |
3509 new ExtensionAppWindowLauncherItemController( | 3510 new ExtensionAppWindowLauncherItemController( |
3510 LauncherItemController::TYPE_APP, app_id1, "id", | 3511 LauncherItemController::TYPE_APP, app_id1, "id", "", |
3511 launcher_controller_.get()); | 3512 launcher_controller_.get()); |
3512 | 3513 |
3513 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem( | 3514 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem( |
3514 app_controller1, app_id1, ash::STATUS_RUNNING); | 3515 app_controller1, app_id1, ash::STATUS_RUNNING); |
3515 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3516 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
3516 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3517 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
3517 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3518 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
3518 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3519 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
3519 | 3520 |
3520 launcher_controller_->CloseLauncherItem(shelfId1); | 3521 launcher_controller_->CloseLauncherItem(shelfId1); |
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4030 | 4031 |
4031 // Pinned state should not change. | 4032 // Pinned state should not change. |
4032 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 4033 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
4033 launcher_controller_->UnpinAppWithID(extension2_->id()); | 4034 launcher_controller_->UnpinAppWithID(extension2_->id()); |
4034 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); | 4035 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); |
4035 | 4036 |
4036 // Resume syncing and sync information overrides local copy. | 4037 // Resume syncing and sync information overrides local copy. |
4037 StartAppSyncService(copy_sync_list); | 4038 StartAppSyncService(copy_sync_list); |
4038 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | 4039 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); |
4039 } | 4040 } |
OLD | NEW |