| 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/profiles/profile.h" | 5 #include "chrome/browser/profiles/profile.h" |
| 6 #include "chrome/browser/sync/test/integration/sync_arc_package_helper.h" | 6 #include "chrome/browser/sync/test/integration/sync_arc_package_helper.h" |
| 7 #include "chrome/browser/sync/test/integration/sync_test.h" | 7 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 8 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" | 8 #include "chrome/browser/sync/test/integration/updated_progress_marker_checker.h
" |
| 9 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" | |
| 10 #include "chrome/browser/ui/app_list/arc/arc_package_syncable_service.h" | 9 #include "chrome/browser/ui/app_list/arc/arc_package_syncable_service.h" |
| 11 #include "components/arc/arc_util.h" | |
| 12 | 10 |
| 13 namespace arc { | 11 namespace arc { |
| 14 | 12 |
| 15 namespace { | 13 namespace { |
| 16 | 14 |
| 17 bool AllProfilesHaveSameArcPackageDetails() { | 15 bool AllProfilesHaveSameArcPackageDetails() { |
| 18 return SyncArcPackageHelper::GetInstance() | 16 return SyncArcPackageHelper::GetInstance() |
| 19 ->AllProfilesHaveSamePackageDetails(); | 17 ->AllProfilesHaveSamePackageDetails(); |
| 20 } | 18 } |
| 21 | 19 |
| 22 } // namespace | 20 } // namespace |
| 23 | 21 |
| 24 class SingleClientArcPackageSyncTest : public SyncTest { | 22 class SingleClientArcPackageSyncTest : public SyncTest { |
| 25 public: | 23 public: |
| 26 SingleClientArcPackageSyncTest() | 24 SingleClientArcPackageSyncTest() : SyncTest(SINGLE_CLIENT) {} |
| 27 : SyncTest(SINGLE_CLIENT), sync_helper_(nullptr) {} | |
| 28 | 25 |
| 29 ~SingleClientArcPackageSyncTest() override {} | 26 ~SingleClientArcPackageSyncTest() override {} |
| 30 | 27 |
| 31 bool SetupClients() override { | |
| 32 if (!SyncTest::SetupClients()) | |
| 33 return false; | |
| 34 | |
| 35 // Init SyncArcPackageHelper to ensure that the arc services are initialized | |
| 36 // for each Profile. | |
| 37 sync_helper_ = SyncArcPackageHelper::GetInstance(); | |
| 38 return sync_helper_ != nullptr; | |
| 39 } | |
| 40 | |
| 41 void SetUpOnMainThread() override { | |
| 42 // This setting does not affect the profile created by InProcessBrowserTest. | |
| 43 // Only sync test profiles are affected. | |
| 44 ArcAppListPrefsFactory::SetFactoryForSyncTest(); | |
| 45 } | |
| 46 | |
| 47 void TearDownOnMainThread() override { | |
| 48 sync_helper_ = nullptr; | |
| 49 SyncTest::TearDownOnMainThread(); | |
| 50 } | |
| 51 | |
| 52 // Sets up command line flags required for Arc sync tests. | |
| 53 void SetUpCommandLine(base::CommandLine* cl) override { | |
| 54 SetArcAvailableCommandLineForTesting(cl); | |
| 55 SyncTest::SetUpCommandLine(cl); | |
| 56 } | |
| 57 | |
| 58 SyncArcPackageHelper* sync_helper() { return sync_helper_; } | |
| 59 | |
| 60 private: | 28 private: |
| 61 SyncArcPackageHelper* sync_helper_; | |
| 62 | |
| 63 DISALLOW_COPY_AND_ASSIGN(SingleClientArcPackageSyncTest); | 29 DISALLOW_COPY_AND_ASSIGN(SingleClientArcPackageSyncTest); |
| 64 }; | 30 }; |
| 65 | 31 |
| 66 IN_PROC_BROWSER_TEST_F(SingleClientArcPackageSyncTest, ArcPackageEmpty) { | 32 IN_PROC_BROWSER_TEST_F(SingleClientArcPackageSyncTest, ArcPackageEmpty) { |
| 67 ASSERT_TRUE(SetupSync()); | 33 ASSERT_TRUE(SetupSync()); |
| 68 | 34 |
| 69 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); | 35 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); |
| 70 } | 36 } |
| 71 | 37 |
| 72 IN_PROC_BROWSER_TEST_F(SingleClientArcPackageSyncTest, | 38 IN_PROC_BROWSER_TEST_F(SingleClientArcPackageSyncTest, |
| 73 ArcPackageInstallSomePackages) { | 39 ArcPackageInstallSomePackages) { |
| 74 ASSERT_TRUE(SetupSync()); | 40 ASSERT_TRUE(SetupSync()); |
| 75 | 41 |
| 76 constexpr size_t kNumPackages = 5; | 42 constexpr size_t kNumPackages = 5; |
| 77 for (size_t i = 0; i < kNumPackages; ++i) { | 43 for (size_t i = 0; i < kNumPackages; ++i) { |
| 78 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); | 44 sync_arc_helper()->InstallPackageWithIndex(GetProfile(0), i); |
| 79 sync_helper()->InstallPackageWithIndex(verifier(), i); | 45 sync_arc_helper()->InstallPackageWithIndex(verifier(), i); |
| 80 } | 46 } |
| 81 | 47 |
| 82 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); | 48 ASSERT_TRUE(UpdatedProgressMarkerChecker(GetSyncService(0)).Wait()); |
| 83 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); | 49 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); |
| 84 } | 50 } |
| 85 | 51 |
| 86 } // namespace arc | 52 } // namespace arc |
| OLD | NEW |