OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
10 #include "base/platform_thread.h" | 10 #include "base/platform_thread.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 // This method will first install Chrome. Deletes either registry or | 203 // This method will first install Chrome. Deletes either registry or |
204 // folder based on the passed argument, then tries to launch Chrome. | 204 // folder based on the passed argument, then tries to launch Chrome. |
205 // Then installs Chrome again to repair. | 205 // Then installs Chrome again to repair. |
206 void ChromeMiniInstaller::Repair( | 206 void ChromeMiniInstaller::Repair( |
207 ChromeMiniInstaller::RepairChrome repair_type) { | 207 ChromeMiniInstaller::RepairChrome repair_type) { |
208 InstallFullInstaller(false); | 208 InstallFullInstaller(false); |
209 if (is_chrome_frame_) { | 209 if (is_chrome_frame_) { |
210 MiniInstallerTestUtil::CloseProcesses( | 210 MiniInstallerTestUtil::CloseProcesses( |
211 mini_installer_constants::kIEProcessName); | 211 mini_installer_constants::kIEProcessName); |
212 } else { | 212 } else { |
213 MiniInstallerTestUtil::CloseProcesses(installer_util::kNaClExe); | 213 MiniInstallerTestUtil::CloseProcesses(installer::kNaClExe); |
214 } | 214 } |
215 MiniInstallerTestUtil::CloseProcesses(installer_util::kChromeExe); | 215 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); |
216 if (repair_type == ChromeMiniInstaller::VERSION_FOLDER) { | 216 if (repair_type == ChromeMiniInstaller::VERSION_FOLDER) { |
217 DeleteFolder(L"version_folder"); | 217 DeleteFolder(L"version_folder"); |
218 printf("Deleted folder. Now trying to launch chrome\n"); | 218 printf("Deleted folder. Now trying to launch chrome\n"); |
219 } else if (repair_type == ChromeMiniInstaller::REGISTRY) { | 219 } else if (repair_type == ChromeMiniInstaller::REGISTRY) { |
220 DeletePvRegistryKey(); | 220 DeletePvRegistryKey(); |
221 printf("Deleted registry. Now trying to launch chrome\n"); | 221 printf("Deleted registry. Now trying to launch chrome\n"); |
222 } | 222 } |
223 FilePath current_path; | 223 FilePath current_path; |
224 ASSERT_TRUE(MiniInstallerTestUtil::ChangeCurrentDirectory(¤t_path)); | 224 ASSERT_TRUE(MiniInstallerTestUtil::ChangeCurrentDirectory(¤t_path)); |
225 VerifyChromeLaunch(false); | 225 VerifyChromeLaunch(false); |
(...skipping 20 matching lines...) Expand all Loading... |
246 product_name = mini_installer_constants::kChromeProductName; | 246 product_name = mini_installer_constants::kChromeProductName; |
247 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 247 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
248 if (!CheckRegistryKey(dist->GetVersionKey())) { | 248 if (!CheckRegistryKey(dist->GetVersionKey())) { |
249 printf("%ls is not installed.\n", product_name.c_str()); | 249 printf("%ls is not installed.\n", product_name.c_str()); |
250 return; | 250 return; |
251 } | 251 } |
252 if (is_chrome_frame_) { | 252 if (is_chrome_frame_) { |
253 MiniInstallerTestUtil::CloseProcesses( | 253 MiniInstallerTestUtil::CloseProcesses( |
254 mini_installer_constants::kIEProcessName); | 254 mini_installer_constants::kIEProcessName); |
255 } else { | 255 } else { |
256 MiniInstallerTestUtil::CloseProcesses(installer_util::kNaClExe); | 256 MiniInstallerTestUtil::CloseProcesses(installer::kNaClExe); |
257 } | 257 } |
258 MiniInstallerTestUtil::CloseProcesses(installer_util::kChromeExe); | 258 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); |
259 std::wstring uninstall_path = GetUninstallPath(); | 259 std::wstring uninstall_path = GetUninstallPath(); |
260 if (uninstall_path == L"") { | 260 if (uninstall_path == L"") { |
261 printf("\n %ls install is in a weird state. Cleaning the machine...\n", | 261 printf("\n %ls install is in a weird state. Cleaning the machine...\n", |
262 product_name.c_str()); | 262 product_name.c_str()); |
263 CleanChromeInstall(); | 263 CleanChromeInstall(); |
264 return; | 264 return; |
265 } | 265 } |
266 ASSERT_TRUE(file_util::PathExists(FilePath(uninstall_path))); | 266 ASSERT_TRUE(file_util::PathExists(FilePath(uninstall_path))); |
267 std::wstring uninstall_args(L"\""); | 267 std::wstring uninstall_args(L"\""); |
268 uninstall_args.append(uninstall_path); | 268 uninstall_args.append(uninstall_path); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
323 } | 323 } |
324 return true; | 324 return true; |
325 } | 325 } |
326 | 326 |
327 // Closes Chrome browser. | 327 // Closes Chrome browser. |
328 bool ChromeMiniInstaller::CloseChromeBrowser() { | 328 bool ChromeMiniInstaller::CloseChromeBrowser() { |
329 int timer = 0; | 329 int timer = 0; |
330 HWND handle = NULL; | 330 HWND handle = NULL; |
331 // This loop iterates through all of the top-level Windows | 331 // This loop iterates through all of the top-level Windows |
332 // named Chrome_WidgetWin_0 and closes them | 332 // named Chrome_WidgetWin_0 and closes them |
333 while ((base::GetProcessCount(installer_util::kChromeExe, NULL) > 0) && | 333 while ((base::GetProcessCount(installer::kChromeExe, NULL) > 0) && |
334 (timer < 40000)) { | 334 (timer < 40000)) { |
335 // Chrome may have been launched, but the window may not have appeared | 335 // Chrome may have been launched, but the window may not have appeared |
336 // yet. Wait for it to appear for 10 seconds, but exit if it takes longer | 336 // yet. Wait for it to appear for 10 seconds, but exit if it takes longer |
337 // than that. | 337 // than that. |
338 while (!handle && timer < 10000) { | 338 while (!handle && timer < 10000) { |
339 handle = FindWindowEx(NULL, handle, L"Chrome_WidgetWin_0", NULL); | 339 handle = FindWindowEx(NULL, handle, L"Chrome_WidgetWin_0", NULL); |
340 if (!handle) { | 340 if (!handle) { |
341 PlatformThread::Sleep(100); | 341 PlatformThread::Sleep(100); |
342 timer = timer + 100; | 342 timer = timer + 100; |
343 } | 343 } |
344 } | 344 } |
345 if (!handle) | 345 if (!handle) |
346 return false; | 346 return false; |
347 SetForegroundWindow(handle); | 347 SetForegroundWindow(handle); |
348 LRESULT _result = SendMessage(handle, WM_CLOSE, 1, 0); | 348 LRESULT _result = SendMessage(handle, WM_CLOSE, 1, 0); |
349 if (_result != 0) | 349 if (_result != 0) |
350 return false; | 350 return false; |
351 PlatformThread::Sleep(1000); | 351 PlatformThread::Sleep(1000); |
352 timer = timer + 1000; | 352 timer = timer + 1000; |
353 } | 353 } |
354 if (base::GetProcessCount(installer_util::kChromeExe, NULL) > 0) { | 354 if (base::GetProcessCount(installer::kChromeExe, NULL) > 0) { |
355 printf("Chrome.exe is still running even after closing all windows\n"); | 355 printf("Chrome.exe is still running even after closing all windows\n"); |
356 return false; | 356 return false; |
357 } | 357 } |
358 if (base::GetProcessCount(installer_util::kNaClExe, NULL) > 0) { | 358 if (base::GetProcessCount(installer::kNaClExe, NULL) > 0) { |
359 printf("NaCl.exe is still running even after closing all windows\n"); | 359 printf("NaCl.exe is still running even after closing all windows\n"); |
360 return false; | 360 return false; |
361 } | 361 } |
362 return true; | 362 return true; |
363 } | 363 } |
364 | 364 |
365 // Checks for Chrome registry keys. | 365 // Checks for Chrome registry keys. |
366 bool ChromeMiniInstaller::CheckRegistryKey(const std::wstring& key_path) { | 366 bool ChromeMiniInstaller::CheckRegistryKey(const std::wstring& key_path) { |
367 RegKey key; | 367 RegKey key; |
368 if (!key.Open(GetRootRegistryKey(), key_path.c_str(), KEY_ALL_ACCESS)) { | 368 if (!key.Open(GetRootRegistryKey(), key_path.c_str(), KEY_ALL_ACCESS)) { |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 if (!GetChromeVersionFromRegistry(®_key_value)) | 499 if (!GetChromeVersionFromRegistry(®_key_value)) |
500 return std::wstring(); | 500 return std::wstring(); |
501 path = GetChromeInstallDirectoryLocation(); | 501 path = GetChromeInstallDirectoryLocation(); |
502 if (is_chrome_frame_) { | 502 if (is_chrome_frame_) { |
503 file_util::AppendToPath(&path, | 503 file_util::AppendToPath(&path, |
504 mini_installer_constants::kChromeFrameAppDir); | 504 mini_installer_constants::kChromeFrameAppDir); |
505 } else { | 505 } else { |
506 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir); | 506 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir); |
507 } | 507 } |
508 file_util::AppendToPath(&path, reg_key_value); | 508 file_util::AppendToPath(&path, reg_key_value); |
509 file_util::AppendToPath(&path, installer_util::kInstallerDir); | 509 file_util::AppendToPath(&path, installer::kInstallerDir); |
510 file_util::AppendToPath(&path, | 510 file_util::AppendToPath(&path, |
511 mini_installer_constants::kChromeSetupExecutable); | 511 mini_installer_constants::kChromeSetupExecutable); |
512 if (!file_util::PathExists(FilePath(path))) { | 512 if (!file_util::PathExists(FilePath(path))) { |
513 printf("This uninstall path is not correct %ls. Will not proceed further", | 513 printf("This uninstall path is not correct %ls. Will not proceed further", |
514 path.c_str()); | 514 path.c_str()); |
515 return L""; | 515 return L""; |
516 } | 516 } |
517 printf("uninstall path is %ls\n", path.c_str()); | 517 printf("uninstall path is %ls\n", path.c_str()); |
518 return path; | 518 return path; |
519 } | 519 } |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
561 printf("Waiting while this process is running %ls ....\n", process_name); | 561 printf("Waiting while this process is running %ls ....\n", process_name); |
562 MiniInstallerTestUtil::VerifyProcessLaunch(process_name, true); | 562 MiniInstallerTestUtil::VerifyProcessLaunch(process_name, true); |
563 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(app_handle)); | 563 ASSERT_TRUE(MiniInstallerTestUtil::VerifyProcessHandleClosed(app_handle)); |
564 } | 564 } |
565 | 565 |
566 // Gets the path to launch Chrome. | 566 // Gets the path to launch Chrome. |
567 bool ChromeMiniInstaller::GetChromeLaunchPath(std::wstring* launch_path) { | 567 bool ChromeMiniInstaller::GetChromeLaunchPath(std::wstring* launch_path) { |
568 std::wstring path; | 568 std::wstring path; |
569 path = GetChromeInstallDirectoryLocation(); | 569 path = GetChromeInstallDirectoryLocation(); |
570 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir); | 570 file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir); |
571 file_util::AppendToPath(&path, installer_util::kChromeExe); | 571 file_util::AppendToPath(&path, installer::kChromeExe); |
572 launch_path->assign(path); | 572 launch_path->assign(path); |
573 return file_util::PathExists(FilePath(path)); | 573 return file_util::PathExists(FilePath(path)); |
574 } | 574 } |
575 | 575 |
576 // Launch Chrome to see if it works after overinstall. Then close it. | 576 // Launch Chrome to see if it works after overinstall. Then close it. |
577 void ChromeMiniInstaller::LaunchAndCloseChrome(bool over_install) { | 577 void ChromeMiniInstaller::LaunchAndCloseChrome(bool over_install) { |
578 VerifyChromeLaunch(true); | 578 VerifyChromeLaunch(true); |
579 if ((install_type_ == mini_installer_constants::kSystemInstall) && | 579 if ((install_type_ == mini_installer_constants::kSystemInstall) && |
580 (!over_install)) { | 580 (!over_install)) { |
581 MiniInstallerTestUtil::VerifyProcessLaunch( | 581 MiniInstallerTestUtil::VerifyProcessLaunch( |
582 installer_util::kChromeExe, true); | 582 installer::kChromeExe, true); |
583 } | 583 } |
584 MiniInstallerTestUtil::CloseProcesses(installer_util::kChromeExe); | 584 MiniInstallerTestUtil::CloseProcesses(installer::kChromeExe); |
585 } | 585 } |
586 | 586 |
587 // This method will get Chrome exe path and launch it. | 587 // This method will get Chrome exe path and launch it. |
588 void ChromeMiniInstaller::VerifyChromeLaunch(bool expected_status) { | 588 void ChromeMiniInstaller::VerifyChromeLaunch(bool expected_status) { |
589 std::wstring launch_path; | 589 std::wstring launch_path; |
590 GetChromeLaunchPath(&launch_path); | 590 GetChromeLaunchPath(&launch_path); |
591 LaunchBrowser(launch_path, L"", installer_util::kChromeExe, expected_status); | 591 LaunchBrowser(launch_path, L"", installer::kChromeExe, expected_status); |
592 } | 592 } |
593 | 593 |
594 // Verifies Chrome/Chrome Frame install. | 594 // Verifies Chrome/Chrome Frame install. |
595 void ChromeMiniInstaller::VerifyInstall(bool over_install) { | 595 void ChromeMiniInstaller::VerifyInstall(bool over_install) { |
596 if (is_chrome_frame_) { | 596 if (is_chrome_frame_) { |
597 VerifyChromeFrameInstall(); | 597 VerifyChromeFrameInstall(); |
598 } else { | 598 } else { |
599 if ((install_type_ == mini_installer_constants::kUserInstall) && | 599 if ((install_type_ == mini_installer_constants::kUserInstall) && |
600 (!over_install)) { | 600 (!over_install)) { |
601 MiniInstallerTestUtil::VerifyProcessLaunch( | 601 MiniInstallerTestUtil::VerifyProcessLaunch( |
602 installer_util::kChromeExe, true); | 602 installer::kChromeExe, true); |
603 } | 603 } |
604 PlatformThread::Sleep(800); | 604 PlatformThread::Sleep(800); |
605 FindChromeShortcut(); | 605 FindChromeShortcut(); |
606 LaunchAndCloseChrome(over_install); | 606 LaunchAndCloseChrome(over_install); |
607 } | 607 } |
608 } | 608 } |
609 | 609 |
610 // This method will verify if ChromeFrame installed successfully. It will | 610 // This method will verify if ChromeFrame installed successfully. It will |
611 // launch IE with cf:about:version, then check if | 611 // launch IE with cf:about:version, then check if |
612 // chrome.exe process got spawned. | 612 // chrome.exe process got spawned. |
613 void ChromeMiniInstaller::VerifyChromeFrameInstall() { | 613 void ChromeMiniInstaller::VerifyChromeFrameInstall() { |
614 FilePath browser_path; | 614 FilePath browser_path; |
615 PathService::Get(base::DIR_PROGRAM_FILES, &browser_path); | 615 PathService::Get(base::DIR_PROGRAM_FILES, &browser_path); |
616 browser_path = browser_path.Append(mini_installer_constants::kIELocation); | 616 browser_path = browser_path.Append(mini_installer_constants::kIELocation); |
617 browser_path = browser_path.Append(mini_installer_constants::kIEProcessName); | 617 browser_path = browser_path.Append(mini_installer_constants::kIEProcessName); |
618 | 618 |
619 CommandLine cmd_line(browser_path); | 619 CommandLine cmd_line(browser_path); |
620 cmd_line.AppendArgNative(L"gcf:about:version"); | 620 cmd_line.AppendArgNative(L"gcf:about:version"); |
621 | 621 |
622 // Launch IE | 622 // Launch IE |
623 base::LaunchApp(cmd_line, false, false, NULL); | 623 base::LaunchApp(cmd_line, false, false, NULL); |
624 | 624 |
625 // Check if Chrome process got spawned. | 625 // Check if Chrome process got spawned. |
626 MiniInstallerTestUtil::VerifyProcessLaunch(installer_util::kChromeExe, true); | 626 MiniInstallerTestUtil::VerifyProcessLaunch(installer::kChromeExe, true); |
627 | 627 |
628 // Verify if IExplore folder got created | 628 // Verify if IExplore folder got created |
629 FilePath path = GetUserDataDirPath(); | 629 FilePath path = GetUserDataDirPath(); |
630 path = path.AppendASCII("IEXPLORE"); | 630 path = path.AppendASCII("IEXPLORE"); |
631 if (!file_util::PathExists(path)) { | 631 if (!file_util::PathExists(path)) { |
632 // The profile folder for IE 6 and 7 lives in the user's Temporary Internet | 632 // The profile folder for IE 6 and 7 lives in the user's Temporary Internet |
633 // Files folder. Check there if the previous one was not found. | 633 // Files folder. Check there if the previous one was not found. |
634 PathService::Get(base::DIR_IE_INTERNET_CACHE, &path); | 634 PathService::Get(base::DIR_IE_INTERNET_CACHE, &path); |
635 path = path.AppendASCII("Google Chrome Frame"); | 635 path = path.AppendASCII("Google Chrome Frame"); |
636 } | 636 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
676 // This method will verify if the installed build is correct. | 676 // This method will verify if the installed build is correct. |
677 bool ChromeMiniInstaller::VerifyStandaloneInstall() { | 677 bool ChromeMiniInstaller::VerifyStandaloneInstall() { |
678 std::wstring reg_key_value_returned, standalone_installer_version; | 678 std::wstring reg_key_value_returned, standalone_installer_version; |
679 MiniInstallerTestUtil::GetStandaloneVersion(&standalone_installer_version); | 679 MiniInstallerTestUtil::GetStandaloneVersion(&standalone_installer_version); |
680 GetChromeVersionFromRegistry(®_key_value_returned); | 680 GetChromeVersionFromRegistry(®_key_value_returned); |
681 if (standalone_installer_version.compare(reg_key_value_returned) == 0) | 681 if (standalone_installer_version.compare(reg_key_value_returned) == 0) |
682 return true; | 682 return true; |
683 else | 683 else |
684 return false; | 684 return false; |
685 } | 685 } |
OLD | NEW |