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

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

Issue 2052013002: Adding ChromeLauncherController interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@chrome_launcher_smaller_api
Patch Set: Rebase Created 4 years, 6 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_impl.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 AppListControllerDelegate::PIN_EDITABLE; 274 AppListControllerDelegate::PIN_EDITABLE;
275 } 275 }
276 bool ShouldShowTooltip() override { return false; } 276 bool ShouldShowTooltip() override { return false; }
277 277
278 private: 278 private:
279 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController); 279 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController);
280 }; 280 };
281 281
282 } // namespace 282 } // namespace
283 283
284 class ChromeLauncherControllerTest : public BrowserWithTestWindowTest { 284 class ChromeLauncherControllerImplTest : public BrowserWithTestWindowTest {
285 protected: 285 protected:
286 ChromeLauncherControllerTest() 286 ChromeLauncherControllerImplTest()
287 : BrowserWithTestWindowTest(Browser::TYPE_TABBED, false), 287 : BrowserWithTestWindowTest(Browser::TYPE_TABBED, false),
288 test_controller_(NULL), 288 test_controller_(NULL),
289 extension_service_(NULL) {} 289 extension_service_(NULL) {}
290 290
291 ~ChromeLauncherControllerTest() override {} 291 ~ChromeLauncherControllerImplTest() override {}
292 292
293 void SetUp() override { 293 void SetUp() override {
294 BrowserWithTestWindowTest::SetUp(); 294 BrowserWithTestWindowTest::SetUp();
295 295
296 model_.reset(new ash::ShelfModel); 296 model_.reset(new ash::ShelfModel);
297 model_observer_.reset(new TestShelfModelObserver); 297 model_observer_.reset(new TestShelfModelObserver);
298 model_->AddObserver(model_observer_.get()); 298 model_->AddObserver(model_observer_.get());
299 299
300 if (ash::Shell::HasInstance()) { 300 if (ash::Shell::HasInstance()) {
301 item_delegate_manager_ = 301 item_delegate_manager_ =
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
461 461
462 void AddAppListLauncherItem() { 462 void AddAppListLauncherItem() {
463 ash::ShelfItem app_list; 463 ash::ShelfItem app_list;
464 app_list.type = ash::TYPE_APP_LIST; 464 app_list.type = ash::TYPE_APP_LIST;
465 model_->Add(app_list); 465 model_->Add(app_list);
466 } 466 }
467 467
468 void InitLauncherController() { 468 void InitLauncherController() {
469 AddAppListLauncherItem(); 469 AddAppListLauncherItem();
470 launcher_controller_.reset( 470 launcher_controller_.reset(
471 new ChromeLauncherController(profile(), model_.get())); 471 new ChromeLauncherControllerImpl(profile(), model_.get()));
472 if (!ash::Shell::HasInstance()) 472 if (!ash::Shell::HasInstance())
473 SetShelfItemDelegateManager(item_delegate_manager_); 473 SetShelfItemDelegateManager(item_delegate_manager_);
474 launcher_controller_->Init(); 474 launcher_controller_->Init();
475 } 475 }
476 476
477 void InitLauncherControllerWithBrowser() { 477 void InitLauncherControllerWithBrowser() {
478 InitLauncherController(); 478 InitLauncherController();
479 chrome::NewTab(browser()); 479 chrome::NewTab(browser());
480 browser()->window()->Show(); 480 browser()->window()->Show();
481 } 481 }
(...skipping 22 matching lines...) Expand all
504 504
505 void InsertPrefValue(base::ListValue* pref_value, 505 void InsertPrefValue(base::ListValue* pref_value,
506 int index, 506 int index,
507 const std::string& extension_id) { 507 const std::string& extension_id) {
508 base::DictionaryValue* entry = new base::DictionaryValue(); 508 base::DictionaryValue* entry = new base::DictionaryValue();
509 entry->SetString(ash::kPinnedAppsPrefAppIDPath, extension_id); 509 entry->SetString(ash::kPinnedAppsPrefAppIDPath, extension_id);
510 pref_value->Insert(index, entry); 510 pref_value->Insert(index, entry);
511 } 511 }
512 512
513 // Gets the currently configured app launchers from the controller. 513 // Gets the currently configured app launchers from the controller.
514 void GetAppLaunchers(ChromeLauncherController* controller, 514 void GetAppLaunchers(ChromeLauncherControllerImpl* controller,
515 std::vector<std::string>* launchers) { 515 std::vector<std::string>* launchers) {
516 launchers->clear(); 516 launchers->clear();
517 for (ash::ShelfItems::const_iterator iter(model_->items().begin()); 517 for (ash::ShelfItems::const_iterator iter(model_->items().begin());
518 iter != model_->items().end(); ++iter) { 518 iter != model_->items().end(); ++iter) {
519 ChromeLauncherController::IDToItemControllerMap::const_iterator 519 ChromeLauncherControllerImpl::IDToItemControllerMap::const_iterator entry(
520 entry(controller->id_to_item_controller_map_.find(iter->id)); 520 controller->id_to_item_controller_map_.find(iter->id));
521 if (iter->type == ash::TYPE_APP_SHORTCUT && 521 if (iter->type == ash::TYPE_APP_SHORTCUT &&
522 entry != controller->id_to_item_controller_map_.end()) { 522 entry != controller->id_to_item_controller_map_.end()) {
523 launchers->push_back(entry->second->app_id()); 523 launchers->push_back(entry->second->app_id());
524 } 524 }
525 } 525 }
526 } 526 }
527 527
528 // Get the setup of the currently shown launcher items in one string. 528 // Get the setup of the currently shown launcher items in one string.
529 // Each pinned element will start with a big letter, each running but not 529 // Each pinned element will start with a big letter, each running but not
530 // pinned V1 app will start with a small letter and each running but not 530 // pinned V1 app will start with a small letter and each running but not
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 scoped_refptr<Extension> extension1_; 680 scoped_refptr<Extension> extension1_;
681 scoped_refptr<Extension> extension2_; 681 scoped_refptr<Extension> extension2_;
682 scoped_refptr<Extension> extension3_; 682 scoped_refptr<Extension> extension3_;
683 scoped_refptr<Extension> extension4_; 683 scoped_refptr<Extension> extension4_;
684 scoped_refptr<Extension> extension5_; 684 scoped_refptr<Extension> extension5_;
685 scoped_refptr<Extension> extension6_; 685 scoped_refptr<Extension> extension6_;
686 scoped_refptr<Extension> extension7_; 686 scoped_refptr<Extension> extension7_;
687 scoped_refptr<Extension> extension8_; 687 scoped_refptr<Extension> extension8_;
688 688
689 ArcAppTest arc_test_; 689 ArcAppTest arc_test_;
690 std::unique_ptr<ChromeLauncherController> launcher_controller_; 690 std::unique_ptr<ChromeLauncherControllerImpl> launcher_controller_;
691 std::unique_ptr<TestShelfModelObserver> model_observer_; 691 std::unique_ptr<TestShelfModelObserver> model_observer_;
692 std::unique_ptr<ash::ShelfModel> model_; 692 std::unique_ptr<ash::ShelfModel> model_;
693 693
694 // |item_delegate_manager_| owns |test_controller_|. 694 // |item_delegate_manager_| owns |test_controller_|.
695 LauncherItemController* test_controller_; 695 LauncherItemController* test_controller_;
696 696
697 ExtensionService* extension_service_; 697 ExtensionService* extension_service_;
698 698
699 ash::ShelfItemDelegateManager* item_delegate_manager_; 699 ash::ShelfItemDelegateManager* item_delegate_manager_;
700 700
701 private: 701 private:
702 TestBrowserWindow* CreateTestBrowserWindowAura() { 702 TestBrowserWindow* CreateTestBrowserWindowAura() {
703 std::unique_ptr<aura::Window> window(new aura::Window(nullptr)); 703 std::unique_ptr<aura::Window> window(new aura::Window(nullptr));
704 window->set_id(0); 704 window->set_id(0);
705 window->SetType(ui::wm::WINDOW_TYPE_NORMAL); 705 window->SetType(ui::wm::WINDOW_TYPE_NORMAL);
706 window->Init(ui::LAYER_TEXTURED); 706 window->Init(ui::LAYER_TEXTURED);
707 aura::client::ParentWindowWithContext(window.get(), GetContext(), 707 aura::client::ParentWindowWithContext(window.get(), GetContext(),
708 gfx::Rect(200, 200)); 708 gfx::Rect(200, 200));
709 709
710 return new TestBrowserWindowAura(std::move(window)); 710 return new TestBrowserWindowAura(std::move(window));
711 } 711 }
712 712
713 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerTest); 713 DISALLOW_COPY_AND_ASSIGN(ChromeLauncherControllerImplTest);
714 }; 714 };
715 715
716 // Watches WebContents and blocks until it is destroyed. This is needed for 716 // Watches WebContents and blocks until it is destroyed. This is needed for
717 // the destruction of a V2 application. 717 // the destruction of a V2 application.
718 class WebContentsDestroyedWatcher : public content::WebContentsObserver { 718 class WebContentsDestroyedWatcher : public content::WebContentsObserver {
719 public: 719 public:
720 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents) 720 explicit WebContentsDestroyedWatcher(content::WebContents* web_contents)
721 : content::WebContentsObserver(web_contents), 721 : content::WebContentsObserver(web_contents),
722 message_loop_runner_(new content::MessageLoopRunner) { 722 message_loop_runner_(new content::MessageLoopRunner) {
723 EXPECT_TRUE(web_contents != NULL); 723 EXPECT_TRUE(web_contents != NULL);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
815 815
816 // The app window which represents the application. Note that the window 816 // The app window which represents the application. Note that the window
817 // deletes itself asynchronously after window_->GetBaseWindow()->Close() gets 817 // deletes itself asynchronously after window_->GetBaseWindow()->Close() gets
818 // called. 818 // called.
819 extensions::AppWindow* window_; 819 extensions::AppWindow* window_;
820 820
821 DISALLOW_COPY_AND_ASSIGN(V2App); 821 DISALLOW_COPY_AND_ASSIGN(V2App);
822 }; 822 };
823 823
824 // The testing framework to test multi profile scenarios. 824 // The testing framework to test multi profile scenarios.
825 class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest 825 class MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest
826 : public ChromeLauncherControllerTest { 826 : public ChromeLauncherControllerImplTest {
827 protected: 827 protected:
828 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest() { 828 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest() {}
829 }
830 829
831 ~MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest() override {} 830 ~MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest()
831 override {}
832 832
833 // Overwrite the Setup function to enable multi profile and needed objects. 833 // Overwrite the Setup function to enable multi profile and needed objects.
834 void SetUp() override { 834 void SetUp() override {
835 profile_manager_.reset( 835 profile_manager_.reset(
836 new TestingProfileManager(TestingBrowserProcess::GetGlobal())); 836 new TestingProfileManager(TestingBrowserProcess::GetGlobal()));
837 837
838 ASSERT_TRUE(profile_manager_->SetUp()); 838 ASSERT_TRUE(profile_manager_->SetUp());
839 839
840 // AvatarMenu and multiple profiles works after user logged in. 840 // AvatarMenu and multiple profiles works after user logged in.
841 profile_manager_->SetLoggedIn(true); 841 profile_manager_->SetLoggedIn(true);
842 842
843 // Initialize the UserManager singleton to a fresh FakeUserManager instance. 843 // Initialize the UserManager singleton to a fresh FakeUserManager instance.
844 user_manager_enabler_.reset(new chromeos::ScopedUserManagerEnabler( 844 user_manager_enabler_.reset(new chromeos::ScopedUserManagerEnabler(
845 new chromeos::FakeChromeUserManager)); 845 new chromeos::FakeChromeUserManager));
846 846
847 // Initialize the WallpaperManager singleton. 847 // Initialize the WallpaperManager singleton.
848 chromeos::WallpaperManager::Initialize(); 848 chromeos::WallpaperManager::Initialize();
849 849
850 // Initialize the rest. 850 // Initialize the rest.
851 ChromeLauncherControllerTest::SetUp(); 851 ChromeLauncherControllerImplTest::SetUp();
852 852
853 // Get some base objects. 853 // Get some base objects.
854 session_delegate()->set_logged_in_users(2); 854 session_delegate()->set_logged_in_users(2);
855 shell_delegate_ = static_cast<ash::test::TestShellDelegate*>( 855 shell_delegate_ = static_cast<ash::test::TestShellDelegate*>(
856 ash::Shell::GetInstance()->delegate()); 856 ash::Shell::GetInstance()->delegate());
857 shell_delegate_->set_multi_profiles_enabled(true); 857 shell_delegate_->set_multi_profiles_enabled(true);
858 } 858 }
859 859
860 void TearDown() override { 860 void TearDown() override {
861 ChromeLauncherControllerTest::TearDown(); 861 ChromeLauncherControllerImplTest::TearDown();
862 user_manager_enabler_.reset(); 862 user_manager_enabler_.reset();
863 for (ProfileToNameMap::iterator it = created_profiles_.begin(); 863 for (ProfileToNameMap::iterator it = created_profiles_.begin();
864 it != created_profiles_.end(); ++it) 864 it != created_profiles_.end(); ++it)
865 profile_manager_->DeleteTestingProfile(it->second); 865 profile_manager_->DeleteTestingProfile(it->second);
866 chromeos::WallpaperManager::Shutdown(); 866 chromeos::WallpaperManager::Shutdown();
867 867
868 // A Task is leaked if we don't destroy everything, then run the message 868 // A Task is leaked if we don't destroy everything, then run the message
869 // loop. 869 // loop.
870 base::ThreadTaskRunnerHandle::Get()->PostTask( 870 base::ThreadTaskRunnerHandle::Get()->PostTask(
871 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure()); 871 FROM_HERE, base::MessageLoop::QuitWhenIdleClosure());
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 } 979 }
980 980
981 std::unique_ptr<TestingProfileManager> profile_manager_; 981 std::unique_ptr<TestingProfileManager> profile_manager_;
982 std::unique_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_; 982 std::unique_ptr<chromeos::ScopedUserManagerEnabler> user_manager_enabler_;
983 983
984 ash::test::TestShellDelegate* shell_delegate_; 984 ash::test::TestShellDelegate* shell_delegate_;
985 985
986 ProfileToNameMap created_profiles_; 986 ProfileToNameMap created_profiles_;
987 987
988 DISALLOW_COPY_AND_ASSIGN( 988 DISALLOW_COPY_AND_ASSIGN(
989 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest); 989 MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest);
990 }; 990 };
991 991
992 TEST_F(ChromeLauncherControllerTest, DefaultApps) { 992 TEST_F(ChromeLauncherControllerImplTest, DefaultApps) {
993 InitLauncherController(); 993 InitLauncherController();
994 // Model should only contain the browser shortcut and app list items. 994 // Model should only contain the browser shortcut and app list items.
995 EXPECT_EQ(2, model_->item_count()); 995 EXPECT_EQ(2, model_->item_count());
996 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 996 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
997 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 997 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
998 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 998 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
999 999
1000 // Installing |extension3_| should add it to the launcher - behind the 1000 // Installing |extension3_| should add it to the launcher - behind the
1001 // chrome icon. 1001 // chrome icon.
1002 extension_service_->AddExtension(extension3_.get()); 1002 extension_service_->AddExtension(extension3_.get());
1003 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 1003 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
1004 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1004 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1005 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1005 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1006 } 1006 }
1007 1007
1008 /* 1008 /*
1009 * Test ChromeLauncherController correctly merges policy pinned apps 1009 * Test ChromeLauncherControllerImpl correctly merges policy pinned apps
1010 * and user pinned apps 1010 * and user pinned apps
1011 */ 1011 */
1012 TEST_F(ChromeLauncherControllerTest, MergePolicyAndUserPrefPinnedApps) { 1012 TEST_F(ChromeLauncherControllerImplTest, MergePolicyAndUserPrefPinnedApps) {
1013 InitLauncherController(); 1013 InitLauncherController();
1014 1014
1015 base::ListValue user_pref_value; 1015 base::ListValue user_pref_value;
1016 extension_service_->AddExtension(extension1_.get()); 1016 extension_service_->AddExtension(extension1_.get());
1017 extension_service_->AddExtension(extension3_.get()); 1017 extension_service_->AddExtension(extension3_.get());
1018 extension_service_->AddExtension(extension4_.get()); 1018 extension_service_->AddExtension(extension4_.get());
1019 extension_service_->AddExtension(extension5_.get()); 1019 extension_service_->AddExtension(extension5_.get());
1020 // extension 1, 3 are pinned by user 1020 // extension 1, 3 are pinned by user
1021 InsertPrefValue(&user_pref_value, 0, extension1_->id()); 1021 InsertPrefValue(&user_pref_value, 0, extension1_->id());
1022 InsertPrefValue(&user_pref_value, 1, extension3_->id()); 1022 InsertPrefValue(&user_pref_value, 1, extension3_->id());
(...skipping 28 matching lines...) Expand all
1051 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, 1051 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED,
1052 launcher_controller_->GetPinnable(extension4_->id())); 1052 launcher_controller_->GetPinnable(extension4_->id()));
1053 1053
1054 // Check the order of shelf pinned apps 1054 // Check the order of shelf pinned apps
1055 EXPECT_EQ("AppList, App2, App4, App1, Chrome, App3", GetPinnedAppStatus()); 1055 EXPECT_EQ("AppList, App2, App4, App1, Chrome, App3", GetPinnedAppStatus());
1056 } 1056 }
1057 1057
1058 // Check that the restauration of launcher items is happening in the same order 1058 // Check that the restauration of launcher items is happening in the same order
1059 // as the user has pinned them (on another system) when they are synced reverse 1059 // as the user has pinned them (on another system) when they are synced reverse
1060 // order. 1060 // order.
1061 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsReverseOrder) { 1061 TEST_F(ChromeLauncherControllerImplTest, RestoreDefaultAppsReverseOrder) {
1062 InitLauncherController(); 1062 InitLauncherController();
1063 1063
1064 base::ListValue policy_value; 1064 base::ListValue policy_value;
1065 InsertPrefValue(&policy_value, 0, extension1_->id()); 1065 InsertPrefValue(&policy_value, 0, extension1_->id());
1066 InsertPrefValue(&policy_value, 1, extension2_->id()); 1066 InsertPrefValue(&policy_value, 1, extension2_->id());
1067 InsertPrefValue(&policy_value, 2, extension3_->id()); 1067 InsertPrefValue(&policy_value, 2, extension3_->id());
1068 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 1068 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
1069 policy_value.DeepCopy()); 1069 policy_value.DeepCopy());
1070 SetShelfChromeIconIndex(0); 1070 SetShelfChromeIconIndex(0);
1071 // Model should only contain the browser shortcut and app list items. 1071 // Model should only contain the browser shortcut and app list items.
(...skipping 18 matching lines...) Expand all
1090 1090
1091 // Installing |extension1_| should add it to the launcher - behind the 1091 // Installing |extension1_| should add it to the launcher - behind the
1092 // chrome icon, but in first location. 1092 // chrome icon, but in first location.
1093 extension_service_->AddExtension(extension1_.get()); 1093 extension_service_->AddExtension(extension1_.get());
1094 EXPECT_EQ("AppList, Chrome, App1, App2, App3", GetPinnedAppStatus()); 1094 EXPECT_EQ("AppList, Chrome, App1, App2, App3", GetPinnedAppStatus());
1095 } 1095 }
1096 1096
1097 // Check that the restauration of launcher items is happening in the same order 1097 // Check that the restauration of launcher items is happening in the same order
1098 // as the user has pinned them (on another system) when they are synced random 1098 // as the user has pinned them (on another system) when they are synced random
1099 // order. 1099 // order.
1100 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsRandomOrder) { 1100 TEST_F(ChromeLauncherControllerImplTest, RestoreDefaultAppsRandomOrder) {
1101 InitLauncherController(); 1101 InitLauncherController();
1102 1102
1103 base::ListValue policy_value; 1103 base::ListValue policy_value;
1104 InsertPrefValue(&policy_value, 0, extension1_->id()); 1104 InsertPrefValue(&policy_value, 0, extension1_->id());
1105 InsertPrefValue(&policy_value, 1, extension2_->id()); 1105 InsertPrefValue(&policy_value, 1, extension2_->id());
1106 InsertPrefValue(&policy_value, 2, extension3_->id()); 1106 InsertPrefValue(&policy_value, 2, extension3_->id());
1107 1107
1108 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 1108 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
1109 policy_value.DeepCopy()); 1109 policy_value.DeepCopy());
1110 SetShelfChromeIconIndex(0); 1110 SetShelfChromeIconIndex(0);
(...skipping 18 matching lines...) Expand all
1129 1129
1130 // Installing |extension3_| should add it to the launcher - behind the 1130 // Installing |extension3_| should add it to the launcher - behind the
1131 // chrome icon, but in first location. 1131 // chrome icon, but in first location.
1132 extension_service_->AddExtension(extension3_.get()); 1132 extension_service_->AddExtension(extension3_.get());
1133 EXPECT_EQ("AppList, Chrome, App1, App2, App3", GetPinnedAppStatus()); 1133 EXPECT_EQ("AppList, Chrome, App1, App2, App3", GetPinnedAppStatus());
1134 } 1134 }
1135 1135
1136 // Check that the restauration of launcher items is happening in the same order 1136 // Check that the restauration of launcher items is happening in the same order
1137 // as the user has pinned / moved them (on another system) when they are synced 1137 // as the user has pinned / moved them (on another system) when they are synced
1138 // random order - including the chrome icon. 1138 // random order - including the chrome icon.
1139 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsRandomOrderChromeMoved) { 1139 TEST_F(ChromeLauncherControllerImplTest,
1140 RestoreDefaultAppsRandomOrderChromeMoved) {
1140 InitLauncherController(); 1141 InitLauncherController();
1141 1142
1142 base::ListValue policy_value; 1143 base::ListValue policy_value;
1143 InsertPrefValue(&policy_value, 0, extension1_->id()); 1144 InsertPrefValue(&policy_value, 0, extension1_->id());
1144 InsertPrefValue(&policy_value, 1, extension2_->id()); 1145 InsertPrefValue(&policy_value, 1, extension2_->id());
1145 InsertPrefValue(&policy_value, 2, extension3_->id()); 1146 InsertPrefValue(&policy_value, 2, extension3_->id());
1146 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 1147 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
1147 policy_value.DeepCopy()); 1148 policy_value.DeepCopy());
1148 SetShelfChromeIconIndex(1); 1149 SetShelfChromeIconIndex(1);
1149 // Model should only contain the browser shortcut and app list items. 1150 // Model should only contain the browser shortcut and app list items.
(...skipping 16 matching lines...) Expand all
1166 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 1167 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
1167 EXPECT_EQ("AppList, App1, Chrome, App2", GetPinnedAppStatus()); 1168 EXPECT_EQ("AppList, App1, Chrome, App2", GetPinnedAppStatus());
1168 1169
1169 // Installing |extension3_| should add it to the launcher - behind the 1170 // Installing |extension3_| should add it to the launcher - behind the
1170 // chrome icon, but in first location. 1171 // chrome icon, but in first location.
1171 extension_service_->AddExtension(extension3_.get()); 1172 extension_service_->AddExtension(extension3_.get());
1172 EXPECT_EQ("AppList, App1, Chrome, App2, App3", GetPinnedAppStatus()); 1173 EXPECT_EQ("AppList, App1, Chrome, App2, App3", GetPinnedAppStatus());
1173 } 1174 }
1174 1175
1175 // Check that syncing to a different state does the correct thing. 1176 // Check that syncing to a different state does the correct thing.
1176 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsResyncOrder) { 1177 TEST_F(ChromeLauncherControllerImplTest, RestoreDefaultAppsResyncOrder) {
1177 InitLauncherController(); 1178 InitLauncherController();
1178 base::ListValue policy_value; 1179 base::ListValue policy_value;
1179 InsertPrefValue(&policy_value, 0, extension1_->id()); 1180 InsertPrefValue(&policy_value, 0, extension1_->id());
1180 InsertPrefValue(&policy_value, 1, extension2_->id()); 1181 InsertPrefValue(&policy_value, 1, extension2_->id());
1181 InsertPrefValue(&policy_value, 2, extension3_->id()); 1182 InsertPrefValue(&policy_value, 2, extension3_->id());
1182 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 1183 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
1183 policy_value.DeepCopy()); 1184 policy_value.DeepCopy());
1184 // The shelf layout has always one static item at the beginning (App List). 1185 // The shelf layout has always one static item at the beginning (App List).
1185 SetShelfChromeIconIndex(0); 1186 SetShelfChromeIconIndex(0);
1186 extension_service_->AddExtension(extension2_.get()); 1187 extension_service_->AddExtension(extension2_.get());
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 UnloadedExtensionInfo::REASON_UNINSTALL); 1228 UnloadedExtensionInfo::REASON_UNINSTALL);
1228 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 1229 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
1229 1230
1230 // Check that an update of an extension does not crash the system. 1231 // Check that an update of an extension does not crash the system.
1231 extension_service_->UnloadExtension(extension3_->id(), 1232 extension_service_->UnloadExtension(extension3_->id(),
1232 UnloadedExtensionInfo::REASON_UPDATE); 1233 UnloadedExtensionInfo::REASON_UPDATE);
1233 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus()); 1234 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
1234 } 1235 }
1235 1236
1236 // Check that simple locking of an application will 'create' a launcher item. 1237 // Check that simple locking of an application will 'create' a launcher item.
1237 TEST_F(ChromeLauncherControllerTest, CheckLockApps) { 1238 TEST_F(ChromeLauncherControllerImplTest, CheckLockApps) {
1238 InitLauncherController(); 1239 InitLauncherController();
1239 // Model should only contain the browser shortcut and app list items. 1240 // Model should only contain the browser shortcut and app list items.
1240 EXPECT_EQ(2, model_->item_count()); 1241 EXPECT_EQ(2, model_->item_count());
1241 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1242 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1242 EXPECT_FALSE( 1243 EXPECT_FALSE(
1243 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); 1244 launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
1244 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1245 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1245 EXPECT_FALSE( 1246 EXPECT_FALSE(
1246 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); 1247 launcher_controller_->IsWindowedAppInLauncher(extension2_->id()));
1247 1248
(...skipping 12 matching lines...) Expand all
1260 EXPECT_EQ(2, model_->item_count()); 1261 EXPECT_EQ(2, model_->item_count());
1261 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1262 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1262 EXPECT_FALSE( 1263 EXPECT_FALSE(
1263 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); 1264 launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
1264 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1265 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1265 EXPECT_FALSE( 1266 EXPECT_FALSE(
1266 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); 1267 launcher_controller_->IsWindowedAppInLauncher(extension2_->id()));
1267 } 1268 }
1268 1269
1269 // Check that multiple locks of an application will be properly handled. 1270 // Check that multiple locks of an application will be properly handled.
1270 TEST_F(ChromeLauncherControllerTest, CheckMultiLockApps) { 1271 TEST_F(ChromeLauncherControllerImplTest, CheckMultiLockApps) {
1271 InitLauncherController(); 1272 InitLauncherController();
1272 // Model should only contain the browser shortcut and app list items. 1273 // Model should only contain the browser shortcut and app list items.
1273 EXPECT_EQ(2, model_->item_count()); 1274 EXPECT_EQ(2, model_->item_count());
1274 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1275 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1275 EXPECT_FALSE( 1276 EXPECT_FALSE(
1276 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); 1277 launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
1277 1278
1278 for (int i = 0; i < 2; i++) { 1279 for (int i = 0; i < 2; i++) {
1279 launcher_controller_->LockV1AppWithID(extension1_->id()); 1280 launcher_controller_->LockV1AppWithID(extension1_->id());
1280 1281
(...skipping 16 matching lines...) Expand all
1297 EXPECT_EQ(2, model_->item_count()); 1298 EXPECT_EQ(2, model_->item_count());
1298 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1299 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1299 EXPECT_FALSE( 1300 EXPECT_FALSE(
1300 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); 1301 launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
1301 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1302 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1302 EXPECT_FALSE( 1303 EXPECT_FALSE(
1303 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); 1304 launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
1304 } 1305 }
1305 1306
1306 // Check that already pinned items are not effected by locks. 1307 // Check that already pinned items are not effected by locks.
1307 TEST_F(ChromeLauncherControllerTest, CheckAlreadyPinnedLockApps) { 1308 TEST_F(ChromeLauncherControllerImplTest, CheckAlreadyPinnedLockApps) {
1308 InitLauncherController(); 1309 InitLauncherController();
1309 // Model should only contain the browser shortcut and app list items. 1310 // Model should only contain the browser shortcut and app list items.
1310 EXPECT_EQ(2, model_->item_count()); 1311 EXPECT_EQ(2, model_->item_count());
1311 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1312 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1312 EXPECT_FALSE( 1313 EXPECT_FALSE(
1313 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); 1314 launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
1314 1315
1315 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1316 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1316 launcher_controller_->PinAppWithID(extension1_->id()); 1317 launcher_controller_->PinAppWithID(extension1_->id());
1317 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1318 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
(...skipping 19 matching lines...) Expand all
1337 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); 1338 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id()));
1338 EXPECT_FALSE( 1339 EXPECT_FALSE(
1339 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); 1340 launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
1340 1341
1341 launcher_controller_->UnpinAppWithID(extension1_->id()); 1342 launcher_controller_->UnpinAppWithID(extension1_->id());
1342 1343
1343 EXPECT_EQ(2, model_->item_count()); 1344 EXPECT_EQ(2, model_->item_count());
1344 } 1345 }
1345 1346
1346 // Check that already pinned items which get locked stay after unpinning. 1347 // Check that already pinned items which get locked stay after unpinning.
1347 TEST_F(ChromeLauncherControllerTest, CheckPinnedAppsStayAfterUnlock) { 1348 TEST_F(ChromeLauncherControllerImplTest, CheckPinnedAppsStayAfterUnlock) {
1348 InitLauncherController(); 1349 InitLauncherController();
1349 // Model should only contain the browser shortcut and app list items. 1350 // Model should only contain the browser shortcut and app list items.
1350 EXPECT_EQ(2, model_->item_count()); 1351 EXPECT_EQ(2, model_->item_count());
1351 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1352 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1352 EXPECT_FALSE( 1353 EXPECT_FALSE(
1353 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); 1354 launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
1354 1355
1355 launcher_controller_->PinAppWithID(extension1_->id()); 1356 launcher_controller_->PinAppWithID(extension1_->id());
1356 1357
1357 EXPECT_EQ(3, model_->item_count()); 1358 EXPECT_EQ(3, model_->item_count());
(...skipping 17 matching lines...) Expand all
1375 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1376 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1376 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); 1377 EXPECT_TRUE(launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
1377 1378
1378 launcher_controller_->UnlockV1AppWithID(extension1_->id()); 1379 launcher_controller_->UnlockV1AppWithID(extension1_->id());
1379 1380
1380 EXPECT_EQ(2, model_->item_count()); 1381 EXPECT_EQ(2, model_->item_count());
1381 } 1382 }
1382 1383
1383 // Check that running applications wich are not pinned get properly restored 1384 // Check that running applications wich are not pinned get properly restored
1384 // upon user change. 1385 // upon user change.
1385 TEST_F(ChromeLauncherControllerTest, CheckRunningAppOrder) { 1386 TEST_F(ChromeLauncherControllerImplTest, CheckRunningAppOrder) {
1386 InitLauncherController(); 1387 InitLauncherController();
1387 // Model should only contain the browser shortcut and app list items. 1388 // Model should only contain the browser shortcut and app list items.
1388 EXPECT_EQ(2, model_->item_count()); 1389 EXPECT_EQ(2, model_->item_count());
1389 1390
1390 // Add a few running applications. 1391 // Add a few running applications.
1391 launcher_controller_->LockV1AppWithID(extension1_->id()); 1392 launcher_controller_->LockV1AppWithID(extension1_->id());
1392 launcher_controller_->LockV1AppWithID(extension2_->id()); 1393 launcher_controller_->LockV1AppWithID(extension2_->id());
1393 launcher_controller_->LockV1AppWithID(extension3_->id()); 1394 launcher_controller_->LockV1AppWithID(extension3_->id());
1394 EXPECT_EQ(5, model_->item_count()); 1395 EXPECT_EQ(5, model_->item_count());
1395 // Note that this not only checks the order of applications but also the 1396 // Note that this not only checks the order of applications but also the
(...skipping 28 matching lines...) Expand all
1424 1425
1425 // Check that removing more items does not crash and changes nothing. 1426 // Check that removing more items does not crash and changes nothing.
1426 launcher_controller_->UnlockV1AppWithID(extension2_->id()); 1427 launcher_controller_->UnlockV1AppWithID(extension2_->id());
1427 RestoreUnpinnedRunningApplicationOrder(current_account_id); 1428 RestoreUnpinnedRunningApplicationOrder(current_account_id);
1428 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus()); 1429 EXPECT_EQ("AppList, Chrome, app3", GetPinnedAppStatus());
1429 launcher_controller_->UnlockV1AppWithID(extension3_->id()); 1430 launcher_controller_->UnlockV1AppWithID(extension3_->id());
1430 RestoreUnpinnedRunningApplicationOrder(current_account_id); 1431 RestoreUnpinnedRunningApplicationOrder(current_account_id);
1431 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus()); 1432 EXPECT_EQ("AppList, Chrome", GetPinnedAppStatus());
1432 } 1433 }
1433 1434
1434 TEST_F(ChromeLauncherControllerTest, ArcDeferredLaunch) { 1435 TEST_F(ChromeLauncherControllerImplTest, ArcDeferredLaunch) {
1435 arc_test_.SetUp(profile()); 1436 arc_test_.SetUp(profile());
1436 1437
1437 launcher_controller_.reset( 1438 launcher_controller_.reset(
1438 ChromeLauncherController::CreateInstance(profile(), model_.get())); 1439 ChromeLauncherControllerImpl::CreateInstance(profile(), model_.get()));
1439 launcher_controller_->Init(); 1440 launcher_controller_->Init();
1440 1441
1441 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0]; 1442 const arc::mojom::AppInfo& app1 = arc_test_.fake_apps()[0];
1442 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1]; 1443 const arc::mojom::AppInfo& app2 = arc_test_.fake_apps()[1];
1443 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2]; 1444 const arc::mojom::AppInfo& app3 = arc_test_.fake_apps()[2];
1444 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1); 1445 const std::string arc_app_id1 = ArcAppTest::GetAppId(app1);
1445 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2); 1446 const std::string arc_app_id2 = ArcAppTest::GetAppId(app2);
1446 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3); 1447 const std::string arc_app_id3 = ArcAppTest::GetAppId(app3);
1447 1448
1448 SendListOfArcApps(); 1449 SendListOfArcApps();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1496 1497
1497 const arc::FakeAppInstance::Request* request1 = 1498 const arc::FakeAppInstance::Request* request1 =
1498 arc_test_.app_instance()->launch_requests()[0]; 1499 arc_test_.app_instance()->launch_requests()[0];
1499 const arc::FakeAppInstance::Request* request2 = 1500 const arc::FakeAppInstance::Request* request2 =
1500 arc_test_.app_instance()->launch_requests()[1]; 1501 arc_test_.app_instance()->launch_requests()[1];
1501 1502
1502 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) || 1503 EXPECT_TRUE((request1->IsForApp(app2) && request2->IsForApp(app3)) ||
1503 (request1->IsForApp(app3) && request2->IsForApp(app2))); 1504 (request1->IsForApp(app3) && request2->IsForApp(app2)));
1504 } 1505 }
1505 1506
1506 TEST_F(ChromeLauncherControllerTest, ArcRunningApp) { 1507 TEST_F(ChromeLauncherControllerImplTest, ArcRunningApp) {
1507 arc_test_.SetUp(profile()); 1508 arc_test_.SetUp(profile());
1508 InitLauncherController(); 1509 InitLauncherController();
1509 1510
1510 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1511 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1511 SendListOfArcApps(); 1512 SendListOfArcApps();
1512 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1513 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1513 1514
1514 // Normal flow, create/destroy tasks. 1515 // Normal flow, create/destroy tasks.
1515 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]); 1516 arc_test_.app_instance()->SendTaskCreated(1, arc_test_.fake_apps()[0]);
1516 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1517 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1517 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[0]); 1518 arc_test_.app_instance()->SendTaskCreated(2, arc_test_.fake_apps()[0]);
1518 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1519 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1519 arc_test_.app_instance()->SendTaskDestroyed(1); 1520 arc_test_.app_instance()->SendTaskDestroyed(1);
1520 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1521 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1521 arc_test_.app_instance()->SendTaskDestroyed(2); 1522 arc_test_.app_instance()->SendTaskDestroyed(2);
1522 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1523 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1523 1524
1524 // Stopping bridge removes apps. 1525 // Stopping bridge removes apps.
1525 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]); 1526 arc_test_.app_instance()->SendTaskCreated(3, arc_test_.fake_apps()[0]);
1526 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1527 EXPECT_NE(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1527 arc_test_.bridge_service()->SetStopped(); 1528 arc_test_.bridge_service()->SetStopped();
1528 base::RunLoop().RunUntilIdle(); 1529 base::RunLoop().RunUntilIdle();
1529 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id)); 1530 EXPECT_EQ(0, launcher_controller_->GetShelfIDForAppID(arc_app_id));
1530 } 1531 }
1531 1532
1532 // Validate that Arc app is pinned correctly and pin is removed automatically 1533 // Validate that Arc app is pinned correctly and pin is removed automatically
1533 // once app is uninstalled. 1534 // once app is uninstalled.
1534 TEST_F(ChromeLauncherControllerTest, ArcAppPin) { 1535 TEST_F(ChromeLauncherControllerImplTest, ArcAppPin) {
1535 arc_test_.SetUp(profile()); 1536 arc_test_.SetUp(profile());
1536 InitLauncherController(); 1537 InitLauncherController();
1537 1538
1538 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]); 1539 const std::string arc_app_id = ArcAppTest::GetAppId(arc_test_.fake_apps()[0]);
1539 1540
1540 SendListOfArcApps(); 1541 SendListOfArcApps();
1541 extension_service_->AddExtension(extension1_.get()); 1542 extension_service_->AddExtension(extension1_.get());
1542 extension_service_->AddExtension(extension2_.get()); 1543 extension_service_->AddExtension(extension2_.get());
1543 1544
1544 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1545 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
(...skipping 26 matching lines...) Expand all
1571 EnableArc(false); 1572 EnableArc(false);
1572 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 1573 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
1573 EnableArc(true); 1574 EnableArc(true);
1574 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 1575 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
1575 SendListOfArcApps(); 1576 SendListOfArcApps();
1576 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 1577 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
1577 } 1578 }
1578 1579
1579 // Check that with multi profile V1 apps are properly added / removed from the 1580 // Check that with multi profile V1 apps are properly added / removed from the
1580 // shelf. 1581 // shelf.
1581 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 1582 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
1582 V1AppUpdateOnUserSwitch) { 1583 V1AppUpdateOnUserSwitch) {
1583 // Create a browser item in the LauncherController. 1584 // Create a browser item in the LauncherController.
1584 InitLauncherController(); 1585 InitLauncherController();
1585 EXPECT_EQ(2, model_->item_count()); 1586 EXPECT_EQ(2, model_->item_count());
1586 { 1587 {
1587 // Create a "windowed gmail app". 1588 // Create a "windowed gmail app".
1588 std::unique_ptr<V1App> v1_app( 1589 std::unique_ptr<V1App> v1_app(
1589 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url)); 1590 CreateRunningV1App(profile(), extension_misc::kGmailAppId, gmail_url));
1590 EXPECT_EQ(3, model_->item_count()); 1591 EXPECT_EQ(3, model_->item_count());
1591 1592
1592 // After switching to a second user the item should be gone. 1593 // After switching to a second user the item should be gone.
1593 std::string user2 = "user2"; 1594 std::string user2 = "user2";
1594 TestingProfile* profile2 = CreateMultiUserProfile(user2); 1595 TestingProfile* profile2 = CreateMultiUserProfile(user2);
1595 const AccountId account_id2( 1596 const AccountId account_id2(
1596 multi_user_util::GetAccountIdFromProfile(profile2)); 1597 multi_user_util::GetAccountIdFromProfile(profile2));
1597 const AccountId account_id( 1598 const AccountId account_id(
1598 multi_user_util::GetAccountIdFromProfile(profile())); 1599 multi_user_util::GetAccountIdFromProfile(profile()));
1599 SwitchActiveUser(account_id2); 1600 SwitchActiveUser(account_id2);
1600 EXPECT_EQ(2, model_->item_count()); 1601 EXPECT_EQ(2, model_->item_count());
1601 1602
1602 // After switching back the item should be back. 1603 // After switching back the item should be back.
1603 SwitchActiveUser(account_id); 1604 SwitchActiveUser(account_id);
1604 EXPECT_EQ(3, model_->item_count()); 1605 EXPECT_EQ(3, model_->item_count());
1605 // Note we destroy now the gmail app with the closure end. 1606 // Note we destroy now the gmail app with the closure end.
1606 } 1607 }
1607 EXPECT_EQ(2, model_->item_count()); 1608 EXPECT_EQ(2, model_->item_count());
1608 } 1609 }
1609 1610
1610 // Check edge cases with multi profile V1 apps in the shelf. 1611 // Check edge cases with multi profile V1 apps in the shelf.
1611 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 1612 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
1612 V1AppUpdateOnUserSwitchEdgecases) { 1613 V1AppUpdateOnUserSwitchEdgecases) {
1613 // Create a browser item in the LauncherController. 1614 // Create a browser item in the LauncherController.
1614 InitLauncherController(); 1615 InitLauncherController();
1615 1616
1616 // First test: Create an app when the user is not active. 1617 // First test: Create an app when the user is not active.
1617 std::string user2 = "user2"; 1618 std::string user2 = "user2";
1618 TestingProfile* profile2 = CreateMultiUserProfile(user2); 1619 TestingProfile* profile2 = CreateMultiUserProfile(user2);
1619 const AccountId account_id2( 1620 const AccountId account_id2(
1620 multi_user_util::GetAccountIdFromProfile(profile2)); 1621 multi_user_util::GetAccountIdFromProfile(profile2));
1621 const AccountId account_id( 1622 const AccountId account_id(
(...skipping 15 matching lines...) Expand all
1637 // Note: the closure ends and the browser will go away. 1638 // Note: the closure ends and the browser will go away.
1638 } 1639 }
1639 EXPECT_EQ(2, model_->item_count()); 1640 EXPECT_EQ(2, model_->item_count());
1640 SwitchActiveUser(account_id2); 1641 SwitchActiveUser(account_id2);
1641 EXPECT_EQ(2, model_->item_count()); 1642 EXPECT_EQ(2, model_->item_count());
1642 SwitchActiveUser(account_id); 1643 SwitchActiveUser(account_id);
1643 EXPECT_EQ(2, model_->item_count()); 1644 EXPECT_EQ(2, model_->item_count());
1644 } 1645 }
1645 1646
1646 // Check edge case where a visiting V1 app gets closed (crbug.com/321374). 1647 // Check edge case where a visiting V1 app gets closed (crbug.com/321374).
1647 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 1648 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
1648 V1CloseOnVisitingDesktop) { 1649 V1CloseOnVisitingDesktop) {
1649 // Create a browser item in the LauncherController. 1650 // Create a browser item in the LauncherController.
1650 InitLauncherController(); 1651 InitLauncherController();
1651 1652
1652 chrome::MultiUserWindowManager* manager = 1653 chrome::MultiUserWindowManager* manager =
1653 chrome::MultiUserWindowManager::GetInstance(); 1654 chrome::MultiUserWindowManager::GetInstance();
1654 1655
1655 // First create an app when the user is active. 1656 // First create an app when the user is active.
1656 std::string user2 = "user2"; 1657 std::string user2 = "user2";
1657 TestingProfile* profile2 = CreateMultiUserProfile(user2); 1658 TestingProfile* profile2 = CreateMultiUserProfile(user2);
(...skipping 23 matching lines...) Expand all
1681 // Create a "windowed gmail app". 1682 // Create a "windowed gmail app".
1682 std::unique_ptr<V1App> v1_app(CreateRunningV1App( 1683 std::unique_ptr<V1App> v1_app(CreateRunningV1App(
1683 profile(), extension_misc::kGmailAppId, kGmailLaunchURL)); 1684 profile(), extension_misc::kGmailAppId, kGmailLaunchURL));
1684 EXPECT_EQ(3, model_->item_count()); 1685 EXPECT_EQ(3, model_->item_count());
1685 } 1686 }
1686 SwitchActiveUser(account_id2); 1687 SwitchActiveUser(account_id2);
1687 EXPECT_EQ(2, model_->item_count()); 1688 EXPECT_EQ(2, model_->item_count());
1688 } 1689 }
1689 1690
1690 // Check edge cases with multi profile V1 apps in the shelf. 1691 // Check edge cases with multi profile V1 apps in the shelf.
1691 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 1692 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
1692 V1AppUpdateOnUserSwitchEdgecases2) { 1693 V1AppUpdateOnUserSwitchEdgecases2) {
1693 // Create a browser item in the LauncherController. 1694 // Create a browser item in the LauncherController.
1694 InitLauncherController(); 1695 InitLauncherController();
1695 SetLauncherControllerHelper(new TestLauncherControllerHelper); 1696 SetLauncherControllerHelper(new TestLauncherControllerHelper);
1696 1697
1697 // First test: Create an app when the user is not active. 1698 // First test: Create an app when the user is not active.
1698 std::string user2 = "user2"; 1699 std::string user2 = "user2";
1699 TestingProfile* profile2 = CreateMultiUserProfile(user2); 1700 TestingProfile* profile2 = CreateMultiUserProfile(user2);
1700 const AccountId account_id( 1701 const AccountId account_id(
1701 multi_user_util::GetAccountIdFromProfile(profile())); 1702 multi_user_util::GetAccountIdFromProfile(profile()));
(...skipping 18 matching lines...) Expand all
1720 } 1721 }
1721 EXPECT_EQ(2, model_->item_count()); 1722 EXPECT_EQ(2, model_->item_count());
1722 SwitchActiveUser(account_id); 1723 SwitchActiveUser(account_id);
1723 EXPECT_EQ(2, model_->item_count()); 1724 EXPECT_EQ(2, model_->item_count());
1724 SwitchActiveUser(account_id2); 1725 SwitchActiveUser(account_id2);
1725 EXPECT_EQ(2, model_->item_count()); 1726 EXPECT_EQ(2, model_->item_count());
1726 } 1727 }
1727 1728
1728 // Check that activating an item which is on another user's desktop, will bring 1729 // Check that activating an item which is on another user's desktop, will bring
1729 // it back. 1730 // it back.
1730 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 1731 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
1731 TestLauncherActivationPullsBackWindow) { 1732 TestLauncherActivationPullsBackWindow) {
1732 // Create a browser item in the LauncherController. 1733 // Create a browser item in the LauncherController.
1733 InitLauncherController(); 1734 InitLauncherController();
1734 chrome::MultiUserWindowManager* manager = 1735 chrome::MultiUserWindowManager* manager =
1735 chrome::MultiUserWindowManager::GetInstance(); 1736 chrome::MultiUserWindowManager::GetInstance();
1736 1737
1737 // Create a second test profile. The first is the one in profile() created in 1738 // Create a second test profile. The first is the one in profile() created in
1738 // BrowserWithTestWindowTest::SetUp(). 1739 // BrowserWithTestWindowTest::SetUp().
1739 // No need to add the profiles to the MultiUserWindowManager here. 1740 // No need to add the profiles to the MultiUserWindowManager here.
1740 // CreateMultiUserProfile() already does that. 1741 // CreateMultiUserProfile() already does that.
(...skipping 17 matching lines...) Expand all
1758 // Transfer the window to another user's desktop and check that activating it 1759 // Transfer the window to another user's desktop and check that activating it
1759 // does pull it back to that user. 1760 // does pull it back to that user.
1760 manager->ShowWindowForUser( 1761 manager->ShowWindowForUser(
1761 window, multi_user_util::GetAccountIdFromProfile(profile2)); 1762 window, multi_user_util::GetAccountIdFromProfile(profile2));
1762 EXPECT_FALSE(manager->IsWindowOnDesktopOfUser(window, current_user)); 1763 EXPECT_FALSE(manager->IsWindowOnDesktopOfUser(window, current_user));
1763 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false); 1764 launcher_controller_->ActivateWindowOrMinimizeIfActive(browser_window, false);
1764 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user)); 1765 EXPECT_TRUE(manager->IsWindowOnDesktopOfUser(window, current_user));
1765 } 1766 }
1766 1767
1767 // Check that lock -> pin -> unlock -> unpin does properly transition. 1768 // Check that lock -> pin -> unlock -> unpin does properly transition.
1768 TEST_F(ChromeLauncherControllerTest, CheckLockPinUnlockUnpin) { 1769 TEST_F(ChromeLauncherControllerImplTest, CheckLockPinUnlockUnpin) {
1769 InitLauncherController(); 1770 InitLauncherController();
1770 // Model should only contain the browser shortcut and app list items. 1771 // Model should only contain the browser shortcut and app list items.
1771 EXPECT_EQ(2, model_->item_count()); 1772 EXPECT_EQ(2, model_->item_count());
1772 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 1773 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
1773 EXPECT_FALSE( 1774 EXPECT_FALSE(
1774 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); 1775 launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
1775 1776
1776 launcher_controller_->LockV1AppWithID(extension1_->id()); 1777 launcher_controller_->LockV1AppWithID(extension1_->id());
1777 1778
1778 EXPECT_EQ(3, model_->item_count()); 1779 EXPECT_EQ(3, model_->item_count());
(...skipping 18 matching lines...) Expand all
1797 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); 1798 launcher_controller_->IsWindowedAppInLauncher(extension1_->id()));
1798 1799
1799 launcher_controller_->UnpinAppWithID(extension1_->id()); 1800 launcher_controller_->UnpinAppWithID(extension1_->id());
1800 1801
1801 EXPECT_EQ(2, model_->item_count()); 1802 EXPECT_EQ(2, model_->item_count());
1802 } 1803 }
1803 1804
1804 // Check that a locked (windowed V1 application) will be properly converted 1805 // Check that a locked (windowed V1 application) will be properly converted
1805 // between locked and pinned when the order gets changed through a profile / 1806 // between locked and pinned when the order gets changed through a profile /
1806 // policy change. 1807 // policy change.
1807 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAndLockedAppsResyncOrder) { 1808 TEST_F(ChromeLauncherControllerImplTest,
1809 RestoreDefaultAndLockedAppsResyncOrder) {
1808 InitLauncherController(); 1810 InitLauncherController();
1809 base::ListValue policy_value0; 1811 base::ListValue policy_value0;
1810 InsertPrefValue(&policy_value0, 0, extension1_->id()); 1812 InsertPrefValue(&policy_value0, 0, extension1_->id());
1811 InsertPrefValue(&policy_value0, 1, extension3_->id()); 1813 InsertPrefValue(&policy_value0, 1, extension3_->id());
1812 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 1814 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
1813 policy_value0.DeepCopy()); 1815 policy_value0.DeepCopy());
1814 // The shelf layout has always one static item at the beginning (App List). 1816 // The shelf layout has always one static item at the beginning (App List).
1815 SetShelfChromeIconIndex(0); 1817 SetShelfChromeIconIndex(0);
1816 extension_service_->AddExtension(extension1_.get()); 1818 extension_service_->AddExtension(extension1_.get());
1817 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); 1819 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1850 base::ListValue policy_value3; 1852 base::ListValue policy_value3;
1851 InsertPrefValue(&policy_value3, 0, extension3_->id()); 1853 InsertPrefValue(&policy_value3, 0, extension3_->id());
1852 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 1854 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
1853 policy_value3.DeepCopy()); 1855 policy_value3.DeepCopy());
1854 EXPECT_EQ("AppList, Chrome, App3, app2", GetPinnedAppStatus()); 1856 EXPECT_EQ("AppList, Chrome, App3, app2", GetPinnedAppStatus());
1855 } 1857 }
1856 1858
1857 // Check that a running and not pinned V2 application will be properly converted 1859 // Check that a running and not pinned V2 application will be properly converted
1858 // between locked and pinned when the order gets changed through a profile / 1860 // between locked and pinned when the order gets changed through a profile /
1859 // policy change. 1861 // policy change.
1860 TEST_F(ChromeLauncherControllerTest, 1862 TEST_F(ChromeLauncherControllerImplTest,
1861 RestoreDefaultAndRunningV2AppsResyncOrder) { 1863 RestoreDefaultAndRunningV2AppsResyncOrder) {
1862 InitLauncherController(); 1864 InitLauncherController();
1863 base::ListValue policy_value0; 1865 base::ListValue policy_value0;
1864 InsertPrefValue(&policy_value0, 0, extension1_->id()); 1866 InsertPrefValue(&policy_value0, 0, extension1_->id());
1865 InsertPrefValue(&policy_value0, 1, extension3_->id()); 1867 InsertPrefValue(&policy_value0, 1, extension3_->id());
1866 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 1868 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
1867 policy_value0.DeepCopy()); 1869 policy_value0.DeepCopy());
1868 // The shelf layout has always one static item at the beginning (app List). 1870 // The shelf layout has always one static item at the beginning (app List).
1869 SetShelfChromeIconIndex(0); 1871 SetShelfChromeIconIndex(0);
1870 extension_service_->AddExtension(extension1_.get()); 1872 extension_service_->AddExtension(extension1_.get());
(...skipping 30 matching lines...) Expand all
1901 // Removing an item should simply close it and everything should shift. 1903 // Removing an item should simply close it and everything should shift.
1902 base::ListValue policy_value3; 1904 base::ListValue policy_value3;
1903 InsertPrefValue(&policy_value3, 0, extension3_->id()); 1905 InsertPrefValue(&policy_value3, 0, extension3_->id());
1904 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 1906 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
1905 policy_value3.DeepCopy()); 1907 policy_value3.DeepCopy());
1906 EXPECT_EQ("AppList, Chrome, App3, *app2", GetPinnedAppStatus()); 1908 EXPECT_EQ("AppList, Chrome, App3, *app2", GetPinnedAppStatus());
1907 } 1909 }
1908 1910
1909 // Each user has a different set of applications pinned. Check that when 1911 // Each user has a different set of applications pinned. Check that when
1910 // switching between the two users, the state gets properly set. 1912 // switching between the two users, the state gets properly set.
1911 TEST_F(ChromeLauncherControllerTest, UserSwitchIconRestore) { 1913 TEST_F(ChromeLauncherControllerImplTest, UserSwitchIconRestore) {
1912 base::ListValue user_a; 1914 base::ListValue user_a;
1913 base::ListValue user_b; 1915 base::ListValue user_b;
1914 SetUpMultiUserScenario(&user_a, &user_b); 1916 SetUpMultiUserScenario(&user_a, &user_b);
1915 // Show user 1. 1917 // Show user 1.
1916 SetShelfChromeIconIndex(6); 1918 SetShelfChromeIconIndex(6);
1917 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 1919 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
1918 user_a.DeepCopy()); 1920 user_a.DeepCopy());
1919 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, App6, Chrome", 1921 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, App6, Chrome",
1920 GetPinnedAppStatus()); 1922 GetPinnedAppStatus());
1921 1923
(...skipping 14 matching lines...) Expand all
1936 // Switch back to 2. 1938 // Switch back to 2.
1937 SetShelfChromeIconIndex(4); 1939 SetShelfChromeIconIndex(4);
1938 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 1940 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
1939 user_b.DeepCopy()); 1941 user_b.DeepCopy());
1940 EXPECT_EQ("AppList, App7, App8, Chrome", GetPinnedAppStatus()); 1942 EXPECT_EQ("AppList, App7, App8, Chrome", GetPinnedAppStatus());
1941 } 1943 }
1942 1944
1943 // Each user has a different set of applications pinned, and one user has an 1945 // Each user has a different set of applications pinned, and one user has an
1944 // application running. Check that when switching between the two users, the 1946 // application running. Check that when switching between the two users, the
1945 // state gets properly set. 1947 // state gets properly set.
1946 TEST_F(ChromeLauncherControllerTest, UserSwitchIconRestoreWithRunningV2App) { 1948 TEST_F(ChromeLauncherControllerImplTest,
1949 UserSwitchIconRestoreWithRunningV2App) {
1947 base::ListValue user_a; 1950 base::ListValue user_a;
1948 base::ListValue user_b; 1951 base::ListValue user_b;
1949 SetUpMultiUserScenario(&user_a, &user_b); 1952 SetUpMultiUserScenario(&user_a, &user_b);
1950 1953
1951 // Run App1 and assume that it is a V2 app. 1954 // Run App1 and assume that it is a V2 app.
1952 CreateRunningV2App(extension1_->id()); 1955 CreateRunningV2App(extension1_->id());
1953 1956
1954 // Show user 1. 1957 // Show user 1.
1955 SetShelfChromeIconIndex(6); 1958 SetShelfChromeIconIndex(6);
1956 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 1959 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
(...skipping 19 matching lines...) Expand all
1976 SetShelfChromeIconIndex(4); 1979 SetShelfChromeIconIndex(4);
1977 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 1980 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
1978 user_b.DeepCopy()); 1981 user_b.DeepCopy());
1979 EXPECT_EQ("AppList, App7, App8, Chrome, *app1", GetPinnedAppStatus()); 1982 EXPECT_EQ("AppList, App7, App8, Chrome, *app1", GetPinnedAppStatus());
1980 } 1983 }
1981 1984
1982 // Each user has a different set of applications pinned, and one user has an 1985 // Each user has a different set of applications pinned, and one user has an
1983 // application running. The chrome icon is not the last item in the list. 1986 // application running. The chrome icon is not the last item in the list.
1984 // Check that when switching between the two users, the state gets properly set. 1987 // Check that when switching between the two users, the state gets properly set.
1985 // There was once a bug associated with this. 1988 // There was once a bug associated with this.
1986 TEST_F(ChromeLauncherControllerTest, 1989 TEST_F(ChromeLauncherControllerImplTest,
1987 UserSwitchIconRestoreWithRunningV2AppChromeInMiddle) { 1990 UserSwitchIconRestoreWithRunningV2AppChromeInMiddle) {
1988 base::ListValue user_a; 1991 base::ListValue user_a;
1989 base::ListValue user_b; 1992 base::ListValue user_b;
1990 SetUpMultiUserScenario(&user_a, &user_b); 1993 SetUpMultiUserScenario(&user_a, &user_b);
1991 1994
1992 // Run App1 and assume that it is a V2 app. 1995 // Run App1 and assume that it is a V2 app.
1993 CreateRunningV2App(extension1_->id()); 1996 CreateRunningV2App(extension1_->id());
1994 1997
1995 // Show user 1. 1998 // Show user 1.
1996 SetShelfChromeIconIndex(5); 1999 SetShelfChromeIconIndex(5);
(...skipping 10 matching lines...) Expand all
2007 EXPECT_EQ("AppList, App7, App8, Chrome, *app1", GetPinnedAppStatus()); 2010 EXPECT_EQ("AppList, App7, App8, Chrome, *app1", GetPinnedAppStatus());
2008 2011
2009 // Switch back to 1. 2012 // Switch back to 1.
2010 SetShelfChromeIconIndex(5); 2013 SetShelfChromeIconIndex(5);
2011 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 2014 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
2012 user_a.DeepCopy()); 2015 user_a.DeepCopy());
2013 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, Chrome, App6", 2016 EXPECT_EQ("AppList, App1, App2, App3, App4, App5, Chrome, App6",
2014 GetPinnedAppStatus()); 2017 GetPinnedAppStatus());
2015 } 2018 }
2016 2019
2017 TEST_F(ChromeLauncherControllerTest, Policy) { 2020 TEST_F(ChromeLauncherControllerImplTest, Policy) {
2018 extension_service_->AddExtension(extension1_.get()); 2021 extension_service_->AddExtension(extension1_.get());
2019 extension_service_->AddExtension(extension3_.get()); 2022 extension_service_->AddExtension(extension3_.get());
2020 2023
2021 base::ListValue policy_value; 2024 base::ListValue policy_value;
2022 InsertPrefValue(&policy_value, 0, extension1_->id()); 2025 InsertPrefValue(&policy_value, 0, extension1_->id());
2023 InsertPrefValue(&policy_value, 1, extension2_->id()); 2026 InsertPrefValue(&policy_value, 1, extension2_->id());
2024 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, 2027 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps,
2025 policy_value.DeepCopy()); 2028 policy_value.DeepCopy());
2026 2029
2027 // Only |extension1_| should get pinned. |extension2_| is specified but not 2030 // Only |extension1_| should get pinned. |extension2_| is specified but not
(...skipping 19 matching lines...) Expand all
2047 policy_value.Remove(0, NULL); 2050 policy_value.Remove(0, NULL);
2048 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, 2051 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps,
2049 policy_value.DeepCopy()); 2052 policy_value.DeepCopy());
2050 EXPECT_EQ(3, model_->item_count()); 2053 EXPECT_EQ(3, model_->item_count());
2051 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); 2054 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type);
2052 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); 2055 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id()));
2053 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); 2056 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
2054 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 2057 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
2055 } 2058 }
2056 2059
2057 TEST_F(ChromeLauncherControllerTest, UnpinWithUninstall) { 2060 TEST_F(ChromeLauncherControllerImplTest, UnpinWithUninstall) {
2058 extension_service_->AddExtension(extension3_.get()); 2061 extension_service_->AddExtension(extension3_.get());
2059 extension_service_->AddExtension(extension4_.get()); 2062 extension_service_->AddExtension(extension4_.get());
2060 2063
2061 InitLauncherController(); 2064 InitLauncherController();
2062 2065
2063 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 2066 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
2064 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id())); 2067 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id()));
2065 2068
2066 extension_service_->UnloadExtension(extension3_->id(), 2069 extension_service_->UnloadExtension(extension3_->id(),
2067 UnloadedExtensionInfo::REASON_UNINSTALL); 2070 UnloadedExtensionInfo::REASON_UNINSTALL);
2068 2071
2069 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 2072 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
2070 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id())); 2073 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id()));
2071 } 2074 }
2072 2075
2073 TEST_F(ChromeLauncherControllerTest, PrefUpdates) { 2076 TEST_F(ChromeLauncherControllerImplTest, PrefUpdates) {
2074 extension_service_->AddExtension(extension2_.get()); 2077 extension_service_->AddExtension(extension2_.get());
2075 extension_service_->AddExtension(extension3_.get()); 2078 extension_service_->AddExtension(extension3_.get());
2076 extension_service_->AddExtension(extension4_.get()); 2079 extension_service_->AddExtension(extension4_.get());
2077 2080
2078 InitLauncherController(); 2081 InitLauncherController();
2079 2082
2080 std::vector<std::string> expected_launchers; 2083 std::vector<std::string> expected_launchers;
2081 std::vector<std::string> actual_launchers; 2084 std::vector<std::string> actual_launchers;
2082 base::ListValue pref_value; 2085 base::ListValue pref_value;
2083 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 2086 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
2119 2122
2120 // Clearing works. 2123 // Clearing works.
2121 pref_value.Clear(); 2124 pref_value.Clear();
2122 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 2125 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
2123 pref_value.DeepCopy()); 2126 pref_value.DeepCopy());
2124 expected_launchers.clear(); 2127 expected_launchers.clear();
2125 GetAppLaunchers(launcher_controller_.get(), &actual_launchers); 2128 GetAppLaunchers(launcher_controller_.get(), &actual_launchers);
2126 EXPECT_EQ(expected_launchers, actual_launchers); 2129 EXPECT_EQ(expected_launchers, actual_launchers);
2127 } 2130 }
2128 2131
2129 TEST_F(ChromeLauncherControllerTest, PendingInsertionOrder) { 2132 TEST_F(ChromeLauncherControllerImplTest, PendingInsertionOrder) {
2130 extension_service_->AddExtension(extension1_.get()); 2133 extension_service_->AddExtension(extension1_.get());
2131 extension_service_->AddExtension(extension3_.get()); 2134 extension_service_->AddExtension(extension3_.get());
2132 2135
2133 InitLauncherController(); 2136 InitLauncherController();
2134 2137
2135 base::ListValue pref_value; 2138 base::ListValue pref_value;
2136 InsertPrefValue(&pref_value, 0, extension1_->id()); 2139 InsertPrefValue(&pref_value, 0, extension1_->id());
2137 InsertPrefValue(&pref_value, 1, extension2_->id()); 2140 InsertPrefValue(&pref_value, 1, extension2_->id());
2138 InsertPrefValue(&pref_value, 2, extension3_->id()); 2141 InsertPrefValue(&pref_value, 2, extension3_->id());
2139 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, 2142 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps,
(...skipping 12 matching lines...) Expand all
2152 expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id()); 2155 expected_launchers.insert(expected_launchers.begin() + 1, extension2_->id());
2153 GetAppLaunchers(launcher_controller_.get(), &actual_launchers); 2156 GetAppLaunchers(launcher_controller_.get(), &actual_launchers);
2154 EXPECT_EQ(expected_launchers, actual_launchers); 2157 EXPECT_EQ(expected_launchers, actual_launchers);
2155 } 2158 }
2156 2159
2157 // Checks the created menus and menu lists for correctness. It uses the given 2160 // Checks the created menus and menu lists for correctness. It uses the given
2158 // |controller| to create the objects for the given |item| and checks the 2161 // |controller| to create the objects for the given |item| and checks the
2159 // found item count against the |expected_items|. The |title| list contains the 2162 // found item count against the |expected_items|. The |title| list contains the
2160 // menu titles in the order of their appearance in the menu (not including the 2163 // menu titles in the order of their appearance in the menu (not including the
2161 // application name). 2164 // application name).
2162 bool CheckMenuCreation(ChromeLauncherController* controller, 2165 bool CheckMenuCreation(ChromeLauncherControllerImpl* controller,
2163 const ash::ShelfItem& item, 2166 const ash::ShelfItem& item,
2164 size_t expected_items, 2167 size_t expected_items,
2165 base::string16 title[], 2168 base::string16 title[],
2166 bool is_browser) { 2169 bool is_browser) {
2167 ChromeLauncherAppMenuItems items = controller->GetApplicationList(item, 0); 2170 ChromeLauncherAppMenuItems items = controller->GetApplicationList(item, 0);
2168 // A new behavior has been added: Only show menus if there is at least one 2171 // A new behavior has been added: Only show menus if there is at least one
2169 // item available. 2172 // item available.
2170 if (expected_items < 1 && is_browser) { 2173 if (expected_items < 1 && is_browser) {
2171 EXPECT_EQ(0u, items.size()); 2174 EXPECT_EQ(0u, items.size());
2172 return items.size() == 0; 2175 return items.size() == 0;
(...skipping 22 matching lines...) Expand all
2195 EXPECT_EQ(expected_menu_items, menu->GetItemCount()); 2198 EXPECT_EQ(expected_menu_items, menu->GetItemCount());
2196 EXPECT_FALSE(menu->IsEnabledAt(first_item)); 2199 EXPECT_FALSE(menu->IsEnabledAt(first_item));
2197 if (expected_items) { 2200 if (expected_items) {
2198 EXPECT_EQ(ui::MenuModel::TYPE_SEPARATOR, 2201 EXPECT_EQ(ui::MenuModel::TYPE_SEPARATOR,
2199 menu->GetTypeAt(first_item + 1)); 2202 menu->GetTypeAt(first_item + 1));
2200 } 2203 }
2201 return items.size() == expected_items + 1; 2204 return items.size() == expected_items + 1;
2202 } 2205 }
2203 2206
2204 // Check that browsers get reflected correctly in the launcher menu. 2207 // Check that browsers get reflected correctly in the launcher menu.
2205 TEST_F(ChromeLauncherControllerTest, BrowserMenuGeneration) { 2208 TEST_F(ChromeLauncherControllerImplTest, BrowserMenuGeneration) {
2206 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); 2209 EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
2207 chrome::NewTab(browser()); 2210 chrome::NewTab(browser());
2208 2211
2209 InitLauncherController(); 2212 InitLauncherController();
2210 2213
2211 // Check that the browser list is empty at this time. 2214 // Check that the browser list is empty at this time.
2212 ash::ShelfItem item_browser; 2215 ash::ShelfItem item_browser;
2213 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; 2216 item_browser.type = ash::TYPE_BROWSER_SHORTCUT;
2214 item_browser.id = 2217 item_browser.id =
2215 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); 2218 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId);
(...skipping 23 matching lines...) Expand all
2239 base::string16 two_menu_items[] = {title1, title2}; 2242 base::string16 two_menu_items[] = {title1, title2};
2240 EXPECT_TRUE(CheckMenuCreation( 2243 EXPECT_TRUE(CheckMenuCreation(
2241 launcher_controller_.get(), item_browser, 2, two_menu_items, true)); 2244 launcher_controller_.get(), item_browser, 2, two_menu_items, true));
2242 2245
2243 // Apparently we have to close all tabs we have. 2246 // Apparently we have to close all tabs we have.
2244 chrome::CloseTab(browser2.get()); 2247 chrome::CloseTab(browser2.get());
2245 } 2248 }
2246 2249
2247 // Check the multi profile case where only user related browsers should show 2250 // Check the multi profile case where only user related browsers should show
2248 // up. 2251 // up.
2249 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 2252 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
2250 BrowserMenuGenerationTwoUsers) { 2253 BrowserMenuGenerationTwoUsers) {
2251 // Create a browser item in the LauncherController. 2254 // Create a browser item in the LauncherController.
2252 InitLauncherController(); 2255 InitLauncherController();
2253 2256
2254 ash::ShelfItem item_browser; 2257 ash::ShelfItem item_browser;
2255 item_browser.type = ash::TYPE_BROWSER_SHORTCUT; 2258 item_browser.type = ash::TYPE_BROWSER_SHORTCUT;
2256 item_browser.id = 2259 item_browser.id =
2257 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId); 2260 launcher_controller_->GetShelfIDForAppID(extension_misc::kChromeAppId);
2258 2261
2259 // Check that the menu is empty. 2262 // Check that the menu is empty.
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2293 EXPECT_TRUE(CheckMenuCreation( 2296 EXPECT_TRUE(CheckMenuCreation(
2294 launcher_controller_.get(), item_browser, 1, one_menu_item2, true)); 2297 launcher_controller_.get(), item_browser, 1, one_menu_item2, true));
2295 2298
2296 chrome::CloseTab(browser2.get()); 2299 chrome::CloseTab(browser2.get());
2297 } 2300 }
2298 2301
2299 // Check that V1 apps are correctly reflected in the launcher menu using the 2302 // Check that V1 apps are correctly reflected in the launcher menu using the
2300 // refocus logic. 2303 // refocus logic.
2301 // Note that the extension matching logic is tested by the extension system 2304 // Note that the extension matching logic is tested by the extension system
2302 // and does not need a separate test here. 2305 // and does not need a separate test here.
2303 TEST_F(ChromeLauncherControllerTest, V1AppMenuGeneration) { 2306 TEST_F(ChromeLauncherControllerImplTest, V1AppMenuGeneration) {
2304 EXPECT_EQ(1U, chrome::GetTotalBrowserCount()); 2307 EXPECT_EQ(1U, chrome::GetTotalBrowserCount());
2305 EXPECT_EQ(0, browser()->tab_strip_model()->count()); 2308 EXPECT_EQ(0, browser()->tab_strip_model()->count());
2306 2309
2307 InitLauncherControllerWithBrowser(); 2310 InitLauncherControllerWithBrowser();
2308 2311
2309 // Model should only contain the browser shortcut and app list items. 2312 // Model should only contain the browser shortcut and app list items.
2310 EXPECT_EQ(2, model_->item_count()); 2313 EXPECT_EQ(2, model_->item_count());
2311 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); 2314 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id()));
2312 2315
2313 // Installing |extension3_| adds it to the launcher. 2316 // Installing |extension3_| adds it to the launcher.
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2366 launcher_controller_->Close(item_gmail.id); 2369 launcher_controller_->Close(item_gmail.id);
2367 2370
2368 EXPECT_TRUE(CheckMenuCreation( 2371 EXPECT_TRUE(CheckMenuCreation(
2369 launcher_controller_.get(), item_gmail, 0, NULL, false)); 2372 launcher_controller_.get(), item_gmail, 0, NULL, false));
2370 base::string16 browser_menu_item2[] = { title2 }; 2373 base::string16 browser_menu_item2[] = { title2 };
2371 EXPECT_TRUE(CheckMenuCreation( 2374 EXPECT_TRUE(CheckMenuCreation(
2372 launcher_controller_.get(), item_browser, 1, browser_menu_item2, false)); 2375 launcher_controller_.get(), item_browser, 1, browser_menu_item2, false));
2373 } 2376 }
2374 2377
2375 // Check the multi profile case where only user related apps should show up. 2378 // Check the multi profile case where only user related apps should show up.
2376 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 2379 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
2377 V1AppMenuGenerationTwoUsers) { 2380 V1AppMenuGenerationTwoUsers) {
2378 // Create a browser item in the LauncherController. 2381 // Create a browser item in the LauncherController.
2379 InitLauncherController(); 2382 InitLauncherController();
2380 chrome::NewTab(browser()); 2383 chrome::NewTab(browser());
2381 2384
2382 // Installing |extension3_| adds it to the launcher. 2385 // Installing |extension3_| adds it to the launcher.
2383 ash::ShelfID gmail_id = model_->next_id(); 2386 ash::ShelfID gmail_id = model_->next_id();
2384 extension_service_->AddExtension(extension3_.get()); 2387 extension_service_->AddExtension(extension3_.get());
2385 EXPECT_EQ(3, model_->item_count()); 2388 EXPECT_EQ(3, model_->item_count());
2386 int gmail_index = model_->ItemIndexByID(gmail_id); 2389 int gmail_index = model_->ItemIndexByID(gmail_id);
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 browser()->window()->GetNativeWindow(), account_id2); 2429 browser()->window()->GetNativeWindow(), account_id2);
2427 2430
2428 EXPECT_TRUE(CheckMenuCreation( 2431 EXPECT_TRUE(CheckMenuCreation(
2429 launcher_controller_.get(), item_browser, 0, NULL, true)); 2432 launcher_controller_.get(), item_browser, 0, NULL, true));
2430 EXPECT_TRUE(CheckMenuCreation( 2433 EXPECT_TRUE(CheckMenuCreation(
2431 launcher_controller_.get(), item_gmail, 0, NULL, false)); 2434 launcher_controller_.get(), item_gmail, 0, NULL, false));
2432 } 2435 }
2433 2436
2434 // Check that V2 applications are creating items properly in the launcher when 2437 // Check that V2 applications are creating items properly in the launcher when
2435 // instantiated by the current user. 2438 // instantiated by the current user.
2436 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 2439 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
2437 V2AppHandlingTwoUsers) { 2440 V2AppHandlingTwoUsers) {
2438 InitLauncherController(); 2441 InitLauncherController();
2439 // Create a profile for our second user (will be destroyed by the framework). 2442 // Create a profile for our second user (will be destroyed by the framework).
2440 TestingProfile* profile2 = CreateMultiUserProfile("user2"); 2443 TestingProfile* profile2 = CreateMultiUserProfile("user2");
2441 const AccountId account_id( 2444 const AccountId account_id(
2442 multi_user_util::GetAccountIdFromProfile(profile())); 2445 multi_user_util::GetAccountIdFromProfile(profile()));
2443 const AccountId account_id2( 2446 const AccountId account_id2(
2444 multi_user_util::GetAccountIdFromProfile(profile2)); 2447 multi_user_util::GetAccountIdFromProfile(profile2));
2445 // Check that there is a browser and a app launcher. 2448 // Check that there is a browser and a app launcher.
2446 EXPECT_EQ(2, model_->item_count()); 2449 EXPECT_EQ(2, model_->item_count());
2447 2450
2448 // Add a v2 app. 2451 // Add a v2 app.
2449 V2App v2_app(profile(), extension1_.get()); 2452 V2App v2_app(profile(), extension1_.get());
2450 EXPECT_EQ(3, model_->item_count()); 2453 EXPECT_EQ(3, model_->item_count());
2451 2454
2452 // After switching users the item should go away. 2455 // After switching users the item should go away.
2453 SwitchActiveUser(account_id2); 2456 SwitchActiveUser(account_id2);
2454 EXPECT_EQ(2, model_->item_count()); 2457 EXPECT_EQ(2, model_->item_count());
2455 2458
2456 // And it should come back when switching back. 2459 // And it should come back when switching back.
2457 SwitchActiveUser(account_id); 2460 SwitchActiveUser(account_id);
2458 EXPECT_EQ(3, model_->item_count()); 2461 EXPECT_EQ(3, model_->item_count());
2459 } 2462 }
2460 2463
2461 // Check that V2 applications are creating items properly in edge cases: 2464 // Check that V2 applications are creating items properly in edge cases:
2462 // a background user creates a V2 app, gets active and inactive again and then 2465 // a background user creates a V2 app, gets active and inactive again and then
2463 // deletes the app. 2466 // deletes the app.
2464 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 2467 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
2465 V2AppHandlingTwoUsersEdgeCases) { 2468 V2AppHandlingTwoUsersEdgeCases) {
2466 InitLauncherController(); 2469 InitLauncherController();
2467 // Create a profile for our second user (will be destroyed by the framework). 2470 // Create a profile for our second user (will be destroyed by the framework).
2468 TestingProfile* profile2 = CreateMultiUserProfile("user2"); 2471 TestingProfile* profile2 = CreateMultiUserProfile("user2");
2469 const AccountId account_id( 2472 const AccountId account_id(
2470 multi_user_util::GetAccountIdFromProfile(profile())); 2473 multi_user_util::GetAccountIdFromProfile(profile()));
2471 const AccountId account_id2( 2474 const AccountId account_id2(
2472 multi_user_util::GetAccountIdFromProfile(profile2)); 2475 multi_user_util::GetAccountIdFromProfile(profile2));
2473 // Check that there is a browser and a app launcher. 2476 // Check that there is a browser and a app launcher.
2474 EXPECT_EQ(2, model_->item_count()); 2477 EXPECT_EQ(2, model_->item_count());
(...skipping 22 matching lines...) Expand all
2497 EXPECT_EQ(2, model_->item_count()); 2500 EXPECT_EQ(2, model_->item_count());
2498 2501
2499 // Switching then back to the default user should not show the additional item 2502 // Switching then back to the default user should not show the additional item
2500 // anymore. 2503 // anymore.
2501 SwitchActiveUser(account_id); 2504 SwitchActiveUser(account_id);
2502 EXPECT_EQ(2, model_->item_count()); 2505 EXPECT_EQ(2, model_->item_count());
2503 } 2506 }
2504 2507
2505 // Check that V2 applications will be made visible on the target desktop if 2508 // Check that V2 applications will be made visible on the target desktop if
2506 // another window of the same type got previously teleported there. 2509 // another window of the same type got previously teleported there.
2507 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 2510 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
2508 V2AppFollowsTeleportedWindow) { 2511 V2AppFollowsTeleportedWindow) {
2509 InitLauncherController(); 2512 InitLauncherController();
2510 chrome::MultiUserWindowManager* manager = 2513 chrome::MultiUserWindowManager* manager =
2511 chrome::MultiUserWindowManager::GetInstance(); 2514 chrome::MultiUserWindowManager::GetInstance();
2512 2515
2513 // Create and add three users / profiles, and go to #1's desktop. 2516 // Create and add three users / profiles, and go to #1's desktop.
2514 TestingProfile* profile1 = CreateMultiUserProfile("user-1"); 2517 TestingProfile* profile1 = CreateMultiUserProfile("user-1");
2515 TestingProfile* profile2 = CreateMultiUserProfile("user-2"); 2518 TestingProfile* profile2 = CreateMultiUserProfile("user-2");
2516 TestingProfile* profile3 = CreateMultiUserProfile("user-3"); 2519 TestingProfile* profile3 = CreateMultiUserProfile("user-3");
2517 const AccountId account_id1( 2520 const AccountId account_id1(
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
2568 SwitchActiveUser(account_id2); 2571 SwitchActiveUser(account_id2);
2569 v2_app_1.window()->Hide(); 2572 v2_app_1.window()->Hide();
2570 V2App v2_app_6(profile1, extension1_.get()); 2573 V2App v2_app_6(profile1, extension1_.get());
2571 EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible()); 2574 EXPECT_FALSE(v2_app_1.window()->GetNativeWindow()->IsVisible());
2572 EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible()); 2575 EXPECT_FALSE(v2_app_2.window()->GetNativeWindow()->IsVisible());
2573 EXPECT_TRUE(v2_app_6.window()->GetNativeWindow()->IsVisible()); 2576 EXPECT_TRUE(v2_app_6.window()->GetNativeWindow()->IsVisible());
2574 } 2577 }
2575 2578
2576 // Check that V2 applications hide correctly on the shelf when the app window 2579 // Check that V2 applications hide correctly on the shelf when the app window
2577 // is hidden. 2580 // is hidden.
2578 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerTest, 2581 TEST_F(MultiProfileMultiBrowserShelfLayoutChromeLauncherControllerImplTest,
2579 V2AppHiddenWindows) { 2582 V2AppHiddenWindows) {
2580 InitLauncherController(); 2583 InitLauncherController();
2581 2584
2582 TestingProfile* profile2 = CreateMultiUserProfile("user-2"); 2585 TestingProfile* profile2 = CreateMultiUserProfile("user-2");
2583 const AccountId account_id( 2586 const AccountId account_id(
2584 multi_user_util::GetAccountIdFromProfile(profile())); 2587 multi_user_util::GetAccountIdFromProfile(profile()));
2585 const AccountId account_id2( 2588 const AccountId account_id2(
2586 multi_user_util::GetAccountIdFromProfile(profile2)); 2589 multi_user_util::GetAccountIdFromProfile(profile2));
2587 SwitchActiveUser(account_id); 2590 SwitchActiveUser(account_id);
2588 EXPECT_EQ(2, model_->item_count()); 2591 EXPECT_EQ(2, model_->item_count());
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
2636 v2_app_2.window()->Show(extensions::AppWindow::SHOW_ACTIVE); 2639 v2_app_2.window()->Show(extensions::AppWindow::SHOW_ACTIVE);
2637 EXPECT_EQ(3, model_->item_count()); 2640 EXPECT_EQ(3, model_->item_count());
2638 2641
2639 v2_app_1.window()->Hide(); 2642 v2_app_1.window()->Hide();
2640 v2_app_2.window()->Hide(); 2643 v2_app_2.window()->Hide();
2641 EXPECT_EQ(2, model_->item_count()); 2644 EXPECT_EQ(2, model_->item_count());
2642 } 2645 }
2643 } 2646 }
2644 2647
2645 // Checks that the generated menu list properly activates items. 2648 // Checks that the generated menu list properly activates items.
2646 TEST_F(ChromeLauncherControllerTest, V1AppMenuExecution) { 2649 TEST_F(ChromeLauncherControllerImplTest, V1AppMenuExecution) {
2647 InitLauncherControllerWithBrowser(); 2650 InitLauncherControllerWithBrowser();
2648 2651
2649 // Add |extension3_| to the launcher and add two items. 2652 // Add |extension3_| to the launcher and add two items.
2650 GURL gmail = GURL("https://mail.google.com/mail/u"); 2653 GURL gmail = GURL("https://mail.google.com/mail/u");
2651 ash::ShelfID gmail_id = model_->next_id(); 2654 ash::ShelfID gmail_id = model_->next_id();
2652 extension_service_->AddExtension(extension3_.get()); 2655 extension_service_->AddExtension(extension3_.get());
2653 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); 2656 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
2654 base::string16 title1 = ASCIIToUTF16("Test1"); 2657 base::string16 title1 = ASCIIToUTF16("Test1");
2655 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); 2658 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
2656 chrome::NewTab(browser()); 2659 chrome::NewTab(browser());
(...skipping 30 matching lines...) Expand all
2687 launcher_controller_->GetApplicationList(item_gmail, 0))); 2690 launcher_controller_->GetApplicationList(item_gmail, 0)));
2688 int first_item = 2691 int first_item =
2689 (menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0; 2692 (menu->GetTypeAt(0) == ui::MenuModel::TYPE_SEPARATOR) ? 1 : 0;
2690 menu->ActivatedAt(first_item + 2); 2693 menu->ActivatedAt(first_item + 2);
2691 } 2694 }
2692 // Now the active tab should be the second item. 2695 // Now the active tab should be the second item.
2693 EXPECT_EQ(0, browser()->tab_strip_model()->active_index()); 2696 EXPECT_EQ(0, browser()->tab_strip_model()->active_index());
2694 } 2697 }
2695 2698
2696 // Checks that the generated menu list properly deletes items. 2699 // Checks that the generated menu list properly deletes items.
2697 TEST_F(ChromeLauncherControllerTest, V1AppMenuDeletionExecution) { 2700 TEST_F(ChromeLauncherControllerImplTest, V1AppMenuDeletionExecution) {
2698 InitLauncherControllerWithBrowser(); 2701 InitLauncherControllerWithBrowser();
2699 2702
2700 // Add |extension3_| to the launcher and add two items. 2703 // Add |extension3_| to the launcher and add two items.
2701 GURL gmail = GURL("https://mail.google.com/mail/u"); 2704 GURL gmail = GURL("https://mail.google.com/mail/u");
2702 ash::ShelfID gmail_id = model_->next_id(); 2705 ash::ShelfID gmail_id = model_->next_id();
2703 extension_service_->AddExtension(extension3_.get()); 2706 extension_service_->AddExtension(extension3_.get());
2704 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url)); 2707 launcher_controller_->SetRefocusURLPatternForTest(gmail_id, GURL(gmail_url));
2705 base::string16 title1 = ASCIIToUTF16("Test1"); 2708 base::string16 title1 = ASCIIToUTF16("Test1");
2706 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1); 2709 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title1);
2707 chrome::NewTab(browser()); 2710 chrome::NewTab(browser());
(...skipping 20 matching lines...) Expand all
2728 // Delete one tab through the menu item. 2731 // Delete one tab through the menu item.
2729 { 2732 {
2730 ChromeLauncherAppMenuItems items = 2733 ChromeLauncherAppMenuItems items =
2731 launcher_controller_->GetApplicationList(item_gmail, 0); 2734 launcher_controller_->GetApplicationList(item_gmail, 0);
2732 items[1]->Execute(ui::EF_SHIFT_DOWN); 2735 items[1]->Execute(ui::EF_SHIFT_DOWN);
2733 EXPECT_EQ(--tabs, browser()->tab_strip_model()->count()); 2736 EXPECT_EQ(--tabs, browser()->tab_strip_model()->count());
2734 } 2737 }
2735 } 2738 }
2736 2739
2737 // Tests that panels create launcher items correctly 2740 // Tests that panels create launcher items correctly
2738 TEST_F(ChromeLauncherControllerTest, AppPanels) { 2741 TEST_F(ChromeLauncherControllerImplTest, AppPanels) {
2739 InitLauncherControllerWithBrowser(); 2742 InitLauncherControllerWithBrowser();
2740 // App list and Browser shortcut ShelfItems are added. 2743 // App list and Browser shortcut ShelfItems are added.
2741 EXPECT_EQ(2, model_observer_->added()); 2744 EXPECT_EQ(2, model_observer_->added());
2742 EXPECT_EQ(1, model_observer_->changed()); 2745 EXPECT_EQ(1, model_observer_->changed());
2743 2746
2744 const std::string app_id = extension1_->id(); 2747 const std::string app_id = extension1_->id();
2745 // app_icon_loader is owned by ChromeLauncherController. 2748 // app_icon_loader is owned by ChromeLauncherControllerImpl.
2746 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl(); 2749 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl();
2747 app_icon_loader->AddSupportedApp(app_id); 2750 app_icon_loader->AddSupportedApp(app_id);
2748 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); 2751 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader));
2749 2752
2750 // Test adding an app panel 2753 // Test adding an app panel
2751 AppWindowLauncherItemController* app_panel_controller = 2754 AppWindowLauncherItemController* app_panel_controller =
2752 new ExtensionAppWindowLauncherItemController( 2755 new ExtensionAppWindowLauncherItemController(
2753 LauncherItemController::TYPE_APP_PANEL, "id", app_id, 2756 LauncherItemController::TYPE_APP_PANEL, "id", app_id,
2754 launcher_controller_.get()); 2757 launcher_controller_.get());
2755 ash::ShelfID shelf_id1 = launcher_controller_->CreateAppLauncherItem( 2758 ash::ShelfID shelf_id1 = launcher_controller_->CreateAppLauncherItem(
(...skipping 27 matching lines...) Expand all
2783 EXPECT_EQ(1, model_observer_->added()); 2786 EXPECT_EQ(1, model_observer_->added());
2784 model_observer_->clear_counts(); 2787 model_observer_->clear_counts();
2785 2788
2786 launcher_controller_->CloseLauncherItem(shelf_id2); 2789 launcher_controller_->CloseLauncherItem(shelf_id2);
2787 launcher_controller_->CloseLauncherItem(shelf_id1); 2790 launcher_controller_->CloseLauncherItem(shelf_id1);
2788 EXPECT_EQ(2, model_observer_->removed()); 2791 EXPECT_EQ(2, model_observer_->removed());
2789 } 2792 }
2790 2793
2791 // Tests that the Gmail extension matches more then the app itself claims with 2794 // Tests that the Gmail extension matches more then the app itself claims with
2792 // the manifest file. 2795 // the manifest file.
2793 TEST_F(ChromeLauncherControllerTest, GmailMatching) { 2796 TEST_F(ChromeLauncherControllerImplTest, GmailMatching) {
2794 InitLauncherControllerWithBrowser(); 2797 InitLauncherControllerWithBrowser();
2795 2798
2796 // Create a Gmail browser tab. 2799 // Create a Gmail browser tab.
2797 chrome::NewTab(browser()); 2800 chrome::NewTab(browser());
2798 base::string16 title = ASCIIToUTF16("Test"); 2801 base::string16 title = ASCIIToUTF16("Test");
2799 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title); 2802 NavigateAndCommitActiveTabWithTitle(browser(), GURL(gmail_url), title);
2800 content::WebContents* content = 2803 content::WebContents* content =
2801 browser()->tab_strip_model()->GetActiveWebContents(); 2804 browser()->tab_strip_model()->GetActiveWebContents();
2802 2805
2803 // Check that the launcher controller does not recognize the running app. 2806 // Check that the launcher controller does not recognize the running app.
(...skipping 11 matching lines...) Expand all
2815 EXPECT_TRUE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); 2818 EXPECT_TRUE(launcher_controller_->ContentCanBeHandledByGmailApp(content));
2816 2819
2817 // Check also that the app has detected that properly. 2820 // Check also that the app has detected that properly.
2818 ash::ShelfItem item_gmail; 2821 ash::ShelfItem item_gmail;
2819 item_gmail.type = ash::TYPE_APP_SHORTCUT; 2822 item_gmail.type = ash::TYPE_APP_SHORTCUT;
2820 item_gmail.id = gmail_id; 2823 item_gmail.id = gmail_id;
2821 EXPECT_EQ(2U, launcher_controller_->GetApplicationList(item_gmail, 0).size()); 2824 EXPECT_EQ(2U, launcher_controller_->GetApplicationList(item_gmail, 0).size());
2822 } 2825 }
2823 2826
2824 // Tests that the Gmail extension does not match the offline verison. 2827 // Tests that the Gmail extension does not match the offline verison.
2825 TEST_F(ChromeLauncherControllerTest, GmailOfflineMatching) { 2828 TEST_F(ChromeLauncherControllerImplTest, GmailOfflineMatching) {
2826 InitLauncherControllerWithBrowser(); 2829 InitLauncherControllerWithBrowser();
2827 2830
2828 // Create a Gmail browser tab. 2831 // Create a Gmail browser tab.
2829 chrome::NewTab(browser()); 2832 chrome::NewTab(browser());
2830 base::string16 title = ASCIIToUTF16("Test"); 2833 base::string16 title = ASCIIToUTF16("Test");
2831 NavigateAndCommitActiveTabWithTitle(browser(), 2834 NavigateAndCommitActiveTabWithTitle(browser(),
2832 GURL(offline_gmail_url), 2835 GURL(offline_gmail_url),
2833 title); 2836 title);
2834 content::WebContents* content = 2837 content::WebContents* content =
2835 browser()->tab_strip_model()->GetActiveWebContents(); 2838 browser()->tab_strip_model()->GetActiveWebContents();
2836 2839
2837 // Installing |extension3_| adds it to the launcher. 2840 // Installing |extension3_| adds it to the launcher.
2838 ash::ShelfID gmail_id = model_->next_id(); 2841 ash::ShelfID gmail_id = model_->next_id();
2839 extension_service_->AddExtension(extension3_.get()); 2842 extension_service_->AddExtension(extension3_.get());
2840 EXPECT_EQ(3, model_->item_count()); 2843 EXPECT_EQ(3, model_->item_count());
2841 int gmail_index = model_->ItemIndexByID(gmail_id); 2844 int gmail_index = model_->ItemIndexByID(gmail_id);
2842 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[gmail_index].type); 2845 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[gmail_index].type);
2843 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 2846 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
2844 2847
2845 // The content should not be able to be handled by the app. 2848 // The content should not be able to be handled by the app.
2846 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content)); 2849 EXPECT_FALSE(launcher_controller_->ContentCanBeHandledByGmailApp(content));
2847 } 2850 }
2848 2851
2849 // Verify that the launcher item positions are persisted and restored. 2852 // Verify that the launcher item positions are persisted and restored.
2850 TEST_F(ChromeLauncherControllerTest, PersistLauncherItemPositions) { 2853 TEST_F(ChromeLauncherControllerImplTest, PersistLauncherItemPositions) {
2851 InitLauncherController(); 2854 InitLauncherController();
2852 2855
2853 TestLauncherControllerHelper* helper = new TestLauncherControllerHelper; 2856 TestLauncherControllerHelper* helper = new TestLauncherControllerHelper;
2854 SetLauncherControllerHelper(helper); 2857 SetLauncherControllerHelper(helper);
2855 2858
2856 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); 2859 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type);
2857 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[1].type); 2860 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[1].type);
2858 2861
2859 TabStripModel* tab_strip_model = browser()->tab_strip_model(); 2862 TabStripModel* tab_strip_model = browser()->tab_strip_model();
2860 EXPECT_EQ(0, tab_strip_model->count()); 2863 EXPECT_EQ(0, tab_strip_model->count());
(...skipping 26 matching lines...) Expand all
2887 delete item_delegate_manager_; 2890 delete item_delegate_manager_;
2888 } else { 2891 } else {
2889 // Clear already registered ShelfItemDelegate. 2892 // Clear already registered ShelfItemDelegate.
2890 ash::test::ShelfItemDelegateManagerTestAPI test(item_delegate_manager_); 2893 ash::test::ShelfItemDelegateManagerTestAPI test(item_delegate_manager_);
2891 test.RemoveAllShelfItemDelegateForTest(); 2894 test.RemoveAllShelfItemDelegateForTest();
2892 } 2895 }
2893 model_.reset(new ash::ShelfModel); 2896 model_.reset(new ash::ShelfModel);
2894 2897
2895 AddAppListLauncherItem(); 2898 AddAppListLauncherItem();
2896 launcher_controller_.reset( 2899 launcher_controller_.reset(
2897 ChromeLauncherController::CreateInstance(profile(), model_.get())); 2900 ChromeLauncherControllerImpl::CreateInstance(profile(), model_.get()));
2898 helper = new TestLauncherControllerHelper; 2901 helper = new TestLauncherControllerHelper;
2899 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); 2902 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1");
2900 helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2"); 2903 helper->SetAppID(tab_strip_model->GetWebContentsAt(1), "2");
2901 SetLauncherControllerHelper(helper); 2904 SetLauncherControllerHelper(helper);
2902 if (!ash::Shell::HasInstance()) { 2905 if (!ash::Shell::HasInstance()) {
2903 item_delegate_manager_ = new ash::ShelfItemDelegateManager(model_.get()); 2906 item_delegate_manager_ = new ash::ShelfItemDelegateManager(model_.get());
2904 SetShelfItemDelegateManager(item_delegate_manager_); 2907 SetShelfItemDelegateManager(item_delegate_manager_);
2905 } 2908 }
2906 launcher_controller_->Init(); 2909 launcher_controller_->Init();
2907 2910
2908 // Check ShelfItems are restored after resetting ChromeLauncherController. 2911 // Check ShelfItems are restored after resetting ChromeLauncherControllerImpl.
2909 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type); 2912 EXPECT_EQ(ash::TYPE_APP_LIST, model_->items()[0].type);
2910 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type); 2913 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[1].type);
2911 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); 2914 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type);
2912 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type); 2915 EXPECT_EQ(ash::TYPE_BROWSER_SHORTCUT, model_->items()[3].type);
2913 } 2916 }
2914 2917
2915 // Verifies pinned apps are persisted and restored. 2918 // Verifies pinned apps are persisted and restored.
2916 TEST_F(ChromeLauncherControllerTest, PersistPinned) { 2919 TEST_F(ChromeLauncherControllerImplTest, PersistPinned) {
2917 InitLauncherControllerWithBrowser(); 2920 InitLauncherControllerWithBrowser();
2918 size_t initial_size = model_->items().size(); 2921 size_t initial_size = model_->items().size();
2919 2922
2920 TabStripModel* tab_strip_model = browser()->tab_strip_model(); 2923 TabStripModel* tab_strip_model = browser()->tab_strip_model();
2921 EXPECT_EQ(1, tab_strip_model->count()); 2924 EXPECT_EQ(1, tab_strip_model->count());
2922 2925
2923 TestLauncherControllerHelper* helper = new TestLauncherControllerHelper; 2926 TestLauncherControllerHelper* helper = new TestLauncherControllerHelper;
2924 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); 2927 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1");
2925 SetLauncherControllerHelper(helper); 2928 SetLauncherControllerHelper(helper);
2926 2929
2927 // app_icon_loader is owned by ChromeLauncherController. 2930 // app_icon_loader is owned by ChromeLauncherControllerImpl.
2928 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl; 2931 TestAppIconLoaderImpl* app_icon_loader = new TestAppIconLoaderImpl;
2929 app_icon_loader->AddSupportedApp("1"); 2932 app_icon_loader->AddSupportedApp("1");
2930 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); 2933 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader));
2931 EXPECT_EQ(0, app_icon_loader->fetch_count()); 2934 EXPECT_EQ(0, app_icon_loader->fetch_count());
2932 2935
2933 launcher_controller_->PinAppWithID("1"); 2936 launcher_controller_->PinAppWithID("1");
2934 ash::ShelfID id = launcher_controller_->GetShelfIDForAppID("1"); 2937 ash::ShelfID id = launcher_controller_->GetShelfIDForAppID("1");
2935 int app_index = model_->ItemIndexByID(id); 2938 int app_index = model_->ItemIndexByID(id);
2936 EXPECT_EQ(1, app_icon_loader->fetch_count()); 2939 EXPECT_EQ(1, app_icon_loader->fetch_count());
2937 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); 2940 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type);
2938 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); 2941 EXPECT_TRUE(launcher_controller_->IsAppPinned("1"));
2939 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); 2942 EXPECT_FALSE(launcher_controller_->IsAppPinned("0"));
2940 EXPECT_EQ(initial_size + 1, model_->items().size()); 2943 EXPECT_EQ(initial_size + 1, model_->items().size());
2941 2944
2942 SetShelfItemDelegateManager(nullptr); 2945 SetShelfItemDelegateManager(nullptr);
2943 launcher_controller_.reset(); 2946 launcher_controller_.reset();
2944 if (!ash::Shell::HasInstance()) { 2947 if (!ash::Shell::HasInstance()) {
2945 delete item_delegate_manager_; 2948 delete item_delegate_manager_;
2946 } else { 2949 } else {
2947 // Clear already registered ShelfItemDelegate. 2950 // Clear already registered ShelfItemDelegate.
2948 ash::test::ShelfItemDelegateManagerTestAPI test(item_delegate_manager_); 2951 ash::test::ShelfItemDelegateManagerTestAPI test(item_delegate_manager_);
2949 test.RemoveAllShelfItemDelegateForTest(); 2952 test.RemoveAllShelfItemDelegateForTest();
2950 } 2953 }
2951 model_.reset(new ash::ShelfModel); 2954 model_.reset(new ash::ShelfModel);
2952 2955
2953 AddAppListLauncherItem(); 2956 AddAppListLauncherItem();
2954 launcher_controller_.reset( 2957 launcher_controller_.reset(
2955 ChromeLauncherController::CreateInstance(profile(), model_.get())); 2958 ChromeLauncherControllerImpl::CreateInstance(profile(), model_.get()));
2956 helper = new TestLauncherControllerHelper; 2959 helper = new TestLauncherControllerHelper;
2957 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); 2960 helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1");
2958 SetLauncherControllerHelper(helper); 2961 SetLauncherControllerHelper(helper);
2959 // app_icon_loader is owned by ChromeLauncherController. 2962 // app_icon_loader is owned by ChromeLauncherControllerImpl.
2960 app_icon_loader = new TestAppIconLoaderImpl; 2963 app_icon_loader = new TestAppIconLoaderImpl;
2961 app_icon_loader->AddSupportedApp("1"); 2964 app_icon_loader->AddSupportedApp("1");
2962 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader)); 2965 SetAppIconLoader(std::unique_ptr<AppIconLoader>(app_icon_loader));
2963 if (!ash::Shell::HasInstance()) { 2966 if (!ash::Shell::HasInstance()) {
2964 item_delegate_manager_ = new ash::ShelfItemDelegateManager(model_.get()); 2967 item_delegate_manager_ = new ash::ShelfItemDelegateManager(model_.get());
2965 SetShelfItemDelegateManager(item_delegate_manager_); 2968 SetShelfItemDelegateManager(item_delegate_manager_);
2966 } 2969 }
2967 launcher_controller_->Init(); 2970 launcher_controller_->Init();
2968 2971
2969 EXPECT_EQ(1, app_icon_loader->fetch_count()); 2972 EXPECT_EQ(1, app_icon_loader->fetch_count());
2970 ASSERT_EQ(initial_size + 1, model_->items().size()); 2973 ASSERT_EQ(initial_size + 1, model_->items().size());
2971 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); 2974 EXPECT_TRUE(launcher_controller_->IsAppPinned("1"));
2972 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); 2975 EXPECT_FALSE(launcher_controller_->IsAppPinned("0"));
2973 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); 2976 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type);
2974 2977
2975 launcher_controller_->UnpinAppWithID("1"); 2978 launcher_controller_->UnpinAppWithID("1");
2976 ASSERT_EQ(initial_size, model_->items().size()); 2979 ASSERT_EQ(initial_size, model_->items().size());
2977 } 2980 }
2978 2981
2979 TEST_F(ChromeLauncherControllerTest, MultipleAppIconLoaders) { 2982 TEST_F(ChromeLauncherControllerImplTest, MultipleAppIconLoaders) {
2980 InitLauncherControllerWithBrowser(); 2983 InitLauncherControllerWithBrowser();
2981 2984
2982 const std::string app_id1 = extension1_->id(); 2985 const std::string app_id1 = extension1_->id();
2983 const std::string app_id2 = extension2_->id(); 2986 const std::string app_id2 = extension2_->id();
2984 const std::string app_id3 = extension3_->id(); 2987 const std::string app_id3 = extension3_->id();
2985 // app_icon_loader1 and app_icon_loader2 are owned by 2988 // app_icon_loader1 and app_icon_loader2 are owned by
2986 // ChromeLauncherController. 2989 // ChromeLauncherControllerImpl.
2987 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl(); 2990 TestAppIconLoaderImpl* app_icon_loader1 = new TestAppIconLoaderImpl();
2988 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl(); 2991 TestAppIconLoaderImpl* app_icon_loader2 = new TestAppIconLoaderImpl();
2989 app_icon_loader1->AddSupportedApp(app_id1); 2992 app_icon_loader1->AddSupportedApp(app_id1);
2990 app_icon_loader2->AddSupportedApp(app_id2); 2993 app_icon_loader2->AddSupportedApp(app_id2);
2991 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1), 2994 SetAppIconLoaders(std::unique_ptr<AppIconLoader>(app_icon_loader1),
2992 std::unique_ptr<AppIconLoader>(app_icon_loader2)); 2995 std::unique_ptr<AppIconLoader>(app_icon_loader2));
2993 2996
2994 AppWindowLauncherItemController* app_panel_controller3 = 2997 AppWindowLauncherItemController* app_panel_controller3 =
2995 new ExtensionAppWindowLauncherItemController( 2998 new ExtensionAppWindowLauncherItemController(
2996 LauncherItemController::TYPE_APP_PANEL, "id", app_id3, 2999 LauncherItemController::TYPE_APP_PANEL, "id", app_id3,
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
3038 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3041 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3039 EXPECT_EQ(1, app_icon_loader2->clear_count()); 3042 EXPECT_EQ(1, app_icon_loader2->clear_count());
3040 3043
3041 launcher_controller_->CloseLauncherItem(shelfId3); 3044 launcher_controller_->CloseLauncherItem(shelfId3);
3042 EXPECT_EQ(1, app_icon_loader1->fetch_count()); 3045 EXPECT_EQ(1, app_icon_loader1->fetch_count());
3043 EXPECT_EQ(1, app_icon_loader1->clear_count()); 3046 EXPECT_EQ(1, app_icon_loader1->clear_count());
3044 EXPECT_EQ(1, app_icon_loader2->fetch_count()); 3047 EXPECT_EQ(1, app_icon_loader2->fetch_count());
3045 EXPECT_EQ(1, app_icon_loader2->clear_count()); 3048 EXPECT_EQ(1, app_icon_loader2->clear_count());
3046 } 3049 }
3047 3050
3048 TEST_F(ChromeLauncherControllerTest, ArcAppPinPolicy) { 3051 TEST_F(ChromeLauncherControllerImplTest, ArcAppPinPolicy) {
3049 arc_test_.SetUp(profile()); 3052 arc_test_.SetUp(profile());
3050 InitLauncherControllerWithBrowser(); 3053 InitLauncherControllerWithBrowser();
3051 3054
3052 arc::mojom::AppInfo appinfo; 3055 arc::mojom::AppInfo appinfo;
3053 appinfo.name = "Some App"; 3056 appinfo.name = "Some App";
3054 appinfo.activity = "SomeActivity"; 3057 appinfo.activity = "SomeActivity";
3055 appinfo.package_name = "com.example.app"; 3058 appinfo.package_name = "com.example.app";
3056 3059
3057 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); 3060 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs();
3058 ASSERT_TRUE(prefs); 3061 ASSERT_TRUE(prefs);
3059 3062
3060 // Adding app to the prefs, and check that the app is accessible by id. 3063 // Adding app to the prefs, and check that the app is accessible by id.
3061 prefs->AddApp(appinfo); 3064 prefs->AddApp(appinfo);
3062 const std::string app_id = 3065 const std::string app_id =
3063 ArcAppListPrefs::GetAppId(appinfo.package_name, appinfo.activity); 3066 ArcAppListPrefs::GetAppId(appinfo.package_name, appinfo.activity);
3064 EXPECT_TRUE(prefs->GetApp(app_id)); 3067 EXPECT_TRUE(prefs->GetApp(app_id));
3065 3068
3066 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app 3069 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app
3067 // package_name (not hash) specified as id. In this test we check that 3070 // package_name (not hash) specified as id. In this test we check that
3068 // by hash we can determine that appropriate package was set by policy. 3071 // by hash we can determine that appropriate package was set by policy.
3069 base::ListValue policy_value; 3072 base::ListValue policy_value;
3070 InsertPrefValue(&policy_value, 0, appinfo.package_name); 3073 InsertPrefValue(&policy_value, 0, appinfo.package_name);
3071 profile()->GetTestingPrefService()->SetManagedPref( 3074 profile()->GetTestingPrefService()->SetManagedPref(
3072 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy()); 3075 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy());
3073 3076
3074 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); 3077 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id));
3075 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, 3078 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED,
3076 launcher_controller_->GetPinnable(app_id)); 3079 launcher_controller_->GetPinnable(app_id));
3077 } 3080 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698