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_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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 338 extensions::TestExtensionSystem* extension_system( | 338 extensions::TestExtensionSystem* extension_system( |
| 339 static_cast<extensions::TestExtensionSystem*>( | 339 static_cast<extensions::TestExtensionSystem*>( |
| 340 extensions::ExtensionSystem::Get(profile()))); | 340 extensions::ExtensionSystem::Get(profile()))); |
| 341 extension_service_ = extension_system->CreateExtensionService( | 341 extension_service_ = extension_system->CreateExtensionService( |
| 342 base::CommandLine::ForCurrentProcess(), base::FilePath(), false); | 342 base::CommandLine::ForCurrentProcess(), base::FilePath(), false); |
| 343 extension_service_->Init(); | 343 extension_service_->Init(); |
| 344 | 344 |
| 345 if (auto_start_arc_test_) | 345 if (auto_start_arc_test_) |
| 346 arc_test_.SetUp(profile()); | 346 arc_test_.SetUp(profile()); |
| 347 | 347 |
| 348 // Wait until |extension_system| is signaled as started. | |
| 349 base::RunLoop run_loop; | |
|
khmel
2016/10/25 15:49:00
to Steven, this fix race condition when StartAppSy
stevenjb
2016/10/25 16:21:32
Acknowledged.
| |
| 350 extension_system->ready().Post(FROM_HERE, run_loop.QuitClosure()); | |
| 351 run_loop.Run(); | |
| 352 | |
| 348 app_service_ = | 353 app_service_ = |
| 349 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); | 354 app_list::AppListSyncableServiceFactory::GetForProfile(profile()); |
| 350 StartAppSyncService(syncer::SyncDataList()); | 355 StartAppSyncService(syncer::SyncDataList()); |
| 351 | 356 |
| 352 std::string error; | 357 std::string error; |
| 353 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, | 358 extension1_ = Extension::Create(base::FilePath(), Manifest::UNPACKED, |
| 354 manifest, | 359 manifest, |
| 355 Extension::NO_FLAGS, | 360 Extension::NO_FLAGS, |
| 356 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", | 361 "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", |
| 357 &error); | 362 &error); |
| (...skipping 3650 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4008 app_service_->GetPinPosition(extension_misc::kChromeAppId))); | 4013 app_service_->GetPinPosition(extension_misc::kChromeAppId))); |
| 4009 EXPECT_TRUE( | 4014 EXPECT_TRUE( |
| 4010 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); | 4015 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); |
| 4011 EXPECT_TRUE( | 4016 EXPECT_TRUE( |
| 4012 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); | 4017 position_1.Equals(app_service_->GetPinPosition(extension1_->id()))); |
| 4013 EXPECT_TRUE( | 4018 EXPECT_TRUE( |
| 4014 position_2.Equals(app_service_->GetPinPosition(extension2_->id()))); | 4019 position_2.Equals(app_service_->GetPinPosition(extension2_->id()))); |
| 4015 EXPECT_TRUE( | 4020 EXPECT_TRUE( |
| 4016 position_3.Equals(app_service_->GetPinPosition(extension3_->id()))); | 4021 position_3.Equals(app_service_->GetPinPosition(extension3_->id()))); |
| 4017 } | 4022 } |
| 4023 | |
| 4024 // Test the case when sync app is turned off and we need to use local copy to | |
| 4025 // support user's pins. | |
| 4026 TEST_F(ChromeLauncherControllerImplTest, SyncOffLocalUpdate) { | |
| 4027 InitLauncherController(); | |
| 4028 | |
| 4029 extension_service_->AddExtension(extension1_.get()); | |
| 4030 extension_service_->AddExtension(extension2_.get()); | |
| 4031 | |
| 4032 syncer::SyncChangeList sync_list; | |
| 4033 InsertAddPinChange(&sync_list, 0, extension_misc::kChromeAppId); | |
| 4034 InsertAddPinChange(&sync_list, 1, extension1_->id()); | |
| 4035 InsertAddPinChange(&sync_list, 1, extension2_->id()); | |
| 4036 SendPinChanges(sync_list, true); | |
| 4037 | |
| 4038 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | |
| 4039 | |
| 4040 syncer::SyncDataList copy_sync_list = | |
| 4041 app_service_->GetAllSyncData(syncer::APP_LIST); | |
| 4042 | |
| 4043 app_service_->StopSyncing(syncer::APP_LIST); | |
| 4044 RecreateChromeLauncher(); | |
| 4045 | |
| 4046 // Pinned state should not change. | |
| 4047 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | |
| 4048 launcher_controller_->UnpinAppWithID(extension2_->id()); | |
| 4049 EXPECT_EQ("AppList, Chrome, App1", GetPinnedAppStatus()); | |
| 4050 | |
| 4051 // Resume syncing and sync information overrides local copy. | |
| 4052 StartAppSyncService(copy_sync_list); | |
| 4053 EXPECT_EQ("AppList, Chrome, App1, App2", GetPinnedAppStatus()); | |
| 4054 } | |
| OLD | NEW |