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/run_loop.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" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 | 61 |
61 SyncArcPackageHelper::~SyncArcPackageHelper() {} | 62 SyncArcPackageHelper::~SyncArcPackageHelper() {} |
62 | 63 |
63 void SyncArcPackageHelper::SetupTest(SyncTest* test) { | 64 void SyncArcPackageHelper::SetupTest(SyncTest* test) { |
64 if (setup_completed_) { | 65 if (setup_completed_) { |
65 DCHECK_EQ(test, test_); | 66 DCHECK_EQ(test, test_); |
66 return; | 67 return; |
67 } | 68 } |
68 test_ = test; | 69 test_ = test; |
69 | 70 |
70 user_manager_enabler_.reset(new chromeos::ScopedUserManagerEnabler( | 71 user_manager_enabler_ = base::MakeUnique<chromeos::ScopedUserManagerEnabler>( |
71 new chromeos::FakeChromeUserManager())); | 72 new chromeos::FakeChromeUserManager()); |
72 base::CommandLine::ForCurrentProcess()->AppendSwitch( | 73 base::CommandLine::ForCurrentProcess()->AppendSwitch( |
73 chromeos::switches::kEnableArc); | 74 chromeos::switches::kEnableArc); |
74 ArcAppListPrefsFactory::SetFactoryForSyncTest(); | 75 ArcAppListPrefsFactory::SetFactoryForSyncTest(); |
75 size_t id = 0; | 76 size_t id = 0; |
76 for (auto* profile : test_->GetAllProfiles()) | 77 for (auto* profile : test_->GetAllProfiles()) |
77 SetupArcService(profile, id++); | 78 SetupArcService(profile, id++); |
78 setup_completed_ = true; | 79 setup_completed_ = true; |
79 } | 80 } |
80 | 81 |
81 void SyncArcPackageHelper::CleanUp() { | 82 void SyncArcPackageHelper::CleanUp() { |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 auth_service->OnPrimaryUserProfilePrepared(profile); | 160 auth_service->OnPrimaryUserProfilePrepared(profile); |
160 auth_service->EnableArc(); | 161 auth_service->EnableArc(); |
161 | 162 |
162 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); | 163 ArcAppListPrefs* arc_app_list_prefs = ArcAppListPrefs::Get(profile); |
163 DCHECK(arc_app_list_prefs); | 164 DCHECK(arc_app_list_prefs); |
164 | 165 |
165 base::RunLoop run_loop; | 166 base::RunLoop run_loop; |
166 arc_app_list_prefs->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); | 167 arc_app_list_prefs->SetDefaltAppsReadyCallback(run_loop.QuitClosure()); |
167 run_loop.Run(); | 168 run_loop.Run(); |
168 | 169 |
169 instance_map_[profile].reset(new FakeAppInstance(arc_app_list_prefs)); | 170 instance_map_[profile] = |
| 171 base::MakeUnique<FakeAppInstance>(arc_app_list_prefs); |
170 DCHECK(instance_map_[profile].get()); | 172 DCHECK(instance_map_[profile].get()); |
171 arc_app_list_prefs->app_instance_holder()->SetInstance( | 173 arc_app_list_prefs->app_instance_holder()->SetInstance( |
172 instance_map_[profile].get()); | 174 instance_map_[profile].get()); |
173 // OnPackageListRefreshed will be called when AppInstance is ready. | 175 // OnPackageListRefreshed will be called when AppInstance is ready. |
174 // For fakeAppInstance we use SendRefreshPackageList to make sure that | 176 // For fakeAppInstance we use SendRefreshPackageList to make sure that |
175 // OnPackageListRefreshed will be called. | 177 // OnPackageListRefreshed will be called. |
176 instance_map_[profile]->SendRefreshPackageList( | 178 instance_map_[profile]->SendRefreshPackageList( |
177 std::vector<arc::mojom::ArcPackageInfo>()); | 179 std::vector<arc::mojom::ArcPackageInfo>()); |
178 } | 180 } |
179 | 181 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 if (package1_info->last_backup_android_id != | 251 if (package1_info->last_backup_android_id != |
250 package2_info->last_backup_android_id) | 252 package2_info->last_backup_android_id) |
251 return false; | 253 return false; |
252 if (package1_info->last_backup_time != package2_info->last_backup_time) | 254 if (package1_info->last_backup_time != package2_info->last_backup_time) |
253 return false; | 255 return false; |
254 } | 256 } |
255 return true; | 257 return true; |
256 } | 258 } |
257 | 259 |
258 } // namespace arc | 260 } // namespace arc |
OLD | NEW |