| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/sync/test/integration/sync_arc_package_helper.h" | 5 #include "chrome/browser/sync/test/integration/sync_arc_package_helper.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <unordered_map> | 8 #include <unordered_map> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/run_loop.h" |
| 11 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 12 #include "chrome/browser/chromeos/arc/arc_auth_service.h" | 13 #include "chrome/browser/chromeos/arc/arc_auth_service.h" |
| 13 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 14 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 14 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 15 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 15 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 16 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" | 18 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
| 18 #include "chrome/browser/sync/test/integration/sync_test.h" | 19 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 19 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" | 20 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs.h" |
| 20 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" | 21 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 138 DVLOG(1) << "Profile2: " | 139 DVLOG(1) << "Profile2: " |
| 139 << ArcPackageSyncableService::Get(profiles.front()); | 140 << ArcPackageSyncableService::Get(profiles.front()); |
| 140 return false; | 141 return false; |
| 141 } | 142 } |
| 142 } | 143 } |
| 143 return true; | 144 return true; |
| 144 } | 145 } |
| 145 | 146 |
| 146 void SyncArcPackageHelper::SetupArcService(Profile* profile, size_t id) { | 147 void SyncArcPackageHelper::SetupArcService(Profile* profile, size_t id) { |
| 147 DCHECK(profile); | 148 DCHECK(profile); |
| 149 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
| 150 chromeos::switches::kEnableArc); |
| 148 const user_manager::User* user = CreateUserAndLogin(profile, id); | 151 const user_manager::User* user = CreateUserAndLogin(profile, id); |
| 149 // Have the user-to-profile mapping ready to avoid using the real profile | 152 // Have the user-to-profile mapping ready to avoid using the real profile |
| 150 // manager (which is null). | 153 // manager (which is null). |
| 151 chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, | 154 chromeos::ProfileHelper::Get()->SetUserToProfileMappingForTesting(user, |
| 152 profile); | 155 profile); |
| 153 | 156 |
| 154 ArcAuthService* auth_service = ArcAuthService::Get(); | 157 ArcAuthService* auth_service = ArcAuthService::Get(); |
| 155 DCHECK(auth_service); | 158 DCHECK(auth_service); |
| 156 ArcAuthService::DisableUIForTesting(); | 159 ArcAuthService::DisableUIForTesting(); |
| 157 auth_service->OnPrimaryUserProfilePrepared(profile); | 160 auth_service->OnPrimaryUserProfilePrepared(profile); |
| 158 auth_service->EnableArc(); | 161 auth_service->EnableArc(); |
| 159 | 162 |
| 160 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); | 163 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); |
| 161 DCHECK(arc_app_list_prefs); | 164 DCHECK(arc_app_list_prefs); |
| 165 |
| 166 base::RunLoop run_loop; |
| 167 arc_app_list_prefs->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); |
| 168 run_loop.Run(); |
| 169 |
| 162 instance_map_[profile].reset(new FakeAppInstance(arc_app_list_prefs)); | 170 instance_map_[profile].reset(new FakeAppInstance(arc_app_list_prefs)); |
| 163 DCHECK(instance_map_[profile].get()); | 171 DCHECK(instance_map_[profile].get()); |
| 164 arc_app_list_prefs->app_instance_holder()->SetInstance( | 172 arc_app_list_prefs->app_instance_holder()->SetInstance( |
| 165 instance_map_[profile].get()); | 173 instance_map_[profile].get()); |
| 166 } | 174 } |
| 167 | 175 |
| 168 void SyncArcPackageHelper::InstallPackage( | 176 void SyncArcPackageHelper::InstallPackage( |
| 169 Profile* profile, | 177 Profile* profile, |
| 170 const mojom::ArcPackageInfo& package) { | 178 const mojom::ArcPackageInfo& package) { |
| 171 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); | 179 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 235 if (package1_info->last_backup_android_id != | 243 if (package1_info->last_backup_android_id != |
| 236 package2_info->last_backup_android_id) | 244 package2_info->last_backup_android_id) |
| 237 return false; | 245 return false; |
| 238 if (package1_info->last_backup_time != package2_info->last_backup_time) | 246 if (package1_info->last_backup_time != package2_info->last_backup_time) |
| 239 return false; | 247 return false; |
| 240 } | 248 } |
| 241 return true; | 249 return true; |
| 242 } | 250 } |
| 243 | 251 |
| 244 } // namespace arc | 252 } // namespace arc |
| OLD | NEW |