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

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

Issue 6001010: Move platform_thread to base/threading and put in the base namespace. I left ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 9 years, 11 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) 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"
11 #include "base/process.h" 10 #include "base/process.h"
12 #include "base/process_util.h" 11 #include "base/process_util.h"
13 #include "base/string_number_conversions.h" 12 #include "base/string_number_conversions.h"
14 #include "base/string_util.h" 13 #include "base/string_util.h"
14 #include "base/threading/platform_thread.h"
15 #include "base/win/registry.h" 15 #include "base/win/registry.h"
16 #include "chrome/installer/util/browser_distribution.h" 16 #include "chrome/installer/util/browser_distribution.h"
17 #include "chrome/installer/util/google_update_constants.h" 17 #include "chrome/installer/util/google_update_constants.h"
18 #include "chrome/test/mini_installer_test/mini_installer_test_constants.h" 18 #include "chrome/test/mini_installer_test/mini_installer_test_constants.h"
19 #include "chrome/test/mini_installer_test/mini_installer_test_util.h" 19 #include "chrome/test/mini_installer_test/mini_installer_test_util.h"
20 #include "testing/gtest/include/gtest/gtest.h" 20 #include "testing/gtest/include/gtest/gtest.h"
21 21
22 using base::win::RegKey; 22 using base::win::RegKey;
23 23
24 ChromeMiniInstaller::ChromeMiniInstaller(const std::wstring& install_type, 24 ChromeMiniInstaller::ChromeMiniInstaller(const std::wstring& install_type,
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
300 bool ChromeMiniInstaller::CloseUninstallWindow() { 300 bool ChromeMiniInstaller::CloseUninstallWindow() {
301 HWND hndl = NULL; 301 HWND hndl = NULL;
302 int timer = 0; 302 int timer = 0;
303 std::wstring window_name; 303 std::wstring window_name;
304 if (is_chrome_frame_) 304 if (is_chrome_frame_)
305 window_name = mini_installer_constants::kChromeFrameAppName; 305 window_name = mini_installer_constants::kChromeFrameAppName;
306 else 306 else
307 window_name = mini_installer_constants::kChromeUninstallDialogName; 307 window_name = mini_installer_constants::kChromeUninstallDialogName;
308 while (hndl == NULL && timer < 5000) { 308 while (hndl == NULL && timer < 5000) {
309 hndl = FindWindow(NULL, window_name.c_str()); 309 hndl = FindWindow(NULL, window_name.c_str());
310 PlatformThread::Sleep(200); 310 base::PlatformThread::Sleep(200);
311 timer = timer + 200; 311 timer = timer + 200;
312 } 312 }
313 313
314 if (!is_chrome_frame_) { 314 if (!is_chrome_frame_) {
315 if (hndl == NULL) 315 if (hndl == NULL)
316 hndl = FindWindow(NULL, mini_installer_constants::kChromeBuildType); 316 hndl = FindWindow(NULL, mini_installer_constants::kChromeBuildType);
317 317
318 if (hndl == NULL) 318 if (hndl == NULL)
319 return false; 319 return false;
320 320
(...skipping 10 matching lines...) Expand all
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::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 base::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 base::PlatformThread::Sleep(1000);
352 timer = timer + 1000; 352 timer = timer + 1000;
353 } 353 }
354 if (base::GetProcessCount(installer::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::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 }
(...skipping 13 matching lines...) Expand all
375 return true; 375 return true;
376 } 376 }
377 377
378 // Checks for Chrome registry keys on uninstall. 378 // Checks for Chrome registry keys on uninstall.
379 bool ChromeMiniInstaller::CheckRegistryKeyOnUninstall( 379 bool ChromeMiniInstaller::CheckRegistryKeyOnUninstall(
380 const std::wstring& key_path) { 380 const std::wstring& key_path) {
381 RegKey key; 381 RegKey key;
382 int timer = 0; 382 int timer = 0;
383 while ((key.Open(GetRootRegistryKey(), key_path.c_str(), KEY_ALL_ACCESS)) && 383 while ((key.Open(GetRootRegistryKey(), key_path.c_str(), KEY_ALL_ACCESS)) &&
384 (timer < 20000)) { 384 (timer < 20000)) {
385 PlatformThread::Sleep(200); 385 base::PlatformThread::Sleep(200);
386 timer = timer + 200; 386 timer = timer + 200;
387 } 387 }
388 return CheckRegistryKey(key_path); 388 return CheckRegistryKey(key_path);
389 } 389 }
390 390
391 // Deletes Installer folder from Applications directory. 391 // Deletes Installer folder from Applications directory.
392 void ChromeMiniInstaller::DeleteFolder(const wchar_t* folder_name) { 392 void ChromeMiniInstaller::DeleteFolder(const wchar_t* folder_name) {
393 FilePath install_path(GetChromeInstallDirectoryLocation()); 393 FilePath install_path(GetChromeInstallDirectoryLocation());
394 std::wstring temp_chrome_dir; 394 std::wstring temp_chrome_dir;
395 if (is_chrome_frame_) { 395 if (is_chrome_frame_) {
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
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::kChromeExe, true); 602 installer::kChromeExe, true);
603 } 603 }
604 PlatformThread::Sleep(800); 604 base::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;
(...skipping 23 matching lines...) Expand all
638 ASSERT_TRUE(file_util::PathExists(path)); 638 ASSERT_TRUE(file_util::PathExists(path));
639 } 639 }
640 640
641 // This method will launch any requested browser. 641 // This method will launch any requested browser.
642 void ChromeMiniInstaller::LaunchBrowser(const std::wstring& launch_path, 642 void ChromeMiniInstaller::LaunchBrowser(const std::wstring& launch_path,
643 const std::wstring& launch_args, 643 const std::wstring& launch_args,
644 const std::wstring& process_name, 644 const std::wstring& process_name,
645 bool expected_status) { 645 bool expected_status) {
646 base::LaunchApp(L"\"" + launch_path + L"\"" + L" " + launch_args, 646 base::LaunchApp(L"\"" + launch_path + L"\"" + L" " + launch_args,
647 false, false, NULL); 647 false, false, NULL);
648 PlatformThread::Sleep(1000); 648 base::PlatformThread::Sleep(1000);
649 MiniInstallerTestUtil::VerifyProcessLaunch(process_name.c_str(), 649 MiniInstallerTestUtil::VerifyProcessLaunch(process_name.c_str(),
650 expected_status); 650 expected_status);
651 } 651 }
652 652
653 // This method compares the registry keys after overinstall. 653 // This method compares the registry keys after overinstall.
654 bool ChromeMiniInstaller::VerifyOverInstall( 654 bool ChromeMiniInstaller::VerifyOverInstall(
655 const std::wstring& value_before_overinstall, 655 const std::wstring& value_before_overinstall,
656 const std::wstring& value_after_overinstall) { 656 const std::wstring& value_after_overinstall) {
657 int64 reg_key_value_before_overinstall; 657 int64 reg_key_value_before_overinstall;
658 base::StringToInt64(value_before_overinstall, 658 base::StringToInt64(value_before_overinstall,
(...skipping 17 matching lines...) Expand all
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(&reg_key_value_returned); 680 GetChromeVersionFromRegistry(&reg_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 }
OLDNEW
« no previous file with comments | « chrome/test/memory_test/memory_test.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