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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // OnPackageListRefreshed will be called. | 176 // OnPackageListRefreshed will be called. |
177 instance_map_[profile]->SendRefreshPackageList( | 177 instance_map_[profile]->SendRefreshPackageList( |
178 std::vector<arc::mojom::ArcPackageInfo>()); | 178 std::vector<arc::mojom::ArcPackageInfo>()); |
179 } | 179 } |
180 | 180 |
181 void SyncArcPackageHelper::InstallPackage( | 181 void SyncArcPackageHelper::InstallPackage( |
182 Profile* profile, | 182 Profile* profile, |
183 const mojom::ArcPackageInfo& package) { | 183 const mojom::ArcPackageInfo& package) { |
184 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); | 184 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); |
185 DCHECK(arc_app_list_prefs); | 185 DCHECK(arc_app_list_prefs); |
186 FakeAppInstance* fake_app_instance = static_cast<FakeAppInstance*>( | 186 mojom::AppInstance* app_instance = ARC_GET_INSTANCE_FOR_METHOD( |
187 arc_app_list_prefs->app_instance_holder()->GetInstanceForMethod( | 187 arc_app_list_prefs->app_instance_holder(), InstallPackage); |
188 "InstallPackage")); | |
189 | 188 |
190 DCHECK(fake_app_instance); | 189 DCHECK(app_instance); |
191 // After this function, new package should be added to local sync service | 190 // After this function, new package should be added to local sync service |
192 // and install event should be sent to sync server. | 191 // and install event should be sent to sync server. |
193 fake_app_instance->InstallPackage(package.Clone()); | 192 app_instance->InstallPackage(package.Clone()); |
194 } | 193 } |
195 | 194 |
196 void SyncArcPackageHelper::UninstallPackage(Profile* profile, | 195 void SyncArcPackageHelper::UninstallPackage(Profile* profile, |
197 const std::string& package_name) { | 196 const std::string& package_name) { |
198 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); | 197 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); |
199 DCHECK(arc_app_list_prefs); | 198 DCHECK(arc_app_list_prefs); |
200 FakeAppInstance* fake_app_instance = static_cast<FakeAppInstance*>( | 199 mojom::AppInstance* app_instance = ARC_GET_INSTANCE_FOR_METHOD( |
201 arc_app_list_prefs->app_instance_holder()->GetInstanceForMethod( | 200 arc_app_list_prefs->app_instance_holder(), UninstallPackage); |
202 "UninstallPackage")); | 201 DCHECK(app_instance); |
203 DCHECK(fake_app_instance); | |
204 // After this function, package should be removed from local sync service | 202 // After this function, package should be removed from local sync service |
205 // and uninstall event should be sent to sync server. | 203 // and uninstall event should be sent to sync server. |
206 fake_app_instance->UninstallPackage(package_name); | 204 app_instance->UninstallPackage(package_name); |
207 } | 205 } |
208 | 206 |
209 // Packages from local pref are used for these test functions. Packages in local | 207 // Packages from local pref are used for these test functions. Packages in local |
210 // pref should be indentical to syncservice after syncservice is launched. | 208 // pref should be indentical to syncservice after syncservice is launched. |
211 // Packagd update behavior is not synced by design. | 209 // Packagd update behavior is not synced by design. |
212 bool SyncArcPackageHelper::ArcPackagesMatch(Profile* profile1, | 210 bool SyncArcPackageHelper::ArcPackagesMatch(Profile* profile1, |
213 Profile* profile2) { | 211 Profile* profile2) { |
214 const ArcAppListPrefs* prefs1 = ArcAppListPrefs::Get(profile1); | 212 const ArcAppListPrefs* prefs1 = ArcAppListPrefs::Get(profile1); |
215 const ArcAppListPrefs* prefs2 = ArcAppListPrefs::Get(profile2); | 213 const ArcAppListPrefs* prefs2 = ArcAppListPrefs::Get(profile2); |
216 DCHECK(prefs1); | 214 DCHECK(prefs1); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
250 if (package1_info->last_backup_android_id != | 248 if (package1_info->last_backup_android_id != |
251 package2_info->last_backup_android_id) | 249 package2_info->last_backup_android_id) |
252 return false; | 250 return false; |
253 if (package1_info->last_backup_time != package2_info->last_backup_time) | 251 if (package1_info->last_backup_time != package2_info->last_backup_time) |
254 return false; | 252 return false; |
255 } | 253 } |
256 return true; | 254 return true; |
257 } | 255 } |
258 | 256 |
259 } // namespace arc | 257 } // namespace arc |
OLD | NEW |