| 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 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 254 DISALLOW_COPY_AND_ASSIGN(TestLauncherControllerHelper); | 254 DISALLOW_COPY_AND_ASSIGN(TestLauncherControllerHelper); |
| 255 }; | 255 }; |
| 256 | 256 |
| 257 // Test implementation of a V2 app launcher item controller. | 257 // Test implementation of a V2 app launcher item controller. |
| 258 class TestV2AppLauncherItemController : public LauncherItemController { | 258 class TestV2AppLauncherItemController : public LauncherItemController { |
| 259 public: | 259 public: |
| 260 TestV2AppLauncherItemController(const std::string& app_id, | 260 TestV2AppLauncherItemController(const std::string& app_id, |
| 261 ChromeLauncherController* controller) | 261 ChromeLauncherController* controller) |
| 262 : LauncherItemController(LauncherItemController::TYPE_APP, | 262 : LauncherItemController(LauncherItemController::TYPE_APP, |
| 263 app_id, | 263 app_id, |
| 264 controller) { | 264 "", |
| 265 } | 265 controller) {} |
| 266 | 266 |
| 267 ~TestV2AppLauncherItemController() override {} | 267 ~TestV2AppLauncherItemController() override {} |
| 268 | 268 |
| 269 // Override for LauncherItemController: | 269 // Override for LauncherItemController: |
| 270 bool IsOpen() const override { return true; } | 270 bool IsOpen() const override { return true; } |
| 271 bool IsVisible() const override { return true; } | 271 bool IsVisible() const override { return true; } |
| 272 void Launch(ash::LaunchSource source, int event_flags) override {} | 272 void Launch(ash::LaunchSource source, int event_flags) override {} |
| 273 ash::ShelfItemDelegate::PerformedAction Activate( | 273 ash::ShelfItemDelegate::PerformedAction Activate( |
| 274 ash::LaunchSource source) override { | 274 ash::LaunchSource source) override { |
| 275 return kExistingWindowActivated; | 275 return kExistingWindowActivated; |
| (...skipping 2927 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3203 | 3203 |
| 3204 const std::string app_id = extension1_->id(); | 3204 const std::string app_id = extension1_->id(); |
| 3205 // app_icon_loader is owned by ChromeLauncherControllerImpl. | 3205 // app_icon_loader is owned by ChromeLauncherControllerImpl. |
| 3206 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl(); | 3206 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl(); |
| 3207 app_icon_loader->AddSupportedApp(app_id); | 3207 app_icon_loader->AddSupportedApp(app_id); |
| 3208 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); | 3208 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); |
| 3209 | 3209 |
| 3210 // Test adding an app panel | 3210 // Test adding an app panel |
| 3211 AppWindowLauncherItemController* app_panel_controller = | 3211 AppWindowLauncherItemController* app_panel_controller = |
| 3212 new ExtensionAppWindowLauncherItemController( | 3212 new ExtensionAppWindowLauncherItemController( |
| 3213 LauncherItemController::TYPE_APP_PANEL, "id", app_id, | 3213 LauncherItemController::TYPE_APP_PANEL, app_id, "id", |
| 3214 launcher_controller_.get()); | 3214 launcher_controller_.get()); |
| 3215 ash::ShelfID shelf_id1 = launcher_controller_->CreateAppLauncherItem( | 3215 ash::ShelfID shelf_id1 = launcher_controller_->CreateAppLauncherItem( |
| 3216 app_panel_controller, app_id, ash::STATUS_RUNNING); | 3216 app_panel_controller, app_id, ash::STATUS_RUNNING); |
| 3217 int panel_index = model_observer_->last_index(); | 3217 int panel_index = model_observer_->last_index(); |
| 3218 EXPECT_EQ(3, model_observer_->added()); | 3218 EXPECT_EQ(3, model_observer_->added()); |
| 3219 EXPECT_EQ(1, model_observer_->changed()); | 3219 EXPECT_EQ(1, model_observer_->changed()); |
| 3220 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 3220 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 3221 model_observer_->clear_counts(); | 3221 model_observer_->clear_counts(); |
| 3222 | 3222 |
| 3223 // App panels should have a separate identifier than the app id | 3223 // App panels should have a separate identifier than the app id |
| 3224 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); | 3224 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3225 | 3225 |
| 3226 // Setting the app image image should not change the panel if it set its icon | 3226 // Setting the app image image should not change the panel if it set its icon |
| 3227 app_panel_controller->set_image_set_by_controller(true); | 3227 app_panel_controller->set_image_set_by_controller(true); |
| 3228 gfx::ImageSkia image; | 3228 gfx::ImageSkia image; |
| 3229 launcher_controller_->OnAppImageUpdated(app_id, image); | 3229 launcher_controller_->OnAppImageUpdated(app_id, image); |
| 3230 EXPECT_EQ(0, model_observer_->changed()); | 3230 EXPECT_EQ(0, model_observer_->changed()); |
| 3231 model_observer_->clear_counts(); | 3231 model_observer_->clear_counts(); |
| 3232 | 3232 |
| 3233 // Add a second app panel and verify that it get the same index as the first | 3233 // Add a second app panel and verify that it get the same index as the first |
| 3234 // one had, being added to the left of the existing panel. | 3234 // one had, being added to the left of the existing panel. |
| 3235 AppWindowLauncherItemController* app_panel_controller2 = | 3235 AppWindowLauncherItemController* app_panel_controller2 = |
| 3236 new ExtensionAppWindowLauncherItemController( | 3236 new ExtensionAppWindowLauncherItemController( |
| 3237 LauncherItemController::TYPE_APP_PANEL, "id", app_id, | 3237 LauncherItemController::TYPE_APP_PANEL, app_id, "id", |
| 3238 launcher_controller_.get()); | 3238 launcher_controller_.get()); |
| 3239 | 3239 |
| 3240 ash::ShelfID shelf_id2 = launcher_controller_->CreateAppLauncherItem( | 3240 ash::ShelfID shelf_id2 = launcher_controller_->CreateAppLauncherItem( |
| 3241 app_panel_controller2, app_id, ash::STATUS_RUNNING); | 3241 app_panel_controller2, app_id, ash::STATUS_RUNNING); |
| 3242 EXPECT_EQ(panel_index, model_observer_->last_index()); | 3242 EXPECT_EQ(panel_index, model_observer_->last_index()); |
| 3243 EXPECT_EQ(1, model_observer_->added()); | 3243 EXPECT_EQ(1, model_observer_->added()); |
| 3244 model_observer_->clear_counts(); | 3244 model_observer_->clear_counts(); |
| 3245 | 3245 |
| 3246 launcher_controller_->CloseLauncherItem(shelf_id2); | 3246 launcher_controller_->CloseLauncherItem(shelf_id2); |
| 3247 launcher_controller_->CloseLauncherItem(shelf_id1); | 3247 launcher_controller_->CloseLauncherItem(shelf_id1); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3422 // ChromeLauncherControllerImpl. | 3422 // ChromeLauncherControllerImpl. |
| 3423 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); | 3423 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); |
| 3424 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); | 3424 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); |
| 3425 app_icon_loader1->AddSupportedApp(app_id1); | 3425 app_icon_loader1->AddSupportedApp(app_id1); |
| 3426 app_icon_loader2->AddSupportedApp(app_id2); | 3426 app_icon_loader2->AddSupportedApp(app_id2); |
| 3427 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), | 3427 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), |
| 3428 std::unique_ptr<AppIconLoader>(app_icon_loader2)); | 3428 std::unique_ptr<AppIconLoader>(app_icon_loader2)); |
| 3429 | 3429 |
| 3430 AppWindowLauncherItemController* app_panel_controller3 = | 3430 AppWindowLauncherItemController* app_panel_controller3 = |
| 3431 new ExtensionAppWindowLauncherItemController( | 3431 new ExtensionAppWindowLauncherItemController( |
| 3432 LauncherItemController::TYPE_APP_PANEL, "id", app_id3, | 3432 LauncherItemController::TYPE_APP_PANEL, app_id3, "id", |
| 3433 launcher_controller_.get()); | 3433 launcher_controller_.get()); |
| 3434 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( | 3434 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( |
| 3435 app_panel_controller3, app_id3, ash::STATUS_RUNNING); | 3435 app_panel_controller3, app_id3, ash::STATUS_RUNNING); |
| 3436 EXPECT_EQ(0, app_icon_loader1->fetch_count()); | 3436 EXPECT_EQ(0, app_icon_loader1->fetch_count()); |
| 3437 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3437 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
| 3438 EXPECT_EQ(0, app_icon_loader2->fetch_count()); | 3438 EXPECT_EQ(0, app_icon_loader2->fetch_count()); |
| 3439 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3439 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
| 3440 | 3440 |
| 3441 AppWindowLauncherItemController* app_panel_controller2 = | 3441 AppWindowLauncherItemController* app_panel_controller2 = |
| 3442 new ExtensionAppWindowLauncherItemController( | 3442 new ExtensionAppWindowLauncherItemController( |
| 3443 LauncherItemController::TYPE_APP_PANEL, "id", app_id2, | 3443 LauncherItemController::TYPE_APP_PANEL, app_id2, "id", |
| 3444 launcher_controller_.get()); | 3444 launcher_controller_.get()); |
| 3445 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem( | 3445 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem( |
| 3446 app_panel_controller2, app_id2, ash::STATUS_RUNNING); | 3446 app_panel_controller2, app_id2, ash::STATUS_RUNNING); |
| 3447 EXPECT_EQ(0, app_icon_loader1->fetch_count()); | 3447 EXPECT_EQ(0, app_icon_loader1->fetch_count()); |
| 3448 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3448 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
| 3449 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3449 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 3450 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3450 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
| 3451 | 3451 |
| 3452 // Test adding an app panel | 3452 // Test adding an app panel |
| 3453 AppWindowLauncherItemController* app_panel_controller1 = | 3453 AppWindowLauncherItemController* app_panel_controller1 = |
| 3454 new ExtensionAppWindowLauncherItemController( | 3454 new ExtensionAppWindowLauncherItemController( |
| 3455 LauncherItemController::TYPE_APP_PANEL, "id", app_id1, | 3455 LauncherItemController::TYPE_APP_PANEL, app_id1, "id", |
| 3456 launcher_controller_.get()); | 3456 launcher_controller_.get()); |
| 3457 | 3457 |
| 3458 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem( | 3458 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem( |
| 3459 app_panel_controller1, app_id1, ash::STATUS_RUNNING); | 3459 app_panel_controller1, app_id1, ash::STATUS_RUNNING); |
| 3460 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3460 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
| 3461 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3461 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
| 3462 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3462 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
| 3463 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3463 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
| 3464 | 3464 |
| 3465 launcher_controller_->CloseLauncherItem(shelfId1); | 3465 launcher_controller_->CloseLauncherItem(shelfId1); |
| (...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3832 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); | 3832 EXPECT_TRUE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
| 3833 | 3833 |
| 3834 std::string window_app_id("org.chromium.arc.1"); | 3834 std::string window_app_id("org.chromium.arc.1"); |
| 3835 CreateArcWindow(window_app_id); | 3835 CreateArcWindow(window_app_id); |
| 3836 arc_test_.app_instance()->SendTaskCreated(1, | 3836 arc_test_.app_instance()->SendTaskCreated(1, |
| 3837 arc_test_.fake_default_apps()[0]); | 3837 arc_test_.fake_default_apps()[0]); |
| 3838 | 3838 |
| 3839 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id)); | 3839 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(app_id)); |
| 3840 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); | 3840 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); |
| 3841 } | 3841 } |
| OLD | NEW |