| 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 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1147 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); | 1147 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension3_->id())); |
| 1148 | 1148 |
| 1149 // Installing |extension3_| should add it to the launcher - behind the | 1149 // Installing |extension3_| should add it to the launcher - behind the |
| 1150 // chrome icon. | 1150 // chrome icon. |
| 1151 extension_service_->AddExtension(extension3_.get()); | 1151 extension_service_->AddExtension(extension3_.get()); |
| 1152 EXPECT_EQ("AppList, Chrome, App3, ", GetPinnedAppStatus()); | 1152 EXPECT_EQ("AppList, Chrome, App3, ", GetPinnedAppStatus()); |
| 1153 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); | 1153 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension1_->id())); |
| 1154 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1154 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
| 1155 } | 1155 } |
| 1156 | 1156 |
| 1157 // Check that changing from the alternate shelf layout to the old shelflayout |
| 1158 // and back does keep the app launcher at location #0. |
| 1159 TEST_F(ChromeLauncherControllerTest, |
| 1160 SwitchingFromAlternateShelfLayoutToLegacyAndBack) { |
| 1161 InitLauncherController(); |
| 1162 |
| 1163 // We simulate this problem by intentionally placing the app list item in |
| 1164 // the middle of several apps which caused a crash (see crbug.com/329597). |
| 1165 const char kAppLauncherIdPlaceholder[] = "AppLauncherIDPlaceholder--------"; |
| 1166 |
| 1167 base::ListValue policy_value; |
| 1168 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 1169 InsertPrefValue(&policy_value, 1, kAppLauncherIdPlaceholder); |
| 1170 InsertPrefValue(&policy_value, 2, extension2_->id()); |
| 1171 profile()->GetTestingPrefService()->SetUserPref(prefs::kPinnedLauncherApps, |
| 1172 policy_value.DeepCopy()); |
| 1173 EXPECT_EQ(0, profile()->GetPrefs()->GetInteger(prefs::kShelfChromeIconIndex)); |
| 1174 // Model should only contain the browser shortcut and app list items. |
| 1175 extension_service_->AddExtension(extension1_.get()); |
| 1176 extension_service_->AddExtension(extension2_.get()); |
| 1177 EXPECT_EQ("AppList, Chrome, App1, App2, ", GetPinnedAppStatus()); |
| 1178 } |
| 1179 |
| 1157 // Check that the restauration of launcher items is happening in the same order | 1180 // Check that the restauration of launcher items is happening in the same order |
| 1158 // as the user has pinned them (on another system) when they are synced reverse | 1181 // as the user has pinned them (on another system) when they are synced reverse |
| 1159 // order. | 1182 // order. |
| 1160 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsReverseOrder) { | 1183 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsReverseOrder) { |
| 1161 InitLauncherController(); | 1184 InitLauncherController(); |
| 1162 | 1185 |
| 1163 base::ListValue policy_value; | 1186 base::ListValue policy_value; |
| 1164 InsertPrefValue(&policy_value, 0, extension1_->id()); | 1187 InsertPrefValue(&policy_value, 0, extension1_->id()); |
| 1165 InsertPrefValue(&policy_value, 1, extension2_->id()); | 1188 InsertPrefValue(&policy_value, 1, extension2_->id()); |
| 1166 InsertPrefValue(&policy_value, 2, extension3_->id()); | 1189 InsertPrefValue(&policy_value, 2, extension3_->id()); |
| (...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2717 | 2740 |
| 2718 EXPECT_EQ(1, app_icon_loader->fetch_count()); | 2741 EXPECT_EQ(1, app_icon_loader->fetch_count()); |
| 2719 ASSERT_EQ(initial_size + 1, model_->items().size()); | 2742 ASSERT_EQ(initial_size + 1, model_->items().size()); |
| 2720 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); | 2743 EXPECT_TRUE(launcher_controller_->IsAppPinned("1")); |
| 2721 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); | 2744 EXPECT_FALSE(launcher_controller_->IsAppPinned("0")); |
| 2722 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); | 2745 EXPECT_EQ(ash::TYPE_APP_SHORTCUT, model_->items()[app_index].type); |
| 2723 | 2746 |
| 2724 launcher_controller_->UnpinAppWithID("1"); | 2747 launcher_controller_->UnpinAppWithID("1"); |
| 2725 ASSERT_EQ(initial_size, model_->items().size()); | 2748 ASSERT_EQ(initial_size, model_->items().size()); |
| 2726 } | 2749 } |
| OLD | NEW |