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

Side by Side Diff: chrome/browser/sync/test/integration/sync_arc_package_helper.cc

Issue 2357053002: Always use arc::InstanceHolder<T>::GetInstanceForMethod (Closed)
Patch Set: rebase, no code change Created 4 years, 2 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 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 <memory>
7 #include <string> 8 #include <string>
8 #include <unordered_map> 9 #include <unordered_map>
10 #include <vector>
9 11
10 #include "base/command_line.h" 12 #include "base/command_line.h"
11 #include "base/strings/string_number_conversions.h" 13 #include "base/strings/string_number_conversions.h"
12 #include "chrome/browser/chromeos/arc/arc_auth_service.h" 14 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
13 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" 15 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h"
14 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" 16 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h"
15 #include "chrome/browser/chromeos/profiles/profile_helper.h" 17 #include "chrome/browser/chromeos/profiles/profile_helper.h"
16 #include "chrome/browser/profiles/profile.h" 18 #include "chrome/browser/profiles/profile.h"
17 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" 19 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h"
18 #include "chrome/browser/sync/test/integration/sync_test.h" 20 #include "chrome/browser/sync/test/integration/sync_test.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 arc_app_list_prefs->app_instance_holder()->SetInstance( 166 arc_app_list_prefs->app_instance_holder()->SetInstance(
165 instance_map_[profile].get()); 167 instance_map_[profile].get());
166 } 168 }
167 169
168 void SyncArcPackageHelper::InstallPackage( 170 void SyncArcPackageHelper::InstallPackage(
169 Profile* profile, 171 Profile* profile,
170 const mojom::ArcPackageInfo& package) { 172 const mojom::ArcPackageInfo& package) {
171 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); 173 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile);
172 DCHECK(arc_app_list_prefs); 174 DCHECK(arc_app_list_prefs);
173 FakeAppInstance* fake_app_instance = static_cast<FakeAppInstance*>( 175 FakeAppInstance* fake_app_instance = static_cast<FakeAppInstance*>(
174 arc_app_list_prefs->app_instance_holder()->instance()); 176 arc_app_list_prefs->app_instance_holder()->GetInstanceForMethod(
177 "InstallPackage"));
175 178
176 DCHECK(fake_app_instance); 179 DCHECK(fake_app_instance);
177 // After this function, new package should be added to local sync service 180 // After this function, new package should be added to local sync service
178 // and install event should be sent to sync server. 181 // and install event should be sent to sync server.
179 fake_app_instance->InstallPackage(package.Clone()); 182 fake_app_instance->InstallPackage(package.Clone());
180 } 183 }
181 184
182 void SyncArcPackageHelper::UninstallPackage(Profile* profile, 185 void SyncArcPackageHelper::UninstallPackage(Profile* profile,
183 const std::string& package_name) { 186 const std::string& package_name) {
184 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); 187 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile);
185 DCHECK(arc_app_list_prefs); 188 DCHECK(arc_app_list_prefs);
186 FakeAppInstance* fake_app_instance = static_cast<FakeAppInstance*>( 189 FakeAppInstance* fake_app_instance = static_cast<FakeAppInstance*>(
187 arc_app_list_prefs->app_instance_holder()->instance()); 190 arc_app_list_prefs->app_instance_holder()->GetInstanceForMethod(
191 "UninstallPackage"));
188 DCHECK(fake_app_instance); 192 DCHECK(fake_app_instance);
189 // After this function, package should be removed from local sync service 193 // After this function, package should be removed from local sync service
190 // and uninstall event should be sent to sync server. 194 // and uninstall event should be sent to sync server.
191 fake_app_instance->UninstallPackage(package_name); 195 fake_app_instance->UninstallPackage(package_name);
192 } 196 }
193 197
194 // Packages from local pref are used for these test functions. Packages in local 198 // Packages from local pref are used for these test functions. Packages in local
195 // pref should be indentical to syncservice after syncservice is launched. 199 // pref should be indentical to syncservice after syncservice is launched.
196 // Packagd update behavior is not synced by design. 200 // Packagd update behavior is not synced by design.
197 bool SyncArcPackageHelper::ArcPackagesMatch(Profile* profile1, 201 bool SyncArcPackageHelper::ArcPackagesMatch(Profile* profile1,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 if (package1_info->last_backup_android_id != 239 if (package1_info->last_backup_android_id !=
236 package2_info->last_backup_android_id) 240 package2_info->last_backup_android_id)
237 return false; 241 return false;
238 if (package1_info->last_backup_time != package2_info->last_backup_time) 242 if (package1_info->last_backup_time != package2_info->last_backup_time)
239 return false; 243 return false;
240 } 244 }
241 return true; 245 return true;
242 } 246 }
243 247
244 } // namespace arc 248 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/speech/tts_chromeos.cc ('k') | chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698