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