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 3249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3260 | 3260 |
3261 // Delete one tab through the menu item. | 3261 // Delete one tab through the menu item. |
3262 { | 3262 { |
3263 ChromeLauncherAppMenuItems items = | 3263 ChromeLauncherAppMenuItems items = |
3264 launcher_controller_->GetApplicationList(item_gmail, 0); | 3264 launcher_controller_->GetApplicationList(item_gmail, 0); |
3265 items[1]->Execute(ui::EF_SHIFT_DOWN); | 3265 items[1]->Execute(ui::EF_SHIFT_DOWN); |
3266 EXPECT_EQ(--tabs, browser()->tab_strip_model()->count()); | 3266 EXPECT_EQ(--tabs, browser()->tab_strip_model()->count()); |
3267 } | 3267 } |
3268 } | 3268 } |
3269 | 3269 |
3270 // Tests that panels create launcher items correctly | |
3271 TEST_F(ChromeLauncherControllerImplTest, AppPanels) { | |
3272 InitLauncherControllerWithBrowser(); | |
3273 // App list and Browser shortcut ShelfItems are added. | |
3274 EXPECT_EQ(2, model_observer_->added()); | |
3275 EXPECT_EQ(1, model_observer_->changed()); | |
3276 | |
3277 const std::string app_id = extension1_->id(); | |
3278 // app_icon_loader is owned by ChromeLauncherControllerImpl. | |
3279 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl(); | |
3280 app_icon_loader->AddSupportedApp(app_id); | |
3281 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); | |
3282 | |
3283 // Test adding an app panel | |
3284 AppWindowLauncherItemController* app_panel_controller = | |
3285 new ExtensionAppWindowLauncherItemController( | |
3286 LauncherItemController::TYPE_APP_PANEL, app_id, "id", | |
3287 launcher_controller_.get()); | |
3288 ash::ShelfID shelf_id1 = launcher_controller_->CreateAppLauncherItem( | |
3289 app_panel_controller, app_id, ash::STATUS_RUNNING); | |
3290 int panel_index = model_observer_->last_index(); | |
3291 EXPECT_EQ(3, model_observer_->added()); | |
3292 EXPECT_EQ(1, model_observer_->changed()); | |
3293 EXPECT_EQ(1, app_icon_loader->fetch_count()); | |
3294 model_observer_->clear_counts(); | |
3295 | |
3296 // App panels should have a separate identifier than the app id | |
3297 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(app_id)); | |
3298 | |
3299 // Setting the app image image should not change the panel if it set its icon | |
3300 app_panel_controller->set_image_set_by_controller(true); | |
3301 gfx::ImageSkia image; | |
3302 launcher_controller_->OnAppImageUpdated(app_id, image); | |
3303 EXPECT_EQ(0, model_observer_->changed()); | |
3304 model_observer_->clear_counts(); | |
3305 | |
3306 // Add a second app panel and verify that it get the same index as the first | |
3307 // one had, being added to the left of the existing panel. | |
3308 AppWindowLauncherItemController* app_panel_controller2 = | |
3309 new ExtensionAppWindowLauncherItemController( | |
3310 LauncherItemController::TYPE_APP_PANEL, app_id, "id", | |
3311 launcher_controller_.get()); | |
3312 | |
3313 ash::ShelfID shelf_id2 = launcher_controller_->CreateAppLauncherItem( | |
3314 app_panel_controller2, app_id, ash::STATUS_RUNNING); | |
3315 EXPECT_EQ(panel_index, model_observer_->last_index()); | |
3316 EXPECT_EQ(1, model_observer_->added()); | |
3317 model_observer_->clear_counts(); | |
3318 | |
3319 launcher_controller_->CloseLauncherItem(shelf_id2); | |
3320 launcher_controller_->CloseLauncherItem(shelf_id1); | |
3321 EXPECT_EQ(2, model_observer_->removed()); | |
3322 } | |
James Cook
2016/11/02 17:53:44
Hrm, kinda like this. Except this lives in chrome.
msw
2016/11/10 21:07:46
I restored and update this; it took a bit of work*
| |
3323 | |
3324 // Tests that the Gmail extension matches more than the app itself claims with | 3270 // Tests that the Gmail extension matches more than the app itself claims with |
3325 // the manifest file. | 3271 // the manifest file. |
3326 TEST_F(ChromeLauncherControllerImplTest, GmailMatching) { | 3272 TEST_F(ChromeLauncherControllerImplTest, GmailMatching) { |
3327 InitLauncherControllerWithBrowser(); | 3273 InitLauncherControllerWithBrowser(); |
3328 | 3274 |
3329 // Create a Gmail browser tab. | 3275 // Create a Gmail browser tab. |
3330 chrome::NewTab(browser()); | 3276 chrome::NewTab(browser()); |
3331 base::string16 title = ASCIIToUTF16("Test"); | 3277 base::string16 title = ASCIIToUTF16("Test"); |
3332 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title); | 3278 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title); |
3333 content::WebContents* content = | 3279 content::WebContents* content = |
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3493 const std::string app_id3 = extension3_->id(); | 3439 const std::string app_id3 = extension3_->id(); |
3494 // app_icon_loader1 and app_icon_loader2 are owned by | 3440 // app_icon_loader1 and app_icon_loader2 are owned by |
3495 // ChromeLauncherControllerImpl. | 3441 // ChromeLauncherControllerImpl. |
3496 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); | 3442 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); |
3497 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); | 3443 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); |
3498 app_icon_loader1->AddSupportedApp(app_id1); | 3444 app_icon_loader1->AddSupportedApp(app_id1); |
3499 app_icon_loader2->AddSupportedApp(app_id2); | 3445 app_icon_loader2->AddSupportedApp(app_id2); |
3500 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), | 3446 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), |
3501 std::unique_ptr<AppIconLoader>(app_icon_loader2)); | 3447 std::unique_ptr<AppIconLoader>(app_icon_loader2)); |
3502 | 3448 |
3503 AppWindowLauncherItemController* app_panel_controller3 = | 3449 AppWindowLauncherItemController* app_controller3 = |
3504 new ExtensionAppWindowLauncherItemController( | 3450 new ExtensionAppWindowLauncherItemController( |
3505 LauncherItemController::TYPE_APP_PANEL, app_id3, "id", | 3451 LauncherItemController::TYPE_APP, app_id3, "id", |
3506 launcher_controller_.get()); | 3452 launcher_controller_.get()); |
3507 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( | 3453 const ash::ShelfID shelfId3 = launcher_controller_->CreateAppLauncherItem( |
3508 app_panel_controller3, app_id3, ash::STATUS_RUNNING); | 3454 app_controller3, app_id3, ash::STATUS_RUNNING); |
3509 EXPECT_EQ(0, app_icon_loader1->fetch_count()); | 3455 EXPECT_EQ(0, app_icon_loader1->fetch_count()); |
3510 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3456 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
3511 EXPECT_EQ(0, app_icon_loader2->fetch_count()); | 3457 EXPECT_EQ(0, app_icon_loader2->fetch_count()); |
3512 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3458 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
3513 | 3459 |
3514 AppWindowLauncherItemController* app_panel_controller2 = | 3460 AppWindowLauncherItemController* app_controller2 = |
3515 new ExtensionAppWindowLauncherItemController( | 3461 new ExtensionAppWindowLauncherItemController( |
3516 LauncherItemController::TYPE_APP_PANEL, app_id2, "id", | 3462 LauncherItemController::TYPE_APP, app_id2, "id", |
3517 launcher_controller_.get()); | 3463 launcher_controller_.get()); |
3518 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem( | 3464 const ash::ShelfID shelfId2 = launcher_controller_->CreateAppLauncherItem( |
3519 app_panel_controller2, app_id2, ash::STATUS_RUNNING); | 3465 app_controller2, app_id2, ash::STATUS_RUNNING); |
3520 EXPECT_EQ(0, app_icon_loader1->fetch_count()); | 3466 EXPECT_EQ(0, app_icon_loader1->fetch_count()); |
3521 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3467 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
3522 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3468 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
3523 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3469 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
3524 | 3470 |
3525 // Test adding an app panel | 3471 AppWindowLauncherItemController* app_controller1 = |
3526 AppWindowLauncherItemController* app_panel_controller1 = | |
3527 new ExtensionAppWindowLauncherItemController( | 3472 new ExtensionAppWindowLauncherItemController( |
3528 LauncherItemController::TYPE_APP_PANEL, app_id1, "id", | 3473 LauncherItemController::TYPE_APP, app_id1, "id", |
3529 launcher_controller_.get()); | 3474 launcher_controller_.get()); |
3530 | 3475 |
3531 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem( | 3476 const ash::ShelfID shelfId1 = launcher_controller_->CreateAppLauncherItem( |
3532 app_panel_controller1, app_id1, ash::STATUS_RUNNING); | 3477 app_controller1, app_id1, ash::STATUS_RUNNING); |
3533 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3478 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
3534 EXPECT_EQ(0, app_icon_loader1->clear_count()); | 3479 EXPECT_EQ(0, app_icon_loader1->clear_count()); |
3535 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3480 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
3536 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3481 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
3537 | 3482 |
3538 launcher_controller_->CloseLauncherItem(shelfId1); | 3483 launcher_controller_->CloseLauncherItem(shelfId1); |
3539 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 3484 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
3540 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 3485 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
3541 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 3486 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
3542 EXPECT_EQ(0, app_icon_loader2->clear_count()); | 3487 EXPECT_EQ(0, app_icon_loader2->clear_count()); |
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4007 app_service_->GetPinPosition(extension_misc::kChromeAppId))); | 3952 app_service_->GetPinPosition(extension_misc::kChromeAppId))); |
4008 EXPECT_TRUE( | 3953 EXPECT_TRUE( |
4009 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); | 3954 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); |
4010 EXPECT_TRUE( | 3955 EXPECT_TRUE( |
4011 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); | 3956 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); |
4012 EXPECT_TRUE( | 3957 EXPECT_TRUE( |
4013 position_2.Equals(app_service_->GetPinPosition(extension2_->id()))); | 3958 position_2.Equals(app_service_->GetPinPosition(extension2_->id()))); |
4014 EXPECT_TRUE( | 3959 EXPECT_TRUE( |
4015 position_3.Equals(app_service_->GetPinPosition(extension3_->id()))); | 3960 position_3.Equals(app_service_->GetPinPosition(extension3_->id()))); |
4016 } | 3961 } |
OLD | NEW |