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

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

Issue 2655563002: [Merge M56] Fix import legacy, pref based pins. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 11 matching lines...) Expand all
22 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 22 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
23 #include "ash/common/wm_shell.h" 23 #include "ash/common/wm_shell.h"
24 #include "ash/display/screen_orientation_controller_chromeos.h" 24 #include "ash/display/screen_orientation_controller_chromeos.h"
25 #include "ash/shell.h" 25 #include "ash/shell.h"
26 #include "ash/test/ash_test_helper.h" 26 #include "ash/test/ash_test_helper.h"
27 #include "ash/test/test_shell_delegate.h" 27 #include "ash/test/test_shell_delegate.h"
28 #include "ash/wm/window_util.h" 28 #include "ash/wm/window_util.h"
29 #include "base/command_line.h" 29 #include "base/command_line.h"
30 #include "base/compiler_specific.h" 30 #include "base/compiler_specific.h"
31 #include "base/files/file_path.h" 31 #include "base/files/file_path.h"
32 #include "base/json/json_string_value_serializer.h"
32 #include "base/location.h" 33 #include "base/location.h"
33 #include "base/macros.h" 34 #include "base/macros.h"
34 #include "base/memory/ptr_util.h" 35 #include "base/memory/ptr_util.h"
35 #include "base/run_loop.h" 36 #include "base/run_loop.h"
36 #include "base/single_thread_task_runner.h" 37 #include "base/single_thread_task_runner.h"
37 #include "base/strings/utf_string_conversions.h" 38 #include "base/strings/utf_string_conversions.h"
38 #include "base/values.h" 39 #include "base/values.h"
39 #include "build/build_config.h" 40 #include "build/build_config.h"
40 #include "chrome/browser/chromeos/arc/arc_support_host.h" 41 #include "chrome/browser/chromeos/arc/arc_support_host.h"
41 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 42 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
42 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 43 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
43 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h" 44 #include "chrome/browser/chromeos/login/users/wallpaper/wallpaper_manager.h"
44 #include "chrome/browser/extensions/extension_service.h" 45 #include "chrome/browser/extensions/extension_service.h"
45 #include "chrome/browser/extensions/test_extension_system.h" 46 #include "chrome/browser/extensions/test_extension_system.h"
46 #include "chrome/browser/lifetime/scoped_keep_alive.h" 47 #include "chrome/browser/lifetime/scoped_keep_alive.h"
48 #include "chrome/browser/prefs/browser_prefs.h"
47 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h" 49 #include "chrome/browser/ui/app_list/app_list_syncable_service_factory.h"
48 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" 50 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h"
49 #include "chrome/browser/ui/app_list/arc/arc_app_test.h" 51 #include "chrome/browser/ui/app_list/arc/arc_app_test.h"
50 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h" 52 #include "chrome/browser/ui/app_list/arc/arc_app_utils.h"
51 #include "chrome/browser/ui/app_list/arc/arc_default_app_list.h" 53 #include "chrome/browser/ui/app_list/arc/arc_default_app_list.h"
52 #include "chrome/browser/ui/apps/chrome_app_delegate.h" 54 #include "chrome/browser/ui/apps/chrome_app_delegate.h"
53 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h" 55 #include "chrome/browser/ui/ash/chrome_launcher_prefs.h"
54 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h" 56 #include "chrome/browser/ui/ash/launcher/app_window_launcher_controller.h"
55 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h" 57 #include "chrome/browser/ui/ash/launcher/arc_app_deferred_launcher_controller.h"
56 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h" 58 #include "chrome/browser/ui/ash/launcher/browser_status_monitor.h"
(...skipping 17 matching lines...) Expand all
74 #include "chrome/common/pref_names.h" 76 #include "chrome/common/pref_names.h"
75 #include "chrome/test/base/browser_with_test_window_test.h" 77 #include "chrome/test/base/browser_with_test_window_test.h"
76 #include "chrome/test/base/test_browser_window_aura.h" 78 #include "chrome/test/base/test_browser_window_aura.h"
77 #include "chrome/test/base/testing_browser_process.h" 79 #include "chrome/test/base/testing_browser_process.h"
78 #include "chrome/test/base/testing_profile.h" 80 #include "chrome/test/base/testing_profile.h"
79 #include "chrome/test/base/testing_profile_manager.h" 81 #include "chrome/test/base/testing_profile_manager.h"
80 #include "chromeos/chromeos_switches.h" 82 #include "chromeos/chromeos_switches.h"
81 #include "components/arc/common/app.mojom.h" 83 #include "components/arc/common/app.mojom.h"
82 #include "components/arc/test/fake_app_instance.h" 84 #include "components/arc/test/fake_app_instance.h"
83 #include "components/exo/shell_surface.h" 85 #include "components/exo/shell_surface.h"
86 #include "components/prefs/pref_notifier_impl.h"
84 #include "components/signin/core/account_id/account_id.h" 87 #include "components/signin/core/account_id/account_id.h"
88 #include "components/sync/model/attachments/attachment_service_proxy_for_test.h"
85 #include "components/sync/model/fake_sync_change_processor.h" 89 #include "components/sync/model/fake_sync_change_processor.h"
86 #include "components/sync/model/sync_error_factory_mock.h" 90 #include "components/sync/model/sync_error_factory_mock.h"
87 #include "components/sync/protocol/sync.pb.h" 91 #include "components/sync/protocol/sync.pb.h"
92 #include "components/sync_preferences/pref_model_associator.h"
88 #include "components/sync_preferences/testing_pref_service_syncable.h" 93 #include "components/sync_preferences/testing_pref_service_syncable.h"
89 #include "components/user_manager/fake_user_manager.h" 94 #include "components/user_manager/fake_user_manager.h"
90 #include "content/public/browser/web_contents.h" 95 #include "content/public/browser/web_contents.h"
91 #include "content/public/browser/web_contents_observer.h" 96 #include "content/public/browser/web_contents_observer.h"
92 #include "content/public/test/test_utils.h" 97 #include "content/public/test/test_utils.h"
93 #include "content/public/test/web_contents_tester.h" 98 #include "content/public/test/web_contents_tester.h"
94 #include "extensions/browser/app_window/app_window_contents.h" 99 #include "extensions/browser/app_window/app_window_contents.h"
95 #include "extensions/browser/app_window/app_window_registry.h" 100 #include "extensions/browser/app_window/app_window_registry.h"
96 #include "extensions/browser/app_window/native_app_window.h" 101 #include "extensions/browser/app_window/native_app_window.h"
97 #include "extensions/common/extension.h" 102 #include "extensions/common/extension.h"
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 // Wait until |extension_system| is signaled as started. 344 // Wait until |extension_system| is signaled as started.
340 base::RunLoop run_loop; 345 base::RunLoop run_loop;
341 extension_system->ready().Post(FROM_HERE, run_loop.QuitClosure()); 346 extension_system->ready().Post(FROM_HERE, run_loop.QuitClosure());
342 run_loop.Run(); 347 run_loop.Run();
343 348
344 app_service_ = 349 app_service_ =
345 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); 350 app_list::AppListSyncableServiceFactory::GetForProfile(profile());
346 StartAppSyncService(syncer::SyncDataList()); 351 StartAppSyncService(syncer::SyncDataList());
347 352
348 std::string error; 353 std::string error;
354 extension_chrome_ = Extension::Create(base::FilePath(), Manifest::UNPACKED,
355 manifest, Extension::NO_FLAGS,
356 extension_misc::kChromeAppId, &error);
349 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, 357 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED,
350 manifest, 358 manifest,
351 Extension::NO_FLAGS, 359 Extension::NO_FLAGS,
352 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", 360 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
353 &error); 361 &error);
354 extension2_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, 362 extension2_ = Extension::Create(base::FilePath(), Manifest::UNPACKED,
355 manifest, 363 manifest,
356 Extension::NO_FLAGS, 364 Extension::NO_FLAGS,
357 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb", 365 "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
358 &error); 366 &error);
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
397 "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee", 405 "eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",
398 &error); 406 &error);
399 extension8_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, 407 extension8_ = Extension::Create(base::FilePath(), Manifest::UNPACKED,
400 manifest, 408 manifest,
401 Extension::NO_FLAGS, 409 Extension::NO_FLAGS,
402 "ffffffffffffffffffffffffffffffff", 410 "ffffffffffffffffffffffffffffffff",
403 &error); 411 &error);
404 arc_support_host_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, 412 arc_support_host_ = Extension::Create(base::FilePath(), Manifest::UNPACKED,
405 manifest, Extension::NO_FLAGS, 413 manifest, Extension::NO_FLAGS,
406 ArcSupportHost::kHostAppId, &error); 414 ArcSupportHost::kHostAppId, &error);
415 extension_service_->AddExtension(extension_chrome_.get());
407 } 416 }
408 417
409 // Creates a running V2 app (not pinned) of type |app_id|. 418 // Creates a running V2 app (not pinned) of type |app_id|.
410 virtual void CreateRunningV2App(const std::string& app_id) { 419 virtual void CreateRunningV2App(const std::string& app_id) {
411 DCHECK(!test_controller_); 420 DCHECK(!test_controller_);
412 ash::ShelfID id = 421 ash::ShelfID id =
413 launcher_controller_->CreateAppShortcutLauncherItemWithType( 422 launcher_controller_->CreateAppShortcutLauncherItemWithType(
414 ash::launcher::AppLauncherId(app_id), model_->item_count(), 423 ash::launcher::AppLauncherId(app_id), model_->item_count(),
415 ash::TYPE_PLATFORM_APP); 424 ash::TYPE_PLATFORM_APP);
416 DCHECK(id); 425 DCHECK(id);
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
513 void StartAppSyncService(const syncer::SyncDataList& init_sync_list) { 522 void StartAppSyncService(const syncer::SyncDataList& init_sync_list) {
514 app_service_->MergeDataAndStartSyncing( 523 app_service_->MergeDataAndStartSyncing(
515 syncer::APP_LIST, init_sync_list, 524 syncer::APP_LIST, init_sync_list,
516 base::MakeUnique<syncer::FakeSyncChangeProcessor>(), 525 base::MakeUnique<syncer::FakeSyncChangeProcessor>(),
517 base::MakeUnique<syncer::SyncErrorFactoryMock>()); 526 base::MakeUnique<syncer::SyncErrorFactoryMock>());
518 EXPECT_EQ(init_sync_list.size(), app_service_->sync_items().size()); 527 EXPECT_EQ(init_sync_list.size(), app_service_->sync_items().size());
519 } 528 }
520 529
521 void StopAppSyncService() { app_service_->StopSyncing(syncer::APP_LIST); } 530 void StopAppSyncService() { app_service_->StopSyncing(syncer::APP_LIST); }
522 531
532 sync_preferences::PrefModelAssociator* GetPrefSyncService() {
533 sync_preferences::PrefServiceSyncable* pref_sync =
534 profile()->GetTestingPrefService();
535 sync_preferences::PrefModelAssociator* pref_sync_service =
536 reinterpret_cast<sync_preferences::PrefModelAssociator*>(
537 pref_sync->GetSyncableService(syncer::PREFERENCES));
538 return pref_sync_service;
539 }
540
541 void StartPrefSyncService(const syncer::SyncDataList& init_sync_list) {
542 syncer::SyncMergeResult r = GetPrefSyncService()->MergeDataAndStartSyncing(
543 syncer::PREFERENCES, init_sync_list,
544 base::MakeUnique<syncer::FakeSyncChangeProcessor>(),
545 base::MakeUnique<syncer::SyncErrorFactoryMock>());
546 EXPECT_FALSE(r.error().IsSet());
547 }
548
549 void StartPrefSyncServiceForPins(const base::ListValue& init_value) {
550 syncer::SyncDataList init_sync_list;
551 std::string serialized;
552 JSONStringValueSerializer json(&serialized);
553 json.Serialize(init_value);
554 sync_pb::EntitySpecifics one;
555 sync_pb::PreferenceSpecifics* pref_one = one.mutable_preference();
556 pref_one->set_name(prefs::kPinnedLauncherApps);
557 pref_one->set_value(serialized);
558 init_sync_list.push_back(syncer::SyncData::CreateRemoteData(
559 1, one, base::Time(), syncer::AttachmentIdList(),
560 syncer::AttachmentServiceProxyForTest::Create()));
561 StartPrefSyncService(init_sync_list);
562 }
563
564 void StopPrefSyncService() {
565 GetPrefSyncService()->StopSyncing(syncer::PREFERENCES);
566 }
567
523 void SetAppIconLoader(std::unique_ptr<AppIconLoader> loader) { 568 void SetAppIconLoader(std::unique_ptr<AppIconLoader> loader) {
524 std::vector<std::unique_ptr<AppIconLoader>> loaders; 569 std::vector<std::unique_ptr<AppIconLoader>> loaders;
525 loaders.push_back(std::move(loader)); 570 loaders.push_back(std::move(loader));
526 launcher_controller_->SetAppIconLoadersForTest(loaders); 571 launcher_controller_->SetAppIconLoadersForTest(loaders);
527 } 572 }
528 573
529 void SetAppIconLoaders(std::unique_ptr<AppIconLoader> loader1, 574 void SetAppIconLoaders(std::unique_ptr<AppIconLoader> loader1,
530 std::unique_ptr<AppIconLoader> loader2) { 575 std::unique_ptr<AppIconLoader> loader2) {
531 std::vector<std::unique_ptr<AppIconLoader>> loaders; 576 std::vector<std::unique_ptr<AppIconLoader>> loaders;
532 loaders.push_back(std::move(loader1)); 577 loaders.push_back(std::move(loader1));
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 appinfo.name, std::string()); 928 appinfo.name, std::string());
884 } 929 }
885 930
886 void NotifyOnTaskOrientationLockRequested(int32_t task_id, 931 void NotifyOnTaskOrientationLockRequested(int32_t task_id,
887 OrientationLock lock) { 932 OrientationLock lock) {
888 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs(); 933 ArcAppListPrefs* const prefs = arc_test_.arc_app_list_prefs();
889 prefs->OnTaskOrientationLockRequested(task_id, lock); 934 prefs->OnTaskOrientationLockRequested(task_id, lock);
890 } 935 }
891 936
892 // Needed for extension service & friends to work. 937 // Needed for extension service & friends to work.
938 scoped_refptr<Extension> extension_chrome_;
893 scoped_refptr<Extension> extension1_; 939 scoped_refptr<Extension> extension1_;
894 scoped_refptr<Extension> extension2_; 940 scoped_refptr<Extension> extension2_;
895 scoped_refptr<Extension> extension3_; 941 scoped_refptr<Extension> extension3_;
896 scoped_refptr<Extension> extension4_; 942 scoped_refptr<Extension> extension4_;
897 scoped_refptr<Extension> extension5_; 943 scoped_refptr<Extension> extension5_;
898 scoped_refptr<Extension> extension6_; 944 scoped_refptr<Extension> extension6_;
899 scoped_refptr<Extension> extension7_; 945 scoped_refptr<Extension> extension7_;
900 scoped_refptr<Extension> extension8_; 946 scoped_refptr<Extension> extension8_;
901 scoped_refptr<Extension> arc_support_host_; 947 scoped_refptr<Extension> arc_support_host_;
902 948
(...skipping 1729 matching lines...) Expand 10 before | Expand all | Expand 10 after
2632 sync_list.clear(); 2678 sync_list.clear();
2633 InsertRemovePinChange(&sync_list, extension3_->id()); 2679 InsertRemovePinChange(&sync_list, extension3_->id());
2634 InsertRemovePinChange(&sync_list, extension2_->id()); 2680 InsertRemovePinChange(&sync_list, extension2_->id());
2635 SendPinChanges(sync_list, false); 2681 SendPinChanges(sync_list, false);
2636 expected_launchers.clear(); 2682 expected_launchers.clear();
2637 GetAppLaunchers(launcher_controller_.get(), &actual_launchers); 2683 GetAppLaunchers(launcher_controller_.get(), &actual_launchers);
2638 EXPECT_EQ(expected_launchers, actual_launchers); 2684 EXPECT_EQ(expected_launchers, actual_launchers);
2639 } 2685 }
2640 2686
2641 TEST_F(ChromeLauncherControllerImplTest, ImportLegacyPin) { 2687 TEST_F(ChromeLauncherControllerImplTest, ImportLegacyPin) {
2688 // Note extension3_ is actually Gmail app which is default pinned.
2689 extension_service_->AddExtension(extension3_.get());
2690 InitLauncherController();
2691
2692 // Default pins should contain Gmail. Pref is not syncing now.
2693 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
2694
2642 extension_service_->AddExtension(extension2_.get()); 2695 extension_service_->AddExtension(extension2_.get());
2643 extension_service_->AddExtension(extension3_.get()); 2696 EXPECT_EQ("AppList, Chrome, App3", GetPinnedAppStatus());
2644 extension_service_->AddExtension(extension4_.get());
2645 2697
2646 // Initially pins are imported from legacy pref based model. 2698 // Initially pins are imported from legacy pref based model.
2647 base::ListValue value; 2699 base::ListValue value;
2648 InsertPrefValue(&value, 0, extension4_->id()); 2700 InsertPrefValue(&value, 0, extension4_->id());
2649 InsertPrefValue(&value, 1, extension2_->id()); 2701 InsertPrefValue(&value, 1, extension2_->id());
2650 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, 2702 InsertPrefValue(&value, 2, extension3_->id());
2651 value.DeepCopy()); 2703 StartPrefSyncServiceForPins(value);
2652 2704
2653 InitLauncherController(); 2705 // Imported pins contain App2. App2 should be added to pins now.
2706 EXPECT_EQ("AppList, Chrome, App2, App3", GetPinnedAppStatus());
2654 2707
2655 EXPECT_EQ("AppList, Chrome, App4, App2", GetPinnedAppStatus()); 2708 // extension4_ is in the pin list.
2709 extension_service_->AddExtension(extension4_.get());
2710 // extension5_ is not in the pin list.
2711 extension_service_->AddExtension(extension5_.get());
2712 EXPECT_EQ("AppList, Chrome, App4, App2, App3", GetPinnedAppStatus());
2713
2714 // Apply app sync, unpin one app and pin new one.
2715 syncer::SyncChangeList sync_list;
2716 InsertAddPinChange(&sync_list, -1, extension3_->id());
2717 InsertAddPinChange(&sync_list, 3, extension5_->id());
2718 SendPinChanges(sync_list, false);
2719 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus());
2656 2720
2657 // At this point changing old pref based model does not affect pin model. 2721 // At this point changing old pref based model does not affect pin model.
2658 InsertPrefValue(&value, 2, extension3_->id()); 2722 InsertPrefValue(&value, 3, extension5_->id());
2659 profile()->GetTestingPrefService()->SetManagedPref(prefs::kPinnedLauncherApps, 2723 StopPrefSyncService();
2660 value.DeepCopy()); 2724 StartPrefSyncServiceForPins(value);
2661 EXPECT_EQ("AppList, Chrome, App4, App2", GetPinnedAppStatus()); 2725 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus());
2726
2727 // Next Chrome start should preserve pins.
2662 RecreateChromeLauncher(); 2728 RecreateChromeLauncher();
2663 EXPECT_EQ("AppList, Chrome, App4, App2", GetPinnedAppStatus()); 2729 StopPrefSyncService();
2730 StartPrefSyncService(syncer::SyncDataList());
2731 EXPECT_EQ("AppList, Chrome, App4, App2, App5", GetPinnedAppStatus());
2664 } 2732 }
2665 2733
2666 TEST_F(ChromeLauncherControllerImplTest, PendingInsertionOrder) { 2734 TEST_F(ChromeLauncherControllerImplTest, PendingInsertionOrder) {
2667 extension_service_->AddExtension(extension1_.get()); 2735 extension_service_->AddExtension(extension1_.get());
2668 extension_service_->AddExtension(extension3_.get()); 2736 extension_service_->AddExtension(extension3_.get());
2669 2737
2670 InitLauncherController(); 2738 InitLauncherController();
2671 2739
2672 syncer::SyncChangeList sync_list; 2740 syncer::SyncChangeList sync_list;
2673 InsertAddPinChange(&sync_list, 0, extension1_->id()); 2741 InsertAddPinChange(&sync_list, 0, extension1_->id());
(...skipping 890 matching lines...) Expand 10 before | Expand all | Expand 10 after
3564 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED, 3632 EXPECT_EQ(AppListControllerDelegate::PIN_FIXED,
3565 GetPinnableForAppID(app_id, profile())); 3633 GetPinnableForAppID(app_id, profile()));
3566 } 3634 }
3567 3635
3568 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcManaged) { 3636 TEST_F(ChromeLauncherControllerImplWithArcTest, ArcManaged) {
3569 extension_service_->AddExtension(arc_support_host_.get()); 3637 extension_service_->AddExtension(arc_support_host_.get());
3570 // Test enables Arc, so turn it off for initial values. 3638 // Test enables Arc, so turn it off for initial values.
3571 EnableArc(false); 3639 EnableArc(false);
3572 3640
3573 InitLauncherController(); 3641 InitLauncherController();
3642
3574 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get()); 3643 arc::ArcAuthService::SetShelfDelegateForTesting(launcher_controller_.get());
3575 3644
3645 // To prevent import legacy pins each time.
3646 // Initially pins are imported from legacy pref based model.
3647 StartPrefSyncService(syncer::SyncDataList());
3648
3576 // Initial run, Arc is not managed and disabled, Play Store pin should be 3649 // Initial run, Arc is not managed and disabled, Play Store pin should be
3577 // available. 3650 // available.
3578 ValidateArcState(false, false, arc::ArcAuthService::State::STOPPED, 3651 ValidateArcState(false, false, arc::ArcAuthService::State::STOPPED,
3579 "AppList, Chrome, Play Store"); 3652 "AppList, Chrome, Play Store");
3580 3653
3581 // Arc is managed and enabled, Play Store pin should be available. 3654 // Arc is managed and enabled, Play Store pin should be available.
3582 // Note: SHOWING_TERMS_OF_SERVICE here means that opt-in flow starts. 3655 // Note: SHOWING_TERMS_OF_SERVICE here means that opt-in flow starts.
3583 profile()->GetTestingPrefService()->SetManagedPref( 3656 profile()->GetTestingPrefService()->SetManagedPref(
3584 prefs::kArcEnabled, new base::FundamentalValue(true)); 3657 prefs::kArcEnabled, new base::FundamentalValue(true));
3585 base::RunLoop().RunUntilIdle(); 3658 base::RunLoop().RunUntilIdle();
(...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after
4035 4108
4036 // Pinned state should not change. 4109 // Pinned state should not change.
4037 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 4110 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
4038 launcher_controller_->UnpinAppWithID(extension2_->id()); 4111 launcher_controller_->UnpinAppWithID(extension2_->id());
4039 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); 4112 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus());
4040 4113
4041 // Resume syncing and sync information overrides local copy. 4114 // Resume syncing and sync information overrides local copy.
4042 StartAppSyncService(copy_sync_list); 4115 StartAppSyncService(copy_sync_list);
4043 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); 4116 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus());
4044 } 4117 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/launcher/chrome_launcher_controller_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698