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

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: Address hidehiko's comments. Rebase. 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
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
12 namespace base {
hidehiko 2017/03/03 12:55:56 Ditto.
lgcheng 2017/03/03 18:39:53 Done.
13 class CommandLine;
14 }
9 15
10 namespace arc { 16 namespace arc {
11 17
12 namespace { 18 namespace {
13 19
14 bool AllProfilesHaveSameArcPackageDetails() { 20 bool AllProfilesHaveSameArcPackageDetails() {
15 return SyncArcPackageHelper::GetInstance() 21 return SyncArcPackageHelper::GetInstance()
16 ->AllProfilesHaveSamePackageDetails(); 22 ->AllProfilesHaveSamePackageDetails();
17 } 23 }
18 24
(...skipping 11 matching lines...) Expand all
30 bool SetupClients() override { 36 bool SetupClients() override {
31 if (!SyncTest::SetupClients()) 37 if (!SyncTest::SetupClients())
32 return false; 38 return false;
33 39
34 // Init SyncArcPackageHelper to ensure that the arc services are initialized 40 // Init SyncArcPackageHelper to ensure that the arc services are initialized
35 // for each Profile. 41 // for each Profile.
36 sync_helper_ = SyncArcPackageHelper::GetInstance(); 42 sync_helper_ = SyncArcPackageHelper::GetInstance();
37 return sync_helper_ != nullptr; 43 return sync_helper_ != nullptr;
38 } 44 }
39 45
46 void SetUpOnMainThread() override {
47 // This setting does not affect the profile created by InProcessBrowserTest.
48 // Only sync test profiles are affected.
49 ArcAppListPrefsFactory::SetFactoryForSyncTest();
50 }
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
40 void TearDownOnMainThread() override { 58 void TearDownOnMainThread() override {
41 sync_helper_->CleanUp();
42 sync_helper_ = nullptr; 59 sync_helper_ = nullptr;
43 SyncTest::TearDownOnMainThread(); 60 SyncTest::TearDownOnMainThread();
44 } 61 }
45 62
46 SyncArcPackageHelper* sync_helper() { return sync_helper_; } 63 SyncArcPackageHelper* sync_helper() { return sync_helper_; }
47 64
48 private: 65 private:
49 SyncArcPackageHelper* sync_helper_; 66 SyncArcPackageHelper* sync_helper_;
50 67
51 DISALLOW_COPY_AND_ASSIGN(TwoClientArcPackageSyncTest); 68 DISALLOW_COPY_AND_ASSIGN(TwoClientArcPackageSyncTest);
(...skipping 26 matching lines...) Expand all
78 ASSERT_TRUE(SetupClients()); 95 ASSERT_TRUE(SetupClients());
79 96
80 constexpr size_t kNumPackages = 5; 97 constexpr size_t kNumPackages = 5;
81 for (size_t i = 0; i < kNumPackages; ++i) { 98 for (size_t i = 0; i < kNumPackages; ++i) {
82 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); 99 sync_helper()->InstallPackageWithIndex(GetProfile(0), i);
83 } 100 }
84 101
85 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails()); 102 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails());
86 103
87 ASSERT_TRUE(SetupSync()); 104 ASSERT_TRUE(SetupSync());
88 105 ASSERT_TRUE(AwaitQuiescence());
89 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); 106 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails());
90 } 107 }
91 108
92 // In this test, packages are installed before sync started. Client1 will have 109 // 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. 110 // package 0 to 9 installed and client2 will have package 0 to 4 installed.
94 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, 111 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest,
95 OneClientHasPackagesAnotherHasSubSet) { 112 OneClientHasPackagesAnotherHasSubSet) {
96 ASSERT_TRUE(SetupClients()); 113 ASSERT_TRUE(SetupClients());
97 114
98 constexpr size_t kNumPackages = 5; 115 constexpr size_t kNumPackages = 5;
99 for (size_t i = 0; i < kNumPackages; ++i) { 116 for (size_t i = 0; i < kNumPackages; ++i) {
100 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); 117 sync_helper()->InstallPackageWithIndex(GetProfile(0), i);
101 sync_helper()->InstallPackageWithIndex(GetProfile(1), i); 118 sync_helper()->InstallPackageWithIndex(GetProfile(1), i);
102 } 119 }
103 120
104 for (size_t i = 0; i < kNumPackages; ++i) { 121 for (size_t i = 0; i < kNumPackages; ++i) {
105 sync_helper()->InstallPackageWithIndex(GetProfile(0), i + kNumPackages); 122 sync_helper()->InstallPackageWithIndex(GetProfile(0), i + kNumPackages);
106 } 123 }
107 124
108 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails()); 125 ASSERT_FALSE(AllProfilesHaveSameArcPackageDetails());
109 126
110 ASSERT_TRUE(SetupSync()); 127 ASSERT_TRUE(SetupSync());
111 128 ASSERT_TRUE(AwaitQuiescence());
112 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); 129 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails());
113 } 130 }
114 131
115 // In this test, packages are installed before sync started. Client1 will have 132 // 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. 133 // package 0 to 4 installed and client2 will have package 1 to 5 installed.
117 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, 134 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest,
118 StartWithDifferentPackages) { 135 StartWithDifferentPackages) {
119 ASSERT_TRUE(SetupClients()); 136 ASSERT_TRUE(SetupClients());
120 137
121 constexpr size_t kNumPackages = 5; 138 constexpr size_t kNumPackages = 5;
122 constexpr size_t kPackageIdDiff = 1; 139 constexpr size_t kPackageIdDiff = 1;
123 for (size_t i = 0; i < kNumPackages; ++i) { 140 for (size_t i = 0; i < kNumPackages; ++i) {
124 sync_helper()->InstallPackageWithIndex(GetProfile(0), i); 141 sync_helper()->InstallPackageWithIndex(GetProfile(0), i);
125 sync_helper()->InstallPackageWithIndex(GetProfile(1), i + kPackageIdDiff); 142 sync_helper()->InstallPackageWithIndex(GetProfile(1), i + kPackageIdDiff);
126 } 143 }
127 144
128 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails()); 145 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails());
129 146
130 ASSERT_TRUE(SetupSync()); 147 ASSERT_TRUE(SetupSync());
131 148 ASSERT_TRUE(AwaitQuiescence());
132 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); 149 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails());
133 } 150 }
134 151
135 // Tests package installaton after sync started. 152 // Tests package installaton after sync started.
136 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, Install) { 153 IN_PROC_BROWSER_TEST_F(TwoClientArcPackageSyncTest, Install) {
137 ASSERT_TRUE(SetupSync()); 154 ASSERT_TRUE(SetupSync());
138 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails()); 155 ASSERT_TRUE(AllProfilesHaveSameArcPackageDetails());
139 156
140 sync_helper()->InstallPackageWithIndex(GetProfile(0), 0); 157 sync_helper()->InstallPackageWithIndex(GetProfile(0), 0);
141 ASSERT_TRUE(AwaitQuiescence()); 158 ASSERT_TRUE(AwaitQuiescence());
(...skipping 27 matching lines...) Expand all
169 ASSERT_TRUE(AwaitQuiescence()); 186 ASSERT_TRUE(AwaitQuiescence());
170 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); 187 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails());
171 188
172 sync_helper()->UninstallPackageWithIndex(GetProfile(1), 1); 189 sync_helper()->UninstallPackageWithIndex(GetProfile(1), 1);
173 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails()); 190 EXPECT_FALSE(AllProfilesHaveSameArcPackageDetails());
174 ASSERT_TRUE(AwaitQuiescence()); 191 ASSERT_TRUE(AwaitQuiescence());
175 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails()); 192 EXPECT_TRUE(AllProfilesHaveSameArcPackageDetails());
176 } 193 }
177 194
178 } // namespace arc 195 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698