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_integration_test_util.h" | 7 #include "chrome/browser/sync/test/integration/sync_integration_test_util.h" |
| 8 #include "chrome/browser/sync/test/integration/sync_test.h" | 8 #include "chrome/browser/sync/test/integration/sync_test.h" |
| 9 #include "chrome/browser/ui/app_list/arc/arc_app_list_prefs_factory.h" | |
| 10 #include "components/arc/arc_util.h" | |
| 9 | 11 |
| 10 namespace arc { | 12 namespace arc { |
| 11 | 13 |
| 12 namespace { | 14 namespace { |
| 13 | 15 |
| 14 bool AllProfilesHaveSameArcPackageDetails() { | 16 bool AllProfilesHaveSameArcPackageDetails() { |
| 15 return SyncArcPackageHelper::GetInstance() | 17 return SyncArcPackageHelper::GetInstance() |
| 16 ->AllProfilesHaveSamePackageDetails(); | 18 ->AllProfilesHaveSamePackageDetails(); |
| 17 } | 19 } |
| 18 | 20 |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 30 bool SetupClients() override { | 32 bool SetupClients() override { |
| 31 if (!SyncTest::SetupClients()) | 33 if (!SyncTest::SetupClients()) |
| 32 return false; | 34 return false; |
| 33 | 35 |
| 34 // Init SyncArcPackageHelper to ensure that the arc services are initialized | 36 // Init SyncArcPackageHelper to ensure that the arc services are initialized |
| 35 // for each Profile. | 37 // for each Profile. |
| 36 sync_helper_ = SyncArcPackageHelper::GetInstance(); | 38 sync_helper_ = SyncArcPackageHelper::GetInstance(); |
| 37 return sync_helper_ != nullptr; | 39 return sync_helper_ != nullptr; |
| 38 } | 40 } |
| 39 | 41 |
| 42 void SetUpOnMainThread() override { | |
| 43 // This setting does not affect the profile created by InProcessBrowserTest. | |
|
skym
2017/03/03 19:44:58
I don't understand how this comment is true. It se
lgcheng
2017/03/03 21:13:01
The ArcAppListPrefs created with InProcessBrowserT
| |
| 44 // Only sync test profiles are affected. | |
| 45 ArcAppListPrefsFactory::SetFactoryForSyncTest(); | |
| 46 } | |
| 47 | |
| 48 // Sets up command line flags required for Arc sync tests. | |
| 49 void SetUpCommandLine(base::CommandLine* cl) override { | |
| 50 SetArcAvailableCommandLineForTesting(cl); | |
| 51 SyncTest::SetUpCommandLine(cl); | |
| 52 } | |
| 53 | |
| 40 void TearDownOnMainThread() override { | 54 void TearDownOnMainThread() override { |
| 41 sync_helper_->CleanUp(); | |
| 42 sync_helper_ = nullptr; | 55 sync_helper_ = nullptr; |
| 43 SyncTest::TearDownOnMainThread(); | 56 SyncTest::TearDownOnMainThread(); |
| 44 } | 57 } |
| 45 | 58 |
| 46 SyncArcPackageHelper* sync_helper() { return sync_helper_; } | 59 SyncArcPackageHelper* sync_helper() { return sync_helper_; } |
| 47 | 60 |
| 48 private: | 61 private: |
| 49 SyncArcPackageHelper* sync_helper_; | 62 SyncArcPackageHelper* sync_helper_; |
| 50 | 63 |
| 51 DISALLOW_COPY_AND_ASSIGN(TwoClientArcPackageSyncTest); | 64 DISALLOW_COPY_AND_ASSIGN(TwoClientArcPackageSyncTest); |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 78 ASSERT_TRUE(SetupClients()); | 91 ASSERT_TRUE(SetupClients()); |
| 79 | 92 |
| 80 constexpr size_t kNumPackages = 5; | 93 constexpr size_t kNumPackages = 5; |
| 81 for (size_t i = 0; i < kNumPackages; ++i) { | 94 for (size_t i = 0; i < kNumPackages; ++i) { |
| 82 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); | 95 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); |
| 83 } | 96 } |
| 84 | 97 |
| 85 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails()); | 98 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails()); |
| 86 | 99 |
| 87 ASSERT_TRUE(SetupSync()); | 100 ASSERT_TRUE(SetupSync()); |
| 88 | 101 ASSERT_TRUE(AwaitQuiescence()); |
|
skym
2017/03/03 19:44:58
I guess this is okay. I'd prefer you created a der
lgcheng
2017/03/03 21:13:01
Acknowledged.
| |
| 89 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); | 102 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); |
| 90 } | 103 } |
| 91 | 104 |
| 92 // In this test, packages are installed before sync started. Client1 will have | 105 // In this test, packages are installed before sync started. Client1 will have |
| 93 // package 0 to 9 installed and client2 will have package 0 to 4 installed. | 106 // package 0 to 9 installed and client2 will have package 0 to 4 installed. |
| 94 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, | 107 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, |
| 95 OneClientHasPackagesAnotherHasSubSet) { | 108 OneClientHasPackagesAnotherHasSubSet) { |
| 96 ASSERT_TRUE(SetupClients()); | 109 ASSERT_TRUE(SetupClients()); |
| 97 | 110 |
| 98 constexpr size_t kNumPackages = 5; | 111 constexpr size_t kNumPackages = 5; |
| 99 for (size_t i = 0; i < kNumPackages; ++i) { | 112 for (size_t i = 0; i < kNumPackages; ++i) { |
| 100 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); | 113 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); |
| 101 sync_helper()->InstallPackageWithIndex(GetProfile(1), i); | 114 sync_helper()->InstallPackageWithIndex(GetProfile(1), i); |
| 102 } | 115 } |
| 103 | 116 |
| 104 for (size_t i = 0; i < kNumPackages; ++i) { | 117 for (size_t i = 0; i < kNumPackages; ++i) { |
| 105 sync_helper()->InstallPackageWithIndex(GetProfile(0), i + kNumPackages); | 118 sync_helper()->InstallPackageWithIndex(GetProfile(0), i + kNumPackages); |
| 106 } | 119 } |
| 107 | 120 |
| 108 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails()); | 121 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails()); |
| 109 | 122 |
| 110 ASSERT_TRUE(SetupSync()); | 123 ASSERT_TRUE(SetupSync()); |
| 111 | 124 ASSERT_TRUE(AwaitQuiescence()); |
| 112 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); | 125 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); |
| 113 } | 126 } |
| 114 | 127 |
| 115 // In this test, packages are installed before sync started. Client1 will have | 128 // In this test, packages are installed before sync started. Client1 will have |
| 116 // package 0 to 4 installed and client2 will have package 1 to 5 installed. | 129 // package 0 to 4 installed and client2 will have package 1 to 5 installed. |
| 117 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, | 130 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, |
| 118 StartWithDifferentPackages) { | 131 StartWithDifferentPackages) { |
| 119 ASSERT_TRUE(SetupClients()); | 132 ASSERT_TRUE(SetupClients()); |
| 120 | 133 |
| 121 constexpr size_t kNumPackages = 5; | 134 constexpr size_t kNumPackages = 5; |
| 122 constexpr size_t kPackageIdDiff = 1; | 135 constexpr size_t kPackageIdDiff = 1; |
| 123 for (size_t i = 0; i < kNumPackages; ++i) { | 136 for (size_t i = 0; i < kNumPackages; ++i) { |
| 124 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); | 137 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); |
| 125 sync_helper()->InstallPackageWithIndex(GetProfile(1), i + kPackageIdDiff); | 138 sync_helper()->InstallPackageWithIndex(GetProfile(1), i + kPackageIdDiff); |
| 126 } | 139 } |
| 127 | 140 |
| 128 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails()); | 141 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails()); |
| 129 | 142 |
| 130 ASSERT_TRUE(SetupSync()); | 143 ASSERT_TRUE(SetupSync()); |
| 131 | 144 ASSERT_TRUE(AwaitQuiescence()); |
| 132 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); | 145 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); |
| 133 } | 146 } |
| 134 | 147 |
| 135 // Tests package installaton after sync started. | 148 // Tests package installaton after sync started. |
| 136 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, Install) { | 149 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, Install) { |
| 137 ASSERT_TRUE(SetupSync()); | 150 ASSERT_TRUE(SetupSync()); |
| 138 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); | 151 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); |
| 139 | 152 |
| 140 sync_helper()->InstallPackageWithIndex(GetProfile(0), 0); | 153 sync_helper()->InstallPackageWithIndex(GetProfile(0), 0); |
| 141 ASSERT_TRUE(AwaitQuiescence()); | 154 ASSERT_TRUE(AwaitQuiescence()); |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 169 ASSERT_TRUE(AwaitQuiescence()); | 182 ASSERT_TRUE(AwaitQuiescence()); |
| 170 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); | 183 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); |
| 171 | 184 |
| 172 sync_helper()->UninstallPackageWithIndex(GetProfile(1), 1); | 185 sync_helper()->UninstallPackageWithIndex(GetProfile(1), 1); |
| 173 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails()); | 186 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails()); |
| 174 ASSERT_TRUE(AwaitQuiescence()); | 187 ASSERT_TRUE(AwaitQuiescence()); |
| 175 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); | 188 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); |
| 176 } | 189 } |
| 177 | 190 |
| 178 } // namespace arc | 191 } // namespace arc |
| OLD | NEW |