| 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" |
| 11 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 12 #include "base/strings/string_number_conversions.h" | 12 #include "base/strings/string_number_conversions.h" |
| 13 #include "chrome/browser/chromeos/arc/arc_session_manager.h" | 13 #include "chrome/browser/chromeos/arc/arc_session_manager.h" |
| 14 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" | 14 #include "chrome/browser/chromeos/login/users/fake_chrome_user_manager.h" |
| 15 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" | 15 #include "chrome/browser/chromeos/login/users/scoped_user_manager_enabler.h" |
| 16 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 16 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" | 18 #include "chrome/browser/sync/test/integration/sync_datatype_helper.h" |
| 19 #include "chrome/browser/sync/test/integration/sync_test.h" | 19 #include "chrome/browser/sync/test/integration/sync_test.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.h" |
| 21 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" | |
| 22 #include "chrome/browser/ui/app_list/arc/arc_package_syncable_service.h" | 21 #include "chrome/browser/ui/app_list/arc/arc_package_syncable_service.h" |
| 23 #include "chromeos/chromeos_switches.h" | 22 #include "chromeos/chromeos_switches.h" |
| 24 #include "components/arc/arc_bridge_service.h" | 23 #include "components/arc/arc_bridge_service.h" |
| 25 #include "components/arc/test/fake_app_instance.h" | 24 #include "components/arc/test/fake_app_instance.h" |
| 26 | 25 |
| 27 namespace arc { | 26 namespace arc { |
| 28 | 27 |
| 29 namespace { | 28 namespace { |
| 30 | 29 |
| 31 std::string GetTestPackageName(size_t id) { | 30 std::string GetTestPackageName(size_t id) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 62 | 61 |
| 63 void SyncArcPackageHelper::SetupTest(SyncTest* test) { | 62 void SyncArcPackageHelper::SetupTest(SyncTest* test) { |
| 64 if (setup_completed_) { | 63 if (setup_completed_) { |
| 65 DCHECK_EQ(test, test_); | 64 DCHECK_EQ(test, test_); |
| 66 return; | 65 return; |
| 67 } | 66 } |
| 68 test_ = test; | 67 test_ = test; |
| 69 | 68 |
| 70 user_manager_enabler_ = base::MakeUnique<chromeos::ScopedUserManagerEnabler>( | 69 user_manager_enabler_ = base::MakeUnique<chromeos::ScopedUserManagerEnabler>( |
| 71 new chromeos::FakeChromeUserManager()); | 70 new chromeos::FakeChromeUserManager()); |
| 72 ArcAppListPrefsFactory::SetFactoryForSyncTest(); | 71 InstanceHolder<mojom::AppInstance>::SetInstanceHolderForSyncTest(); |
| 72 ArcSessionManager::SetSessionManagerForSyncTest(); |
| 73 size_t id = 0; | 73 size_t id = 0; |
| 74 for (auto* profile : test_->GetAllProfiles()) | 74 for (auto* profile : test_->GetAllProfiles()) |
| 75 SetupArcService(profile, id++); | 75 SetupArcService(profile, id++); |
| 76 setup_completed_ = true; | 76 setup_completed_ = true; |
| 77 } | 77 } |
| 78 | 78 |
| 79 void SyncArcPackageHelper::CleanUp() { | 79 void SyncArcPackageHelper::CleanUp() { |
| 80 ArcSessionManager::Get()->Shutdown(); | 80 ArcSessionManager::Get()->Shutdown(); |
| 81 user_manager_enabler_.reset(); | 81 user_manager_enabler_.reset(); |
| 82 chromeos::ProfileHelper::Get()->ClearUserToProfileMappingForTesting(); |
| 82 } | 83 } |
| 83 | 84 |
| 84 void SyncArcPackageHelper::InstallPackageWithIndex(Profile* profile, | 85 void SyncArcPackageHelper::InstallPackageWithIndex(Profile* profile, |
| 85 size_t id) { | 86 size_t id) { |
| 86 std::string package_name = GetTestPackageName(id); | 87 std::string package_name = GetTestPackageName(id); |
| 87 | 88 |
| 88 mojom::ArcPackageInfo package; | 89 mojom::ArcPackageInfo package; |
| 89 package.package_name = package_name; | 90 package.package_name = package_name; |
| 90 package.package_version = id; | 91 package.package_version = id; |
| 91 package.last_backup_android_id = id; | 92 package.last_backup_android_id = id; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 profile); | 151 profile); |
| 151 | 152 |
| 152 ArcSessionManager* arc_session_manager = ArcSessionManager::Get(); | 153 ArcSessionManager* arc_session_manager = ArcSessionManager::Get(); |
| 153 DCHECK(arc_session_manager); | 154 DCHECK(arc_session_manager); |
| 154 ArcSessionManager::DisableUIForTesting(); | 155 ArcSessionManager::DisableUIForTesting(); |
| 155 arc_session_manager->OnPrimaryUserProfilePrepared(profile); | 156 arc_session_manager->OnPrimaryUserProfilePrepared(profile); |
| 156 arc_session_manager->SetArcPlayStoreEnabled(true); | 157 arc_session_manager->SetArcPlayStoreEnabled(true); |
| 157 | 158 |
| 158 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); | 159 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); |
| 159 DCHECK(arc_app_list_prefs); | 160 DCHECK(arc_app_list_prefs); |
| 160 | |
| 161 base::RunLoop run_loop; | 161 base::RunLoop run_loop; |
| 162 arc_app_list_prefs->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); | 162 arc_app_list_prefs->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); |
| 163 run_loop.Run(); | 163 run_loop.Run(); |
| 164 | 164 |
| 165 instance_map_[profile] = | 165 instance_map_[profile] = |
| 166 base::MakeUnique<FakeAppInstance>(arc_app_list_prefs); | 166 base::MakeUnique<FakeAppInstance>(arc_app_list_prefs); |
| 167 DCHECK(instance_map_[profile].get()); | 167 DCHECK(instance_map_[profile].get()); |
| 168 arc_app_list_prefs->app_instance_holder()->SetInstance( | 168 arc_app_list_prefs->app_instance_holder()->SetInstance( |
| 169 instance_map_[profile].get()); | 169 instance_map_[profile].get()); |
| 170 // OnPackageListRefreshed will be called when AppInstance is ready. | 170 // OnPackageListRefreshed will be called when AppInstance is ready. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 if (package1_info->last_backup_android_id != | 244 if (package1_info->last_backup_android_id != |
| 245 package2_info->last_backup_android_id) | 245 package2_info->last_backup_android_id) |
| 246 return false; | 246 return false; |
| 247 if (package1_info->last_backup_time != package2_info->last_backup_time) | 247 if (package1_info->last_backup_time != package2_info->last_backup_time) |
| 248 return false; | 248 return false; |
| 249 } | 249 } |
| 250 return true; | 250 return true; |
| 251 } | 251 } |
| 252 | 252 |
| 253 } // namespace arc | 253 } // namespace arc |
| OLD | NEW |