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

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

Issue 2711033002: Fix Arc integration test. (Closed)
Patch Set: Rebase Created 3 years, 10 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
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"
9 10
10 namespace arc { 11 namespace arc {
11 12
12 namespace { 13 namespace {
13 14
14 bool AllProfilesHaveSameArcPackageDetails() { 15 bool AllProfilesHaveSameArcPackageDetails() {
15 return SyncArcPackageHelper::GetInstance() 16 return SyncArcPackageHelper::GetInstance()
16 ->AllProfilesHaveSamePackageDetails(); 17 ->AllProfilesHaveSamePackageDetails();
17 } 18 }
18 19
(...skipping 11 matching lines...) Expand all
30 bool SetupClients() override { 31 bool SetupClients() override {
31 if (!SyncTest::SetupClients()) 32 if (!SyncTest::SetupClients())
32 return false; 33 return false;
33 34
34 // Init SyncArcPackageHelper to ensure that the arc services are initialized 35 // Init SyncArcPackageHelper to ensure that the arc services are initialized
35 // for each Profile. 36 // for each Profile.
36 sync_helper_ = SyncArcPackageHelper::GetInstance(); 37 sync_helper_ = SyncArcPackageHelper::GetInstance();
37 return sync_helper_ != nullptr; 38 return sync_helper_ != nullptr;
38 } 39 }
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
40 void TearDownOnMainThread() override { 47 void TearDownOnMainThread() override {
41 sync_helper_->CleanUp();
42 sync_helper_ = nullptr; 48 sync_helper_ = nullptr;
43 SyncTest::TearDownOnMainThread(); 49 SyncTest::TearDownOnMainThread();
44 } 50 }
45 51
46 SyncArcPackageHelper* sync_helper() { return sync_helper_; } 52 SyncArcPackageHelper* sync_helper() { return sync_helper_; }
47 53
48 private: 54 private:
49 SyncArcPackageHelper* sync_helper_; 55 SyncArcPackageHelper* sync_helper_;
50 56
51 DISALLOW_COPY_AND_ASSIGN(TwoClientArcPackageSyncTest); 57 DISALLOW_COPY_AND_ASSIGN(TwoClientArcPackageSyncTest);
(...skipping 26 matching lines...) Expand all
78 ASSERT_TRUE(SetupClients()); 84 ASSERT_TRUE(SetupClients());
79 85
80 constexpr size_t kNumPackages = 5; 86 constexpr size_t kNumPackages = 5;
81 for (size_t i = 0; i < kNumPackages; ++i) { 87 for (size_t i = 0; i < kNumPackages; ++i) {
82 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); 88 sync_helper()->InstallPackageWithIndex(GetProfile(0), i);
83 } 89 }
84 90
85 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails()); 91 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails());
86 92
87 ASSERT_TRUE(SetupSync()); 93 ASSERT_TRUE(SetupSync());
88 94 ASSERT_TRUE(AwaitQuiescence());
89 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); 95 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails());
90 } 96 }
91 97
92 // In this test, packages are installed before sync started. Client1 will have 98 // 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. 99 // package 0 to 9 installed and client2 will have package 0 to 4 installed.
94 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, 100 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest,
95 OneClientHasPackagesAnotherHasSubSet) { 101 OneClientHasPackagesAnotherHasSubSet) {
96 ASSERT_TRUE(SetupClients()); 102 ASSERT_TRUE(SetupClients());
97 103
98 constexpr size_t kNumPackages = 5; 104 constexpr size_t kNumPackages = 5;
99 for (size_t i = 0; i < kNumPackages; ++i) { 105 for (size_t i = 0; i < kNumPackages; ++i) {
100 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); 106 sync_helper()->InstallPackageWithIndex(GetProfile(0), i);
101 sync_helper()->InstallPackageWithIndex(GetProfile(1), i); 107 sync_helper()->InstallPackageWithIndex(GetProfile(1), i);
102 } 108 }
103 109
104 for (size_t i = 0; i < kNumPackages; ++i) { 110 for (size_t i = 0; i < kNumPackages; ++i) {
105 sync_helper()->InstallPackageWithIndex(GetProfile(0), i + kNumPackages); 111 sync_helper()->InstallPackageWithIndex(GetProfile(0), i + kNumPackages);
106 } 112 }
107 113
108 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails()); 114 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails());
109 115
110 ASSERT_TRUE(SetupSync()); 116 ASSERT_TRUE(SetupSync());
111 117 ASSERT_TRUE(AwaitQuiescence());
112 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); 118 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails());
113 } 119 }
114 120
115 // In this test, packages are installed before sync started. Client1 will have 121 // 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. 122 // package 0 to 4 installed and client2 will have package 1 to 5 installed.
117 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, 123 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest,
118 StartWithDifferentPackages) { 124 StartWithDifferentPackages) {
119 ASSERT_TRUE(SetupClients()); 125 ASSERT_TRUE(SetupClients());
120 126
121 constexpr size_t kNumPackages = 5; 127 constexpr size_t kNumPackages = 5;
122 constexpr size_t kPackageIdDiff = 1; 128 constexpr size_t kPackageIdDiff = 1;
123 for (size_t i = 0; i < kNumPackages; ++i) { 129 for (size_t i = 0; i < kNumPackages; ++i) {
124 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); 130 sync_helper()->InstallPackageWithIndex(GetProfile(0), i);
125 sync_helper()->InstallPackageWithIndex(GetProfile(1), i + kPackageIdDiff); 131 sync_helper()->InstallPackageWithIndex(GetProfile(1), i + kPackageIdDiff);
126 } 132 }
127 133
128 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails()); 134 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails());
129 135
130 ASSERT_TRUE(SetupSync()); 136 ASSERT_TRUE(SetupSync());
131 137 ASSERT_TRUE(AwaitQuiescence());
132 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); 138 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails());
133 } 139 }
134 140
135 // Tests package installaton after sync started. 141 // Tests package installaton after sync started.
136 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, Install) { 142 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, Install) {
137 ASSERT_TRUE(SetupSync()); 143 ASSERT_TRUE(SetupSync());
138 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); 144 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails());
139 145
140 sync_helper()->InstallPackageWithIndex(GetProfile(0), 0); 146 sync_helper()->InstallPackageWithIndex(GetProfile(0), 0);
141 ASSERT_TRUE(AwaitQuiescence()); 147 ASSERT_TRUE(AwaitQuiescence());
(...skipping 27 matching lines...) Expand all
169 ASSERT_TRUE(AwaitQuiescence()); 175 ASSERT_TRUE(AwaitQuiescence());
170 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); 176 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails());
171 177
172 sync_helper()->UninstallPackageWithIndex(GetProfile(1), 1); 178 sync_helper()->UninstallPackageWithIndex(GetProfile(1), 1);
173 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails()); 179 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails());
174 ASSERT_TRUE(AwaitQuiescence()); 180 ASSERT_TRUE(AwaitQuiescence());
175 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); 181 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails());
176 } 182 }
177 183
178 } // namespace arc 184 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698