OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 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/installer/util/installer_state.h" | 5 #include "chrome/installer/util/installer_state.h" |
6 | 6 |
7 #include <windows.h> | 7 #include <windows.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <fstream> | 10 #include <fstream> |
11 | 11 |
12 #include "base/base_paths.h" | 12 #include "base/base_paths.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/files/file_enumerator.h" | |
15 #include "base/files/file_path.h" | 14 #include "base/files/file_path.h" |
16 #include "base/files/file_util.h" | 15 #include "base/files/file_util.h" |
17 #include "base/files/scoped_temp_dir.h" | 16 #include "base/files/scoped_temp_dir.h" |
18 #include "base/macros.h" | 17 #include "base/macros.h" |
19 #include "base/path_service.h" | 18 #include "base/path_service.h" |
20 #include "base/strings/string_util.h" | 19 #include "base/strings/string_util.h" |
21 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
22 #include "base/test/scoped_path_override.h" | 21 #include "base/test/scoped_path_override.h" |
23 #include "base/test/test_reg_util_win.h" | 22 #include "base/test/test_reg_util_win.h" |
24 #include "base/version.h" | 23 #include "base/version.h" |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 MockInstallerState() : InstallerState() { } | 62 MockInstallerState() : InstallerState() { } |
64 void set_target_path(const base::FilePath& target_path) { | 63 void set_target_path(const base::FilePath& target_path) { |
65 target_path_ = target_path; | 64 target_path_ = target_path; |
66 } | 65 } |
67 static bool IsFileInUse(const base::FilePath& file) { | 66 static bool IsFileInUse(const base::FilePath& file) { |
68 return InstallerState::IsFileInUse(file); | 67 return InstallerState::IsFileInUse(file); |
69 } | 68 } |
70 const Version& critical_update_version() const { | 69 const Version& critical_update_version() const { |
71 return critical_update_version_; | 70 return critical_update_version_; |
72 } | 71 } |
73 void GetExistingExeVersions(std::set<std::string>* existing_version_strings) { | |
74 return InstallerState::GetExistingExeVersions(existing_version_strings); | |
75 } | |
76 }; | 72 }; |
77 | 73 |
78 // Simple function to dump some text into a new file. | 74 // Simple function to dump some text into a new file. |
79 void CreateTextFile(const std::wstring& filename, | 75 void CreateTextFile(const std::wstring& filename, |
80 const std::wstring& contents) { | 76 const std::wstring& contents) { |
81 std::ofstream file; | 77 std::ofstream file; |
82 file.open(filename.c_str()); | 78 file.open(filename.c_str()); |
83 ASSERT_TRUE(file.is_open()); | 79 ASSERT_TRUE(file.is_open()); |
84 file << contents; | 80 file << contents; |
85 file.close(); | 81 file.close(); |
86 } | 82 } |
87 | 83 |
88 void BuildSingleChromeState(const base::FilePath& target_dir, | 84 void BuildSingleChromeState(const base::FilePath& target_dir, |
89 MockInstallerState* installer_state) { | 85 MockInstallerState* installer_state) { |
90 base::CommandLine cmd_line = base::CommandLine::FromString(L"setup.exe"); | 86 base::CommandLine cmd_line = base::CommandLine::FromString(L"setup.exe"); |
91 MasterPreferences prefs(cmd_line); | 87 MasterPreferences prefs(cmd_line); |
92 InstallationState machine_state; | 88 InstallationState machine_state; |
93 machine_state.Initialize(); | 89 machine_state.Initialize(); |
94 installer_state->Initialize(cmd_line, prefs, machine_state); | 90 installer_state->Initialize(cmd_line, prefs, machine_state); |
95 installer_state->set_target_path(target_dir); | 91 installer_state->set_target_path(target_dir); |
96 EXPECT_TRUE(installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER) | 92 EXPECT_TRUE(installer_state->FindProduct(BrowserDistribution::CHROME_BROWSER) |
97 != NULL); | 93 != NULL); |
98 } | 94 } |
99 | 95 |
100 wchar_t text_content_1[] = L"delete me"; | |
101 wchar_t text_content_2[] = L"delete me as well"; | |
102 | |
103 // Delete version directories. Everything lower than the given version | |
104 // should be deleted. | |
105 TEST_F(InstallerStateTest, Delete) { | |
106 // TODO(grt): move common stuff into the test fixture. | |
107 // Create a Chrome dir | |
108 base::FilePath chrome_dir(test_dir_.path()); | |
109 chrome_dir = chrome_dir.AppendASCII("chrome"); | |
110 base::CreateDirectory(chrome_dir); | |
111 ASSERT_TRUE(base::PathExists(chrome_dir)); | |
112 | |
113 base::FilePath chrome_dir_1(chrome_dir); | |
114 chrome_dir_1 = chrome_dir_1.AppendASCII("1.0.1.0"); | |
115 base::CreateDirectory(chrome_dir_1); | |
116 ASSERT_TRUE(base::PathExists(chrome_dir_1)); | |
117 | |
118 base::FilePath chrome_dir_2(chrome_dir); | |
119 chrome_dir_2 = chrome_dir_2.AppendASCII("1.0.2.0"); | |
120 base::CreateDirectory(chrome_dir_2); | |
121 ASSERT_TRUE(base::PathExists(chrome_dir_2)); | |
122 | |
123 base::FilePath chrome_dir_3(chrome_dir); | |
124 chrome_dir_3 = chrome_dir_3.AppendASCII("1.0.3.0"); | |
125 base::CreateDirectory(chrome_dir_3); | |
126 ASSERT_TRUE(base::PathExists(chrome_dir_3)); | |
127 | |
128 base::FilePath chrome_dir_4(chrome_dir); | |
129 chrome_dir_4 = chrome_dir_4.AppendASCII("1.0.4.0"); | |
130 base::CreateDirectory(chrome_dir_4); | |
131 ASSERT_TRUE(base::PathExists(chrome_dir_4)); | |
132 | |
133 base::FilePath chrome_dll_1(chrome_dir_1); | |
134 chrome_dll_1 = chrome_dll_1.AppendASCII("chrome.dll"); | |
135 CreateTextFile(chrome_dll_1.value(), text_content_1); | |
136 ASSERT_TRUE(base::PathExists(chrome_dll_1)); | |
137 | |
138 base::FilePath chrome_dll_2(chrome_dir_2); | |
139 chrome_dll_2 = chrome_dll_2.AppendASCII("chrome.dll"); | |
140 CreateTextFile(chrome_dll_2.value(), text_content_1); | |
141 ASSERT_TRUE(base::PathExists(chrome_dll_2)); | |
142 | |
143 base::FilePath chrome_dll_3(chrome_dir_3); | |
144 chrome_dll_3 = chrome_dll_3.AppendASCII("chrome.dll"); | |
145 CreateTextFile(chrome_dll_3.value(), text_content_1); | |
146 ASSERT_TRUE(base::PathExists(chrome_dll_3)); | |
147 | |
148 base::FilePath chrome_dll_4(chrome_dir_4); | |
149 chrome_dll_4 = chrome_dll_4.AppendASCII("chrome.dll"); | |
150 CreateTextFile(chrome_dll_4.value(), text_content_1); | |
151 ASSERT_TRUE(base::PathExists(chrome_dll_4)); | |
152 | |
153 MockInstallerState installer_state; | |
154 BuildSingleChromeState(chrome_dir, &installer_state); | |
155 Version latest_version("1.0.4.0"); | |
156 { | |
157 base::ScopedTempDir temp_dir; | |
158 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | |
159 installer_state.RemoveOldVersionDirectories(latest_version, NULL, | |
160 temp_dir.path()); | |
161 } | |
162 | |
163 // old versions should be gone | |
164 EXPECT_FALSE(base::PathExists(chrome_dir_1)); | |
165 EXPECT_FALSE(base::PathExists(chrome_dir_2)); | |
166 EXPECT_FALSE(base::PathExists(chrome_dir_3)); | |
167 // the latest version should stay | |
168 EXPECT_TRUE(base::PathExists(chrome_dll_4)); | |
169 } | |
170 | |
171 // Delete older version directories, keeping the one in used intact. | |
172 TEST_F(InstallerStateTest, DeleteInUsed) { | |
173 // Create a Chrome dir | |
174 base::FilePath chrome_dir(test_dir_.path()); | |
175 chrome_dir = chrome_dir.AppendASCII("chrome"); | |
176 base::CreateDirectory(chrome_dir); | |
177 ASSERT_TRUE(base::PathExists(chrome_dir)); | |
178 | |
179 base::FilePath chrome_dir_1(chrome_dir); | |
180 chrome_dir_1 = chrome_dir_1.AppendASCII("1.0.1.0"); | |
181 base::CreateDirectory(chrome_dir_1); | |
182 ASSERT_TRUE(base::PathExists(chrome_dir_1)); | |
183 | |
184 base::FilePath chrome_dir_2(chrome_dir); | |
185 chrome_dir_2 = chrome_dir_2.AppendASCII("1.0.2.0"); | |
186 base::CreateDirectory(chrome_dir_2); | |
187 ASSERT_TRUE(base::PathExists(chrome_dir_2)); | |
188 | |
189 base::FilePath chrome_dir_3(chrome_dir); | |
190 chrome_dir_3 = chrome_dir_3.AppendASCII("1.0.3.0"); | |
191 base::CreateDirectory(chrome_dir_3); | |
192 ASSERT_TRUE(base::PathExists(chrome_dir_3)); | |
193 | |
194 base::FilePath chrome_dir_4(chrome_dir); | |
195 chrome_dir_4 = chrome_dir_4.AppendASCII("1.0.4.0"); | |
196 base::CreateDirectory(chrome_dir_4); | |
197 ASSERT_TRUE(base::PathExists(chrome_dir_4)); | |
198 | |
199 base::FilePath chrome_dll_1(chrome_dir_1); | |
200 chrome_dll_1 = chrome_dll_1.AppendASCII("chrome.dll"); | |
201 CreateTextFile(chrome_dll_1.value(), text_content_1); | |
202 ASSERT_TRUE(base::PathExists(chrome_dll_1)); | |
203 | |
204 base::FilePath chrome_dll_2(chrome_dir_2); | |
205 chrome_dll_2 = chrome_dll_2.AppendASCII("chrome.dll"); | |
206 CreateTextFile(chrome_dll_2.value(), text_content_1); | |
207 ASSERT_TRUE(base::PathExists(chrome_dll_2)); | |
208 | |
209 // Open the file to make it in use. | |
210 std::ofstream file; | |
211 file.open(chrome_dll_2.value().c_str()); | |
212 | |
213 base::FilePath chrome_othera_2(chrome_dir_2); | |
214 chrome_othera_2 = chrome_othera_2.AppendASCII("othera.dll"); | |
215 CreateTextFile(chrome_othera_2.value(), text_content_2); | |
216 ASSERT_TRUE(base::PathExists(chrome_othera_2)); | |
217 | |
218 base::FilePath chrome_otherb_2(chrome_dir_2); | |
219 chrome_otherb_2 = chrome_otherb_2.AppendASCII("otherb.dll"); | |
220 CreateTextFile(chrome_otherb_2.value(), text_content_2); | |
221 ASSERT_TRUE(base::PathExists(chrome_otherb_2)); | |
222 | |
223 base::FilePath chrome_dll_3(chrome_dir_3); | |
224 chrome_dll_3 = chrome_dll_3.AppendASCII("chrome.dll"); | |
225 CreateTextFile(chrome_dll_3.value(), text_content_1); | |
226 ASSERT_TRUE(base::PathExists(chrome_dll_3)); | |
227 | |
228 base::FilePath chrome_dll_4(chrome_dir_4); | |
229 chrome_dll_4 = chrome_dll_4.AppendASCII("chrome.dll"); | |
230 CreateTextFile(chrome_dll_4.value(), text_content_1); | |
231 ASSERT_TRUE(base::PathExists(chrome_dll_4)); | |
232 | |
233 MockInstallerState installer_state; | |
234 BuildSingleChromeState(chrome_dir, &installer_state); | |
235 Version latest_version("1.0.4.0"); | |
236 Version existing_version("1.0.1.0"); | |
237 { | |
238 base::ScopedTempDir temp_dir; | |
239 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | |
240 installer_state.RemoveOldVersionDirectories(latest_version, | |
241 &existing_version, | |
242 temp_dir.path()); | |
243 } | |
244 | |
245 // the version defined as the existing version should stay | |
246 EXPECT_TRUE(base::PathExists(chrome_dir_1)); | |
247 // old versions not in used should be gone | |
248 EXPECT_FALSE(base::PathExists(chrome_dir_3)); | |
249 // every thing under in used version should stay | |
250 EXPECT_TRUE(base::PathExists(chrome_dir_2)); | |
251 EXPECT_TRUE(base::PathExists(chrome_dll_2)); | |
252 EXPECT_TRUE(base::PathExists(chrome_othera_2)); | |
253 EXPECT_TRUE(base::PathExists(chrome_otherb_2)); | |
254 // the latest version should stay | |
255 EXPECT_TRUE(base::PathExists(chrome_dll_4)); | |
256 } | |
257 | |
258 // Tests a few basic things of the Package class. Makes sure that the path | |
259 // operations are correct | |
260 TEST_F(InstallerStateTest, Basic) { | |
261 const bool multi_install = false; | |
262 const bool system_level = true; | |
263 base::CommandLine cmd_line = base::CommandLine::FromString( | |
264 std::wstring(L"setup.exe") + | |
265 (multi_install ? L" --multi-install --chrome" : L"") + | |
266 (system_level ? L" --system-level" : L"")); | |
267 MasterPreferences prefs(cmd_line); | |
268 InstallationState machine_state; | |
269 machine_state.Initialize(); | |
270 MockInstallerState installer_state; | |
271 installer_state.Initialize(cmd_line, prefs, machine_state); | |
272 installer_state.set_target_path(test_dir_.path()); | |
273 EXPECT_EQ(test_dir_.path().value(), installer_state.target_path().value()); | |
274 EXPECT_EQ(1U, installer_state.products().size()); | |
275 | |
276 const char kOldVersion[] = "1.2.3.4"; | |
277 const char kNewVersion[] = "2.3.4.5"; | |
278 | |
279 Version new_version(kNewVersion); | |
280 Version old_version(kOldVersion); | |
281 ASSERT_TRUE(new_version.IsValid()); | |
282 ASSERT_TRUE(old_version.IsValid()); | |
283 | |
284 base::FilePath installer_dir( | |
285 installer_state.GetInstallerDirectory(new_version)); | |
286 EXPECT_FALSE(installer_dir.empty()); | |
287 | |
288 base::FilePath new_version_dir(installer_state.target_path().Append( | |
289 base::UTF8ToWide(new_version.GetString()))); | |
290 base::FilePath old_version_dir(installer_state.target_path().Append( | |
291 base::UTF8ToWide(old_version.GetString()))); | |
292 | |
293 EXPECT_FALSE(base::PathExists(new_version_dir)); | |
294 EXPECT_FALSE(base::PathExists(old_version_dir)); | |
295 | |
296 EXPECT_FALSE(base::PathExists(installer_dir)); | |
297 base::CreateDirectory(installer_dir); | |
298 EXPECT_TRUE(base::PathExists(new_version_dir)); | |
299 | |
300 base::CreateDirectory(old_version_dir); | |
301 EXPECT_TRUE(base::PathExists(old_version_dir)); | |
302 | |
303 // Create a fake chrome.dll key file in the old version directory. This | |
304 // should prevent the old version directory from getting deleted. | |
305 base::FilePath old_chrome_dll(old_version_dir.Append(installer::kChromeDll)); | |
306 EXPECT_FALSE(base::PathExists(old_chrome_dll)); | |
307 | |
308 // Hold on to the file exclusively to prevent the directory from | |
309 // being deleted. | |
310 base::win::ScopedHandle file( | |
311 ::CreateFile(old_chrome_dll.value().c_str(), GENERIC_READ, | |
312 0, NULL, OPEN_ALWAYS, 0, NULL)); | |
313 EXPECT_TRUE(file.IsValid()); | |
314 EXPECT_TRUE(base::PathExists(old_chrome_dll)); | |
315 | |
316 base::ScopedTempDir temp_dir; | |
317 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | |
318 | |
319 // Don't explicitly tell the directory cleanup logic not to delete the | |
320 // old version, rely on the key files to keep it around. | |
321 installer_state.RemoveOldVersionDirectories(new_version, | |
322 NULL, | |
323 temp_dir.path()); | |
324 | |
325 // The old directory should still exist. | |
326 EXPECT_TRUE(base::PathExists(old_version_dir)); | |
327 EXPECT_TRUE(base::PathExists(new_version_dir)); | |
328 | |
329 // Now close the file handle to make it possible to delete our key file. | |
330 file.Close(); | |
331 | |
332 installer_state.RemoveOldVersionDirectories(new_version, | |
333 NULL, | |
334 temp_dir.path()); | |
335 // The new directory should still exist. | |
336 EXPECT_TRUE(base::PathExists(new_version_dir)); | |
337 | |
338 // Now, the old directory and key file should be gone. | |
339 EXPECT_FALSE(base::PathExists(old_chrome_dll)); | |
340 EXPECT_FALSE(base::PathExists(old_version_dir)); | |
341 } | |
342 | |
343 TEST_F(InstallerStateTest, WithProduct) { | 96 TEST_F(InstallerStateTest, WithProduct) { |
344 const bool multi_install = false; | 97 const bool multi_install = false; |
345 const bool system_level = true; | 98 const bool system_level = true; |
346 base::CommandLine cmd_line = base::CommandLine::FromString( | 99 base::CommandLine cmd_line = base::CommandLine::FromString( |
347 std::wstring(L"setup.exe") + | 100 std::wstring(L"setup.exe") + |
348 (multi_install ? L" --multi-install --chrome" : L"") + | 101 (multi_install ? L" --multi-install --chrome" : L"") + |
349 (system_level ? L" --system-level" : L"")); | 102 (system_level ? L" --system-level" : L"")); |
350 MasterPreferences prefs(cmd_line); | 103 MasterPreferences prefs(cmd_line); |
351 InstallationState machine_state; | 104 InstallationState machine_state; |
352 machine_state.Initialize(); | 105 machine_state.Initialize(); |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 ASSERT_TRUE(temp_handle.IsValid()); | 253 ASSERT_TRUE(temp_handle.IsValid()); |
501 | 254 |
502 // The file should now be in use. | 255 // The file should now be in use. |
503 EXPECT_TRUE(MockInstallerState::IsFileInUse(temp_file)); | 256 EXPECT_TRUE(MockInstallerState::IsFileInUse(temp_file)); |
504 } | 257 } |
505 | 258 |
506 // And once the handle is gone, it should no longer be in use. | 259 // And once the handle is gone, it should no longer be in use. |
507 EXPECT_FALSE(MockInstallerState::IsFileInUse(temp_file)); | 260 EXPECT_FALSE(MockInstallerState::IsFileInUse(temp_file)); |
508 } | 261 } |
509 | 262 |
510 TEST_F(InstallerStateTest, RemoveOldVersionDirs) { | |
511 MockInstallerState installer_state; | |
512 installer_state.set_target_path(test_dir_.path()); | |
513 EXPECT_EQ(test_dir_.path().value(), installer_state.target_path().value()); | |
514 | |
515 const char kOldVersion[] = "2.0.0.0"; | |
516 const char kNewVersion[] = "3.0.0.0"; | |
517 const char kOldChromeExeVersion[] = "2.1.0.0"; | |
518 const char kChromeExeVersion[] = "2.1.1.1"; | |
519 const char kNewChromeExeVersion[] = "3.0.0.0"; | |
520 | |
521 Version new_version(kNewVersion); | |
522 Version old_version(kOldVersion); | |
523 Version old_chrome_exe_version(kOldChromeExeVersion); | |
524 Version chrome_exe_version(kChromeExeVersion); | |
525 Version new_chrome_exe_version(kNewChromeExeVersion); | |
526 | |
527 ASSERT_TRUE(new_version.IsValid()); | |
528 ASSERT_TRUE(old_version.IsValid()); | |
529 ASSERT_TRUE(old_chrome_exe_version.IsValid()); | |
530 ASSERT_TRUE(chrome_exe_version.IsValid()); | |
531 ASSERT_TRUE(new_chrome_exe_version.IsValid()); | |
532 | |
533 // Set up a bunch of version dir paths. | |
534 base::FilePath version_dirs[] = { | |
535 installer_state.target_path().Append(L"1.2.3.4"), | |
536 installer_state.target_path().Append(L"1.2.3.5"), | |
537 installer_state.target_path().Append(L"1.2.3.6"), | |
538 installer_state.target_path().AppendASCII(kOldVersion), | |
539 installer_state.target_path().AppendASCII(kOldChromeExeVersion), | |
540 installer_state.target_path().Append(L"2.1.1.0"), | |
541 installer_state.target_path().AppendASCII(kChromeExeVersion), | |
542 installer_state.target_path().AppendASCII(kNewVersion), | |
543 installer_state.target_path().Append(L"3.9.1.1"), | |
544 }; | |
545 | |
546 // Create the version directories. | |
547 for (size_t i = 0; i < arraysize(version_dirs); i++) { | |
548 base::CreateDirectory(version_dirs[i]); | |
549 EXPECT_TRUE(base::PathExists(version_dirs[i])); | |
550 } | |
551 | |
552 // Create exes with the appropriate version resource. | |
553 // Use the current test exe as a baseline. | |
554 base::FilePath exe_path; | |
555 ASSERT_TRUE(PathService::Get(base::FILE_EXE, &exe_path)); | |
556 | |
557 struct target_info { | |
558 base::FilePath target_file; | |
559 const Version& target_version; | |
560 } targets[] = { | |
561 { installer_state.target_path().Append(installer::kChromeOldExe), | |
562 old_chrome_exe_version }, | |
563 { installer_state.target_path().Append(installer::kChromeExe), | |
564 chrome_exe_version }, | |
565 { installer_state.target_path().Append(installer::kChromeNewExe), | |
566 new_chrome_exe_version }, | |
567 }; | |
568 for (size_t i = 0; i < arraysize(targets); ++i) { | |
569 ASSERT_TRUE(upgrade_test::GenerateSpecificPEFileVersion( | |
570 exe_path, targets[i].target_file, targets[i].target_version)); | |
571 } | |
572 | |
573 // Call GetExistingExeVersions, validate that picks up the | |
574 // exe resources. | |
575 std::set<std::string> expected_exe_versions; | |
576 expected_exe_versions.insert(kOldChromeExeVersion); | |
577 expected_exe_versions.insert(kChromeExeVersion); | |
578 expected_exe_versions.insert(kNewChromeExeVersion); | |
579 | |
580 std::set<std::string> actual_exe_versions; | |
581 installer_state.GetExistingExeVersions(&actual_exe_versions); | |
582 EXPECT_EQ(expected_exe_versions, actual_exe_versions); | |
583 | |
584 // Call RemoveOldVersionDirectories | |
585 installer_state.RemoveOldVersionDirectories(new_version, | |
586 &old_version, | |
587 installer_state.target_path()); | |
588 | |
589 // What we expect to have left. | |
590 std::set<std::string> expected_remaining_dirs; | |
591 expected_remaining_dirs.insert(kOldVersion); | |
592 expected_remaining_dirs.insert(kNewVersion); | |
593 expected_remaining_dirs.insert(kOldChromeExeVersion); | |
594 expected_remaining_dirs.insert(kChromeExeVersion); | |
595 expected_remaining_dirs.insert(kNewChromeExeVersion); | |
596 | |
597 // Enumerate dirs in target_path(), ensure only desired remain. | |
598 base::FileEnumerator version_enum(installer_state.target_path(), false, | |
599 base::FileEnumerator::DIRECTORIES); | |
600 for (base::FilePath next_version = version_enum.Next(); !next_version.empty(); | |
601 next_version = version_enum.Next()) { | |
602 base::FilePath dir_name(next_version.BaseName()); | |
603 Version version(base::UTF16ToASCII(dir_name.value())); | |
604 if (version.IsValid()) { | |
605 EXPECT_TRUE(expected_remaining_dirs.erase(version.GetString())) | |
606 << "Unexpected version dir found: " << version.GetString(); | |
607 } | |
608 } | |
609 | |
610 std::set<std::string>::const_iterator iter( | |
611 expected_remaining_dirs.begin()); | |
612 for (; iter != expected_remaining_dirs.end(); ++iter) | |
613 ADD_FAILURE() << "Expected to find version dir for " << *iter; | |
614 } | |
615 | |
616 TEST_F(InstallerStateTest, InitializeTwice) { | 263 TEST_F(InstallerStateTest, InitializeTwice) { |
617 // Override these paths so that they can be found after the registry override | 264 // Override these paths so that they can be found after the registry override |
618 // manager is in place. | 265 // manager is in place. |
619 base::FilePath temp; | 266 base::FilePath temp; |
620 PathService::Get(base::DIR_PROGRAM_FILES, &temp); | 267 PathService::Get(base::DIR_PROGRAM_FILES, &temp); |
621 base::ScopedPathOverride program_files_override(base::DIR_PROGRAM_FILES, | 268 base::ScopedPathOverride program_files_override(base::DIR_PROGRAM_FILES, |
622 temp); | 269 temp); |
623 PathService::Get(base::DIR_PROGRAM_FILESX86, &temp); | 270 PathService::Get(base::DIR_PROGRAM_FILESX86, &temp); |
624 base::ScopedPathOverride program_filesx86_override(base::DIR_PROGRAM_FILESX86, | 271 base::ScopedPathOverride program_filesx86_override(base::DIR_PROGRAM_FILESX86, |
625 temp); | 272 temp); |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
825 // Critical update newer than the new version. | 472 // Critical update newer than the new version. |
826 EXPECT_FALSE( | 473 EXPECT_FALSE( |
827 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); | 474 installer_state.DetermineCriticalVersion(NULL, *pv_version_).IsValid()); |
828 EXPECT_FALSE( | 475 EXPECT_FALSE( |
829 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) | 476 installer_state.DetermineCriticalVersion(opv_version_, *pv_version_) |
830 .IsValid()); | 477 .IsValid()); |
831 EXPECT_FALSE( | 478 EXPECT_FALSE( |
832 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) | 479 installer_state.DetermineCriticalVersion(pv_version_, *pv_version_) |
833 .IsValid()); | 480 .IsValid()); |
834 } | 481 } |
OLD | NEW |