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