Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(90)

Side by Side Diff: chrome/browser/sync/test/integration/two_client_arc_package_sync_test.cc

Issue 2740363002: [Sync] Fix EnableDisableSingleClientTest (Closed)
Patch Set: add {} Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « chrome/browser/sync/test/integration/sync_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 9
12 namespace arc { 10 namespace arc {
13 11
14 namespace { 12 namespace {
15 13
16 bool AllProfilesHaveSameArcPackageDetails() { 14 bool AllProfilesHaveSameArcPackageDetails() {
17 return SyncArcPackageHelper::GetInstance() 15 return SyncArcPackageHelper::GetInstance()
18 ->AllProfilesHaveSamePackageDetails(); 16 ->AllProfilesHaveSamePackageDetails();
19 } 17 }
20 18
21 } // namespace 19 } // namespace
22 20
23 class TwoClientArcPackageSyncTest : public SyncTest { 21 class TwoClientArcPackageSyncTest : public SyncTest {
24 public: 22 public:
25 TwoClientArcPackageSyncTest() 23 TwoClientArcPackageSyncTest() : SyncTest(TWO_CLIENT_LEGACY) {
26 : SyncTest(TWO_CLIENT_LEGACY), sync_helper_(nullptr) {
27 DisableVerifier(); 24 DisableVerifier();
28 } 25 }
29 26
30 ~TwoClientArcPackageSyncTest() override {} 27 ~TwoClientArcPackageSyncTest() override {}
31 28
32 bool SetupClients() override {
33 if (!SyncTest::SetupClients())
34 return false;
35
36 // Init SyncArcPackageHelper to ensure that the arc services are initialized
37 // for each Profile.
38 sync_helper_ = SyncArcPackageHelper::GetInstance();
39 return sync_helper_ != nullptr;
40 }
41
42 void SetUpOnMainThread() override {
43 // This setting does not affect the profile created by InProcessBrowserTest.
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
54 void TearDownOnMainThread() override {
55 sync_helper_ = nullptr;
56 SyncTest::TearDownOnMainThread();
57 }
58
59 SyncArcPackageHelper* sync_helper() { return sync_helper_; }
60
61 private: 29 private:
62 SyncArcPackageHelper* sync_helper_;
63
64 DISALLOW_COPY_AND_ASSIGN(TwoClientArcPackageSyncTest); 30 DISALLOW_COPY_AND_ASSIGN(TwoClientArcPackageSyncTest);
65 }; 31 };
66 32
67 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, StartWithNoPackages) { 33 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, StartWithNoPackages) {
68 ASSERT_TRUE(SetupSync()); 34 ASSERT_TRUE(SetupSync());
69 35
70 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); 36 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails());
71 } 37 }
72 38
73 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, StartWithSamePackages) { 39 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, StartWithSamePackages) {
74 ASSERT_TRUE(SetupClients()); 40 ASSERT_TRUE(SetupClients());
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(GetProfile(1), i); 45 sync_arc_helper()->InstallPackageWithIndex(GetProfile(1), i);
80 } 46 }
81 47
82 ASSERT_TRUE(SetupSync()); 48 ASSERT_TRUE(SetupSync());
83 49
84 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); 50 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails());
85 } 51 }
86 52
87 // In this test, packages are installed before sync started. Client1 will have 53 // In this test, packages are installed before sync started. Client1 will have
88 // package 0 to 4 installed while client2 has no package installed. 54 // package 0 to 4 installed while client2 has no package installed.
89 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, 55 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest,
90 OneClientHasPackagesAnotherHasNone) { 56 OneClientHasPackagesAnotherHasNone) {
91 ASSERT_TRUE(SetupClients()); 57 ASSERT_TRUE(SetupClients());
92 58
93 constexpr size_t kNumPackages = 5; 59 constexpr size_t kNumPackages = 5;
94 for (size_t i = 0; i < kNumPackages; ++i) { 60 for (size_t i = 0; i < kNumPackages; ++i) {
95 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); 61 sync_arc_helper()->InstallPackageWithIndex(GetProfile(0), i);
96 } 62 }
97 63
98 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails()); 64 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails());
99 65
100 ASSERT_TRUE(SetupSync()); 66 ASSERT_TRUE(SetupSync());
101 ASSERT_TRUE(AwaitQuiescence()); 67 ASSERT_TRUE(AwaitQuiescence());
102 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); 68 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails());
103 } 69 }
104 70
105 // In this test, packages are installed before sync started. Client1 will have 71 // In this test, packages are installed before sync started. Client1 will have
106 // package 0 to 9 installed and client2 will have package 0 to 4 installed. 72 // package 0 to 9 installed and client2 will have package 0 to 4 installed.
107 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, 73 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest,
108 OneClientHasPackagesAnotherHasSubSet) { 74 OneClientHasPackagesAnotherHasSubSet) {
109 ASSERT_TRUE(SetupClients()); 75 ASSERT_TRUE(SetupClients());
110 76
111 constexpr size_t kNumPackages = 5; 77 constexpr size_t kNumPackages = 5;
112 for (size_t i = 0; i < kNumPackages; ++i) { 78 for (size_t i = 0; i < kNumPackages; ++i) {
113 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); 79 sync_arc_helper()->InstallPackageWithIndex(GetProfile(0), i);
114 sync_helper()->InstallPackageWithIndex(GetProfile(1), i); 80 sync_arc_helper()->InstallPackageWithIndex(GetProfile(1), i);
115 } 81 }
116 82
117 for (size_t i = 0; i < kNumPackages; ++i) { 83 for (size_t i = 0; i < kNumPackages; ++i) {
118 sync_helper()->InstallPackageWithIndex(GetProfile(0), i + kNumPackages); 84 sync_arc_helper()->InstallPackageWithIndex(GetProfile(0), i + kNumPackages);
119 } 85 }
120 86
121 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails()); 87 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails());
122 88
123 ASSERT_TRUE(SetupSync()); 89 ASSERT_TRUE(SetupSync());
124 ASSERT_TRUE(AwaitQuiescence()); 90 ASSERT_TRUE(AwaitQuiescence());
125 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); 91 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails());
126 } 92 }
127 93
128 // In this test, packages are installed before sync started. Client1 will have 94 // In this test, packages are installed before sync started. Client1 will have
129 // package 0 to 4 installed and client2 will have package 1 to 5 installed. 95 // package 0 to 4 installed and client2 will have package 1 to 5 installed.
130 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, 96 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest,
131 StartWithDifferentPackages) { 97 StartWithDifferentPackages) {
132 ASSERT_TRUE(SetupClients()); 98 ASSERT_TRUE(SetupClients());
133 99
134 constexpr size_t kNumPackages = 5; 100 constexpr size_t kNumPackages = 5;
135 constexpr size_t kPackageIdDiff = 1; 101 constexpr size_t kPackageIdDiff = 1;
136 for (size_t i = 0; i < kNumPackages; ++i) { 102 for (size_t i = 0; i < kNumPackages; ++i) {
137 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); 103 sync_arc_helper()->InstallPackageWithIndex(GetProfile(0), i);
138 sync_helper()->InstallPackageWithIndex(GetProfile(1), i + kPackageIdDiff); 104 sync_arc_helper()->InstallPackageWithIndex(GetProfile(1),
105 i + kPackageIdDiff);
139 } 106 }
140 107
141 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails()); 108 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails());
142 109
143 ASSERT_TRUE(SetupSync()); 110 ASSERT_TRUE(SetupSync());
144 ASSERT_TRUE(AwaitQuiescence()); 111 ASSERT_TRUE(AwaitQuiescence());
145 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); 112 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails());
146 } 113 }
147 114
148 // Tests package installaton after sync started. 115 // Tests package installaton after sync started.
149 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, Install) { 116 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, Install) {
150 ASSERT_TRUE(SetupSync()); 117 ASSERT_TRUE(SetupSync());
151 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); 118 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails());
152 119
153 sync_helper()->InstallPackageWithIndex(GetProfile(0), 0); 120 sync_arc_helper()->InstallPackageWithIndex(GetProfile(0), 0);
154 ASSERT_TRUE(AwaitQuiescence()); 121 ASSERT_TRUE(AwaitQuiescence());
155 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); 122 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails());
156 } 123 }
157 124
158 // In this test, packages are installed after sync started. Client1 installs 125 // In this test, packages are installed after sync started. Client1 installs
159 // package 0 to 4 and client2 installs package 3 to 7. 126 // package 0 to 4 and client2 installs package 3 to 7.
160 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, InstallDifferent) { 127 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, InstallDifferent) {
161 ASSERT_TRUE(SetupSync()); 128 ASSERT_TRUE(SetupSync());
162 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); 129 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails());
163 130
164 constexpr size_t kNumPackages = 5; 131 constexpr size_t kNumPackages = 5;
165 constexpr size_t kPackageIdDiff = 3; 132 constexpr size_t kPackageIdDiff = 3;
166 for (size_t i = 0; i < kNumPackages; ++i) { 133 for (size_t i = 0; i < kNumPackages; ++i) {
167 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); 134 sync_arc_helper()->InstallPackageWithIndex(GetProfile(0), i);
168 sync_helper()->InstallPackageWithIndex(GetProfile(1), i + kPackageIdDiff); 135 sync_arc_helper()->InstallPackageWithIndex(GetProfile(1),
136 i + kPackageIdDiff);
169 } 137 }
170 138
171 ASSERT_TRUE(AwaitQuiescence()); 139 ASSERT_TRUE(AwaitQuiescence());
172 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); 140 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails());
173 } 141 }
174 142
175 // Installs package from one client and uninstalls from another after sync 143 // Installs package from one client and uninstalls from another after sync
176 // started. 144 // started.
177 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, Uninstall) { 145 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, Uninstall) {
178 ASSERT_TRUE(SetupSync()); 146 ASSERT_TRUE(SetupSync());
179 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); 147 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails());
180 148
181 sync_helper()->InstallPackageWithIndex(GetProfile(0), 1); 149 sync_arc_helper()->InstallPackageWithIndex(GetProfile(0), 1);
182 ASSERT_TRUE(AwaitQuiescence()); 150 ASSERT_TRUE(AwaitQuiescence());
183 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); 151 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails());
184 152
185 sync_helper()->UninstallPackageWithIndex(GetProfile(1), 1); 153 sync_arc_helper()->UninstallPackageWithIndex(GetProfile(1), 1);
186 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails()); 154 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails());
187 ASSERT_TRUE(AwaitQuiescence()); 155 ASSERT_TRUE(AwaitQuiescence());
188 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); 156 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails());
189 } 157 }
190 158
191 } // namespace arc 159 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sync_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698