OLD | NEW |
| (Empty) |
1 // Copyright 2007-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 | |
16 #include <vector> | |
17 #include "base/scoped_ptr.h" | |
18 #include "omaha/base/app_util.h" | |
19 #include "omaha/base/error.h" | |
20 #include "omaha/base/file.h" | |
21 #include "omaha/base/omaha_version.h" | |
22 #include "omaha/base/path.h" | |
23 #include "omaha/base/utils.h" | |
24 #include "omaha/base/vistautil.h" | |
25 #include "omaha/common/config_manager.h" | |
26 #include "omaha/common/const_goopdate.h" | |
27 #include "omaha/setup/setup_files.h" | |
28 #include "omaha/testing/unit_test.h" | |
29 | |
30 namespace omaha { | |
31 | |
32 namespace { | |
33 | |
34 // TODO(omaha3): Update the numbers in the else block as we build more files. | |
35 // Eventually use the original values in the if block. | |
36 const int kNumberOfLanguageDlls = 55; | |
37 const int kNumberOfRequiredFiles = 6; | |
38 #if 0 | |
39 const int kNumberOfOptionalFiles = 4; | |
40 #else | |
41 const int kNumberOfOptionalFiles = 3; | |
42 #endif | |
43 const int kNumberOfInstalledRequiredFiles = | |
44 kNumberOfLanguageDlls + kNumberOfRequiredFiles; | |
45 // FindFiles returns "." and ".." in addition to the actual files. | |
46 const int kExtraFilesReturnedByFindFiles = 2; | |
47 const int kExpectedFilesReturnedByFindFiles = | |
48 kNumberOfInstalledRequiredFiles + kNumberOfOptionalFiles + | |
49 kExtraFilesReturnedByFindFiles; | |
50 | |
51 const TCHAR kFutureVersionString[] = _T("9.8.7.6"); | |
52 const ULONGLONG kFutureVersion = 0x0009000800070006; | |
53 | |
54 } // namespace | |
55 | |
56 void CopyGoopdateFiles(const CString& omaha_path, const CString& version) { | |
57 EXPECT_SUCCEEDED(CreateDir(omaha_path, NULL)); | |
58 const CString version_path = ConcatenatePath(omaha_path, version); | |
59 | |
60 EXPECT_SUCCEEDED(File::Copy( | |
61 ConcatenatePath(app_util::GetCurrentModuleDirectory(), | |
62 kOmahaShellFileName), | |
63 ConcatenatePath(omaha_path, kOmahaShellFileName), | |
64 false)); | |
65 | |
66 EXPECT_SUCCEEDED(CreateDir(version_path, NULL)); | |
67 | |
68 const TCHAR* files[] = {kCrashHandlerFileName, | |
69 kOmahaShellFileName, | |
70 kHelperInstallerName, | |
71 kOmahaDllName, | |
72 kOmahaBrokerFileName, | |
73 kOmahaOnDemandFileName, | |
74 // TODO(omaha3): Enable once this is being built. | |
75 #if 0 | |
76 _T("GoopdateBho.dll"), | |
77 #endif | |
78 UPDATE_PLUGIN_FILENAME, | |
79 kPSFileNameMachine, | |
80 kPSFileNameUser, | |
81 }; | |
82 for (size_t i = 0; i < arraysize(files); ++i) { | |
83 EXPECT_SUCCEEDED(File::Copy( | |
84 ConcatenatePath(app_util::GetCurrentModuleDirectory(), | |
85 files[i]), | |
86 ConcatenatePath(version_path, files[i]), | |
87 false)) << _T("Failed copying ") << files[i]; | |
88 } | |
89 | |
90 EXPECT_SUCCEEDED(File::CopyWildcards(app_util::GetCurrentModuleDirectory(), | |
91 version_path, | |
92 _T("goopdateres_\?\?.dll"), | |
93 false)); | |
94 EXPECT_SUCCEEDED(File::CopyWildcards(app_util::GetCurrentModuleDirectory(), | |
95 version_path, | |
96 _T("goopdateres_\?\?\?.dll"), | |
97 false)); | |
98 EXPECT_SUCCEEDED(File::CopyWildcards(app_util::GetCurrentModuleDirectory(), | |
99 version_path, | |
100 _T("goopdateres_\?\?-\?\?.dll"), | |
101 false)); | |
102 EXPECT_SUCCEEDED(File::CopyWildcards(app_util::GetCurrentModuleDirectory(), | |
103 version_path, | |
104 _T("goopdateres_\?\?-\?\?\?.dll"), | |
105 false)); | |
106 } | |
107 | |
108 class SetupFilesTest : public testing::Test { | |
109 protected: | |
110 explicit SetupFilesTest(bool is_machine) | |
111 : is_machine_(is_machine), | |
112 omaha_path_(is_machine ? | |
113 GetGoogleUpdateMachinePath() : GetGoogleUpdateUserPath()), | |
114 hive_override_key_name_(kRegistryHiveOverrideRoot) { | |
115 } | |
116 | |
117 static void SetUpTestCase() { | |
118 exe_parent_dir_ = ConcatenatePath(app_util::GetCurrentModuleDirectory(), | |
119 _T("unittest_support\\")); | |
120 | |
121 this_version_ = GetVersionString(); | |
122 | |
123 expected_is_overinstall_ = !OFFICIAL_BUILD; | |
124 #ifdef DEBUG | |
125 if (RegKey::HasValue(MACHINE_REG_UPDATE_DEV, kRegValueNameOverInstall)) { | |
126 DWORD value = 0; | |
127 EXPECT_SUCCEEDED(RegKey::GetValue(MACHINE_REG_UPDATE_DEV, | |
128 kRegValueNameOverInstall, | |
129 &value)); | |
130 expected_is_overinstall_ = value != 0; | |
131 } | |
132 #endif | |
133 } | |
134 | |
135 virtual void SetUp() { | |
136 RegKey::DeleteKey(hive_override_key_name_, true); | |
137 // Do not override HKLM because it contains the CSIDL_* definitions. | |
138 OverrideSpecifiedRegistryHives(hive_override_key_name_, false, true); | |
139 | |
140 setup_files_.reset(new SetupFiles(is_machine_)); | |
141 | |
142 ASSERT_HRESULT_SUCCEEDED(setup_files_->Init()); | |
143 } | |
144 | |
145 virtual void TearDown() { | |
146 RestoreRegistryHives(); | |
147 ASSERT_SUCCEEDED(RegKey::DeleteKey(hive_override_key_name_, true)); | |
148 } | |
149 | |
150 static bool IsOlderShellVersionCompatible(ULONGLONG version) { | |
151 return SetupFiles::IsOlderShellVersionCompatible(version); | |
152 } | |
153 | |
154 // Assumes the executable version has been changed to the future version. | |
155 void InstallHelper(const CString& omaha_path) { | |
156 const CString version_path = ConcatenatePath(omaha_path, | |
157 kFutureVersionString); | |
158 | |
159 ASSERT_EQ(kNumberOfInstalledRequiredFiles, | |
160 setup_files_->core_program_files_.size()); | |
161 ASSERT_EQ(kNumberOfOptionalFiles, setup_files_->optional_files_.size()); | |
162 | |
163 DeleteDirectory(version_path); | |
164 ASSERT_FALSE(File::IsDirectory(version_path)); | |
165 | |
166 EXPECT_SUCCEEDED(setup_files_->Install()); | |
167 | |
168 EXPECT_TRUE(File::Exists(ConcatenatePath(omaha_path, | |
169 kOmahaShellFileName))); | |
170 | |
171 EXPECT_TRUE(File::IsDirectory(version_path)); | |
172 | |
173 std::vector<CString> files; | |
174 EXPECT_SUCCEEDED(FindFiles(version_path, _T("*.*"), &files)); | |
175 ASSERT_EQ(kExpectedFilesReturnedByFindFiles, files.size()); | |
176 int file_index = kExtraFilesReturnedByFindFiles; | |
177 EXPECT_STREQ(kCrashHandlerFileName, files[file_index++]); | |
178 EXPECT_STREQ(kOmahaShellFileName, files[file_index++]); | |
179 EXPECT_STREQ(kOmahaBrokerFileName, files[file_index++]); | |
180 EXPECT_STREQ(kHelperInstallerName, files[file_index++]); | |
181 EXPECT_STREQ(kOmahaOnDemandFileName, files[file_index++]); | |
182 EXPECT_STREQ(kOmahaDllName, files[file_index++]); | |
183 // TODO(omaha3): Enable as this is built. | |
184 #if 0 | |
185 EXPECT_STREQ(_T("GoopdateBho.dll"), files[file_index++]); | |
186 #endif | |
187 EXPECT_STREQ(_T("goopdateres_am.dll"), files[file_index++]); | |
188 EXPECT_STREQ(_T("goopdateres_ar.dll"), files[file_index++]); | |
189 EXPECT_STREQ(_T("goopdateres_bg.dll"), files[file_index++]); | |
190 EXPECT_STREQ(_T("goopdateres_bn.dll"), files[file_index++]); | |
191 EXPECT_STREQ(_T("goopdateres_ca.dll"), files[file_index++]); | |
192 EXPECT_STREQ(_T("goopdateres_cs.dll"), files[file_index++]); | |
193 EXPECT_STREQ(_T("goopdateres_da.dll"), files[file_index++]); | |
194 EXPECT_STREQ(_T("goopdateres_de.dll"), files[file_index++]); | |
195 EXPECT_STREQ(_T("goopdateres_el.dll"), files[file_index++]); | |
196 EXPECT_STREQ(_T("goopdateres_en-GB.dll"), files[file_index++]); | |
197 EXPECT_STREQ(_T("goopdateres_en.dll"), files[file_index++]); | |
198 EXPECT_STREQ(_T("goopdateres_es-419.dll"), files[file_index++]); | |
199 EXPECT_STREQ(_T("goopdateres_es.dll"), files[file_index++]); | |
200 EXPECT_STREQ(_T("goopdateres_et.dll"), files[file_index++]); | |
201 EXPECT_STREQ(_T("goopdateres_fa.dll"), files[file_index++]); | |
202 EXPECT_STREQ(_T("goopdateres_fi.dll"), files[file_index++]); | |
203 EXPECT_STREQ(_T("goopdateres_fil.dll"), files[file_index++]); | |
204 EXPECT_STREQ(_T("goopdateres_fr.dll"), files[file_index++]); | |
205 EXPECT_STREQ(_T("goopdateres_gu.dll"), files[file_index++]); | |
206 EXPECT_STREQ(_T("goopdateres_hi.dll"), files[file_index++]); | |
207 EXPECT_STREQ(_T("goopdateres_hr.dll"), files[file_index++]); | |
208 EXPECT_STREQ(_T("goopdateres_hu.dll"), files[file_index++]); | |
209 EXPECT_STREQ(_T("goopdateres_id.dll"), files[file_index++]); | |
210 EXPECT_STREQ(_T("goopdateres_is.dll"), files[file_index++]); | |
211 EXPECT_STREQ(_T("goopdateres_it.dll"), files[file_index++]); | |
212 EXPECT_STREQ(_T("goopdateres_iw.dll"), files[file_index++]); | |
213 EXPECT_STREQ(_T("goopdateres_ja.dll"), files[file_index++]); | |
214 EXPECT_STREQ(_T("goopdateres_kn.dll"), files[file_index++]); | |
215 EXPECT_STREQ(_T("goopdateres_ko.dll"), files[file_index++]); | |
216 EXPECT_STREQ(_T("goopdateres_lt.dll"), files[file_index++]); | |
217 EXPECT_STREQ(_T("goopdateres_lv.dll"), files[file_index++]); | |
218 EXPECT_STREQ(_T("goopdateres_ml.dll"), files[file_index++]); | |
219 EXPECT_STREQ(_T("goopdateres_mr.dll"), files[file_index++]); | |
220 EXPECT_STREQ(_T("goopdateres_ms.dll"), files[file_index++]); | |
221 EXPECT_STREQ(_T("goopdateres_nl.dll"), files[file_index++]); | |
222 EXPECT_STREQ(_T("goopdateres_no.dll"), files[file_index++]); | |
223 EXPECT_STREQ(_T("goopdateres_pl.dll"), files[file_index++]); | |
224 EXPECT_STREQ(_T("goopdateres_pt-BR.dll"), files[file_index++]); | |
225 EXPECT_STREQ(_T("goopdateres_pt-PT.dll"), files[file_index++]); | |
226 EXPECT_STREQ(_T("goopdateres_ro.dll"), files[file_index++]); | |
227 EXPECT_STREQ(_T("goopdateres_ru.dll"), files[file_index++]); | |
228 EXPECT_STREQ(_T("goopdateres_sk.dll"), files[file_index++]); | |
229 EXPECT_STREQ(_T("goopdateres_sl.dll"), files[file_index++]); | |
230 EXPECT_STREQ(_T("goopdateres_sr.dll"), files[file_index++]); | |
231 EXPECT_STREQ(_T("goopdateres_sv.dll"), files[file_index++]); | |
232 EXPECT_STREQ(_T("goopdateres_sw.dll"), files[file_index++]); | |
233 EXPECT_STREQ(_T("goopdateres_ta.dll"), files[file_index++]); | |
234 EXPECT_STREQ(_T("goopdateres_te.dll"), files[file_index++]); | |
235 EXPECT_STREQ(_T("goopdateres_th.dll"), files[file_index++]); | |
236 EXPECT_STREQ(_T("goopdateres_tr.dll"), files[file_index++]); | |
237 EXPECT_STREQ(_T("goopdateres_uk.dll"), files[file_index++]); | |
238 EXPECT_STREQ(_T("goopdateres_ur.dll"), files[file_index++]); | |
239 EXPECT_STREQ(_T("goopdateres_vi.dll"), files[file_index++]); | |
240 EXPECT_STREQ(_T("goopdateres_zh-CN.dll"), files[file_index++]); | |
241 EXPECT_STREQ(_T("goopdateres_zh-TW.dll"), files[file_index++]); | |
242 EXPECT_STREQ(UPDATE_PLUGIN_FILENAME, files[file_index++]); | |
243 EXPECT_STREQ(kPSFileNameMachine, files[file_index++]); | |
244 EXPECT_STREQ(kPSFileNameUser, files[file_index++]); | |
245 | |
246 EXPECT_SUCCEEDED(DeleteDirectory(version_path)); | |
247 } | |
248 | |
249 HRESULT ShouldCopyShell(const CString& shell_install_path, | |
250 bool* should_copy, | |
251 bool* already_exists) const { | |
252 return setup_files_->ShouldCopyShell(shell_install_path, | |
253 should_copy, | |
254 already_exists); | |
255 } | |
256 | |
257 const bool is_machine_; | |
258 const CString omaha_path_; | |
259 const CString hive_override_key_name_; | |
260 scoped_ptr<SetupFiles> setup_files_; | |
261 | |
262 static CString exe_parent_dir_; | |
263 static CString this_version_; | |
264 static bool expected_is_overinstall_; | |
265 }; | |
266 | |
267 CString SetupFilesTest::exe_parent_dir_; | |
268 CString SetupFilesTest::this_version_; | |
269 bool SetupFilesTest::expected_is_overinstall_; | |
270 | |
271 class SetupFilesMachineTest : public SetupFilesTest { | |
272 protected: | |
273 SetupFilesMachineTest() | |
274 : SetupFilesTest(true) { | |
275 } | |
276 }; | |
277 | |
278 class SetupFilesUserTest : public SetupFilesTest { | |
279 protected: | |
280 SetupFilesUserTest() | |
281 : SetupFilesTest(false) { | |
282 } | |
283 }; | |
284 | |
285 TEST_F(SetupFilesUserTest, | |
286 ShouldOverinstallSameVersion_SameVersionFilesMissing) { | |
287 ASSERT_SUCCEEDED(RegKey::SetValue(USER_REG_CLIENTS_GOOPDATE, | |
288 kRegValueProductVersion, | |
289 this_version_)); | |
290 ASSERT_SUCCEEDED( | |
291 DeleteDirectory(ConcatenatePath(omaha_path_, this_version_))); | |
292 CString file_path = ConcatenatePath( | |
293 ConcatenatePath(omaha_path_, this_version_), | |
294 kOmahaDllName); | |
295 ASSERT_FALSE(File::Exists(file_path)); | |
296 | |
297 EXPECT_TRUE(setup_files_->ShouldOverinstallSameVersion()); | |
298 } | |
299 | |
300 TEST_F(SetupFilesUserTest, | |
301 ShouldOverinstallSameVersion_SameVersionFilesPresent) { | |
302 ASSERT_SUCCEEDED(RegKey::SetValue(USER_REG_CLIENTS_GOOPDATE, | |
303 kRegValueProductVersion, | |
304 this_version_)); | |
305 | |
306 CopyGoopdateFiles(omaha_path_, this_version_); | |
307 | |
308 EXPECT_FALSE(setup_files_->ShouldOverinstallSameVersion()); | |
309 } | |
310 | |
311 TEST_F(SetupFilesUserTest, | |
312 ShouldOverinstallSameVersion_SameVersionRequiredFileMissing) { | |
313 ASSERT_SUCCEEDED(RegKey::SetValue(USER_REG_CLIENTS_GOOPDATE, | |
314 kRegValueProductVersion, | |
315 this_version_)); | |
316 | |
317 CopyGoopdateFiles(omaha_path_, this_version_); | |
318 CString path = ConcatenatePath(ConcatenatePath(omaha_path_, this_version_), | |
319 kOmahaDllName); | |
320 ASSERT_SUCCEEDED(File::Remove(path)); | |
321 ASSERT_FALSE(File::Exists(path)); | |
322 | |
323 EXPECT_TRUE(setup_files_->ShouldOverinstallSameVersion()); | |
324 } | |
325 | |
326 TEST_F(SetupFilesUserTest, | |
327 ShouldOverinstallSameVersion_SameVersionOptionalFileMissing) { | |
328 ASSERT_SUCCEEDED(RegKey::SetValue(USER_REG_CLIENTS_GOOPDATE, | |
329 kRegValueProductVersion, | |
330 this_version_)); | |
331 | |
332 CopyGoopdateFiles(omaha_path_, this_version_); | |
333 CString path = ConcatenatePath(ConcatenatePath(omaha_path_, this_version_), | |
334 UPDATE_PLUGIN_FILENAME); | |
335 ASSERT_SUCCEEDED(File::Remove(path)); | |
336 ASSERT_FALSE(File::Exists(path)); | |
337 | |
338 EXPECT_TRUE(setup_files_->ShouldOverinstallSameVersion()); | |
339 } | |
340 | |
341 TEST_F(SetupFilesUserTest, | |
342 ShouldOverinstallSameVersion_SameVersionShellMissing) { | |
343 ASSERT_SUCCEEDED(RegKey::SetValue(USER_REG_CLIENTS_GOOPDATE, | |
344 kRegValueProductVersion, | |
345 this_version_)); | |
346 | |
347 CopyGoopdateFiles(omaha_path_, this_version_); | |
348 CString shell_path = ConcatenatePath(omaha_path_, kOmahaShellFileName); | |
349 ASSERT_TRUE(SUCCEEDED(File::DeleteAfterReboot(shell_path)) || | |
350 !vista_util::IsUserAdmin()); | |
351 ASSERT_FALSE(File::Exists(shell_path)); | |
352 | |
353 EXPECT_TRUE(setup_files_->ShouldOverinstallSameVersion()); | |
354 } | |
355 | |
356 TEST_F(SetupFilesUserTest, | |
357 ShouldOverinstallSameVersion_NewerVersionShellMissing) { | |
358 ASSERT_SUCCEEDED(RegKey::SetValue(USER_REG_CLIENTS_GOOPDATE, | |
359 kRegValueProductVersion, | |
360 kFutureVersionString)); | |
361 | |
362 CopyGoopdateFiles(omaha_path_, kFutureVersionString); | |
363 CString shell_path = ConcatenatePath(omaha_path_, kOmahaShellFileName); | |
364 ASSERT_TRUE(SUCCEEDED(File::DeleteAfterReboot(shell_path)) || | |
365 !vista_util::IsUserAdmin()); | |
366 ASSERT_FALSE(File::Exists(shell_path)); | |
367 | |
368 // Does not check the version. | |
369 EXPECT_TRUE(setup_files_->ShouldOverinstallSameVersion()); | |
370 | |
371 EXPECT_SUCCEEDED( | |
372 DeleteDirectory(ConcatenatePath(omaha_path_, kFutureVersionString))); | |
373 } | |
374 | |
375 // "NotOverInstall" refers to there not being files in the directory. | |
376 // should_over_install/overwrite will be true for unofficial builds. | |
377 TEST_F(SetupFilesMachineTest, Install_NotOverInstall) { | |
378 if (vista_util::IsUserAdmin()) { | |
379 // Fake the version | |
380 const ULONGLONG module_version = GetVersion(); | |
381 InitializeVersion(kFutureVersion); | |
382 | |
383 InstallHelper(omaha_path_); | |
384 | |
385 InitializeVersion(module_version); | |
386 } else { | |
387 // This method expects to be called elevated for machine installs. | |
388 ExpectAsserts expect_asserts; | |
389 EXPECT_EQ(GOOPDATE_E_ACCESSDENIED_COPYING_CORE_FILES, | |
390 setup_files_->Install()); | |
391 } | |
392 } | |
393 | |
394 TEST_F(SetupFilesUserTest, Install_NotOverInstall) { | |
395 // Fake the version | |
396 const ULONGLONG module_version = GetVersion(); | |
397 InitializeVersion(kFutureVersion); | |
398 | |
399 InstallHelper(omaha_path_); | |
400 | |
401 InitializeVersion(module_version); | |
402 } | |
403 | |
404 // TODO(omaha3): Need a 1.3.x_newer directory. | |
405 TEST_F(SetupFilesUserTest, DISABLED_ShouldCopyShell_ExistingIsNewer) { | |
406 CString target_path = ConcatenatePath( | |
407 ConcatenatePath(exe_parent_dir_, _T("omaha_1.3.x_newer")), | |
408 kOmahaShellFileName); | |
409 ASSERT_TRUE(File::Exists(target_path)); | |
410 bool should_copy = false; | |
411 bool already_exists = false; | |
412 EXPECT_SUCCEEDED(ShouldCopyShell(target_path, &should_copy, &already_exists)); | |
413 EXPECT_FALSE(should_copy); | |
414 EXPECT_TRUE(already_exists); | |
415 } | |
416 | |
417 TEST_F(SetupFilesUserTest, ShouldCopyShell_ExistingIsSame) { | |
418 CString target_path = ConcatenatePath(app_util::GetCurrentModuleDirectory(), | |
419 kOmahaShellFileName); | |
420 ASSERT_TRUE(File::Exists(target_path)); | |
421 bool should_copy = false; | |
422 bool already_exists = false; | |
423 | |
424 EXPECT_SUCCEEDED(ShouldCopyShell(target_path, &should_copy, &already_exists)); | |
425 EXPECT_EQ(expected_is_overinstall_, should_copy); | |
426 EXPECT_TRUE(already_exists); | |
427 | |
428 if (!ShouldRunLargeTest()) { | |
429 return; | |
430 } | |
431 | |
432 // Override OverInstall to test official behavior on non-official builds. | |
433 | |
434 DWORD existing_overinstall(0); | |
435 bool had_existing_overinstall = SUCCEEDED(RegKey::GetValue( | |
436 MACHINE_REG_UPDATE_DEV, | |
437 kRegValueNameOverInstall, | |
438 &existing_overinstall)); | |
439 | |
440 EXPECT_SUCCEEDED(RegKey::SetValue(MACHINE_REG_UPDATE_DEV, | |
441 kRegValueNameOverInstall, | |
442 static_cast<DWORD>(0))); | |
443 | |
444 EXPECT_SUCCEEDED( | |
445 ShouldCopyShell(target_path, &should_copy, &already_exists)); | |
446 #ifdef DEBUG | |
447 EXPECT_FALSE(should_copy); | |
448 #else | |
449 EXPECT_EQ(expected_is_overinstall_, should_copy); | |
450 #endif | |
451 EXPECT_TRUE(already_exists); | |
452 | |
453 // Restore "overinstall" | |
454 if (had_existing_overinstall) { | |
455 EXPECT_SUCCEEDED(RegKey::SetValue(MACHINE_REG_UPDATE_DEV, | |
456 kRegValueNameOverInstall, | |
457 existing_overinstall)); | |
458 } else { | |
459 EXPECT_SUCCEEDED(RegKey::DeleteValue(MACHINE_REG_UPDATE_DEV, | |
460 kRegValueNameOverInstall)); | |
461 } | |
462 } | |
463 | |
464 TEST_F(SetupFilesUserTest, IsOlderShellVersionCompatible_Compatible) { | |
465 EXPECT_TRUE(IsOlderShellVersionCompatible(MAKEDLLVERULL(1, 2, 131, 7))); | |
466 EXPECT_TRUE(IsOlderShellVersionCompatible(MAKEDLLVERULL(1, 2, 183, 9))); | |
467 } | |
468 | |
469 TEST_F(SetupFilesUserTest, IsOlderShellVersionCompatible_Incompatible) { | |
470 // Vary the four elements of the version. | |
471 EXPECT_FALSE(IsOlderShellVersionCompatible(MAKEDLLVERULL(1, 2, 183, 7))); | |
472 EXPECT_FALSE(IsOlderShellVersionCompatible(MAKEDLLVERULL(1, 2, 185, 9))); | |
473 EXPECT_FALSE(IsOlderShellVersionCompatible(MAKEDLLVERULL(1, 3, 183, 9))); | |
474 EXPECT_FALSE(IsOlderShellVersionCompatible(MAKEDLLVERULL(2, 2, 183, 9))); | |
475 | |
476 // Corner cases | |
477 EXPECT_FALSE(IsOlderShellVersionCompatible(_UI64_MAX)); | |
478 EXPECT_FALSE(IsOlderShellVersionCompatible(0)); | |
479 EXPECT_FALSE(IsOlderShellVersionCompatible(1)); | |
480 } | |
481 | |
482 TEST_F(SetupFilesUserTest, | |
483 ShouldCopyShell_ExistingIsOlderButCompatible_1_2_131_7) { | |
484 CString target_path = ConcatenatePath( | |
485 ConcatenatePath(exe_parent_dir_, _T("omaha_1.2.131.7_shell")), | |
486 kOmahaShellFileName); | |
487 ASSERT_TRUE(File::Exists(target_path)); | |
488 bool should_copy = false; | |
489 bool already_exists = false; | |
490 EXPECT_SUCCEEDED(ShouldCopyShell(target_path, &should_copy, &already_exists)); | |
491 EXPECT_FALSE(should_copy); | |
492 EXPECT_TRUE(already_exists); | |
493 } | |
494 | |
495 TEST_F(SetupFilesUserTest, | |
496 ShouldCopyShell_ExistingIsOlderButCompatible_1_2_183_9) { | |
497 CString target_path = ConcatenatePath( | |
498 ConcatenatePath(exe_parent_dir_, _T("omaha_1.2.183.9_shell")), | |
499 kOmahaShellFileName); | |
500 ASSERT_TRUE(File::Exists(target_path)); | |
501 bool should_copy = false; | |
502 bool already_exists = false; | |
503 EXPECT_SUCCEEDED(ShouldCopyShell(target_path, &should_copy, &already_exists)); | |
504 EXPECT_FALSE(should_copy); | |
505 EXPECT_TRUE(already_exists); | |
506 } | |
507 | |
508 TEST_F(SetupFilesUserTest, ShouldCopyShell_ExistingIsOlderMinor) { | |
509 CString target_path = ConcatenatePath( | |
510 ConcatenatePath(exe_parent_dir_, _T("omaha_1.2.x")), | |
511 kOmahaShellFileName); | |
512 ASSERT_TRUE(File::Exists(target_path)); | |
513 bool should_copy = false; | |
514 bool already_exists = false; | |
515 EXPECT_SUCCEEDED(ShouldCopyShell(target_path, &should_copy, &already_exists)); | |
516 EXPECT_TRUE(should_copy); | |
517 EXPECT_TRUE(already_exists); | |
518 } | |
519 | |
520 // The 1.3.x directory will not always have an older GoogleUpdate.exe than the | |
521 // saved version that we use for official builds. | |
522 #if !OFFICIAL_BUILD | |
523 TEST_F(SetupFilesUserTest, ShouldCopyShell_ExistingIsOlderSameMinor) { | |
524 CString target_path = ConcatenatePath( | |
525 ConcatenatePath(exe_parent_dir_, _T("omaha_1.3.x")), | |
526 kOmahaShellFileName); | |
527 ASSERT_TRUE(File::Exists(target_path)); | |
528 bool should_copy = false; | |
529 bool already_exists = false; | |
530 EXPECT_SUCCEEDED(ShouldCopyShell(target_path, &should_copy, &already_exists)); | |
531 EXPECT_TRUE(should_copy); | |
532 EXPECT_TRUE(already_exists); | |
533 } | |
534 #endif | |
535 | |
536 // Assumes LongRunningSilent.exe does not have a version resource. | |
537 TEST_F(SetupFilesUserTest, ShouldCopyShell_ExistingHasNoVersion) { | |
538 CString target_path = ConcatenatePath( | |
539 ConcatenatePath(exe_parent_dir_, _T("does_not_shutdown")), | |
540 kOmahaShellFileName); | |
541 ASSERT_TRUE(File::Exists(target_path)); | |
542 bool should_copy = false; | |
543 bool already_exists = false; | |
544 ExpectAsserts expect_asserts; | |
545 EXPECT_SUCCEEDED(ShouldCopyShell(target_path, &should_copy, &already_exists)); | |
546 EXPECT_TRUE(should_copy); | |
547 EXPECT_TRUE(already_exists); | |
548 } | |
549 | |
550 TEST_F(SetupFilesUserTest, ShouldCopyShell_NoExistingFile) { | |
551 CString target_path = ConcatenatePath( | |
552 ConcatenatePath(exe_parent_dir_, _T("no_such_dir")), | |
553 kOmahaShellFileName); | |
554 ASSERT_FALSE(File::Exists(target_path)); | |
555 bool should_copy = false; | |
556 bool already_exists = false; | |
557 EXPECT_SUCCEEDED(ShouldCopyShell(target_path, &should_copy, &already_exists)); | |
558 EXPECT_TRUE(should_copy); | |
559 EXPECT_FALSE(already_exists); | |
560 } | |
561 | |
562 } // namespace omaha | |
OLD | NEW |