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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 new ChromeLauncherAppMenuItem(base::string16(), NULL, false)); | 266 new ChromeLauncherAppMenuItem(base::string16(), NULL, false)); |
267 items.push_back( | 267 items.push_back( |
268 new ChromeLauncherAppMenuItem(base::string16(), NULL, false)); | 268 new ChromeLauncherAppMenuItem(base::string16(), NULL, false)); |
269 return items; | 269 return items; |
270 } | 270 } |
271 ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) override { | 271 ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) override { |
272 return NULL; | 272 return NULL; |
273 } | 273 } |
274 bool IsDraggable() override { return false; } | 274 bool IsDraggable() override { return false; } |
275 bool CanPin() const override { | 275 bool CanPin() const override { |
276 return launcher_controller()->CanPin(app_id()); | 276 return launcher_controller()->GetPinnable(app_id()) == |
| 277 AppListControllerDelegate::PIN_EDITABLE; |
277 } | 278 } |
278 bool ShouldShowTooltip() override { return false; } | 279 bool ShouldShowTooltip() override { return false; } |
279 | 280 |
280 private: | 281 private: |
281 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController); | 282 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController); |
282 }; | 283 }; |
283 | 284 |
284 } // namespace | 285 } // namespace |
285 | 286 |
286 class ChromeLauncherControllerTest : public BrowserWithTestWindowTest { | 287 class ChromeLauncherControllerTest : public BrowserWithTestWindowTest { |
(...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1046 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); | 1047 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension1_->id())); |
1047 // 2 is not pinned as it's not installed | 1048 // 2 is not pinned as it's not installed |
1048 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); | 1049 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); |
1049 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); | 1050 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); |
1050 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id())); | 1051 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id())); |
1051 // install extension 2 and check | 1052 // install extension 2 and check |
1052 extension_service_->AddExtension(extension2_.get()); | 1053 extension_service_->AddExtension(extension2_.get()); |
1053 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); | 1054 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); |
1054 | 1055 |
1055 // Check user can manually pin or unpin these apps | 1056 // Check user can manually pin or unpin these apps |
1056 EXPECT_TRUE(launcher_controller_->CanPin(extension1_->id())); | 1057 EXPECT_EQ(AppListControllerDelegate::PIN_EDITABLE, |
1057 EXPECT_FALSE(launcher_controller_->CanPin(extension2_->id())); | 1058 launcher_controller_->GetPinnable(extension1_->id())); |
1058 EXPECT_TRUE(launcher_controller_->CanPin(extension3_->id())); | 1059 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, |
1059 EXPECT_FALSE(launcher_controller_->CanPin(extension4_->id())); | 1060 launcher_controller_->GetPinnable(extension2_->id())); |
| 1061 EXPECT_EQ(AppListControllerDelegate::PIN_EDITABLE, |
| 1062 launcher_controller_->GetPinnable(extension3_->id())); |
| 1063 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, |
| 1064 launcher_controller_->GetPinnable(extension4_->id())); |
1060 | 1065 |
1061 // Check the order of shelf pinned apps | 1066 // Check the order of shelf pinned apps |
1062 EXPECT_EQ("AppList, App2, App4, App1, Chrome, App3", GetPinnedAppStatus()); | 1067 EXPECT_EQ("AppList, App2, App4, App1, Chrome, App3", GetPinnedAppStatus()); |
1063 } | 1068 } |
1064 | 1069 |
1065 // Check that the restauration of launcher items is happening in the same order | 1070 // Check that the restauration of launcher items is happening in the same order |
1066 // as the user has pinned them (on another system) when they are synced reverse | 1071 // as the user has pinned them (on another system) when they are synced reverse |
1067 // order. | 1072 // order. |
1068 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsReverseOrder) { | 1073 TEST_F(ChromeLauncherControllerTest, RestoreDefaultAppsReverseOrder) { |
1069 InitLauncherController(); | 1074 InitLauncherController(); |
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2935 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 2940 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
2936 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 2941 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
2937 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 2942 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
2938 | 2943 |
2939 launcher_controller_->CloseLauncherItem(shelfId3); | 2944 launcher_controller_->CloseLauncherItem(shelfId3); |
2940 EXPECT_EQ(1, app_icon_loader1->fetch_count()); | 2945 EXPECT_EQ(1, app_icon_loader1->fetch_count()); |
2941 EXPECT_EQ(1, app_icon_loader1->clear_count()); | 2946 EXPECT_EQ(1, app_icon_loader1->clear_count()); |
2942 EXPECT_EQ(1, app_icon_loader2->fetch_count()); | 2947 EXPECT_EQ(1, app_icon_loader2->fetch_count()); |
2943 EXPECT_EQ(1, app_icon_loader2->clear_count()); | 2948 EXPECT_EQ(1, app_icon_loader2->clear_count()); |
2944 } | 2949 } |
OLD | NEW |