OLD | NEW |
| (Empty) |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/command_line.h" | |
6 #include "base/files/file_path.h" | |
7 #include "base/memory/scoped_ptr.h" | |
8 #include "base/process/kill.h" | |
9 #include "base/strings/string_util.h" | |
10 #include "chrome/common/chrome_result_codes.h" | |
11 #include "chrome/common/chrome_switches.h" | |
12 #include "chrome/installer/util/install_util.h" | |
13 #include "chrome/installer/util/installation_validator.h" | |
14 #include "chrome/installer/util/util_constants.h" | |
15 #include "chrome/test/mini_installer_test/installer_path_provider.h" | |
16 #include "chrome/test/mini_installer_test/installer_test_util.h" | |
17 #include "chrome/test/mini_installer_test/mini_installer_test_constants.h" | |
18 #include "chrome/test/mini_installer_test/switch_builder.h" | |
19 #include "testing/gtest/include/gtest/gtest.h" | |
20 | |
21 using installer::InstallationValidator; | |
22 using installer_test::InstallerPathProvider; | |
23 using installer_test::SwitchBuilder; | |
24 | |
25 namespace { | |
26 | |
27 class MiniInstallTest : public testing::Test { | |
28 public: | |
29 virtual void SetUp() { | |
30 std::vector<installer_test::InstalledProduct> installed; | |
31 if (installer_test::GetInstalledProducts(&installed)) { | |
32 ASSERT_TRUE(installer_test::UninstallAll()); | |
33 } | |
34 } | |
35 | |
36 virtual void TearDown() { | |
37 installer_test::UninstallAll(); | |
38 } | |
39 | |
40 protected: | |
41 static void SetUpTestCase() { | |
42 std::string build_under_test; | |
43 const CommandLine* cmd = CommandLine::ForCurrentProcess(); | |
44 build_under_test = cmd->GetSwitchValueASCII(switches::kInstallerTestBuild); | |
45 if (build_under_test.empty()) | |
46 provider_ = new InstallerPathProvider(); | |
47 else | |
48 provider_ = new InstallerPathProvider(build_under_test); | |
49 ASSERT_FALSE(provider_->GetCurrentBuild().empty()); | |
50 ASSERT_TRUE(provider_->GetFullInstaller(&full_installer_)); | |
51 ASSERT_TRUE(provider_->GetPreviousInstaller(&previous_installer_)); | |
52 ASSERT_TRUE(provider_->GetDiffInstaller(&diff_installer_)); | |
53 ASSERT_TRUE( | |
54 provider_->GetSignedStandaloneInstaller(&standalone_installer_)); | |
55 ASSERT_TRUE(provider_->GetMiniInstaller(&mini_installer_)); | |
56 } | |
57 | |
58 static void TearDownTestCase() { | |
59 delete provider_; | |
60 provider_ = NULL; | |
61 } | |
62 | |
63 static InstallerPathProvider* provider_; | |
64 static base::FilePath full_installer_; | |
65 static base::FilePath previous_installer_; | |
66 static base::FilePath diff_installer_; | |
67 static base::FilePath standalone_installer_; | |
68 static base::FilePath mini_installer_; | |
69 }; | |
70 | |
71 InstallerPathProvider* MiniInstallTest::provider_; | |
72 base::FilePath MiniInstallTest::full_installer_; | |
73 base::FilePath MiniInstallTest::previous_installer_; | |
74 base::FilePath MiniInstallTest::diff_installer_; | |
75 base::FilePath MiniInstallTest::standalone_installer_; | |
76 base::FilePath MiniInstallTest::mini_installer_; | |
77 | |
78 } // namespace | |
79 | |
80 #if defined(GOOGLE_CHROME_BUILD) | |
81 // Could use a parameterized gtest to slim down this list of tests, but since | |
82 // these tests will often be run manually, don't want to have obscure test | |
83 // names. | |
84 | |
85 // Install full installer at user level. | |
86 TEST_F(MiniInstallTest, FullInstallerUser) { | |
87 ASSERT_TRUE(installer_test::Install( | |
88 full_installer_, SwitchBuilder().AddChrome())); | |
89 ASSERT_TRUE(installer_test::ValidateInstall(false, | |
90 InstallationValidator::CHROME_SINGLE, provider_->GetCurrentBuild())); | |
91 } | |
92 | |
93 // Install full installer at system level. | |
94 TEST_F(MiniInstallTest, FullInstallerSys) { | |
95 ASSERT_TRUE(installer_test::Install(full_installer_, | |
96 SwitchBuilder().AddChrome().AddSystemInstall())); | |
97 ASSERT_TRUE(installer_test::ValidateInstall(true, | |
98 InstallationValidator::CHROME_SINGLE, provider_->GetCurrentBuild())); | |
99 } | |
100 | |
101 // Overinstall full installer. | |
102 TEST_F(MiniInstallTest, FullOverPreviousFullUser) { | |
103 ASSERT_TRUE(installer_test::Install( | |
104 previous_installer_, SwitchBuilder().AddChrome())); | |
105 ASSERT_TRUE(installer_test::ValidateInstall(false, | |
106 InstallationValidator::CHROME_SINGLE, provider_->GetPreviousBuild())); | |
107 ASSERT_TRUE(installer_test::Install( | |
108 full_installer_, SwitchBuilder().AddChrome())); | |
109 ASSERT_TRUE(installer_test::ValidateInstall(false, | |
110 InstallationValidator::CHROME_SINGLE, provider_->GetCurrentBuild())); | |
111 } | |
112 | |
113 TEST_F(MiniInstallTest, FullOverPreviousFullSys) { | |
114 ASSERT_TRUE(installer_test::Install(previous_installer_, | |
115 SwitchBuilder().AddChrome().AddSystemInstall())); | |
116 ASSERT_TRUE(installer_test::ValidateInstall(true, | |
117 InstallationValidator::CHROME_SINGLE, provider_->GetPreviousBuild())); | |
118 ASSERT_TRUE(installer_test::Install(full_installer_, | |
119 SwitchBuilder().AddChrome().AddSystemInstall())); | |
120 ASSERT_TRUE(installer_test::ValidateInstall(true, | |
121 InstallationValidator::CHROME_SINGLE, provider_->GetCurrentBuild())); | |
122 } | |
123 | |
124 TEST_F(MiniInstallTest, FreshChromeFrameUser) { | |
125 ASSERT_TRUE(installer_test::Install( | |
126 full_installer_, SwitchBuilder().AddChromeFrame())); | |
127 ASSERT_TRUE(installer_test::ValidateInstall( | |
128 false, | |
129 InstallationValidator::CHROME_FRAME_SINGLE, | |
130 provider_->GetCurrentBuild())); | |
131 } | |
132 | |
133 // Overinstall full Chrome Frame installer while IE browser is running. | |
134 TEST_F(MiniInstallTest, FullFrameOverPreviousFullIERunningSys) { | |
135 installer_test::LaunchIE("http://www.google.com"); | |
136 ASSERT_TRUE(installer_test::Install(previous_installer_, | |
137 SwitchBuilder().AddChromeFrame().AddSystemInstall())); | |
138 ASSERT_TRUE(installer_test::ValidateInstall( | |
139 true, | |
140 InstallationValidator::CHROME_FRAME_SINGLE, | |
141 provider_->GetPreviousBuild())); | |
142 ASSERT_TRUE(installer_test::Install(full_installer_, | |
143 SwitchBuilder().AddChromeFrame().AddSystemInstall())); | |
144 ASSERT_TRUE(installer_test::ValidateInstall( | |
145 true, | |
146 InstallationValidator::CHROME_FRAME_SINGLE, | |
147 provider_->GetCurrentBuild())); | |
148 } | |
149 | |
150 // Overinstall diff installer. | |
151 TEST_F(MiniInstallTest, DiffOverPreviousFullUser) { | |
152 ASSERT_TRUE(installer_test::Install( | |
153 previous_installer_, SwitchBuilder().AddChrome())); | |
154 ASSERT_TRUE(installer_test::ValidateInstall(false, | |
155 InstallationValidator::CHROME_SINGLE, provider_->GetPreviousBuild())); | |
156 ASSERT_TRUE(installer_test::Install( | |
157 diff_installer_, SwitchBuilder().AddChrome())); | |
158 ASSERT_TRUE(installer_test::ValidateInstall(false, | |
159 InstallationValidator::CHROME_SINGLE, provider_->GetCurrentBuild())); | |
160 } | |
161 | |
162 TEST_F(MiniInstallTest, DiffOverPreviousFullSys) { | |
163 ASSERT_TRUE(installer_test::Install(previous_installer_, | |
164 SwitchBuilder().AddChrome().AddSystemInstall())); | |
165 ASSERT_TRUE(installer_test::ValidateInstall(true, | |
166 InstallationValidator::CHROME_SINGLE, provider_->GetPreviousBuild())); | |
167 ASSERT_TRUE(installer_test::Install(diff_installer_, | |
168 SwitchBuilder().AddChrome().AddSystemInstall())); | |
169 ASSERT_TRUE(installer_test::ValidateInstall(true, | |
170 InstallationValidator::CHROME_SINGLE, provider_->GetCurrentBuild())); | |
171 } | |
172 | |
173 // Overinstall diff Chrome Frame installer while IE browser is running. | |
174 TEST_F(MiniInstallTest, DiffFrameOverPreviousFullIERunningSys) { | |
175 installer_test::LaunchIE("http://www.google.com"); | |
176 ASSERT_TRUE(installer_test::Install(previous_installer_, | |
177 SwitchBuilder().AddChromeFrame().AddSystemInstall())); | |
178 ASSERT_TRUE(installer_test::ValidateInstall( | |
179 true, | |
180 InstallationValidator::CHROME_FRAME_SINGLE, | |
181 provider_->GetPreviousBuild())); | |
182 ASSERT_TRUE(installer_test::Install(diff_installer_, | |
183 SwitchBuilder().AddChromeFrame().AddSystemInstall())); | |
184 ASSERT_TRUE(installer_test::ValidateInstall( | |
185 true, | |
186 InstallationValidator::CHROME_FRAME_SINGLE, | |
187 provider_->GetCurrentBuild())); | |
188 } | |
189 | |
190 TEST_F(MiniInstallTest, InstallChromeMultiOverChromeSys) { | |
191 ASSERT_TRUE(installer_test::Install(full_installer_, | |
192 SwitchBuilder().AddChrome().AddSystemInstall())); | |
193 ASSERT_TRUE(installer_test::ValidateInstall(true, | |
194 InstallationValidator::CHROME_SINGLE, provider_->GetCurrentBuild())); | |
195 ASSERT_TRUE(installer_test::Install(full_installer_, | |
196 SwitchBuilder().AddChrome().AddSystemInstall().AddMultiInstall())); | |
197 ASSERT_TRUE(installer_test::ValidateInstall(true, | |
198 InstallationValidator::CHROME_MULTI, provider_->GetCurrentBuild())); | |
199 } | |
200 | |
201 // Repair version folder. | |
202 TEST_F(MiniInstallTest, RepairFolderOnFullUser) { | |
203 ASSERT_TRUE(installer_test::Install( | |
204 full_installer_, SwitchBuilder().AddChrome())); | |
205 ASSERT_TRUE(installer_test::ValidateInstall(false, | |
206 InstallationValidator::CHROME_SINGLE, provider_->GetCurrentBuild())); | |
207 base::CleanupProcesses(installer::kChromeExe, base::TimeDelta(), | |
208 content::RESULT_CODE_HUNG, NULL); | |
209 ASSERT_TRUE(installer_test::DeleteInstallDirectory( | |
210 false, // system level | |
211 InstallationValidator::CHROME_SINGLE)); | |
212 ASSERT_TRUE(installer_test::Install( | |
213 full_installer_, SwitchBuilder().AddChrome())); | |
214 ASSERT_TRUE(installer_test::ValidateInstall(false, | |
215 InstallationValidator::CHROME_SINGLE, provider_->GetCurrentBuild())); | |
216 } | |
217 | |
218 TEST_F(MiniInstallTest, RepairFolderOnFullSys) { | |
219 ASSERT_TRUE(installer_test::Install(full_installer_, | |
220 SwitchBuilder().AddChrome().AddSystemInstall())); | |
221 ASSERT_TRUE(installer_test::ValidateInstall(true, | |
222 InstallationValidator::CHROME_SINGLE, provider_->GetCurrentBuild())); | |
223 base::CleanupProcesses(installer::kChromeExe, base::TimeDelta(), | |
224 content::RESULT_CODE_HUNG, NULL); | |
225 ASSERT_TRUE(installer_test::DeleteInstallDirectory( | |
226 true, // system level | |
227 InstallationValidator::CHROME_SINGLE)); | |
228 ASSERT_TRUE(installer_test::Install(full_installer_, | |
229 SwitchBuilder().AddChrome().AddSystemInstall())); | |
230 ASSERT_TRUE(installer_test::ValidateInstall(true, | |
231 InstallationValidator::CHROME_SINGLE, provider_->GetCurrentBuild())); | |
232 } | |
233 | |
234 // Repair registry. | |
235 TEST_F(MiniInstallTest, RepairRegistryOnFullUser) { | |
236 ASSERT_TRUE(installer_test::Install( | |
237 full_installer_, SwitchBuilder().AddChrome())); | |
238 ASSERT_TRUE(installer_test::ValidateInstall(false, | |
239 InstallationValidator::CHROME_SINGLE, provider_->GetCurrentBuild())); | |
240 base::CleanupProcesses(installer::kChromeExe, base::TimeDelta(), | |
241 content::RESULT_CODE_HUNG, NULL); | |
242 ASSERT_TRUE(installer_test::DeleteRegistryKey( | |
243 false, // system level | |
244 InstallationValidator::CHROME_SINGLE, 0)); // no WOW64 | |
245 ASSERT_TRUE( | |
246 installer_test::Install(full_installer_, SwitchBuilder().AddChrome())); | |
247 ASSERT_TRUE(installer_test::ValidateInstall(false, | |
248 InstallationValidator::CHROME_SINGLE, provider_->GetCurrentBuild())); | |
249 } | |
250 | |
251 TEST_F(MiniInstallTest, RepairRegistryOnFullSys) { | |
252 ASSERT_TRUE(installer_test::Install(full_installer_, | |
253 SwitchBuilder().AddChrome().AddSystemInstall())); | |
254 ASSERT_TRUE(installer_test::ValidateInstall(true, | |
255 InstallationValidator::CHROME_SINGLE, provider_->GetCurrentBuild())); | |
256 ASSERT_TRUE(installer_test::DeleteRegistryKey( | |
257 true, // system level | |
258 InstallationValidator::CHROME_SINGLE, 0)); // no WOW64 | |
259 ASSERT_TRUE(installer_test::Install(full_installer_, | |
260 SwitchBuilder().AddChrome().AddSystemInstall())); | |
261 ASSERT_TRUE(installer_test::ValidateInstall(true, | |
262 InstallationValidator::CHROME_SINGLE, provider_->GetCurrentBuild())); | |
263 } | |
264 | |
265 // Run full Chrome Frame install then uninstall it while IE browser is running. | |
266 TEST_F(MiniInstallTest, FullInstallAndUnInstallChromeFrameWithIERunning) { | |
267 ASSERT_TRUE(installer_test::Install(full_installer_, | |
268 SwitchBuilder().AddChromeFrame().AddSystemInstall())); | |
269 ASSERT_TRUE(installer_test::ValidateInstall( | |
270 true, | |
271 InstallationValidator::CHROME_FRAME_SINGLE, | |
272 provider_->GetCurrentBuild())); | |
273 // Launch IE and let TearDown step perform uninstall. | |
274 installer_test::LaunchIE("http://www.google.com"); | |
275 } | |
276 | |
277 // Install standalone. | |
278 TEST_F(MiniInstallTest, InstallStandaloneUser) { | |
279 ASSERT_TRUE(installer_test::Install(standalone_installer_)); | |
280 ASSERT_TRUE(installer_test::ValidateInstall(false, | |
281 InstallationValidator::CHROME_MULTI, provider_->GetCurrentBuild())); | |
282 } | |
283 | |
284 // This test doesn't make sense. Disabling for now. | |
285 TEST_F(MiniInstallTest, DISABLED_MiniInstallerOverChromeMetaInstallerTest) { | |
286 } | |
287 | |
288 // Encountering issue 9593. Disabling temporarily. | |
289 TEST_F(MiniInstallTest, | |
290 DISABLED_InstallLatestStableFullInstallerOverChromeMetaInstaller) { | |
291 } | |
292 | |
293 // Encountering issue 9593. Disabling temporarily. | |
294 TEST_F(MiniInstallTest, | |
295 DISABLED_InstallLatestDevFullInstallerOverChromeMetaInstallerTest) { | |
296 } | |
297 | |
298 TEST_F(MiniInstallTest, | |
299 InstallChromeUsingMultiInstallUser) { | |
300 ASSERT_TRUE(installer_test::Install(full_installer_, | |
301 SwitchBuilder().AddChrome().AddMultiInstall())); | |
302 ASSERT_TRUE(installer_test::ValidateInstall(false, | |
303 InstallationValidator::CHROME_MULTI, provider_->GetCurrentBuild())); | |
304 } | |
305 | |
306 TEST_F(MiniInstallTest, | |
307 InstallChromeUsingMultiInstallSys) { | |
308 ASSERT_TRUE(installer_test::Install(full_installer_, | |
309 SwitchBuilder().AddChrome().AddMultiInstall().AddSystemInstall())); | |
310 ASSERT_TRUE(installer_test::ValidateInstall(true, | |
311 InstallationValidator::CHROME_MULTI, provider_->GetCurrentBuild())); | |
312 } | |
313 | |
314 TEST_F(MiniInstallTest, InstallChromeAndChromeFrameMultiInstallUser) { | |
315 ASSERT_TRUE(installer_test::Install(full_installer_, | |
316 SwitchBuilder().AddChrome().AddChromeFrame().AddMultiInstall())); | |
317 ASSERT_TRUE(installer_test::ValidateInstall( | |
318 false, | |
319 InstallationValidator::CHROME_FRAME_MULTI_CHROME_MULTI, | |
320 provider_->GetCurrentBuild())); | |
321 } | |
322 | |
323 TEST_F(MiniInstallTest, InstallChromeAndChromeFrameMultiInstallSys) { | |
324 ASSERT_TRUE(installer_test::Install( | |
325 full_installer_, SwitchBuilder().AddChrome() | |
326 .AddChromeFrame().AddMultiInstall().AddSystemInstall())); | |
327 ASSERT_TRUE(installer_test::ValidateInstall( | |
328 true, | |
329 InstallationValidator::CHROME_FRAME_MULTI_CHROME_MULTI, | |
330 provider_->GetCurrentBuild())); | |
331 } | |
332 | |
333 TEST_F(MiniInstallTest, InstallChromeFrameUsingMultiInstallUser) { | |
334 ASSERT_TRUE(installer_test::Install(full_installer_, | |
335 SwitchBuilder().AddChromeFrame().AddMultiInstall())); | |
336 ASSERT_TRUE(installer_test::ValidateInstall( | |
337 false, | |
338 InstallationValidator::CHROME_FRAME_MULTI, | |
339 provider_->GetCurrentBuild())); | |
340 } | |
341 | |
342 TEST_F(MiniInstallTest, InstallChromeFrameUsingMultiInstallSys) { | |
343 ASSERT_TRUE(installer_test::Install(full_installer_, | |
344 SwitchBuilder().AddChromeFrame().AddMultiInstall().AddSystemInstall())); | |
345 ASSERT_TRUE(installer_test::ValidateInstall( | |
346 true, | |
347 InstallationValidator::CHROME_FRAME_MULTI, | |
348 provider_->GetCurrentBuild())); | |
349 } | |
350 | |
351 // Chrome Frame is in use while Chrome is install. | |
352 TEST_F(MiniInstallTest, InstallChromeWithExistingChromeFrameMultiInstallUser) { | |
353 ASSERT_TRUE(installer_test::Install(previous_installer_, | |
354 SwitchBuilder().AddChromeFrame().AddMultiInstall())); | |
355 ASSERT_TRUE(installer_test::ValidateInstall( | |
356 false, | |
357 InstallationValidator::CHROME_FRAME_MULTI, | |
358 provider_->GetPreviousBuild())); | |
359 ASSERT_TRUE(installer_test::Install(full_installer_, | |
360 SwitchBuilder().AddChrome().AddMultiInstall())); | |
361 ASSERT_TRUE(installer_test::ValidateInstall( | |
362 false, | |
363 InstallationValidator::CHROME_FRAME_MULTI_CHROME_MULTI, | |
364 provider_->GetCurrentBuild())); | |
365 } | |
366 | |
367 // Chrome Frame is in use while Chrome is install. | |
368 TEST_F(MiniInstallTest, InstallChromeWithExistingChromeFrameMultiInstallSys) { | |
369 ASSERT_TRUE(installer_test::Install(previous_installer_, | |
370 SwitchBuilder().AddChromeFrame().AddMultiInstall().AddSystemInstall())); | |
371 ASSERT_TRUE(installer_test::ValidateInstall( | |
372 true, | |
373 InstallationValidator::CHROME_FRAME_MULTI, | |
374 provider_->GetPreviousBuild())); | |
375 ASSERT_TRUE(installer_test::Install(full_installer_, | |
376 SwitchBuilder().AddChrome().AddMultiInstall())); | |
377 ASSERT_TRUE(installer_test::ValidateInstall(true, | |
378 InstallationValidator::CHROME_MULTI, provider_->GetCurrentBuild())); | |
379 } | |
380 | |
381 TEST_F(MiniInstallTest, OverInstallChromeWhenInUseUser) { | |
382 ASSERT_TRUE(installer_test::Install(full_installer_, | |
383 SwitchBuilder().AddChrome().AddMultiInstall())); | |
384 ASSERT_TRUE(installer_test::ValidateInstall(false, | |
385 InstallationValidator::CHROME_MULTI, provider_->GetCurrentBuild())); | |
386 installer_test::LaunchChrome(false, false); | |
387 ASSERT_TRUE(installer_test::Install(full_installer_, | |
388 SwitchBuilder().AddChrome().AddMultiInstall())); | |
389 ASSERT_TRUE(installer_test::ValidateInstall(false, | |
390 InstallationValidator::CHROME_MULTI, provider_->GetCurrentBuild())); | |
391 } | |
392 | |
393 TEST_F(MiniInstallTest, OverInstallChromeWhenInUseSys) { | |
394 ASSERT_TRUE(installer_test::Install(full_installer_, | |
395 SwitchBuilder().AddChrome().AddMultiInstall().AddSystemInstall())); | |
396 ASSERT_TRUE(installer_test::ValidateInstall(true, | |
397 InstallationValidator::CHROME_MULTI, provider_->GetCurrentBuild())); | |
398 installer_test::LaunchChrome(false, true); | |
399 ASSERT_TRUE(installer_test::Install(full_installer_, | |
400 SwitchBuilder().AddChrome().AddMultiInstall().AddSystemInstall())); | |
401 ASSERT_TRUE(installer_test::ValidateInstall(true, | |
402 InstallationValidator::CHROME_MULTI, provider_->GetCurrentBuild())); | |
403 } | |
404 | |
405 #endif | |
406 | |
407 TEST(GenericInstallTest, MiniInstallTestValidWindowsVersion) { | |
408 // We run the tests on all supported OSes. | |
409 // Make sure the code agrees. | |
410 EXPECT_TRUE(InstallUtil::IsOSSupported()); | |
411 } | |
412 | |
OLD | NEW |