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

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

Issue 2090133003: Moved methods that don't rely on internal state out of ChromeLauncherController. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changed to profile_ Created 4 years, 5 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_impl.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 <map> 10 #include <map>
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "chrome/browser/extensions/test_extension_system.h" 42 #include "chrome/browser/extensions/test_extension_system.h"
43 #include "chrome/browser/lifetime/scoped_keep_alive.h" 43 #include "chrome/browser/lifetime/scoped_keep_alive.h"
44 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" 44 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
45 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 45 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
46 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" 46 #include "chrome/browser/ui/app_list/arc/arc_app_test.h"
47 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 47 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
48 #include "chrome/browser/ui/apps/chrome_app_delegate.h" 48 #include "chrome/browser/ui/apps/chrome_app_delegate.h"
49 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" 49 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
50 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" 50 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h"
51 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" 51 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h"
52 #include "chrome/browser/ui/ash/launcher/chrome_launcher_controller_util.h"
52 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont roller.h" 53 #include "chrome/browser/ui/ash/launcher/extension_app_window_launcher_item_cont roller.h"
53 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h" 54 #include "chrome/browser/ui/ash/launcher/launcher_application_menu_item_model.h"
54 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h" 55 #include "chrome/browser/ui/ash/launcher/launcher_controller_helper.h"
55 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h" 56 #include "chrome/browser/ui/ash/launcher/launcher_item_controller.h"
56 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h" 57 #include "chrome/browser/ui/ash/multi_user/multi_user_util.h"
57 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h" 58 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager.h"
58 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h" 59 #include "chrome/browser/ui/ash/multi_user/multi_user_window_manager_chromeos.h"
59 #include "chrome/browser/ui/browser.h" 60 #include "chrome/browser/ui/browser.h"
60 #include "chrome/browser/ui/browser_commands.h" 61 #include "chrome/browser/ui/browser_commands.h"
61 #include "chrome/browser/ui/browser_finder.h" 62 #include "chrome/browser/ui/browser_finder.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 new ChromeLauncherAppMenuItem(base::string16(), NULL, false)); 276 new ChromeLauncherAppMenuItem(base::string16(), NULL, false));
276 items.push_back( 277 items.push_back(
277 new ChromeLauncherAppMenuItem(base::string16(), NULL, false)); 278 new ChromeLauncherAppMenuItem(base::string16(), NULL, false));
278 return items; 279 return items;
279 } 280 }
280 ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) override { 281 ash::ShelfMenuModel* CreateApplicationMenu(int event_flags) override {
281 return NULL; 282 return NULL;
282 } 283 }
283 bool IsDraggable() override { return false; } 284 bool IsDraggable() override { return false; }
284 bool CanPin() const override { 285 bool CanPin() const override {
285 return launcher_controller()->GetPinnable(app_id()) == 286 return GetPinnableForAppID(app_id(), launcher_controller()->GetProfile()) ==
286 AppListControllerDelegate::PIN_EDITABLE; 287 AppListControllerDelegate::PIN_EDITABLE;
287 } 288 }
288 bool ShouldShowTooltip() override { return false; } 289 bool ShouldShowTooltip() override { return false; }
289 290
290 private: 291 private:
291 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController); 292 DISALLOW_COPY_AND_ASSIGN(TestV2AppLauncherItemController);
292 }; 293 };
293 294
294 } // namespace 295 } // namespace
295 296
(...skipping 1028 matching lines...) Expand 10 before | Expand all | Expand 10 after
1324 // 2 is not pinned as it's not installed 1325 // 2 is not pinned as it's not installed
1325 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id())); 1326 EXPECT_FALSE(launcher_controller_->IsAppPinned(extension2_->id()));
1326 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id())); 1327 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension3_->id()));
1327 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id())); 1328 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension4_->id()));
1328 // install extension 2 and check 1329 // install extension 2 and check
1329 extension_service_->AddExtension(extension2_.get()); 1330 extension_service_->AddExtension(extension2_.get());
1330 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id())); 1331 EXPECT_TRUE(launcher_controller_->IsAppPinned(extension2_->id()));
1331 1332
1332 // Check user can manually pin or unpin these apps 1333 // Check user can manually pin or unpin these apps
1333 EXPECT_EQ(AppListControllerDelegate::PIN_EDITABLE, 1334 EXPECT_EQ(AppListControllerDelegate::PIN_EDITABLE,
1334 launcher_controller_->GetPinnable(extension1_->id())); 1335 GetPinnableForAppID(extension1_->id(),
1336 launcher_controller_->GetProfile()));
msw 2016/06/27 18:50:26 nit: use profile() (or cache this for the 4 uses h
1335 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, 1337 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED,
1336 launcher_controller_->GetPinnable(extension2_->id())); 1338 GetPinnableForAppID(extension2_->id(),
1339 launcher_controller_->GetProfile()));
1337 EXPECT_EQ(AppListControllerDelegate::PIN_EDITABLE, 1340 EXPECT_EQ(AppListControllerDelegate::PIN_EDITABLE,
1338 launcher_controller_->GetPinnable(extension3_->id())); 1341 GetPinnableForAppID(extension3_->id(),
1342 launcher_controller_->GetProfile()));
1339 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, 1343 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED,
1340 launcher_controller_->GetPinnable(extension4_->id())); 1344 GetPinnableForAppID(extension4_->id(),
1345 launcher_controller_->GetProfile()));
1341 1346
1342 // Check the order of shelf pinned apps 1347 // Check the order of shelf pinned apps
1343 EXPECT_EQ("AppList, App2, App4, App1, Chrome, App3", GetPinnedAppStatus()); 1348 EXPECT_EQ("AppList, App2, App4, App1, Chrome, App3", GetPinnedAppStatus());
1344 } 1349 }
1345 1350
1346 // Check that the restauration of launcher items is happening in the same order 1351 // Check that the restauration of launcher items is happening in the same order
1347 // as the user has pinned them (on another system) when they are synced reverse 1352 // as the user has pinned them (on another system) when they are synced reverse
1348 // order. 1353 // order.
1349 TEST_F(ChromeLauncherControllerImplTest, RestoreDefaultAppsReverseOrder) { 1354 TEST_F(ChromeLauncherControllerImplTest, RestoreDefaultAppsReverseOrder) {
1350 InitLauncherController(); 1355 InitLauncherController();
(...skipping 2017 matching lines...) Expand 10 before | Expand all | Expand 10 after
3368 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app 3373 // Set policy, that makes pins ARC app. Unlike native extension, for ARC app
3369 // package_name (not hash) specified as id. In this test we check that 3374 // package_name (not hash) specified as id. In this test we check that
3370 // by hash we can determine that appropriate package was set by policy. 3375 // by hash we can determine that appropriate package was set by policy.
3371 base::ListValue policy_value; 3376 base::ListValue policy_value;
3372 InsertPrefValue(&policy_value, 0, appinfo.package_name); 3377 InsertPrefValue(&policy_value, 0, appinfo.package_name);
3373 profile()->GetTestingPrefService()->SetManagedPref( 3378 profile()->GetTestingPrefService()->SetManagedPref(
3374 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy()); 3379 prefs::kPolicyPinnedLauncherApps, policy_value.DeepCopy());
3375 3380
3376 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id)); 3381 EXPECT_TRUE(launcher_controller_->IsAppPinned(app_id));
3377 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, 3382 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED,
3378 launcher_controller_->GetPinnable(app_id)); 3383 GetPinnableForAppID(app_id, launcher_controller_->GetProfile()));
msw 2016/06/27 18:50:26 nit: use profile().
3379 } 3384 }
3380 3385
3381 TEST_F(ChromeLauncherControllerImplTest, ArcManaged) { 3386 TEST_F(ChromeLauncherControllerImplTest, ArcManaged) {
3382 extension_service_->AddExtension(arc_support_host_.get()); 3387 extension_service_->AddExtension(arc_support_host_.get());
3383 arc_test_.SetUp(profile()); 3388 arc_test_.SetUp(profile());
3384 // Test enables Arc, so turn it off for initial values. 3389 // Test enables Arc, so turn it off for initial values.
3385 EnableArc(false); 3390 EnableArc(false);
3386 3391
3387 InitLauncherController(); 3392 InitLauncherController();
3388 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); 3393 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get());
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
3421 // be automatically removed. 3426 // be automatically removed.
3422 EnableArc(false); 3427 EnableArc(false);
3423 ValidateArcState(false, false, arc::ArcAuthService::State::STOPPED, 3428 ValidateArcState(false, false, arc::ArcAuthService::State::STOPPED,
3424 "AppList, Chrome"); 3429 "AppList, Chrome");
3425 3430
3426 // Even if re-enable it again, Play Store pin does not appear automatically. 3431 // Even if re-enable it again, Play Store pin does not appear automatically.
3427 EnableArc(true); 3432 EnableArc(true);
3428 ValidateArcState(true, false, arc::ArcAuthService::State::FETCHING_CODE, 3433 ValidateArcState(true, false, arc::ArcAuthService::State::FETCHING_CODE,
3429 "AppList, Chrome"); 3434 "AppList, Chrome");
3430 } 3435 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698