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

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

Issue 280004: Revert wstring patch (r29078 and follow up commits). It is causing failures o... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 years, 2 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/platform_thread.h" 9 #include "base/platform_thread.h"
10 #include "base/process_util.h" 10 #include "base/process_util.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 InstallMiniInstaller(over_install, full_installer_file_name); 105 InstallMiniInstaller(over_install, full_installer_file_name);
106 } 106 }
107 107
108 // Installs the Chrome mini-installer, checks the registry and shortcuts. 108 // Installs the Chrome mini-installer, checks the registry and shortcuts.
109 void ChromeMiniInstaller::InstallMiniInstaller(bool over_install, 109 void ChromeMiniInstaller::InstallMiniInstaller(bool over_install,
110 const std::wstring& path) { 110 const std::wstring& path) {
111 std::wstring exe_name = file_util::GetFilenameFromPath(path); 111 std::wstring exe_name = file_util::GetFilenameFromPath(path);
112 printf("\nChrome will be installed at %ls level\n", install_type_.c_str()); 112 printf("\nChrome will be installed at %ls level\n", install_type_.c_str());
113 printf("\nWill proceed with the test only if this path exists: %ls\n\n", 113 printf("\nWill proceed with the test only if this path exists: %ls\n\n",
114 path.c_str()); 114 path.c_str());
115 ASSERT_TRUE(file_util::PathExists(FilePath::FromWStringHack(path))); 115 ASSERT_TRUE(file_util::PathExists(path));
116 LaunchInstaller(path, exe_name.c_str()); 116 LaunchInstaller(path, exe_name.c_str());
117 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); 117 BrowserDistribution* dist = BrowserDistribution::GetDistribution();
118 ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey())); 118 ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey()));
119 printf("\nInstall Checks:\n\n"); 119 printf("\nInstall Checks:\n\n");
120 if ((install_type_ == mini_installer_constants::kUserInstall) && 120 if ((install_type_ == mini_installer_constants::kUserInstall) &&
121 (!over_install)) 121 (!over_install))
122 CloseFirstRunUIDialog(over_install); 122 CloseFirstRunUIDialog(over_install);
123 PlatformThread::Sleep(800); 123 PlatformThread::Sleep(800);
124 FindChromeShortcut(); 124 FindChromeShortcut();
125 LaunchAndCloseChrome(over_install); 125 LaunchAndCloseChrome(over_install);
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 } 223 }
224 printf("\n\nUninstalling Chrome...\n"); 224 printf("\n\nUninstalling Chrome...\n");
225 printf("Closing Chrome processes, if any...\n"); 225 printf("Closing Chrome processes, if any...\n");
226 MiniInstallerTestUtil::CloseProcesses(installer_util::kChromeExe); 226 MiniInstallerTestUtil::CloseProcesses(installer_util::kChromeExe);
227 std::wstring uninstall_path = GetUninstallPath(); 227 std::wstring uninstall_path = GetUninstallPath();
228 if (uninstall_path == L"") { 228 if (uninstall_path == L"") {
229 printf("\n Chrome install is in a weird state. Cleaning the machine...\n"); 229 printf("\n Chrome install is in a weird state. Cleaning the machine...\n");
230 CleanChromeInstall(); 230 CleanChromeInstall();
231 return; 231 return;
232 } 232 }
233 ASSERT_TRUE(file_util::PathExists(FilePath::FromWStringHack(uninstall_path))); 233 ASSERT_TRUE(file_util::PathExists(uninstall_path));
234 std::wstring uninstall_args = L"\"" + uninstall_path + 234 std::wstring uninstall_args = L"\"" + uninstall_path +
235 L"\"" + L" --uninstall --force-uninstall"; 235 L"\"" + L" --uninstall --force-uninstall";
236 if (install_type_ == mini_installer_constants::kSystemInstall) 236 if (install_type_ == mini_installer_constants::kSystemInstall)
237 uninstall_args = uninstall_args + L" --system-level"; 237 uninstall_args = uninstall_args + L" --system-level";
238 base::LaunchApp(uninstall_args, false, false, NULL); 238 base::LaunchApp(uninstall_args, false, false, NULL);
239 printf("Launched setup.exe. Here are the commands passed: %ls\n", 239 printf("Launched setup.exe. Here are the commands passed: %ls\n",
240 uninstall_args.c_str()); 240 uninstall_args.c_str());
241 // ASSERT_TRUE(CloseUninstallWindow()); 241 // ASSERT_TRUE(CloseUninstallWindow());
242 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose( 242 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose(
243 mini_installer_constants::kChromeSetupExecutable)); 243 mini_installer_constants::kChromeSetupExecutable));
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 printf("Deleted %ls key\n", pv_key.c_str()); 396 printf("Deleted %ls key\n", pv_key.c_str());
397 } 397 }
398 398
399 // Verifies if Chrome shortcut exists. 399 // Verifies if Chrome shortcut exists.
400 void ChromeMiniInstaller::FindChromeShortcut() { 400 void ChromeMiniInstaller::FindChromeShortcut() {
401 std::wstring username, path, append_path, uninstall_lnk, shortcut_path; 401 std::wstring username, path, append_path, uninstall_lnk, shortcut_path;
402 bool return_val = false; 402 bool return_val = false;
403 path = GetStartMenuShortcutPath(); 403 path = GetStartMenuShortcutPath();
404 file_util::AppendToPath(&path, mini_installer_constants::kChromeBuildType); 404 file_util::AppendToPath(&path, mini_installer_constants::kChromeBuildType);
405 // Verify if path exists. 405 // Verify if path exists.
406 if (file_util::PathExists(FilePath::FromWStringHack(path))) { 406 if (file_util::PathExists(path)) {
407 return_val = true; 407 return_val = true;
408 uninstall_lnk = path; 408 uninstall_lnk = path;
409 file_util::AppendToPath(&path, 409 file_util::AppendToPath(&path,
410 mini_installer_constants::kChromeLaunchShortcut); 410 mini_installer_constants::kChromeLaunchShortcut);
411 file_util::AppendToPath(&uninstall_lnk, 411 file_util::AppendToPath(&uninstall_lnk,
412 mini_installer_constants::kChromeUninstallShortcut); 412 mini_installer_constants::kChromeUninstallShortcut);
413 ASSERT_TRUE(file_util::PathExists(FilePath::FromWStringHack(path))); 413 ASSERT_TRUE(file_util::PathExists(path));
414 ASSERT_TRUE(file_util::PathExists( 414 ASSERT_TRUE(file_util::PathExists(uninstall_lnk));
415 FilePath::FromWStringHack(uninstall_lnk)));
416 } 415 }
417 if (return_val) 416 if (return_val)
418 printf("Chrome shortcuts found are:\n%ls\n%ls\n\n", 417 printf("Chrome shortcuts found are:\n%ls\n%ls\n\n",
419 path.c_str(), uninstall_lnk.c_str()); 418 path.c_str(), uninstall_lnk.c_str());
420 else 419 else
421 printf("Chrome shortcuts not found\n\n"); 420 printf("Chrome shortcuts not found\n\n");
422 } 421 }
423 422
424 // This method returns path to either program files 423 // This method returns path to either program files
425 // or documents and setting based on the install type. 424 // or documents and setting based on the install type.
(...skipping 20 matching lines...) Expand all
446 std::wstring ChromeMiniInstaller::GetUninstallPath() { 445 std::wstring ChromeMiniInstaller::GetUninstallPath() {
447 std::wstring username, append_path, path, reg_key_value; 446 std::wstring username, append_path, path, reg_key_value;
448 if (!GetChromeVersionFromRegistry(&reg_key_value)) 447 if (!GetChromeVersionFromRegistry(&reg_key_value))
449 return L""; 448 return L"";
450 path = GetChromeInstallDirectoryLocation(); 449 path = GetChromeInstallDirectoryLocation();
451 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir); 450 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir);
452 file_util::AppendToPath(&path, reg_key_value); 451 file_util::AppendToPath(&path, reg_key_value);
453 file_util::AppendToPath(&path, installer_util::kInstallerDir); 452 file_util::AppendToPath(&path, installer_util::kInstallerDir);
454 file_util::AppendToPath(&path, 453 file_util::AppendToPath(&path,
455 mini_installer_constants::kChromeSetupExecutable); 454 mini_installer_constants::kChromeSetupExecutable);
456 if (!file_util::PathExists(FilePath::FromWStringHack(path))) { 455 if (!file_util::PathExists(path)) {
457 printf("This uninstall path is not correct %ls. Will not proceed further", 456 printf("This uninstall path is not correct %ls. Will not proceed further",
458 path.c_str()); 457 path.c_str());
459 return L""; 458 return L"";
460 } 459 }
461 printf("uninstall path is %ls\n", path.c_str()); 460 printf("uninstall path is %ls\n", path.c_str());
462 return path; 461 return path;
463 } 462 }
464 463
465 // Returns Chrome pv registry key value 464 // Returns Chrome pv registry key value
466 bool ChromeMiniInstaller::GetChromeVersionFromRegistry( 465 bool ChromeMiniInstaller::GetChromeVersionFromRegistry(
(...skipping 12 matching lines...) Expand all
479 HKEY ChromeMiniInstaller::GetRootRegistryKey() { 478 HKEY ChromeMiniInstaller::GetRootRegistryKey() {
480 HKEY type = HKEY_CURRENT_USER; 479 HKEY type = HKEY_CURRENT_USER;
481 if (install_type_ == mini_installer_constants::kSystemInstall) 480 if (install_type_ == mini_installer_constants::kSystemInstall)
482 type = HKEY_LOCAL_MACHINE; 481 type = HKEY_LOCAL_MACHINE;
483 return type; 482 return type;
484 } 483 }
485 484
486 // Launches the chrome installer and waits for it to end. 485 // Launches the chrome installer and waits for it to end.
487 void ChromeMiniInstaller::LaunchInstaller(const std::wstring& path, 486 void ChromeMiniInstaller::LaunchInstaller(const std::wstring& path,
488 const wchar_t* process_name) { 487 const wchar_t* process_name) {
489 ASSERT_TRUE(file_util::PathExists(FilePath::FromWStringHack(path))); 488 ASSERT_TRUE(file_util::PathExists(path));
490 if (install_type_ == mini_installer_constants::kSystemInstall) { 489 if (install_type_ == mini_installer_constants::kSystemInstall) {
491 std::wstring launch_args = L" -system-level"; 490 std::wstring launch_args = L" -system-level";
492 base::LaunchApp(L"\"" + path + L"\"" + launch_args, false, false, NULL); 491 base::LaunchApp(L"\"" + path + L"\"" + launch_args, false, false, NULL);
493 } else { 492 } else {
494 base::LaunchApp(L"\"" + path + L"\"", false, false, NULL); 493 base::LaunchApp(L"\"" + path + L"\"", false, false, NULL);
495 } 494 }
496 printf("Waiting while this process is running %ls ....\n", process_name); 495 printf("Waiting while this process is running %ls ....\n", process_name);
497 MiniInstallerTestUtil::VerifyProcessLaunch(process_name, true); 496 MiniInstallerTestUtil::VerifyProcessLaunch(process_name, true);
498 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose(process_name)); 497 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose(process_name));
499 } 498 }
500 499
501 // Gets the path to launch Chrome. 500 // Gets the path to launch Chrome.
502 bool ChromeMiniInstaller::GetChromeLaunchPath(std::wstring* launch_path) { 501 bool ChromeMiniInstaller::GetChromeLaunchPath(std::wstring* launch_path) {
503 std::wstring path; 502 std::wstring path;
504 path = GetChromeInstallDirectoryLocation(); 503 path = GetChromeInstallDirectoryLocation();
505 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir); 504 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir);
506 file_util::AppendToPath(&path, installer_util::kChromeExe); 505 file_util::AppendToPath(&path, installer_util::kChromeExe);
507 launch_path->assign(path); 506 launch_path->assign(path);
508 return(file_util::PathExists(FilePath::FromWStringHack(path))); 507 return(file_util::PathExists(path));
509 } 508 }
510 509
511 // Launch Chrome to see if it works after overinstall. Then close it. 510 // Launch Chrome to see if it works after overinstall. Then close it.
512 void ChromeMiniInstaller::LaunchAndCloseChrome(bool over_install) { 511 void ChromeMiniInstaller::LaunchAndCloseChrome(bool over_install) {
513 VerifyChromeLaunch(true); 512 VerifyChromeLaunch(true);
514 if ((install_type_ == mini_installer_constants::kSystemInstall) && 513 if ((install_type_ == mini_installer_constants::kSystemInstall) &&
515 (!over_install)) 514 (!over_install))
516 CloseFirstRunUIDialog(over_install); 515 CloseFirstRunUIDialog(over_install);
517 MiniInstallerTestUtil::CloseProcesses(installer_util::kChromeExe); 516 MiniInstallerTestUtil::CloseProcesses(installer_util::kChromeExe);
518 } 517 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 // This method will verify if the installed build is correct. 549 // This method will verify if the installed build is correct.
551 bool ChromeMiniInstaller::VerifyStandaloneInstall() { 550 bool ChromeMiniInstaller::VerifyStandaloneInstall() {
552 std::wstring reg_key_value_returned, standalone_installer_version; 551 std::wstring reg_key_value_returned, standalone_installer_version;
553 MiniInstallerTestUtil::GetStandaloneVersion(&standalone_installer_version); 552 MiniInstallerTestUtil::GetStandaloneVersion(&standalone_installer_version);
554 GetChromeVersionFromRegistry(&reg_key_value_returned); 553 GetChromeVersionFromRegistry(&reg_key_value_returned);
555 if (standalone_installer_version.compare(reg_key_value_returned) == 0) 554 if (standalone_installer_version.compare(reg_key_value_returned) == 0)
556 return true; 555 return true;
557 else 556 else
558 return false; 557 return false;
559 } 558 }
OLDNEW
« no previous file with comments | « chrome/installer/util/shell_util.cc ('k') | chrome/test/mini_installer_test/mini_installer_test_util.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698