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

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

Issue 276016: Remove some deprecated file_util wstring functions. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: lint 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(path)); 115 ASSERT_TRUE(file_util::PathExists(FilePath::FromWStringHack(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(uninstall_path)); 233 ASSERT_TRUE(file_util::PathExists(FilePath::FromWStringHack(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(path)) { 406 if (file_util::PathExists(FilePath::FromWStringHack(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(path)); 413 ASSERT_TRUE(file_util::PathExists(FilePath::FromWStringHack(path)));
414 ASSERT_TRUE(file_util::PathExists(uninstall_lnk)); 414 ASSERT_TRUE(file_util::PathExists(
415 FilePath::FromWStringHack(uninstall_lnk)));
415 } 416 }
416 if (return_val) 417 if (return_val)
417 printf("Chrome shortcuts found are:\n%ls\n%ls\n\n", 418 printf("Chrome shortcuts found are:\n%ls\n%ls\n\n",
418 path.c_str(), uninstall_lnk.c_str()); 419 path.c_str(), uninstall_lnk.c_str());
419 else 420 else
420 printf("Chrome shortcuts not found\n\n"); 421 printf("Chrome shortcuts not found\n\n");
421 } 422 }
422 423
423 // This method returns path to either program files 424 // This method returns path to either program files
424 // or documents and setting based on the install type. 425 // or documents and setting based on the install type.
(...skipping 20 matching lines...) Expand all
445 std::wstring ChromeMiniInstaller::GetUninstallPath() { 446 std::wstring ChromeMiniInstaller::GetUninstallPath() {
446 std::wstring username, append_path, path, reg_key_value; 447 std::wstring username, append_path, path, reg_key_value;
447 if (!GetChromeVersionFromRegistry(&reg_key_value)) 448 if (!GetChromeVersionFromRegistry(&reg_key_value))
448 return L""; 449 return L"";
449 path = GetChromeInstallDirectoryLocation(); 450 path = GetChromeInstallDirectoryLocation();
450 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir); 451 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir);
451 file_util::AppendToPath(&path, reg_key_value); 452 file_util::AppendToPath(&path, reg_key_value);
452 file_util::AppendToPath(&path, installer_util::kInstallerDir); 453 file_util::AppendToPath(&path, installer_util::kInstallerDir);
453 file_util::AppendToPath(&path, 454 file_util::AppendToPath(&path,
454 mini_installer_constants::kChromeSetupExecutable); 455 mini_installer_constants::kChromeSetupExecutable);
455 if (!file_util::PathExists(path)) { 456 if (!file_util::PathExists(FilePath::FromWStringHack(path))) {
456 printf("This uninstall path is not correct %ls. Will not proceed further", 457 printf("This uninstall path is not correct %ls. Will not proceed further",
457 path.c_str()); 458 path.c_str());
458 return L""; 459 return L"";
459 } 460 }
460 printf("uninstall path is %ls\n", path.c_str()); 461 printf("uninstall path is %ls\n", path.c_str());
461 return path; 462 return path;
462 } 463 }
463 464
464 // Returns Chrome pv registry key value 465 // Returns Chrome pv registry key value
465 bool ChromeMiniInstaller::GetChromeVersionFromRegistry( 466 bool ChromeMiniInstaller::GetChromeVersionFromRegistry(
(...skipping 12 matching lines...) Expand all
478 HKEY ChromeMiniInstaller::GetRootRegistryKey() { 479 HKEY ChromeMiniInstaller::GetRootRegistryKey() {
479 HKEY type = HKEY_CURRENT_USER; 480 HKEY type = HKEY_CURRENT_USER;
480 if (install_type_ == mini_installer_constants::kSystemInstall) 481 if (install_type_ == mini_installer_constants::kSystemInstall)
481 type = HKEY_LOCAL_MACHINE; 482 type = HKEY_LOCAL_MACHINE;
482 return type; 483 return type;
483 } 484 }
484 485
485 // Launches the chrome installer and waits for it to end. 486 // Launches the chrome installer and waits for it to end.
486 void ChromeMiniInstaller::LaunchInstaller(const std::wstring& path, 487 void ChromeMiniInstaller::LaunchInstaller(const std::wstring& path,
487 const wchar_t* process_name) { 488 const wchar_t* process_name) {
488 ASSERT_TRUE(file_util::PathExists(path)); 489 ASSERT_TRUE(file_util::PathExists(FilePath::FromWStringHack(path)));
489 if (install_type_ == mini_installer_constants::kSystemInstall) { 490 if (install_type_ == mini_installer_constants::kSystemInstall) {
490 std::wstring launch_args = L" -system-level"; 491 std::wstring launch_args = L" -system-level";
491 base::LaunchApp(L"\"" + path + L"\"" + launch_args, false, false, NULL); 492 base::LaunchApp(L"\"" + path + L"\"" + launch_args, false, false, NULL);
492 } else { 493 } else {
493 base::LaunchApp(L"\"" + path + L"\"", false, false, NULL); 494 base::LaunchApp(L"\"" + path + L"\"", false, false, NULL);
494 } 495 }
495 printf("Waiting while this process is running %ls ....\n", process_name); 496 printf("Waiting while this process is running %ls ....\n", process_name);
496 MiniInstallerTestUtil::VerifyProcessLaunch(process_name, true); 497 MiniInstallerTestUtil::VerifyProcessLaunch(process_name, true);
497 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose(process_name)); 498 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessClose(process_name));
498 } 499 }
499 500
500 // Gets the path to launch Chrome. 501 // Gets the path to launch Chrome.
501 bool ChromeMiniInstaller::GetChromeLaunchPath(std::wstring* launch_path) { 502 bool ChromeMiniInstaller::GetChromeLaunchPath(std::wstring* launch_path) {
502 std::wstring path; 503 std::wstring path;
503 path = GetChromeInstallDirectoryLocation(); 504 path = GetChromeInstallDirectoryLocation();
504 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir); 505 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir);
505 file_util::AppendToPath(&path, installer_util::kChromeExe); 506 file_util::AppendToPath(&path, installer_util::kChromeExe);
506 launch_path->assign(path); 507 launch_path->assign(path);
507 return(file_util::PathExists(path)); 508 return(file_util::PathExists(FilePath::FromWStringHack(path)));
508 } 509 }
509 510
510 // Launch Chrome to see if it works after overinstall. Then close it. 511 // Launch Chrome to see if it works after overinstall. Then close it.
511 void ChromeMiniInstaller::LaunchAndCloseChrome(bool over_install) { 512 void ChromeMiniInstaller::LaunchAndCloseChrome(bool over_install) {
512 VerifyChromeLaunch(true); 513 VerifyChromeLaunch(true);
513 if ((install_type_ == mini_installer_constants::kSystemInstall) && 514 if ((install_type_ == mini_installer_constants::kSystemInstall) &&
514 (!over_install)) 515 (!over_install))
515 CloseFirstRunUIDialog(over_install); 516 CloseFirstRunUIDialog(over_install);
516 MiniInstallerTestUtil::CloseProcesses(installer_util::kChromeExe); 517 MiniInstallerTestUtil::CloseProcesses(installer_util::kChromeExe);
517 } 518 }
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
549 // This method will verify if the installed build is correct. 550 // This method will verify if the installed build is correct.
550 bool ChromeMiniInstaller::VerifyStandaloneInstall() { 551 bool ChromeMiniInstaller::VerifyStandaloneInstall() {
551 std::wstring reg_key_value_returned, standalone_installer_version; 552 std::wstring reg_key_value_returned, standalone_installer_version;
552 MiniInstallerTestUtil::GetStandaloneVersion(&standalone_installer_version); 553 MiniInstallerTestUtil::GetStandaloneVersion(&standalone_installer_version);
553 GetChromeVersionFromRegistry(&reg_key_value_returned); 554 GetChromeVersionFromRegistry(&reg_key_value_returned);
554 if (standalone_installer_version.compare(reg_key_value_returned) == 0) 555 if (standalone_installer_version.compare(reg_key_value_returned) == 0)
555 return true; 556 return true;
556 else 557 else
557 return false; 558 return false;
558 } 559 }
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