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

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

Issue 2290603002: Enhance chrome.app.window API for shelf integration with pinning support (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review v3 Created 4 years, 3 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 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 3137 matching lines...) Expand 10 before | Expand all | Expand 10 after
3148 3148
3149 const std::string app_id = extension1_->id(); 3149 const std::string app_id = extension1_->id();
3150 // app_icon_loader is owned by ChromeLauncherControllerImpl. 3150 // app_icon_loader is owned by ChromeLauncherControllerImpl.
3151 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl(); 3151 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl();
3152 app_icon_loader->AddSupportedApp(app_id); 3152 app_icon_loader->AddSupportedApp(app_id);
3153 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); 3153 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader));
3154 3154
3155 // Test adding an app panel 3155 // Test adding an app panel
3156 AppWindowLauncherItemController* app_panel_controller = 3156 AppWindowLauncherItemController* app_panel_controller =
3157 new ExtensionAppWindowLauncherItemController( 3157 new ExtensionAppWindowLauncherItemController(
3158 LauncherItemController::TYPE_APP_PANEL, "id", app_id, 3158 LauncherItemController::TYPE_APP_PANEL, app_id, "id",
3159 launcher_controller_.get()); 3159 launcher_controller_.get());
3160 ash::ShelfID shelf_id1 = launcher_controller_->CreateAppLauncherItem( 3160 ash::ShelfID shelf_id1 = launcher_controller_->CreateAppLauncherItem(
3161 app_panel_controller, app_id, ash::STATUS_RUNNING); 3161 app_panel_controller, app_id, ash::STATUS_RUNNING);
3162 int panel_index = model_observer_->last_index(); 3162 int panel_index = model_observer_->last_index();
3163 EXPECT_EQ(3, model_observer_->added()); 3163 EXPECT_EQ(3, model_observer_->added());
3164 EXPECT_EQ(1, model_observer_->changed()); 3164 EXPECT_EQ(1, model_observer_->changed());
3165 EXPECT_EQ(1, app_icon_loader->fetch_count()); 3165 EXPECT_EQ(1, app_icon_loader->fetch_count());
3166 model_observer_->clear_counts(); 3166 model_observer_->clear_counts();
3167 3167
3168 // App panels should have a separate identifier than the app id 3168 // App panels should have a separate identifier than the app id
3169 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); 3169 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id));
3170 3170
3171 // Setting the app image image should not change the panel if it set its icon 3171 // Setting the app image image should not change the panel if it set its icon
3172 app_panel_controller->set_image_set_by_controller(true); 3172 app_panel_controller->set_image_set_by_controller(true);
3173 gfx::ImageSkia image; 3173 gfx::ImageSkia image;
3174 launcher_controller_->OnAppImageUpdated(app_id, image); 3174 launcher_controller_->OnAppImageUpdated(app_id, image);
3175 EXPECT_EQ(0, model_observer_->changed()); 3175 EXPECT_EQ(0, model_observer_->changed());
3176 model_observer_->clear_counts(); 3176 model_observer_->clear_counts();
3177 3177
3178 // Add a second app panel and verify that it get the same index as the first 3178 // Add a second app panel and verify that it get the same index as the first
3179 // one had, being added to the left of the existing panel. 3179 // one had, being added to the left of the existing panel.
3180 AppWindowLauncherItemController* app_panel_controller2 = 3180 AppWindowLauncherItemController* app_panel_controller2 =
3181 new ExtensionAppWindowLauncherItemController( 3181 new ExtensionAppWindowLauncherItemController(
3182 LauncherItemController::TYPE_APP_PANEL, "id", app_id, 3182 LauncherItemController::TYPE_APP_PANEL, app_id, "id",
3183 launcher_controller_.get()); 3183 launcher_controller_.get());
3184 3184
3185 ash::ShelfID shelf_id2 = launcher_controller_->CreateAppLauncherItem( 3185 ash::ShelfID shelf_id2 = launcher_controller_->CreateAppLauncherItem(
3186 app_panel_controller2, app_id, ash::STATUS_RUNNING); 3186 app_panel_controller2, app_id, ash::STATUS_RUNNING);
3187 EXPECT_EQ(panel_index, model_observer_->last_index()); 3187 EXPECT_EQ(panel_index, model_observer_->last_index());
3188 EXPECT_EQ(1, model_observer_->added()); 3188 EXPECT_EQ(1, model_observer_->added());
3189 model_observer_->clear_counts(); 3189 model_observer_->clear_counts();
3190 3190
3191 launcher_controller_->CloseLauncherItem(shelf_id2); 3191 launcher_controller_->CloseLauncherItem(shelf_id2);
3192 launcher_controller_->CloseLauncherItem(shelf_id1); 3192 launcher_controller_->CloseLauncherItem(shelf_id1);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
3367 // ChromeLauncherControllerImpl. 3367 // ChromeLauncherControllerImpl.
3368 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); 3368 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl();
3369 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); 3369 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl();
3370 app_icon_loader1->AddSupportedApp(app_id1); 3370 app_icon_loader1->AddSupportedApp(app_id1);
3371 app_icon_loader2->AddSupportedApp(app_id2); 3371 app_icon_loader2->AddSupportedApp(app_id2);
3372 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), 3372 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1),
3373 std::unique_ptr<AppIconLoader>(app_icon_loader2)); 3373 std::unique_ptr<AppIconLoader>(app_icon_loader2));
3374 3374
3375 AppWindowLauncherItemController* app_panel_controller3 = 3375 AppWindowLauncherItemController* app_panel_controller3 =
3376 new ExtensionAppWindowLauncherItemController( 3376 new ExtensionAppWindowLauncherItemController(
3377 LauncherItemController::TYPE_APP_PANEL, "id", app_id3, 3377 LauncherItemController::TYPE_APP_PANEL, app_id3, "id",
3378 launcher_controller_.get()); 3378 launcher_controller_.get());
3379 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( 3379 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem(
3380 app_panel_controller3, app_id3, ash::STATUS_RUNNING); 3380 app_panel_controller3, app_id3, ash::STATUS_RUNNING);
3381 EXPECT_EQ(0, app_icon_loader1->fetch_count()); 3381 EXPECT_EQ(0, app_icon_loader1->fetch_count());
3382 EXPECT_EQ(0, app_icon_loader1->clear_count()); 3382 EXPECT_EQ(0, app_icon_loader1->clear_count());
3383 EXPECT_EQ(0, app_icon_loader2->fetch_count()); 3383 EXPECT_EQ(0, app_icon_loader2->fetch_count());
3384 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3384 EXPECT_EQ(0, app_icon_loader2->clear_count());
3385 3385
3386 AppWindowLauncherItemController* app_panel_controller2 = 3386 AppWindowLauncherItemController* app_panel_controller2 =
3387 new ExtensionAppWindowLauncherItemController( 3387 new ExtensionAppWindowLauncherItemController(
3388 LauncherItemController::TYPE_APP_PANEL, "id", app_id2, 3388 LauncherItemController::TYPE_APP_PANEL, app_id2, "id",
3389 launcher_controller_.get()); 3389 launcher_controller_.get());
3390 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem( 3390 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem(
3391 app_panel_controller2, app_id2, ash::STATUS_RUNNING); 3391 app_panel_controller2, app_id2, ash::STATUS_RUNNING);
3392 EXPECT_EQ(0, app_icon_loader1->fetch_count()); 3392 EXPECT_EQ(0, app_icon_loader1->fetch_count());
3393 EXPECT_EQ(0, app_icon_loader1->clear_count()); 3393 EXPECT_EQ(0, app_icon_loader1->clear_count());
3394 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3394 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3395 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3395 EXPECT_EQ(0, app_icon_loader2->clear_count());
3396 3396
3397 // Test adding an app panel 3397 // Test adding an app panel
3398 AppWindowLauncherItemController* app_panel_controller1 = 3398 AppWindowLauncherItemController* app_panel_controller1 =
3399 new ExtensionAppWindowLauncherItemController( 3399 new ExtensionAppWindowLauncherItemController(
3400 LauncherItemController::TYPE_APP_PANEL, "id", app_id1, 3400 LauncherItemController::TYPE_APP_PANEL, app_id1, "id",
3401 launcher_controller_.get()); 3401 launcher_controller_.get());
3402 3402
3403 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem( 3403 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem(
3404 app_panel_controller1, app_id1, ash::STATUS_RUNNING); 3404 app_panel_controller1, app_id1, ash::STATUS_RUNNING);
3405 EXPECT_EQ(1, app_icon_loader1->fetch_count()); 3405 EXPECT_EQ(1, app_icon_loader1->fetch_count());
3406 EXPECT_EQ(0, app_icon_loader1->clear_count()); 3406 EXPECT_EQ(0, app_icon_loader1->clear_count());
3407 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3407 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3408 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3408 EXPECT_EQ(0, app_icon_loader2->clear_count());
3409 3409
3410 launcher_controller_->CloseLauncherItem(shelfId1); 3410 launcher_controller_->CloseLauncherItem(shelfId1);
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after
3729 EXPECT_FALSE(controller->rotation_locked()); 3729 EXPECT_FALSE(controller->rotation_locked());
3730 EXPECT_EQ(display::Display::ROTATE_0, 3730 EXPECT_EQ(display::Display::ROTATE_0,
3731 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); 3731 display::Screen::GetScreen()->GetPrimaryDisplay().rotation());
3732 3732
3733 NotifyOnTaskOrientationLockRequested(task_id_current_, 3733 NotifyOnTaskOrientationLockRequested(task_id_current_,
3734 OrientationLock::CURRENT); 3734 OrientationLock::CURRENT);
3735 EXPECT_TRUE(controller->rotation_locked()); 3735 EXPECT_TRUE(controller->rotation_locked());
3736 EXPECT_EQ(display::Display::ROTATE_0, 3736 EXPECT_EQ(display::Display::ROTATE_0,
3737 display::Screen::GetScreen()->GetPrimaryDisplay().rotation()); 3737 display::Screen::GetScreen()->GetPrimaryDisplay().rotation());
3738 } 3738 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698