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

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

Issue 2900783003: Handle app custom icon via aura::Window property. (Closed)
Patch Set: cleanup Created 3 years, 7 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.h" 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.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 1990 matching lines...) Expand 10 before | Expand all | Expand 10 after
2001 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); 2001 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id));
2002 const ash::ShelfID shelf_id(app_id); 2002 const ash::ShelfID shelf_id(app_id);
2003 const ash::ShelfItem* item = launcher_controller_->GetItem(shelf_id); 2003 const ash::ShelfItem* item = launcher_controller_->GetItem(shelf_id);
2004 ASSERT_NE(nullptr, item); 2004 ASSERT_NE(nullptr, item);
2005 EXPECT_EQ(ash::STATUS_CLOSED, item->status); 2005 EXPECT_EQ(ash::STATUS_CLOSED, item->status);
2006 EXPECT_EQ(ash::TYPE_PINNED_APP, item->type); 2006 EXPECT_EQ(ash::TYPE_PINNED_APP, item->type);
2007 2007
2008 // Play Store app is ARC app that might be represented by native Chrome 2008 // Play Store app is ARC app that might be represented by native Chrome
2009 // platform app. 2009 // platform app.
2010 model_->SetShelfItemDelegate( 2010 model_->SetShelfItemDelegate(
2011 shelf_id, 2011 shelf_id, base::MakeUnique<ExtensionAppWindowLauncherItemController>(
2012 base::MakeUnique<ExtensionAppWindowLauncherItemController>(shelf_id)); 2012 shelf_id, launcher_controller_));
2013 launcher_controller_->SetItemStatus(shelf_id, ash::STATUS_RUNNING); 2013 launcher_controller_->SetItemStatus(shelf_id, ash::STATUS_RUNNING);
2014 2014
2015 // This launch request should be ignored in case of active app. 2015 // This launch request should be ignored in case of active app.
2016 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON); 2016 arc::LaunchApp(profile(), app_id, ui::EF_LEFT_MOUSE_BUTTON);
2017 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id)); 2017 EXPECT_FALSE(launcher_controller_->GetArcDeferredLauncher()->HasApp(app_id));
2018 2018
2019 // Closing the app should leave a pinned but closed shelf item shortcut. 2019 // Closing the app should leave a pinned but closed shelf item shortcut.
2020 launcher_controller_->CloseLauncherItem(shelf_id); 2020 launcher_controller_->CloseLauncherItem(shelf_id);
2021 item = launcher_controller_->GetItem(shelf_id); 2021 item = launcher_controller_->GetItem(shelf_id);
2022 ASSERT_NE(nullptr, item); 2022 ASSERT_NE(nullptr, item);
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after
2329 2329
2330 // No custom icon set. Acitivating windows should not change icon. 2330 // No custom icon set. Acitivating windows should not change icon.
2331 EXPECT_FALSE(item_delegate->image_set_by_controller()); 2331 EXPECT_FALSE(item_delegate->image_set_by_controller());
2332 window1->Activate(); 2332 window1->Activate();
2333 EXPECT_FALSE(item_delegate->image_set_by_controller()); 2333 EXPECT_FALSE(item_delegate->image_set_by_controller());
2334 window2->Activate(); 2334 window2->Activate();
2335 EXPECT_FALSE(item_delegate->image_set_by_controller()); 2335 EXPECT_FALSE(item_delegate->image_set_by_controller());
2336 2336
2337 // Set custom icon on active item. Icon should change to custom. 2337 // Set custom icon on active item. Icon should change to custom.
2338 arc_test_.app_instance()->SendTaskDescription(2, std::string(), png_data); 2338 arc_test_.app_instance()->SendTaskDescription(2, std::string(), png_data);
2339 base::RunLoop().RunUntilIdle();
2339 EXPECT_TRUE(item_delegate->image_set_by_controller()); 2340 EXPECT_TRUE(item_delegate->image_set_by_controller());
2340 2341
2341 // Switch back to the item without custom icon. Icon should be changed to 2342 // Switch back to the item without custom icon. Icon should be changed to
2342 // default. 2343 // default.
2343 window1->Activate(); 2344 window1->Activate();
2344 EXPECT_FALSE(item_delegate->image_set_by_controller()); 2345 EXPECT_FALSE(item_delegate->image_set_by_controller());
2345 // Test that setting an invalid icon should not change custom icon. 2346 // Test that setting an invalid icon should not change custom icon.
2346 arc_test_.app_instance()->SendTaskDescription(1, std::string(), png_data); 2347 arc_test_.app_instance()->SendTaskDescription(1, std::string(), png_data);
2347 EXPECT_TRUE(item_delegate->image_set_by_controller()); 2348 EXPECT_TRUE(item_delegate->image_set_by_controller());
2348 arc_test_.app_instance()->SendTaskDescription(1, std::string(), 2349 arc_test_.app_instance()->SendTaskDescription(1, std::string(),
(...skipping 1294 matching lines...) Expand 10 before | Expand all | Expand 10 after
3643 // app_icon_loader1 and app_icon_loader2 are owned by 3644 // app_icon_loader1 and app_icon_loader2 are owned by
3644 // ChromeLauncherController. 3645 // ChromeLauncherController.
3645 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); 3646 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl();
3646 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); 3647 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl();
3647 app_icon_loader1->AddSupportedApp(shelf_id1.app_id); 3648 app_icon_loader1->AddSupportedApp(shelf_id1.app_id);
3648 app_icon_loader2->AddSupportedApp(shelf_id2.app_id); 3649 app_icon_loader2->AddSupportedApp(shelf_id2.app_id);
3649 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), 3650 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1),
3650 std::unique_ptr<AppIconLoader>(app_icon_loader2)); 3651 std::unique_ptr<AppIconLoader>(app_icon_loader2));
3651 3652
3652 launcher_controller_->CreateAppLauncherItem( 3653 launcher_controller_->CreateAppLauncherItem(
3653 base::MakeUnique<ExtensionAppWindowLauncherItemController>(shelf_id3), 3654 base::MakeUnique<ExtensionAppWindowLauncherItemController>(
3655 shelf_id3, launcher_controller_),
3654 ash::STATUS_RUNNING); 3656 ash::STATUS_RUNNING);
3655 EXPECT_EQ(0, app_icon_loader1->fetch_count()); 3657 EXPECT_EQ(0, app_icon_loader1->fetch_count());
3656 EXPECT_EQ(0, app_icon_loader1->clear_count()); 3658 EXPECT_EQ(0, app_icon_loader1->clear_count());
3657 EXPECT_EQ(0, app_icon_loader2->fetch_count()); 3659 EXPECT_EQ(0, app_icon_loader2->fetch_count());
3658 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3660 EXPECT_EQ(0, app_icon_loader2->clear_count());
3659 3661
3660 launcher_controller_->CreateAppLauncherItem( 3662 launcher_controller_->CreateAppLauncherItem(
3661 base::MakeUnique<ExtensionAppWindowLauncherItemController>(shelf_id2), 3663 base::MakeUnique<ExtensionAppWindowLauncherItemController>(
3664 shelf_id2, launcher_controller_),
3662 ash::STATUS_RUNNING); 3665 ash::STATUS_RUNNING);
3663 EXPECT_EQ(0, app_icon_loader1->fetch_count()); 3666 EXPECT_EQ(0, app_icon_loader1->fetch_count());
3664 EXPECT_EQ(0, app_icon_loader1->clear_count()); 3667 EXPECT_EQ(0, app_icon_loader1->clear_count());
3665 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3668 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3666 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3669 EXPECT_EQ(0, app_icon_loader2->clear_count());
3667 3670
3668 launcher_controller_->CreateAppLauncherItem( 3671 launcher_controller_->CreateAppLauncherItem(
3669 base::MakeUnique<ExtensionAppWindowLauncherItemController>(shelf_id1), 3672 base::MakeUnique<ExtensionAppWindowLauncherItemController>(
3673 shelf_id1, launcher_controller_),
3670 ash::STATUS_RUNNING); 3674 ash::STATUS_RUNNING);
3671 EXPECT_EQ(1, app_icon_loader1->fetch_count()); 3675 EXPECT_EQ(1, app_icon_loader1->fetch_count());
3672 EXPECT_EQ(0, app_icon_loader1->clear_count()); 3676 EXPECT_EQ(0, app_icon_loader1->clear_count());
3673 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3677 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3674 EXPECT_EQ(0, app_icon_loader2->clear_count()); 3678 EXPECT_EQ(0, app_icon_loader2->clear_count());
3675 3679
3676 launcher_controller_->CloseLauncherItem(shelf_id1); 3680 launcher_controller_->CloseLauncherItem(shelf_id1);
3677 EXPECT_EQ(1, app_icon_loader1->fetch_count()); 3681 EXPECT_EQ(1, app_icon_loader1->fetch_count());
3678 EXPECT_EQ(1, app_icon_loader1->clear_count()); 3682 EXPECT_EQ(1, app_icon_loader1->clear_count());
3679 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3683 EXPECT_EQ(1, app_icon_loader2->fetch_count());
(...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after
4285 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS, 4289 EXPECT_EQ(ash::SHELF_AUTO_HIDE_BEHAVIOR_ALWAYS,
4286 shelf_controller->auto_hide()); 4290 shelf_controller->auto_hide());
4287 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count()); 4291 EXPECT_EQ(2u, shelf_controller->auto_hide_change_count());
4288 4292
4289 PrefService* prefs = profile()->GetTestingPrefService(); 4293 PrefService* prefs = profile()->GetTestingPrefService();
4290 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal)); 4294 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignmentLocal));
4291 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment)); 4295 EXPECT_EQ("Left", prefs->GetString(prefs::kShelfAlignment));
4292 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal)); 4296 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehaviorLocal));
4293 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior)); 4297 EXPECT_EQ("Always", prefs->GetString(prefs::kShelfAutoHideBehavior));
4294 } 4298 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698