Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" | 5 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 } | 170 } |
| 171 | 171 |
| 172 private: | 172 private: |
| 173 typedef std::map<content::WebContents*, std::string> TabToStringMap; | 173 typedef std::map<content::WebContents*, std::string> TabToStringMap; |
| 174 | 174 |
| 175 TabToStringMap tab_id_map_; | 175 TabToStringMap tab_id_map_; |
| 176 | 176 |
| 177 DISALLOW_COPY_AND_ASSIGN(TestAppTabHelperImpl); | 177 DISALLOW_COPY_AND_ASSIGN(TestAppTabHelperImpl); |
| 178 }; | 178 }; |
| 179 | 179 |
| 180 // Test implementation of a V2 app launcher item controller. | |
| 181 class TestV2AppLauncherItemController : public LauncherItemController { | |
| 182 public: | |
| 183 TestV2AppLauncherItemController(const std::string& app_id, | |
| 184 ChromeLauncherController* controller) | |
| 185 : LauncherItemController(LauncherItemController::TYPE_APP, | |
| 186 app_id, | |
| 187 controller) { | |
| 188 } | |
| 189 | |
| 190 virtual ~TestV2AppLauncherItemController() {} | |
| 191 | |
| 192 // Override for LauncherItemController: | |
| 193 virtual string16 GetTitle() OVERRIDE; | |
| 194 virtual bool IsCurrentlyShownInWindow(aura::Window* window) const OVERRIDE; | |
| 195 virtual bool IsOpen() const OVERRIDE; | |
| 196 virtual bool IsVisible() const OVERRIDE; | |
| 197 virtual void Launch(int event_flags) OVERRIDE; | |
| 198 virtual void Activate() OVERRIDE; | |
| 199 virtual void Close() OVERRIDE; | |
| 200 virtual void Clicked(const ui::Event& event) OVERRIDE; | |
| 201 virtual void OnRemoved() OVERRIDE; | |
| 202 virtual ChromeLauncherAppMenuItems GetApplicationList( | |
| 203 int event_flags) OVERRIDE; | |
| 204 | |
| 205 private: | |
| 206 | |
| 207 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController); | |
| 208 }; | |
| 209 | |
| 210 string16 TestV2AppLauncherItemController::GetTitle() { return string16(); } | |
| 211 bool TestV2AppLauncherItemController::IsCurrentlyShownInWindow( | |
| 212 aura::Window* window) const { return true; } | |
| 213 bool TestV2AppLauncherItemController::IsOpen() const { return true; } | |
| 214 bool TestV2AppLauncherItemController::IsVisible() const { return true; } | |
| 215 void TestV2AppLauncherItemController::Launch(int event_flags) {} | |
| 216 void TestV2AppLauncherItemController::Activate() {} | |
| 217 void TestV2AppLauncherItemController::Close() {} | |
| 218 void TestV2AppLauncherItemController::Clicked(const ui::Event& event) {} | |
| 219 void TestV2AppLauncherItemController::OnRemoved() {} | |
| 220 ChromeLauncherAppMenuItems TestV2AppLauncherItemController::GetApplicationList( | |
| 221 int event_flags) { | |
| 222 ChromeLauncherAppMenuItems items; | |
| 223 items.push_back(new ChromeLauncherAppMenuItem(string16(), NULL, false)); | |
| 224 items.push_back(new ChromeLauncherAppMenuItem(string16(), NULL, false)); | |
| 225 return items.Pass(); | |
|
oshima
2013/09/19 21:43:25
can you just inline them?
Mr4D (OOO till 08-26)
2013/09/19 22:31:50
Done.
| |
| 226 } | |
| 227 | |
| 180 } // namespace | 228 } // namespace |
| 181 | 229 |
| 182 class ChromeLauncherControllerTest : public BrowserWithTestWindowTest { | 230 class ChromeLauncherControllerTest : public BrowserWithTestWindowTest { |
| 183 protected: | 231 protected: |
| 184 ChromeLauncherControllerTest() : extension_service_(NULL) { | 232 ChromeLauncherControllerTest() : extension_service_(NULL) { |
| 185 SetHostDesktopType(chrome::HOST_DESKTOP_TYPE_ASH); | 233 SetHostDesktopType(chrome::HOST_DESKTOP_TYPE_ASH); |
| 186 } | 234 } |
| 187 | 235 |
| 188 virtual ~ChromeLauncherControllerTest() { | 236 virtual ~ChromeLauncherControllerTest() { |
| 189 } | 237 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 239 &error); | 287 &error); |
| 240 | 288 |
| 241 // Fake search extension. | 289 // Fake search extension. |
| 242 extension4_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 290 extension4_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 243 manifest, | 291 manifest, |
| 244 Extension::NO_FLAGS, | 292 Extension::NO_FLAGS, |
| 245 extension_misc::kGoogleSearchAppId, | 293 extension_misc::kGoogleSearchAppId, |
| 246 &error); | 294 &error); |
| 247 } | 295 } |
| 248 | 296 |
| 297 // Creates a running V2 app (not pinned) of type |app_id|. | |
| 298 virtual void CreateRunningV2App(const std::string& app_id) { | |
| 299 ash::LauncherID id = | |
| 300 launcher_controller_->CreateAppShortcutLauncherItemWithType( | |
| 301 app_id, | |
| 302 model_->item_count(), | |
| 303 ash::TYPE_PLATFORM_APP); | |
| 304 DCHECK(id); | |
| 305 // Change the created launcher controller into a V2 app controller. | |
| 306 launcher_controller_->SetItemController(id, | |
| 307 new TestV2AppLauncherItemController(app_id, | |
| 308 launcher_controller_.get())); | |
| 309 } | |
| 310 | |
| 249 virtual void TearDown() OVERRIDE { | 311 virtual void TearDown() OVERRIDE { |
| 250 model_->RemoveObserver(model_observer_.get()); | 312 model_->RemoveObserver(model_observer_.get()); |
| 251 model_observer_.reset(); | 313 model_observer_.reset(); |
| 252 launcher_controller_.reset(); | 314 launcher_controller_.reset(); |
| 253 model_.reset(); | 315 model_.reset(); |
| 254 | 316 |
| 255 BrowserWithTestWindowTest::TearDown(); | 317 BrowserWithTestWindowTest::TearDown(); |
| 256 } | 318 } |
| 257 | 319 |
| 258 void AddAppListLauncherItem() { | 320 void AddAppListLauncherItem() { |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 iter != model_->items().end(); ++iter) { | 360 iter != model_->items().end(); ++iter) { |
| 299 ChromeLauncherController::IDToItemControllerMap::const_iterator | 361 ChromeLauncherController::IDToItemControllerMap::const_iterator |
| 300 entry(controller->id_to_item_controller_map_.find(iter->id)); | 362 entry(controller->id_to_item_controller_map_.find(iter->id)); |
| 301 if (iter->type == ash::TYPE_APP_SHORTCUT && | 363 if (iter->type == ash::TYPE_APP_SHORTCUT && |
| 302 entry != controller->id_to_item_controller_map_.end()) { | 364 entry != controller->id_to_item_controller_map_.end()) { |
| 303 launchers->push_back(entry->second->app_id()); | 365 launchers->push_back(entry->second->app_id()); |
| 304 } | 366 } |
| 305 } | 367 } |
| 306 } | 368 } |
| 307 | 369 |
| 370 // Get the setup of the currently shown launcher items in one string. | |
| 371 // Each pinned element will start with a big letter, each running but not | |
| 372 // pinned V1 app will start with a small letter and each running but not | |
| 373 // pinned V2 app will start with a '*' + small letter. | |
| 308 std::string GetPinnedAppStatus() { | 374 std::string GetPinnedAppStatus() { |
| 309 std::string result; | 375 std::string result; |
| 310 for (int i = 0; i < model_->item_count(); i++) { | 376 for (int i = 0; i < model_->item_count(); i++) { |
| 311 switch (model_->items()[i].type) { | 377 switch (model_->items()[i].type) { |
| 378 case ash::TYPE_PLATFORM_APP: | |
| 379 result+= "*"; | |
| 380 // FALLTHROUGH | |
| 381 case ash::TYPE_WINDOWED_APP: { | |
| 382 const std::string& app = | |
| 383 launcher_controller_->GetAppIDForLauncherID( | |
| 384 model_->items()[i].id); | |
| 385 if (app == extension1_->id()) { | |
| 386 result += "app1, "; | |
| 387 EXPECT_FALSE( | |
| 388 launcher_controller_->IsAppPinned(extension1_->id())); | |
| 389 } else if (app == extension2_->id()) { | |
| 390 result += "app2, "; | |
| 391 EXPECT_FALSE( | |
| 392 launcher_controller_->IsAppPinned(extension2_->id())); | |
| 393 } else if (app == extension3_->id()) { | |
| 394 result += "app3, "; | |
| 395 EXPECT_FALSE( | |
| 396 launcher_controller_->IsAppPinned(extension3_->id())); | |
| 397 } else if (app == extension4_->id()) { | |
| 398 result += "app4, "; | |
| 399 EXPECT_FALSE( | |
| 400 launcher_controller_->IsAppPinned(extension4_->id())); | |
| 401 } else { | |
| 402 result += "unknown, "; | |
| 403 } | |
| 404 break; | |
| 405 } | |
| 312 case ash::TYPE_APP_SHORTCUT: { | 406 case ash::TYPE_APP_SHORTCUT: { |
| 313 const std::string& app = | 407 const std::string& app = |
| 314 launcher_controller_->GetAppIDForLauncherID( | 408 launcher_controller_->GetAppIDForLauncherID( |
| 315 model_->items()[i].id); | 409 model_->items()[i].id); |
| 316 if (app == extension1_->id()) { | 410 if (app == extension1_->id()) { |
| 317 result += "App1, "; | 411 result += "App1, "; |
| 318 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 412 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 319 } else if (app == extension2_->id()) { | 413 } else if (app == extension2_->id()) { |
| 320 result += "App2, "; | 414 result += "App2, "; |
| 321 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 415 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 340 result += "Unknown"; | 434 result += "Unknown"; |
| 341 break; | 435 break; |
| 342 } | 436 } |
| 343 } | 437 } |
| 344 return result; | 438 return result; |
| 345 } | 439 } |
| 346 | 440 |
| 347 // Set the index at which the chrome icon should be. | 441 // Set the index at which the chrome icon should be. |
| 348 void SetShelfChromeIconIndex(int index) { | 442 void SetShelfChromeIconIndex(int index) { |
| 349 profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, | 443 profile()->GetTestingPrefService()->SetInteger(prefs::kShelfChromeIconIndex, |
| 350 index + 1); | 444 index); |
| 351 } | 445 } |
| 352 | 446 |
| 353 // Needed for extension service & friends to work. | 447 // Needed for extension service & friends to work. |
| 354 scoped_refptr<Extension> extension1_; | 448 scoped_refptr<Extension> extension1_; |
| 355 scoped_refptr<Extension> extension2_; | 449 scoped_refptr<Extension> extension2_; |
| 356 scoped_refptr<Extension> extension3_; | 450 scoped_refptr<Extension> extension3_; |
| 357 scoped_refptr<Extension> extension4_; | 451 scoped_refptr<Extension> extension4_; |
| 358 scoped_ptr<ChromeLauncherController> launcher_controller_; | 452 scoped_ptr<ChromeLauncherController> launcher_controller_; |
| 359 scoped_ptr<TestLauncherModelObserver> model_observer_; | 453 scoped_ptr<TestLauncherModelObserver> model_observer_; |
| 360 scoped_ptr<ash::LauncherModel> model_; | 454 scoped_ptr<ash::LauncherModel> model_; |
| (...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 780 EXPECT_EQ(2, model_->item_count()); | 874 EXPECT_EQ(2, model_->item_count()); |
| 781 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 875 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 782 EXPECT_FALSE( | 876 EXPECT_FALSE( |
| 783 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 877 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 784 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 878 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 785 EXPECT_FALSE( | 879 EXPECT_FALSE( |
| 786 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); | 880 launcher_controller_->IsWindowedAppInLauncher(extension2_->id())); |
| 787 } | 881 } |
| 788 | 882 |
| 789 // Check that multiple locks of an application will be properly handled. | 883 // Check that multiple locks of an application will be properly handled. |
| 790 TEST_F(ChromeLauncherControllerTest, CheckMukltiLockApps) { | 884 TEST_F(ChromeLauncherControllerTest, CheckMultiLockApps) { |
| 791 InitLauncherController(); | 885 InitLauncherController(); |
| 792 // Model should only contain the browser shortcut and app list items. | 886 // Model should only contain the browser shortcut and app list items. |
| 793 EXPECT_EQ(2, model_->item_count()); | 887 EXPECT_EQ(2, model_->item_count()); |
| 794 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 888 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 795 EXPECT_FALSE( | 889 EXPECT_FALSE( |
| 796 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 890 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 797 | 891 |
| 798 for (int i = 0; i < 2; i++) { | 892 for (int i = 0; i < 2; i++) { |
| 799 launcher_controller_->LockV1AppWithID(extension1_->id()); | 893 launcher_controller_->LockV1AppWithID(extension1_->id()); |
| 800 | 894 |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 930 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); | 1024 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[2].type); |
| 931 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1025 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 932 EXPECT_FALSE( | 1026 EXPECT_FALSE( |
| 933 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); | 1027 launcher_controller_->IsWindowedAppInLauncher(extension1_->id())); |
| 934 | 1028 |
| 935 launcher_controller_->UnpinAppWithID(extension1_->id()); | 1029 launcher_controller_->UnpinAppWithID(extension1_->id()); |
| 936 | 1030 |
| 937 EXPECT_EQ(2, model_->item_count()); | 1031 EXPECT_EQ(2, model_->item_count()); |
| 938 } | 1032 } |
| 939 | 1033 |
| 1034 // Check that a locked (windowed V1 application) will be properly converted | |
| 1035 // between locked and pinned when the order gets changed through a profile / | |
| 1036 // policy change. | |
| 1037 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAndLockedAppsResyncOrder) { | |
| 1038 InitLauncherController(); | |
| 1039 base::ListValue policy_value0; | |
| 1040 InsertPrefValue(&policy_value0, 0, extension1_->id()); | |
| 1041 InsertPrefValue(&policy_value0, 1, extension3_->id()); | |
| 1042 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | |
| 1043 policy_value0.DeepCopy()); | |
| 1044 // The shelf layout has always one static item at the beginning (App List). | |
| 1045 SetShelfChromeIconIndex(0); | |
| 1046 extension_service_->AddExtension(extension1_.get()); | |
| 1047 EXPECT_EQ("AppList, Chrome, App1, ", GetPinnedAppStatus()); | |
| 1048 extension_service_->AddExtension(extension2_.get()); | |
| 1049 // No new app icon will be generated. | |
| 1050 EXPECT_EQ("AppList, Chrome, App1, ", GetPinnedAppStatus()); | |
| 1051 // Add the app as locked app which will add it (un-pinned). | |
| 1052 launcher_controller_->LockV1AppWithID(extension2_->id()); | |
| 1053 EXPECT_EQ("AppList, Chrome, App1, app2, ", GetPinnedAppStatus()); | |
| 1054 extension_service_->AddExtension(extension3_.get()); | |
| 1055 EXPECT_EQ("AppList, Chrome, App1, App3, app2, ", GetPinnedAppStatus()); | |
| 1056 | |
| 1057 // Now request to pin all items which should convert the locked item into a | |
| 1058 // pinned item. | |
| 1059 base::ListValue policy_value1; | |
| 1060 InsertPrefValue(&policy_value1, 0, extension3_->id()); | |
| 1061 InsertPrefValue(&policy_value1, 1, extension2_->id()); | |
| 1062 InsertPrefValue(&policy_value1, 2, extension1_->id()); | |
| 1063 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | |
| 1064 policy_value1.DeepCopy()); | |
| 1065 EXPECT_EQ("AppList, Chrome, App3, App2, App1, ", GetPinnedAppStatus()); | |
| 1066 | |
| 1067 // Going back to a status where there is no requirement for app 2 to be pinned | |
| 1068 // should convert it back to locked but not pinned and state. The position | |
| 1069 // is determined by the |LauncherModel|'s weight system. Since at the moment | |
| 1070 // the weight of a running app has the same as a shortcut, it will remain | |
| 1071 // where it is. Surely note ideal, but since the sync process can shift around | |
| 1072 // locations - as well as many other edge cases - this gets nearly impossible | |
| 1073 // to get right. | |
| 1074 // TODO(skuhne): Filed crbug.com/293761 to track of this. | |
| 1075 base::ListValue policy_value2; | |
| 1076 InsertPrefValue(&policy_value2, 0, extension3_->id()); | |
| 1077 InsertPrefValue(&policy_value2, 1, extension1_->id()); | |
| 1078 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | |
| 1079 policy_value2.DeepCopy()); | |
| 1080 EXPECT_EQ("AppList, Chrome, App3, app2, App1, ", GetPinnedAppStatus()); | |
| 1081 | |
| 1082 // Removing an item should simply close it and everything should shift. | |
| 1083 base::ListValue policy_value3; | |
| 1084 InsertPrefValue(&policy_value3, 0, extension3_->id()); | |
| 1085 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | |
| 1086 policy_value3.DeepCopy()); | |
| 1087 EXPECT_EQ("AppList, Chrome, App3, app2, ", GetPinnedAppStatus()); | |
| 1088 } | |
| 1089 | |
| 1090 // Check that a running and not pinned V2 application will be properly converted | |
| 1091 // between locked and pinned when the order gets changed through a profile / | |
| 1092 // policy change. | |
| 1093 TEST_F(ChromeLauncherControllerTest, | |
| 1094 RestoreDefaultAndRunningV2AppsResyncOrder) { | |
| 1095 InitLauncherController(); | |
| 1096 base::ListValue policy_value0; | |
| 1097 InsertPrefValue(&policy_value0, 0, extension1_->id()); | |
| 1098 InsertPrefValue(&policy_value0, 1, extension3_->id()); | |
| 1099 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | |
| 1100 policy_value0.DeepCopy()); | |
| 1101 // The shelf layout has always one static item at the beginning (app List). | |
| 1102 SetShelfChromeIconIndex(0); | |
| 1103 extension_service_->AddExtension(extension1_.get()); | |
| 1104 EXPECT_EQ("AppList, Chrome, App1, ", GetPinnedAppStatus()); | |
| 1105 extension_service_->AddExtension(extension2_.get()); | |
| 1106 // No new app icon will be generated. | |
| 1107 EXPECT_EQ("AppList, Chrome, App1, ", GetPinnedAppStatus()); | |
| 1108 // Add the app as an unpinned but running V2 app. | |
| 1109 CreateRunningV2App(extension2_->id()); | |
| 1110 EXPECT_EQ("AppList, Chrome, App1, *app2, ", GetPinnedAppStatus()); | |
| 1111 extension_service_->AddExtension(extension3_.get()); | |
| 1112 EXPECT_EQ("AppList, Chrome, App1, App3, *app2, ", GetPinnedAppStatus()); | |
| 1113 | |
| 1114 // Now request to pin all items which should convert the locked item into a | |
| 1115 // pinned item. | |
| 1116 base::ListValue policy_value1; | |
| 1117 InsertPrefValue(&policy_value1, 0, extension3_->id()); | |
| 1118 InsertPrefValue(&policy_value1, 1, extension2_->id()); | |
| 1119 InsertPrefValue(&policy_value1, 2, extension1_->id()); | |
| 1120 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | |
| 1121 policy_value1.DeepCopy()); | |
| 1122 EXPECT_EQ("AppList, Chrome, App3, App2, App1, ", GetPinnedAppStatus()); | |
| 1123 | |
| 1124 // Going back to a status where there is no requirement for app 2 to be pinned | |
| 1125 // should convert it back to running V2 app. Since the position is determined | |
| 1126 // by the |LauncherModel|'s weight system, it will be after last pinned item. | |
| 1127 base::ListValue policy_value2; | |
| 1128 InsertPrefValue(&policy_value2, 0, extension3_->id()); | |
| 1129 InsertPrefValue(&policy_value2, 1, extension1_->id()); | |
| 1130 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | |
| 1131 policy_value2.DeepCopy()); | |
| 1132 EXPECT_EQ("AppList, Chrome, App3, App1, *app2, ", GetPinnedAppStatus()); | |
| 1133 | |
| 1134 // Removing an item should simply close it and everything should shift. | |
| 1135 base::ListValue policy_value3; | |
| 1136 InsertPrefValue(&policy_value3, 0, extension3_->id()); | |
| 1137 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, | |
| 1138 policy_value3.DeepCopy()); | |
| 1139 EXPECT_EQ("AppList, Chrome, App3, *app2, ", GetPinnedAppStatus()); | |
| 1140 } | |
| 1141 | |
| 940 TEST_F(ChromeLauncherControllerTest, Policy) { | 1142 TEST_F(ChromeLauncherControllerTest, Policy) { |
| 941 extension_service_->AddExtension(extension1_.get()); | 1143 extension_service_->AddExtension(extension1_.get()); |
| 942 extension_service_->AddExtension(extension3_.get()); | 1144 extension_service_->AddExtension(extension3_.get()); |
| 943 | 1145 |
| 944 base::ListValue policy_value; | 1146 base::ListValue policy_value; |
| 945 InsertPrefValue(&policy_value, 0, extension1_->id()); | 1147 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 946 InsertPrefValue(&policy_value, 1, extension2_->id()); | 1148 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 947 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, | 1149 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, |
| 948 policy_value.DeepCopy()); | 1150 policy_value.DeepCopy()); |
| 949 | 1151 |
| (...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1510 ash::LauncherID id = launcher_controller_->GetLauncherIDForAppID("1"); | 1712 ash::LauncherID id = launcher_controller_->GetLauncherIDForAppID("1"); |
| 1511 int app_index = model_->ItemIndexByID(id); | 1713 int app_index = model_->ItemIndexByID(id); |
| 1512 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 1714 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 1513 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 1715 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
| 1514 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 1716 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
| 1515 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 1717 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
| 1516 EXPECT_EQ(initial_size + 1, model_->items().size()); | 1718 EXPECT_EQ(initial_size + 1, model_->items().size()); |
| 1517 | 1719 |
| 1518 launcher_controller_.reset(); | 1720 launcher_controller_.reset(); |
| 1519 model_.reset(new ash::LauncherModel); | 1721 model_.reset(new ash::LauncherModel); |
| 1722 AddAppListLauncherItem(); | |
| 1520 launcher_controller_.reset( | 1723 launcher_controller_.reset( |
| 1521 ChromeLauncherController::CreateInstance(profile(), model_.get())); | 1724 ChromeLauncherController::CreateInstance(profile(), model_.get())); |
| 1522 app_tab_helper = new TestAppTabHelperImpl; | 1725 app_tab_helper = new TestAppTabHelperImpl; |
| 1523 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); | 1726 app_tab_helper->SetAppID(tab_strip_model->GetWebContentsAt(0), "1"); |
| 1524 SetAppTabHelper(app_tab_helper); | 1727 SetAppTabHelper(app_tab_helper); |
| 1525 app_icon_loader = new TestAppIconLoaderImpl; | 1728 app_icon_loader = new TestAppIconLoaderImpl; |
| 1526 SetAppIconLoader(app_icon_loader); | 1729 SetAppIconLoader(app_icon_loader); |
| 1527 AddAppListLauncherItem(); | |
| 1528 launcher_controller_->Init(); | 1730 launcher_controller_->Init(); |
| 1529 | 1731 |
| 1530 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 1732 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 1531 ASSERT_EQ(initial_size + 1, model_->items().size()); | 1733 ASSERT_EQ(initial_size + 1, model_->items().size()); |
| 1532 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 1734 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
| 1533 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 1735 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
| 1534 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 1736 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
| 1535 | 1737 |
| 1536 launcher_controller_->UnpinAppWithID("1"); | 1738 launcher_controller_->UnpinAppWithID("1"); |
| 1537 ASSERT_EQ(initial_size, model_->items().size()); | 1739 ASSERT_EQ(initial_size, model_->items().size()); |
| 1538 } | 1740 } |
| OLD | NEW |