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

Side by Side Diff: chrome/test/mini_installer_test/chrome_mini_installer.cc

Issue 8037004: Adding simple Chrome install testing using multi-install and cleaning up a bit. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync to head and merge Created 9 years, 3 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/test/mini_installer_test/chrome_mini_installer.h" 5 #include "chrome/test/mini_installer_test/chrome_mini_installer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/process.h" 12 #include "base/process.h"
13 #include "base/process_util.h" 13 #include "base/process_util.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "base/string_util.h" 15 #include "base/string_util.h"
16 #include "base/stringprintf.h" 16 #include "base/stringprintf.h"
17 #include "base/threading/platform_thread.h" 17 #include "base/threading/platform_thread.h"
18 #include "base/win/registry.h" 18 #include "base/win/registry.h"
19 #include "chrome/installer/util/browser_distribution.h" 19 #include "chrome/installer/util/browser_distribution.h"
20 #include "chrome/installer/util/google_update_constants.h" 20 #include "chrome/installer/util/google_update_constants.h"
21 #include "chrome/installer/util/helper.h"
22 #include "chrome/installer/util/install_util.h"
21 #include "chrome/installer/util/installation_validation_helper.h" 23 #include "chrome/installer/util/installation_validation_helper.h"
24 #include "chrome/test/base/chrome_process_util.h"
22 #include "chrome/test/mini_installer_test/mini_installer_test_constants.h" 25 #include "chrome/test/mini_installer_test/mini_installer_test_constants.h"
23 #include "chrome/test/mini_installer_test/mini_installer_test_util.h" 26 #include "chrome/test/mini_installer_test/mini_installer_test_util.h"
24 #include "testing/gtest/include/gtest/gtest.h" 27 #include "testing/gtest/include/gtest/gtest.h"
25 28
26 using base::win::RegKey; 29 using base::win::RegKey;
30 using installer::InstallationValidator;
27 31
28 namespace { 32 namespace {
29 33
30 struct FilePathInfo { 34 struct FilePathInfo {
31 file_util::FileEnumerator::FindInfo info; 35 file_util::FileEnumerator::FindInfo info;
32 FilePath path; 36 FilePath path;
33 }; 37 };
34 38
35 bool CompareDate(const FilePathInfo& a, 39 bool CompareDate(const FilePathInfo& a,
36 const FilePathInfo& b) { 40 const FilePathInfo& b) {
37 #if defined(OS_POSIX) 41 #if defined(OS_POSIX)
38 return a.info.stat.st_mtime > b.info.stat.st_mtime; 42 return a.info.stat.st_mtime > b.info.stat.st_mtime;
39 #elif defined(OS_WIN) 43 #elif defined(OS_WIN)
40 if (a.info.ftLastWriteTime.dwHighDateTime == 44 if (a.info.ftLastWriteTime.dwHighDateTime ==
41 b.info.ftLastWriteTime.dwHighDateTime) { 45 b.info.ftLastWriteTime.dwHighDateTime) {
42 return a.info.ftLastWriteTime.dwLowDateTime > 46 return a.info.ftLastWriteTime.dwLowDateTime >
43 b.info.ftLastWriteTime.dwLowDateTime; 47 b.info.ftLastWriteTime.dwLowDateTime;
44 } else { 48 } else {
45 return a.info.ftLastWriteTime.dwHighDateTime > 49 return a.info.ftLastWriteTime.dwHighDateTime >
46 b.info.ftLastWriteTime.dwHighDateTime; 50 b.info.ftLastWriteTime.dwHighDateTime;
47 } 51 }
48 #endif 52 #endif
49 } 53 }
50 54
55 class ChromeProcessFilter : public base::ProcessFilter {
56 public:
57 explicit ChromeProcessFilter(base::ProcessId pid)
58 :process_id(pid) {}
kkania 2011/09/26 20:00:53 4 space indent here, and 1 space between : and pro
Huyen 2011/09/27 23:00:24 Done.
59
60 virtual bool Includes(const base::ProcessEntry& entry) const {
61 return process_id == entry.pid();
kkania 2011/09/26 20:00:53 two space indent here
Huyen 2011/09/27 23:00:24 Done.
62 }
63
64 private:
65 const base::ProcessId process_id;
66
67 DISALLOW_COPY_AND_ASSIGN(ChromeProcessFilter);
68 };
69
70 // Copied from chrome/test/base/chrome_process_util.cc
71 class ChildProcessFilter : public base::ProcessFilter {
72 public:
73 explicit ChildProcessFilter(base::ProcessId parent_pid)
74 : parent_pids_(&parent_pid, (&parent_pid) + 1) {}
75
76 explicit ChildProcessFilter(std::vector<base::ProcessId> parent_pids)
77 : parent_pids_(parent_pids.begin(), parent_pids.end()) {}
78
79 virtual bool Includes(const base::ProcessEntry& entry) const {
80 return parent_pids_.find(entry.parent_pid()) != parent_pids_.end();
81 }
82
83 private:
84 const std::set<base::ProcessId> parent_pids_;
85
86 DISALLOW_COPY_AND_ASSIGN(ChildProcessFilter);
87 };
88
51 // Get list of file |type| matching |pattern| in |root|. 89 // Get list of file |type| matching |pattern| in |root|.
52 // The list is sorted in last modified date order. 90 // The list is sorted in last modified date order.
53 // Return true if files/directories are found. 91 // Return true if files/directories are found.
54 bool FindMatchingFiles(const FilePath& root, 92 bool FindMatchingFiles(const FilePath& root,
55 const FilePath::StringType& pattern, 93 const FilePath::StringType& pattern,
56 file_util::FileEnumerator::FileType type, 94 file_util::FileEnumerator::FileType type,
57 std::vector<FilePath>* paths) { 95 std::vector<FilePath>* paths) {
58 file_util::FileEnumerator files(root, false, type, pattern); 96 file_util::FileEnumerator files(root, false, type, pattern);
59 std::vector<FilePathInfo> matches; 97 std::vector<FilePathInfo> matches;
60 for (FilePath current = files.Next(); !current.empty(); 98 for (FilePath current = files.Next(); !current.empty();
(...skipping 22 matching lines...) Expand all
83 std::vector<FilePath> paths; 121 std::vector<FilePath> paths;
84 if (FindMatchingFiles(root, pattern, type, &paths)) { 122 if (FindMatchingFiles(root, pattern, type, &paths)) {
85 *path = paths[0]; 123 *path = paths[0];
86 return true; 124 return true;
87 } 125 }
88 return false; 126 return false;
89 } 127 }
90 128
91 } // namespace 129 } // namespace
92 130
93 ChromeMiniInstaller::ChromeMiniInstaller(const std::wstring& install_type, 131 ChromeMiniInstaller::ChromeMiniInstaller(bool system_install,
94 bool is_chrome_frame) 132 bool is_chrome_frame)
95 : is_chrome_frame_(is_chrome_frame), 133 : is_chrome_frame_(is_chrome_frame),
96 install_type_(install_type) {} 134 system_install_(system_install) {}
97 135
98 void ChromeMiniInstaller::SetBuildUnderTest( 136 void ChromeMiniInstaller::SetBuildUnderTest(
99 const std::wstring& build) { 137 const std::wstring& build) {
100 if (!LocateInstallers(build)) { 138 if (!LocateInstallers(build)) {
101 LOG(WARNING) << "Could not find one or more installers."; 139 LOG(WARNING) << "Could not find one or more installers.";
102 } 140 }
103 } 141 }
104 142
105 // Installs Chrome. 143 // Installs Chrome.
106 void ChromeMiniInstaller::Install() { 144 void ChromeMiniInstaller::Install() {
107 FilePath installer_path = MiniInstallerTestUtil::GetFilePath( 145 InstallMiniInstaller(false, mini_installer_);
kkania 2011/09/26 20:00:53 not sure why this passes mini_installer_ if its ac
Huyen 2011/09/27 23:00:24 Because sometime we use diff installer or other ty
108 mini_installer_constants::kChromeMiniInstallerExecutable);
109 InstallMiniInstaller(false, installer_path);
110 } 146 }
111 147
112 // This method will get the previous latest full installer from 148 // This method will get the previous latest full installer from
113 // nightly location, install it and over install with specified install_type. 149 // nightly location, install it and over install with specified install_type.
114 void ChromeMiniInstaller::OverInstallOnFullInstaller( 150 void ChromeMiniInstaller::OverInstallOnFullInstaller(
115 const std::wstring& install_type, bool should_start_ie) { 151 const std::wstring& install_type, bool should_start_ie) {
116 ASSERT_TRUE(!full_installer_.empty() && !diff_installer_.empty() && 152 ASSERT_TRUE(!full_installer_.empty() && !diff_installer_.empty() &&
117 !previous_installer_.empty()); 153 !previous_installer_.empty());
118 154
119 if (should_start_ie) 155 if (should_start_ie)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 // This method will get the latest full installer from nightly location 193 // This method will get the latest full installer from nightly location
158 // and installs it. 194 // and installs it.
159 void ChromeMiniInstaller::InstallFullInstaller(bool over_install) { 195 void ChromeMiniInstaller::InstallFullInstaller(bool over_install) {
160 if (!full_installer_.empty()) 196 if (!full_installer_.empty())
161 InstallMiniInstaller(over_install, full_installer_); 197 InstallMiniInstaller(over_install, full_installer_);
162 } 198 }
163 199
164 // Installs the Chrome mini-installer, checks the registry and shortcuts. 200 // Installs the Chrome mini-installer, checks the registry and shortcuts.
165 void ChromeMiniInstaller::InstallMiniInstaller(bool over_install, 201 void ChromeMiniInstaller::InstallMiniInstaller(bool over_install,
166 const FilePath& path) { 202 const FilePath& path) {
167 LOG(INFO) << "Chrome will be installed at " 203 LOG(INFO) << "Install level is: "
168 << install_type_ << "level."; 204 << system_install_ << " (1 means system, otherwise user)";
kkania 2011/09/26 20:00:53 use the ternary operator here to print out 'system
Huyen 2011/09/27 23:00:24 Done.
169 LOG(INFO) << "Will proceed with the test only if this path exists: " 205 LaunchInstaller(path, CommandLine::CommandLine(CommandLine::NO_PROGRAM));
170 << path.value();
171 206
172 ASSERT_TRUE(file_util::PathExists(path)) << path.value() 207 std::wstring version;
173 << " does not exist."; 208 ASSERT_TRUE(GetChromeVersionFromRegistry(&version))
174 LaunchInstaller(path, path.BaseName().value().c_str()); 209 << "Install failed: unable to get version.";
210 VerifyInstall(over_install);
211 }
212
213 void ChromeMiniInstaller::InstallUsingMultiInstall() {
214 ASSERT_TRUE(file_util::PathExists(full_installer_));
215 CommandLine args(CommandLine::NO_PROGRAM);
216 args.AppendArg("--multi-install");
kkania 2011/09/26 20:00:53 use http://codesearch.google.com/codesearch#OAMlx_
Huyen 2011/09/27 23:00:24 Done.
217 args.AppendArg("--chrome");
218 LaunchInstaller(mini_installer_, args);
219 VerifyMultiInstall();
220 }
221
222 void ChromeMiniInstaller::VerifyMultiInstall() {
223 InstallationValidator::InstallationType type =
224 installer::ExpectValidInstallation(system_install_);
175 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 225 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
176 ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey())) << dist->GetVersionKey() 226 ASSERT_TRUE(InstallUtil::IsMultiInstall(dist, system_install_));
177 << " does not exist."; 227 if (is_chrome_frame_) {
178 VerifyInstall(over_install); 228 EXPECT_NE(0,
kkania 2011/09/26 20:00:53 how about just EXPECT_TRUE(type & ....); same belo
Huyen 2011/09/27 23:00:24 Done.
229 type & InstallationValidator::ProductBits::CHROME_FRAME_MULTI);
230 VerifyChromeFrameInstall();
231 } else {
232 EXPECT_NE(0, type & InstallationValidator::ProductBits::CHROME_MULTI);
233 }
234 FindChromeShortcut();
235 LaunchChrome(false);
179 } 236 }
180 237
181 // This method tests the standalone installer by verifying the steps listed at: 238 // This method tests the standalone installer by verifying the steps listed at:
182 // https://sites.google.com/a/google.com/chrome-pmo/ 239 // https://sites.google.com/a/google.com/chrome-pmo/
183 // standalone-installers/testing-standalone-installers 240 // standalone-installers/testing-standalone-installers
184 // This method applies appropriate tags to standalone installer and deletes 241 // This method applies appropriate tags to standalone installer and deletes
185 // old installer before running the new tagged installer. It also verifies 242 // old installer before running the new tagged installer. It also verifies
186 // that the installed version is correct. 243 // that the installed version is correct.
187 void ChromeMiniInstaller::InstallStandaloneInstaller() { 244 void ChromeMiniInstaller::InstallStandaloneInstaller() {
188 file_util::Delete(mini_installer_constants::kStandaloneInstaller, true); 245 file_util::Delete(mini_installer_constants::kStandaloneInstaller, true);
(...skipping 23 matching lines...) Expand all
212 mini_installer_constants::kChromeApplyTagParameters)); 269 mini_installer_constants::kChromeApplyTagParameters));
213 LOG(INFO) << "Tagging command: " << command.GetCommandLineString(); 270 LOG(INFO) << "Tagging command: " << command.GetCommandLineString();
214 return command; 271 return command;
215 } 272 }
216 273
217 // Installs chromesetup.exe, waits for the install to finish and then 274 // Installs chromesetup.exe, waits for the install to finish and then
218 // checks the registry and shortcuts. 275 // checks the registry and shortcuts.
219 void ChromeMiniInstaller::InstallMetaInstaller() { 276 void ChromeMiniInstaller::InstallMetaInstaller() {
220 // Install Google Chrome through meta installer. 277 // Install Google Chrome through meta installer.
221 LaunchInstaller(FilePath(mini_installer_constants::kChromeMetaInstallerExe), 278 LaunchInstaller(FilePath(mini_installer_constants::kChromeMetaInstallerExe),
222 mini_installer_constants::kChromeSetupExecutable); 279 CommandLine::CommandLine(CommandLine::NO_PROGRAM));
223 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose( 280 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose(
224 mini_installer_constants::kChromeMetaInstallerExecutable)); 281 mini_installer_constants::kChromeMetaInstallerExecutable));
282
225 std::wstring chrome_google_update_state_key( 283 std::wstring chrome_google_update_state_key(
226 google_update::kRegPathClients); 284 google_update::kRegPathClients);
227 chrome_google_update_state_key.append(L"\\"); 285 chrome_google_update_state_key.append(L"\\");
228 286
229 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 287 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
230 chrome_google_update_state_key.append(dist->GetAppGuid()); 288 chrome_google_update_state_key.append(dist->GetAppGuid());
231 289
232 ASSERT_TRUE(CheckRegistryKey(chrome_google_update_state_key)); 290 ASSERT_TRUE(CheckRegistryKey(chrome_google_update_state_key));
233 ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey())); 291 ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey()));
234 FindChromeShortcut(); 292 FindChromeShortcut();
235 LaunchAndCloseChrome(false); 293 LaunchChrome(true);
236 } 294 }
237 295
238 // If the build type is Google Chrome, then it first installs meta installer 296 // If the build type is Google Chrome, then it first installs meta installer
239 // and then over installs with mini_installer. It also verifies if Chrome can 297 // and then over installs with mini_installer. It also verifies if Chrome can
240 // be launched successfully after overinstall. 298 // be launched successfully after overinstall.
241 void ChromeMiniInstaller::OverInstall() { 299 void ChromeMiniInstaller::OverInstall() {
242 InstallMetaInstaller(); 300 InstallMetaInstaller();
243 std::wstring reg_key_value_returned; 301 std::wstring reg_key_value_returned;
244 // gets the registry key value before overinstall. 302 // gets the registry key value before overinstall.
245 GetChromeVersionFromRegistry(&reg_key_value_returned); 303 GetChromeVersionFromRegistry(&reg_key_value_returned);
(...skipping 21 matching lines...) Expand all
267 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); 325 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe);
268 if (repair_type == ChromeMiniInstaller::VERSION_FOLDER) { 326 if (repair_type == ChromeMiniInstaller::VERSION_FOLDER) {
269 DeleteFolder(L"version_folder"); 327 DeleteFolder(L"version_folder");
270 printf("Deleted folder. Now trying to launch chrome\n"); 328 printf("Deleted folder. Now trying to launch chrome\n");
271 } else if (repair_type == ChromeMiniInstaller::REGISTRY) { 329 } else if (repair_type == ChromeMiniInstaller::REGISTRY) {
272 DeletePvRegistryKey(); 330 DeletePvRegistryKey();
273 printf("Deleted registry. Now trying to launch chrome\n"); 331 printf("Deleted registry. Now trying to launch chrome\n");
274 } 332 }
275 FilePath current_path; 333 FilePath current_path;
276 ASSERT_TRUE(MiniInstallerTestUtil::ChangeCurrentDirectory(&current_path)); 334 ASSERT_TRUE(MiniInstallerTestUtil::ChangeCurrentDirectory(&current_path));
277 VerifyChromeLaunch(false); 335 LaunchChrome(false);
278 printf("\nInstalling Chrome again to see if it can be repaired\n\n"); 336 LOG(INFO) << "Installing Chrome again to see if it can be repaired.";
279 InstallFullInstaller(true); 337 InstallFullInstaller(true);
280 printf("Chrome repair successful.\n"); 338 LOG(INFO) << "Chrome repair successful.";
281 // Set the current directory back to original path. 339 // Set the current directory back to original path.
282 file_util::SetCurrentDirectory(current_path); 340 file_util::SetCurrentDirectory(current_path);
283 } 341 }
284 342
285 // This method first checks if Chrome is running. 343 // This method first checks if Chrome is running.
286 // If yes, will close all the processes. 344 // If yes, will close all the processes.
287 // Then will find and spawn uninstall path. 345 // Then will find and spawn uninstall path.
288 // Handles uninstall confirm dialog. 346 // Handles uninstall confirm dialog.
289 // Waits until setup.exe ends. 347 // Waits until setup.exe ends.
290 // Checks if registry key exist even after uninstall. 348 // Checks if registry key exist even after uninstall.
291 // Deletes App dir. 349 // Deletes App dir.
292 // Closes feedback form. 350 // Closes feedback form.
293 void ChromeMiniInstaller::UnInstall() { 351 void ChromeMiniInstaller::UnInstall() {
294 std::wstring product_name;
295 if (is_chrome_frame_)
296 product_name = mini_installer_constants::kChromeFrameProductName;
297 else
298 product_name = mini_installer_constants::kChromeProductName;
299 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 352 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
300 if (!CheckRegistryKey(dist->GetVersionKey())) { 353 std::wstring version;
301 printf("%ls is not installed.\n", product_name.c_str()); 354 std::string result;
302 return; 355 if (GetChromeVersionFromRegistry(&version)) {
kkania 2011/09/26 20:00:53 This function fails silently in a lot of places. I
Huyen 2011/09/27 23:00:24 This seems to be used by the setup and teardown st
303 } 356 // Close running products.
304 if (is_chrome_frame_) { 357 if (is_chrome_frame_) {
305 MiniInstallerTestUtil::CloseProcesses( 358 MiniInstallerTestUtil::CloseProcesses(
306 mini_installer_constants::kIEProcessName); 359 mini_installer_constants::kIEProcessName);
360 } else {
361 MiniInstallerTestUtil::CloseProcesses(installer::kNaClExe);
362 }
363 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe);
364 // Get uninstall command.
365 CommandLine cmd = InstallUtil::GetChromeUninstallCmd(
366 system_install_, dist->GetType());
367
368 if (cmd.GetCommandLineString().empty()) {
369 LOG(ERROR) << "Unable to get uninstall command.";
370 CleanChromeInstall();
371 }
372 LOG(INFO) << "Uninstall command: " << cmd.GetCommandLineString();
373 ASSERT_TRUE(file_util::PathExists(cmd.GetProgram()));
374
375 cmd.AppendArg("--uninstall");
kkania 2011/09/26 20:00:53 same here
Huyen 2011/09/27 23:00:24 Done.
376 cmd.AppendArg("--force-uninstall");
377 if (is_chrome_frame_)
378 cmd.AppendArg("--chrome-frame");
379 if (system_install_)
380 cmd.AppendArg("--system-level");
381
382 base::ProcessHandle setup_handle;
383 if (!base::LaunchProcess(cmd, base::LaunchOptions(), &setup_handle)) {
384 LOG(ERROR) << "Failed to launch uninstall command.";
385 }
386
387 if (is_chrome_frame_)
388 ASSERT_TRUE(CloseUninstallWindow());
389 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(setup_handle));
390 ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey()));
391
392 DeleteUserDataFolder();
393 // Close IE survey window that gets launched on uninstall.
394 if (!is_chrome_frame_) {
395 FindChromeShortcut();
396 MiniInstallerTestUtil::CloseProcesses(
397 mini_installer_constants::kIEExecutable);
398 ASSERT_EQ(0,
399 base::GetProcessCount(mini_installer_constants::kIEExecutable, NULL));
400 }
307 } else { 401 } else {
308 MiniInstallerTestUtil::CloseProcesses(installer::kNaClExe); 402 LOG(WARNING) << "Chrome is not installed: attempt to uninstall failed.";
309 }
310 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe);
311 std::wstring uninstall_path = GetUninstallPath();
312 if (uninstall_path.empty()) {
313 printf("\n %ls install is in a weird state. Cleaning the machine...\n",
314 product_name.c_str());
315 CleanChromeInstall();
316 return;
317 }
318 ASSERT_TRUE(file_util::PathExists(FilePath(uninstall_path)));
319 std::wstring uninstall_args(L"\"");
320 uninstall_args.append(uninstall_path);
321 uninstall_args.append(L"\" --uninstall --force-uninstall");
322 if (is_chrome_frame_)
323 uninstall_args.append(L" --chrome-frame");
324 if (install_type_ == mini_installer_constants::kSystemInstall)
325 uninstall_args = uninstall_args + L" --system-level";
326
327 base::ProcessHandle setup_handle;
328 base::LaunchProcess(uninstall_args, base::LaunchOptions(), &setup_handle);
329
330 if (is_chrome_frame_)
331 ASSERT_TRUE(CloseUninstallWindow());
332 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(setup_handle));
333 ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey()));
334
335 DeleteUserDataFolder();
336 // Close IE survey window that gets launched on uninstall.
337 if (!is_chrome_frame_) {
338 FindChromeShortcut();
339 MiniInstallerTestUtil::CloseProcesses(
340 mini_installer_constants::kIEExecutable);
341 ASSERT_EQ(0,
342 base::GetProcessCount(mini_installer_constants::kIEExecutable, NULL));
343 } 403 }
344 } 404 }
345 405
346 void ChromeMiniInstaller::UnInstallChromeFrameWithIERunning() { 406 void ChromeMiniInstaller::UnInstallChromeFrameWithIERunning() {
407 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
347 std::wstring product_name = 408 std::wstring product_name =
348 mini_installer_constants::kChromeFrameProductName; 409 mini_installer_constants::kChromeFrameProductName;
349 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
350 if (!CheckRegistryKey(dist->GetVersionKey())) { 410 if (!CheckRegistryKey(dist->GetVersionKey())) {
351 printf("%ls is not installed.\n", product_name.c_str()); 411 printf("%ls is not installed.\n", product_name.c_str());
352 return; 412 return;
353 } 413 }
354 414
355 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); 415 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe);
356 std::wstring uninstall_path = GetUninstallPath();
357 416
358 if (uninstall_path.empty()) { 417 CommandLine cmd = InstallUtil::GetChromeUninstallCmd(
359 printf("\n %ls install is in a weird state. Cleaning the machine...\n", 418 system_install_, dist->GetType());
360 product_name.c_str()); 419
420 if (cmd.GetCommandLineString().empty()) {
421 LOG(ERROR) << "Unable to get uninstall command.";
361 CleanChromeInstall(); 422 CleanChromeInstall();
362 return;
363 } 423 }
364 424
365 ASSERT_TRUE(file_util::PathExists(FilePath(uninstall_path))); 425 ASSERT_TRUE(file_util::PathExists(cmd.GetProgram()));
366 std::wstring uninstall_args(L"\"");
367 uninstall_args.append(uninstall_path);
368 uninstall_args.append(L"\" --uninstall --force-uninstall");
369 uninstall_args.append(L" --chrome-frame");
370 426
371 if (install_type_ == mini_installer_constants::kSystemInstall) 427 cmd.AppendArg("--uninstall");
kkania 2011/09/26 20:00:53 don't hardcode these
Huyen 2011/09/27 23:00:24 Done.
372 uninstall_args = uninstall_args + L" --system-level"; 428 cmd.AppendArg("--force-uninstall");
429 cmd.AppendArg("--chrome-frame");
430
431 if (system_install_)
432 cmd.AppendArg("--system-level");
373 433
374 base::ProcessHandle setup_handle; 434 base::ProcessHandle setup_handle;
375 base::LaunchProcess(uninstall_args, base::LaunchOptions(), &setup_handle); 435 base::LaunchProcess(cmd, base::LaunchOptions(), &setup_handle);
376 436
377 ASSERT_TRUE(CloseUninstallWindow()); 437 ASSERT_TRUE(CloseUninstallWindow());
378 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(setup_handle)); 438 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(setup_handle));
379 ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey())); 439 ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey()));
380 440
381 DeleteUserDataFolder(); 441 DeleteUserDataFolder();
382 MiniInstallerTestUtil::CloseProcesses( 442 MiniInstallerTestUtil::CloseProcesses(
383 mini_installer_constants::kIEProcessName); 443 mini_installer_constants::kIEProcessName);
384 } 444 }
385 445
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 KEY_ALL_ACCESS) == ERROR_SUCCESS) && 537 KEY_ALL_ACCESS) == ERROR_SUCCESS) &&
478 (timer < 20000)) { 538 (timer < 20000)) {
479 base::PlatformThread::Sleep(200); 539 base::PlatformThread::Sleep(200);
480 timer = timer + 200; 540 timer = timer + 200;
481 } 541 }
482 return CheckRegistryKey(key_path); 542 return CheckRegistryKey(key_path);
483 } 543 }
484 544
485 // Deletes Installer folder from Applications directory. 545 // Deletes Installer folder from Applications directory.
486 void ChromeMiniInstaller::DeleteFolder(const wchar_t* folder_name) { 546 void ChromeMiniInstaller::DeleteFolder(const wchar_t* folder_name) {
487 FilePath install_path(GetChromeInstallDirectoryLocation()); 547 FilePath install_path;
548 ASSERT_TRUE(GetChromeInstallDirectoryLocation(&install_path));
488 std::wstring temp_chrome_dir; 549 std::wstring temp_chrome_dir;
489 if (is_chrome_frame_) { 550 if (is_chrome_frame_) {
490 temp_chrome_dir = mini_installer_constants::kChromeFrameAppDir; 551 temp_chrome_dir = mini_installer_constants::kChromeFrameAppDir;
491 } else {
492 temp_chrome_dir = mini_installer_constants::kChromeAppDir;
493 } 552 }
494 553
495 if (wcscmp(folder_name, L"version_folder") == 0) { 554 if (wcscmp(folder_name, L"version_folder") == 0) {
496 std::wstring build_number; 555 std::wstring build_number;
497 GetChromeVersionFromRegistry(&build_number); 556 GetChromeVersionFromRegistry(&build_number);
498 temp_chrome_dir = temp_chrome_dir + build_number; 557 temp_chrome_dir = temp_chrome_dir + build_number;
499 install_path = install_path.Append(temp_chrome_dir); 558 install_path = install_path.Append(temp_chrome_dir);
500 } else if (wcscmp(folder_name, temp_chrome_dir.c_str()) == 0) { 559 } else if (wcscmp(folder_name, temp_chrome_dir.c_str()) == 0) {
501 install_path = install_path.Append(folder_name).StripTrailingSeparators(); 560 install_path = install_path.Append(folder_name).StripTrailingSeparators();
502 } 561 }
503 printf("This path will be deleted: %ls\n", install_path.value().c_str()); 562 ASSERT_TRUE(file_util::PathExists(install_path))
563 << "Could not find path to delete:" << install_path.value();
564 LOG(INFO) << "This path will be deleted: " << install_path.value();
504 ASSERT_TRUE(file_util::Delete(install_path, true)); 565 ASSERT_TRUE(file_util::Delete(install_path, true));
505 } 566 }
506 567
507 // Will delete user data profile. 568 // Will delete user data profile.
508 void ChromeMiniInstaller::DeleteUserDataFolder() { 569 void ChromeMiniInstaller::DeleteUserDataFolder() {
509 FilePath path = GetUserDataDirPath(); 570 FilePath path = GetUserDataDirPath();
510 if (file_util::PathExists(path)) 571 if (file_util::PathExists(path))
511 ASSERT_TRUE(file_util::Delete(path, true)); 572 ASSERT_TRUE(file_util::Delete(path, true));
512 } 573 }
513 574
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 if (file_util::PathExists(path)) { 615 if (file_util::PathExists(path)) {
555 return_val = true; 616 return_val = true;
556 uninstall_lnk = path; 617 uninstall_lnk = path;
557 path = path.Append(mini_installer_constants::kChromeLaunchShortcut); 618 path = path.Append(mini_installer_constants::kChromeLaunchShortcut);
558 uninstall_lnk = uninstall_lnk.Append( 619 uninstall_lnk = uninstall_lnk.Append(
559 mini_installer_constants::kChromeUninstallShortcut); 620 mini_installer_constants::kChromeUninstallShortcut);
560 ASSERT_TRUE(file_util::PathExists(path)); 621 ASSERT_TRUE(file_util::PathExists(path));
561 ASSERT_TRUE(file_util::PathExists(uninstall_lnk)); 622 ASSERT_TRUE(file_util::PathExists(uninstall_lnk));
562 } 623 }
563 if (return_val) { 624 if (return_val) {
564 printf("Chrome shortcuts found are:\n%ls\n%ls\n\n", 625 LOG(INFO) << "Found Chrome shortcuts:\n"
565 path.value().c_str(), uninstall_lnk.value().c_str()); 626 << path.value() << "\n"
627 << uninstall_lnk.value();
566 } else { 628 } else {
567 printf("Chrome shortcuts not found\n\n"); 629 LOG(INFO) << "No Chrome shortcuts found.";
568 } 630 }
569 } 631 }
570 632
571 // This method returns path to either program files 633 bool ChromeMiniInstaller::GetChromeInstallDirectoryLocation(FilePath* path) {
572 // or documents and setting based on the install type. 634 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
573 std::wstring ChromeMiniInstaller::GetChromeInstallDirectoryLocation() { 635 *path = installer::GetChromeInstallPath(system_install_, dist);
574 FilePath path; 636 FilePath parent;
575 if (install_type_ == mini_installer_constants::kSystemInstall) 637 if (system_install_) {
576 PathService::Get(base::DIR_PROGRAM_FILES, &path); 638 PathService::Get(base::DIR_PROGRAM_FILES, &parent);
577 else 639 return file_util::ContainsPath(parent, *path);
578 PathService::Get(base::DIR_LOCAL_APP_DATA, &path); 640 } else {
579 return path.value(); 641 PathService::Get(base::DIR_LOCAL_APP_DATA, &parent);
642 return file_util::ContainsPath(parent, *path);
643 }
580 } 644 }
581 645
582 FilePath ChromeMiniInstaller::GetStartMenuShortcutPath() { 646 FilePath ChromeMiniInstaller::GetStartMenuShortcutPath() {
583 FilePath path_name; 647 FilePath path_name;
584 if (install_type_ == mini_installer_constants::kSystemInstall) 648 if (system_install_)
585 PathService::Get(base::DIR_COMMON_START_MENU, &path_name); 649 PathService::Get(base::DIR_COMMON_START_MENU, &path_name);
586 else 650 else
587 PathService::Get(base::DIR_START_MENU, &path_name); 651 PathService::Get(base::DIR_START_MENU, &path_name);
588 return path_name; 652 return path_name;
589 } 653 }
590 654
591 // Gets the path for uninstall.
592 std::wstring ChromeMiniInstaller::GetUninstallPath() {
593 std::wstring path, reg_key_value;
594 if (!GetChromeVersionFromRegistry(&reg_key_value))
595 return std::wstring();
596 path = GetChromeInstallDirectoryLocation();
597 if (is_chrome_frame_) {
598 file_util::AppendToPath(&path,
599 mini_installer_constants::kChromeFrameAppDir);
600 } else {
601 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir);
602 }
603 file_util::AppendToPath(&path, reg_key_value);
604 file_util::AppendToPath(&path, installer::kInstallerDir);
605 file_util::AppendToPath(&path,
606 mini_installer_constants::kChromeSetupExecutable);
607 if (!file_util::PathExists(FilePath(path))) {
608 printf("This uninstall path is not correct %ls. Will not proceed further",
609 path.c_str());
610 return L"";
611 }
612 printf("uninstall path is %ls\n", path.c_str());
613 return path;
614 }
615
616 // Returns Chrome pv registry key value 655 // Returns Chrome pv registry key value
617 bool ChromeMiniInstaller::GetChromeVersionFromRegistry( 656 bool ChromeMiniInstaller::GetChromeVersionFromRegistry(
618 std::wstring* build_key_value) { 657 std::wstring* build_key_value) {
619 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 658 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
620 RegKey key(GetRootRegistryKey(), dist->GetVersionKey().c_str(), KEY_READ); 659 RegKey key(GetRootRegistryKey(), dist->GetVersionKey().c_str(), KEY_READ);
621 LONG result = key.ReadValue(L"pv", build_key_value); 660 LONG result = key.ReadValue(L"pv", build_key_value);
622 if (result != ERROR_SUCCESS) { 661 if (result != ERROR_SUCCESS) {
623 printf("registry read for chrome version failed. error: %d\n", result); 662 LOG(WARNING) << "Registry read for Chrome version error: " << result;
624 return false; 663 return false;
625 } 664 }
626 printf("Build key value is %ls\n\n", build_key_value->c_str()); 665 LOG(INFO) << "Build key value is " << build_key_value;
627 return true; 666 return true;
628 } 667 }
629 668
630 // Get HKEY based on install type. 669 // Get HKEY based on install type.
631 HKEY ChromeMiniInstaller::GetRootRegistryKey() { 670 HKEY ChromeMiniInstaller::GetRootRegistryKey() {
632 HKEY type = HKEY_CURRENT_USER; 671 HKEY type = HKEY_CURRENT_USER;
633 if (install_type_ == mini_installer_constants::kSystemInstall) 672 if (system_install_)
634 type = HKEY_LOCAL_MACHINE; 673 type = HKEY_LOCAL_MACHINE;
635 return type; 674 return type;
636 } 675 }
637 676
638 // Launches the chrome installer and waits for it to end. 677 // Launches the chrome installer and waits for it to end.
639 void ChromeMiniInstaller::LaunchInstaller(const FilePath& path, 678 void ChromeMiniInstaller::LaunchInstaller(const FilePath& path,
640 const wchar_t* process_name) { 679 const CommandLine& args) {
641 ASSERT_TRUE(file_util::PathExists(path)); 680 ASSERT_TRUE(file_util::PathExists(path));
642 std::wstring launch_args; 681 CommandLine installer(path);
682 installer.AppendArguments(args, false);
643 if (is_chrome_frame_) { 683 if (is_chrome_frame_) {
644 launch_args.append(L" --do-not-create-shortcuts"); 684 installer.AppendArg("--do-not-create-shortcuts");
kkania 2011/09/26 20:00:53 same here
Huyen 2011/09/27 23:00:24 Done.
645 launch_args.append(L" --do-not-launch-chrome"); 685 installer.AppendArg("--do-not-launch-chrome");
646 launch_args.append(L" --do-not-register-for-update-launch"); 686 installer.AppendArg("--do-not-register-for-update-launch");
647 launch_args.append(L" --chrome-frame"); 687 installer.AppendArg("--chrome-frame");
648 } 688 }
649 if (install_type_ == mini_installer_constants::kSystemInstall) { 689 if (system_install_) {
650 launch_args.append(L" --system-level"); 690 installer.AppendArg("--system-level");
651 } 691 }
652 692
693 LOG(INFO) << "Running installer command: "
694 << installer.GetCommandLineString();
653 base::ProcessHandle app_handle; 695 base::ProcessHandle app_handle;
654 base::LaunchProcess(L"\"" + path.value() + L"\"" + launch_args, 696 if (!base::LaunchProcess(installer, base::LaunchOptions(), &app_handle))
655 base::LaunchOptions(), &app_handle); 697 LOG(ERROR) << "Installer failed.";
656 698
657 printf("Waiting while this process is running %ls ....\n", process_name); 699 if (!base::WaitForSingleProcess(app_handle, 60 * 1000))
658 MiniInstallerTestUtil::VerifyProcessLaunch(process_name, true); 700 LOG(ERROR) << "Installer did not complete.";
659 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(app_handle)); 701
702 // Kill Chrome instance launched by installer.
703 ChildProcessFilter children(base::GetProcId(app_handle));
704 if (base::GetProcessCount(installer::kChromeExe, &children) > 0) {
705 LOG(INFO) << "Terminating all Chrome instances now.";
706 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe);
kkania 2011/09/26 20:00:53 what's better about this new way?
Huyen 2011/09/27 23:00:24 I thought this wasn't really needed either. Consid
707 }
660 } 708 }
661 709
662 // Gets the path to launch Chrome. 710 void ChromeMiniInstaller::LaunchChrome(bool kill) {
663 bool ChromeMiniInstaller::GetChromeLaunchPath(FilePath* launch_path) { 711 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe);
664 std::wstring path;
665 path = GetChromeInstallDirectoryLocation();
666 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir);
667 file_util::AppendToPath(&path, installer::kChromeExe);
668 *launch_path = FilePath(path);
669 return file_util::PathExists(*launch_path);
670 }
671 712
672 // Launch Chrome to see if it works after overinstall. Then close it. 713 FilePath install_path;
673 void ChromeMiniInstaller::LaunchAndCloseChrome(bool over_install) { 714 ASSERT_TRUE(GetChromeInstallDirectoryLocation(&install_path));
674 VerifyChromeLaunch(true); 715 install_path = install_path.Append(installer::kChromeExe);
675 if ((install_type_ == mini_installer_constants::kSystemInstall) && 716 CommandLine browser(install_path);
676 (!over_install)) { 717
677 MiniInstallerTestUtil::VerifyProcessLaunch( 718 FilePath exe = browser.GetProgram();
678 installer::kChromeExe, true); 719 LOG(INFO) << "Browser launch command: " << browser.GetCommandLineString();
720 base::ProcessHandle chrome;
721 bool launched = base::LaunchProcess(browser, base::LaunchOptions(), &chrome);
722 if (!launched) {
723 LOG(ERROR) << "Could not launch process: " << exe.value();
679 } 724 }
680 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe);
681 }
682 725
683 // This method will get Chrome exe path and launch it. 726 ChromeProcessFilter filter(base::GetProcId(chrome));
684 void ChromeMiniInstaller::VerifyChromeLaunch(bool expected_status) { 727 ASSERT_TRUE(base::GetProcessCount(exe.BaseName().value(), &filter) == 1);
685 FilePath launch_path; 728 LOG(INFO) << "Launched browser.";
686 GetChromeLaunchPath(&launch_path); 729 if (kill) {
687 LaunchBrowser(launch_path, L"", expected_status); 730 ASSERT_TRUE(base::KillProcess(chrome, 0, true));
731 }
688 } 732 }
689 733
690 // Verifies Chrome/Chrome Frame install. 734 // Verifies Chrome/Chrome Frame install.
691 void ChromeMiniInstaller::VerifyInstall(bool over_install) { 735 void ChromeMiniInstaller::VerifyInstall(bool over_install) {
692 VerifyMachineState();
693 if (is_chrome_frame_) {
694 VerifyChromeFrameInstall();
695 } else {
696 if ((install_type_ == mini_installer_constants::kUserInstall) &&
697 (!over_install)) {
698 MiniInstallerTestUtil::VerifyProcessLaunch(
699 installer::kChromeExe, true);
700 }
701 base::PlatformThread::Sleep(800);
702 FindChromeShortcut();
703 LaunchAndCloseChrome(over_install);
704 }
705 }
706
707 // This method verifies installation of Chrome/Chrome Frame via machine
708 // introspection.
709 void ChromeMiniInstaller::VerifyMachineState() {
710 using installer::InstallationValidator;
711
712 InstallationValidator::InstallationType type = 736 InstallationValidator::InstallationType type =
713 installer::ExpectValidInstallation( 737 installer::ExpectValidInstallation(system_install_);
714 install_type_ == mini_installer_constants::kSystemInstall);
715 if (is_chrome_frame_) { 738 if (is_chrome_frame_) {
716 EXPECT_NE(0, 739 EXPECT_NE(0,
717 type & InstallationValidator::ProductBits::CHROME_FRAME_SINGLE); 740 type & InstallationValidator::ProductBits::CHROME_FRAME_SINGLE);
718 } else { 741 } else {
719 EXPECT_NE(0, type & InstallationValidator::ProductBits::CHROME_SINGLE); 742 EXPECT_NE(0, type & InstallationValidator::ProductBits::CHROME_SINGLE);
720 } 743 }
744
745 if (is_chrome_frame_) {
746 VerifyChromeFrameInstall();
747 } else if ((!system_install_) &&
kkania 2011/09/26 20:00:53 one line, don't need all these parens
Huyen 2011/09/27 23:00:24 Done.
748 (!over_install)) {
749 MiniInstallerTestUtil::VerifyProcessLaunch(
750 installer::kChromeExe, true);
751 }
752
753 base::PlatformThread::Sleep(800);
754 FindChromeShortcut();
755 LaunchChrome(true);
721 } 756 }
722 757
723 // This method will verify if ChromeFrame installed successfully. It will 758 // This method will verify if ChromeFrame installed successfully. It will
724 // launch IE with cf:about:version, then check if 759 // launch IE with cf:about:version, then check if
725 // chrome.exe process got spawned. 760 // chrome.exe process got spawned.
726 void ChromeMiniInstaller::VerifyChromeFrameInstall() { 761 void ChromeMiniInstaller::VerifyChromeFrameInstall() {
727 // Launch IE 762 // Launch IE
728 LaunchIE(L"gcf:about:version"); 763 LaunchIE(L"gcf:about:version");
729 764
730 // Check if Chrome process got spawned. 765 // Check if Chrome process got spawned.
731 MiniInstallerTestUtil::VerifyProcessLaunch(installer::kChromeExe, true); 766 MiniInstallerTestUtil::VerifyProcessLaunch(installer::kChromeExe, true);
732 } 767 }
733 768
734 void ChromeMiniInstaller::LaunchIE(const std::wstring& navigate_url) { 769 void ChromeMiniInstaller::LaunchIE(const std::wstring& navigate_url) {
735 FilePath browser_path; 770 FilePath browser_path;
736 PathService::Get(base::DIR_PROGRAM_FILES, &browser_path); 771 PathService::Get(base::DIR_PROGRAM_FILES, &browser_path);
737 browser_path = browser_path.Append(mini_installer_constants::kIELocation); 772 browser_path = browser_path.Append(mini_installer_constants::kIELocation);
738 browser_path = browser_path.Append(mini_installer_constants::kIEProcessName); 773 browser_path = browser_path.Append(mini_installer_constants::kIEProcessName);
739 774
740 CommandLine cmd_line(browser_path); 775 CommandLine cmd_line(browser_path);
741 cmd_line.AppendArgNative(navigate_url); 776 cmd_line.AppendArgNative(navigate_url);
742 777
743 base::LaunchProcess(cmd_line, base::LaunchOptions(), NULL); 778 base::LaunchProcess(cmd_line, base::LaunchOptions(), NULL);
744 } 779 }
745 780
746 // This method will launch any requested browser.
747 void ChromeMiniInstaller::LaunchBrowser(const FilePath& path,
748 const std::wstring& args,
749 bool expected_status) {
750 LOG(INFO) << "Browser executable: " << path.value();
751 bool launched = base::LaunchProcess(
752 L"\"" + path.value() + L"\"" + L" " + args,
753 base::LaunchOptions(), NULL);
754 if (!launched) {
755 LOG(ERROR) << "Could not launch process: " << path.BaseName().value();
756 }
757 base::PlatformThread::Sleep(1000);
758 MiniInstallerTestUtil::VerifyProcessLaunch(path.BaseName().value().c_str(),
759 expected_status);
760 }
761
762 // This method compares the registry keys after overinstall. 781 // This method compares the registry keys after overinstall.
763 bool ChromeMiniInstaller::VerifyOverInstall( 782 bool ChromeMiniInstaller::VerifyOverInstall(
764 const std::wstring& value_before_overinstall, 783 const std::wstring& value_before_overinstall,
765 const std::wstring& value_after_overinstall) { 784 const std::wstring& value_after_overinstall) {
766 int64 reg_key_value_before_overinstall; 785 int64 reg_key_value_before_overinstall;
767 base::StringToInt64(value_before_overinstall, 786 base::StringToInt64(value_before_overinstall,
768 &reg_key_value_before_overinstall); 787 &reg_key_value_before_overinstall);
769 int64 reg_key_value_after_overinstall; 788 int64 reg_key_value_after_overinstall;
770 base::StringToInt64(value_after_overinstall, 789 base::StringToInt64(value_after_overinstall,
771 &reg_key_value_after_overinstall); 790 &reg_key_value_after_overinstall);
(...skipping 19 matching lines...) Expand all
791 else 810 else
792 return false; 811 return false;
793 } 812 }
794 813
795 // Search all the specified |build| directory to find the latest 814 // Search all the specified |build| directory to find the latest
796 // diff and full installers. |build| can be empty. 815 // diff and full installers. |build| can be empty.
797 bool ChromeMiniInstaller::LocateInstallers( 816 bool ChromeMiniInstaller::LocateInstallers(
798 const std::wstring& build) { 817 const std::wstring& build) {
799 FilePath::StringType full_installer_pattern = 818 FilePath::StringType full_installer_pattern =
800 FILE_PATH_LITERAL("*_chrome_installer*"); 819 FILE_PATH_LITERAL("*_chrome_installer*");
801 FilePath::StringType diff_installer_pattern = FILE_PATH_LITERAL("*_from_*"); 820 FilePath::StringType diff_installer_pattern =
821 FILE_PATH_LITERAL("*_from_*");
822 FilePath::StringType mini_installer_pattern =
823 FILE_PATH_LITERAL("mini_installer.exe");
802 FilePath root(mini_installer_constants::kChromeInstallersLocation); 824 FilePath root(mini_installer_constants::kChromeInstallersLocation);
803 std::vector<FilePath> paths; 825 std::vector<FilePath> paths;
804 if (!FindMatchingFiles(root, build, 826 if (!FindMatchingFiles(root, build,
805 file_util::FileEnumerator::DIRECTORIES, &paths)) { 827 file_util::FileEnumerator::DIRECTORIES, &paths)) {
806 return false; 828 return false;
807 } 829 }
808 830
809 // Find full and diff installers; 831 // Find full and diff installers;
810 std::vector<FilePath>::const_iterator dir; 832 std::vector<FilePath>::const_iterator dir;
811 for (dir = paths.begin(); dir != paths.end(); ++dir) { 833 for (dir = paths.begin(); dir != paths.end(); ++dir) {
812 FilePath windir = dir->Append( 834 FilePath windir = dir->Append(
813 mini_installer_constants::kWinFolder); 835 mini_installer_constants::kWinFolder);
814 if (FindNewestMatchingFile(windir, full_installer_pattern, 836 if (FindNewestMatchingFile(windir, full_installer_pattern,
815 file_util::FileEnumerator::FILES, &full_installer_) && 837 file_util::FileEnumerator::FILES, &full_installer_) &&
816 FindNewestMatchingFile(windir, diff_installer_pattern, 838 FindNewestMatchingFile(windir, diff_installer_pattern,
817 file_util::FileEnumerator::FILES, &diff_installer_)) { 839 file_util::FileEnumerator::FILES, &diff_installer_) &&
840 FindNewestMatchingFile(windir, mini_installer_pattern,
841 file_util::FileEnumerator::FILES, &mini_installer_)) {
818 break; 842 break;
819 } 843 }
820 } 844 }
821 845
822 // Set current build directory.
823 if (full_installer_.empty() || diff_installer_.empty()) 846 if (full_installer_.empty() || diff_installer_.empty())
824 return false; 847 return false;
825 848
826 current_build_ = 849 current_build_ =
827 full_installer_.DirName().DirName().BaseName().value(); 850 full_installer_.DirName().DirName().BaseName().value();
828 851
829 // Find previous full installer. 852 // Find previous full installer.
830 std::vector<std::wstring> tokenized_name; 853 std::vector<std::wstring> tokenized_name;
831 Tokenize(diff_installer_.BaseName().value(), 854 Tokenize(diff_installer_.BaseName().value(),
832 L"_", &tokenized_name); 855 L"_", &tokenized_name);
(...skipping 25 matching lines...) Expand all
858 L"%ls%ls_%ls.exe", mini_installer_constants::kUntaggedInstallerPattern, 881 L"%ls%ls_%ls.exe", mini_installer_constants::kUntaggedInstallerPattern,
859 tokenizedBuildNumber[2].c_str(), tokenizedBuildNumber[3].c_str()); 882 tokenizedBuildNumber[2].c_str(), tokenizedBuildNumber[3].c_str());
860 standalone_installer = standalone_installer.Append(current_build_) 883 standalone_installer = standalone_installer.Append(current_build_)
861 .Append(mini_installer_constants::kWinFolder) 884 .Append(mini_installer_constants::kWinFolder)
862 .Append(standalone_installer_filename); 885 .Append(standalone_installer_filename);
863 886
864 standalone_installer_ = standalone_installer; 887 standalone_installer_ = standalone_installer;
865 888
866 return !standalone_installer_.empty(); 889 return !standalone_installer_.empty();
867 } 890 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698