diff options
5 files changed, 179 insertions, 34 deletions
diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.cc b/chrome/test/mini_installer_test/chrome_mini_installer.cc index ec14997..bb22908 100644 --- a/chrome/test/mini_installer_test/chrome_mini_installer.cc +++ b/chrome/test/mini_installer_test/chrome_mini_installer.cc @@ -5,6 +5,7 @@ #include "chrome/test/mini_installer_test/chrome_mini_installer.h" #include "base/path_service.h" +#include "base/platform_thread.h" #include "base/process_util.h" #include "base/registry.h" #include "base/string_util.h" @@ -17,14 +18,14 @@ #include "testing/gtest/include/gtest/gtest.h" // Installs the Chrome mini-installer, checks the registry and shortcuts. -void ChromeMiniInstaller::InstallMiniInstaller(bool over_install) { - std::wstring mini_installer_path = GetMiniInstallerExePath(); +void ChromeMiniInstaller::InstallMiniInstaller(bool over_install, + const wchar_t exe_name[]) { + std::wstring installer_path = GetInstallerExePath(exe_name); printf("\nChrome will be installed at %ls level\n", install_type_.c_str()); printf("\nWill proceed with the test only if mini_installer.exe exists\n"); - ASSERT_TRUE(file_util::PathExists(mini_installer_path)); - printf("\nmini_installer found at %ls\n", mini_installer_path.c_str()); - LaunchInstaller(mini_installer_path, - mini_installer_constants::kChromeMiniInstallerExecutable); + ASSERT_TRUE(file_util::PathExists(installer_path)); + printf("\ninstaller found at %ls\n", installer_path.c_str()); + LaunchInstaller(installer_path, exe_name); BrowserDistribution* dist = BrowserDistribution::GetDistribution(); ASSERT_TRUE(CheckRegistryKey(dist->GetVersionKey())); FindChromeShortcut(); @@ -32,11 +33,32 @@ void ChromeMiniInstaller::InstallMiniInstaller(bool over_install) { CloseFirstRunUIDialog(over_install); } +// This method tests the standalone installer by verifying the steps listed at: +// https://sites.google.com/a/google.com/chrome-pmo/ +// standalone-installers/testing-standalone-installers +// This method applies appropriate tags to standalone installer and deletes +// old installer before running the new tagged installer. It also verifies +// that the installed version is correct. +void ChromeMiniInstaller::InstallStandaloneIntaller() { + if (!IsChromiumBuild()) { + standalone_installer = true; + file_util::Delete(mini_installer_constants::kStandaloneInstaller, true); + std::wstring tag_installer_command; + ASSERT_TRUE(GetCommandForTagging(&tag_installer_command)); + base::LaunchApp(tag_installer_command, true, false, NULL); + InstallMiniInstaller(false, mini_installer_constants::kStandaloneInstaller); + ASSERT_TRUE(VerifyStandaloneInstall()); + file_util::Delete(mini_installer_constants::kStandaloneInstaller, true); + } else { + printf("\n\nThis test doesn't run on a chromium build\n"); + } +} + // Installs chromesetup.exe, waits for the install to finish and then // checks the registry and shortcuts. void ChromeMiniInstaller::InstallMetaInstaller() { // Install Google Chrome through meta installer. - LaunchInstaller(mini_installer_constants::kChromeMetaInstallerExeLocation, + LaunchInstaller(mini_installer_constants::kChromeMetaInstallerExe, mini_installer_constants::kChromeSetupExecutable); WaitUntilProcessStopsRunning( mini_installer_constants::kChromeMetaInstallerExecutable); @@ -64,9 +86,8 @@ void ChromeMiniInstaller::OverInstall() { // gets the registry key value before overinstall. GetRegistryKey(®_key_value_returned); printf("\n\nPreparing to overinstall...\n"); - std::wstring mini_installer_path = GetMiniInstallerExePath(); - printf("\nOverinstall path is %ls\n", mini_installer_path.c_str()); - InstallMiniInstaller(true); + InstallMiniInstaller( + true, mini_installer_constants::kChromeMiniInstallerExecutable); std::wstring reg_key_value_after_overinstall; // Get the registry key value after over install GetRegistryKey(®_key_value_after_overinstall); @@ -120,9 +141,9 @@ bool ChromeMiniInstaller::CloseWindow(LPCWSTR window_name, UINT message) { int timer = 0; bool return_val = false; HWND hndl = FindWindow(NULL, window_name); - while (hndl== NULL && (timer < 60000)) { + while (hndl == NULL && (timer < 60000)) { hndl = FindWindow(NULL, window_name); - Sleep(200); + PlatformThread::Sleep(200); timer = timer + 200; } if (hndl != NULL) { @@ -156,7 +177,7 @@ void ChromeMiniInstaller::CloseProcesses(const std::wstring& executable_name) { while ((base::GetProcessCount(executable_name, NULL) > 0) && (timer < 20000)) { base::KillProcesses(executable_name, 1, NULL); - Sleep(200); + PlatformThread::Sleep(200); timer = timer + 200; } ASSERT_EQ(0, base::GetProcessCount(executable_name, NULL)); @@ -222,12 +243,12 @@ std::wstring ChromeMiniInstaller::GetChromeInstallDirectoryLocation() { } // Get path for mini_installer.exe. -std::wstring ChromeMiniInstaller::GetMiniInstallerExePath() { - std::wstring mini_installer_path; - PathService::Get(base::DIR_EXE, &mini_installer_path); - file_util::AppendToPath(&mini_installer_path, - mini_installer_constants::kChromeMiniInstallerExecutable); - return mini_installer_path; +std::wstring ChromeMiniInstaller::GetInstallerExePath(const wchar_t name[]) { + std::wstring installer_path; + PathService::Get(base::DIR_EXE, &installer_path); + file_util::AppendToPath(&installer_path, name); + printf("Chrome exe path is %ls\n", installer_path.c_str()); + return installer_path; } // This method gets the shortcut path from startmenu based on install type @@ -240,6 +261,55 @@ std::wstring ChromeMiniInstaller::GetStartMenuShortcutPath() { return path_name; } +// This method will get the standalone installer filename from the directory. +bool ChromeMiniInstaller::GetStandaloneInstallerFileName(std::wstring* name) { + std::wstring search_path, file_name; + size_t position_found; + file_name.append( + mini_installer_constants::kChromeStandAloneInstallerLocation); + file_name.append(L"*.exe"); + WIN32_FIND_DATA find_file_data; + HANDLE file_handle = FindFirstFile(file_name.c_str(), &find_file_data); + if (file_handle == INVALID_HANDLE_VALUE) { + printf("Handle is invalid\n"); + return false; + } + BOOL ret = TRUE; + while (ret) { + search_path = find_file_data.cFileName; + position_found = search_path.find(L"ChromeStandaloneSetup_"); + if (position_found == 0) { + name->assign(find_file_data.cFileName); + printf("Untagged installer name is %ls\n", name->c_str()); + break; + } + ret = FindNextFile(file_handle, &find_file_data); + } + FindClose(file_handle); + return true; +} + +// This method will get the version number from the filename. +bool ChromeMiniInstaller::GetStandaloneVersion(std::wstring* return_file_name) { + std::wstring file_name; + if (!GetStandaloneInstallerFileName(&file_name)) + return false; + // Returned file name will have following convention: + // ChromeStandaloneSetup_<build>_<patch>.exe + // Following code will extract build, patch details from the file + // and concatenate with 1.0 to form the build version. + // Patteren followed: 1.0.<build>.<patch> + file_name = file_name.substr(22, 25); + std::wstring::size_type last_dot = file_name.find(L'.'); + file_name = file_name.substr(0, last_dot); + std::wstring::size_type pos = file_name.find(L'_'); + file_name.replace(pos, 1, L"."); + file_name = L"1.0." + file_name; + return_file_name->assign(file_name.c_str()); + printf("Standalone installer version is %ls\n", file_name.c_str()); + return true; +} + // Gets the path for uninstall. std::wstring ChromeMiniInstaller::GetUninstallPath() { std::wstring username, append_path, path, reg_key_value; @@ -295,9 +365,35 @@ void ChromeMiniInstaller::LaunchInstaller(std::wstring path, } printf("Waiting while this process is running %ls ....", process_name); WaitUntilProcessStartsRunning(process_name); + // This is a temporary workaround until thankyou dialog is supressed. + if (standalone_installer == true) { + WaitUntilProcessStartsRunning(installer_util::kChromeExe); + PlatformThread::Sleep(1200); + CloseProcesses(mini_installer_constants::kGoogleUpdateExecutable); + } WaitUntilProcessStopsRunning(process_name); } +// This method will create a command line to run apply tag. +bool ChromeMiniInstaller::GetCommandForTagging(std::wstring *return_command) { + std::wstring standalone_installer_name, standalone_installer_path; + if (!GetStandaloneInstallerFileName(&standalone_installer_name)) + return false; + standalone_installer_path.assign( + mini_installer_constants::kChromeStandAloneInstallerLocation); + standalone_installer_path.append(standalone_installer_name); + return_command->append( + mini_installer_constants::kChromeApplyTagExe); + return_command->append(L" "); + return_command->append(standalone_installer_path); + return_command->append(L" "); + return_command->append(mini_installer_constants::kStandaloneInstaller); + return_command->append(L" "); + return_command->append(mini_installer_constants::kChromeApplyTagParameters); + printf("Command to run Apply tag is %ls\n", return_command->c_str()); + return true; +} + // Launch Chrome to see if it works after overinstall. Then close it. void ChromeMiniInstaller::VerifyChromeLaunch() { std::wstring username, path, append_path; @@ -307,7 +403,7 @@ void ChromeMiniInstaller::VerifyChromeLaunch() { printf("\n\nChrome is launched from %ls\n\n", path.c_str()); base::LaunchApp(L"\"" + path + L"\"", false, false, NULL); WaitUntilProcessStartsRunning(installer_util::kChromeExe); - Sleep(1200); + PlatformThread::Sleep(1200); } // This method compares the registry keys after overinstall. @@ -330,13 +426,23 @@ bool ChromeMiniInstaller::VerifyOverInstall( return true; } +// This method will verify if the installed build is correct. +bool ChromeMiniInstaller::VerifyStandaloneInstall() { + std::wstring reg_key_value_returned, standalone_installer_version; + GetStandaloneVersion(&standalone_installer_version); + GetRegistryKey(®_key_value_returned); + if (standalone_installer_version.compare(reg_key_value_returned) == 0) + return true; + else + return false; +} // Waits until the process starts running. void ChromeMiniInstaller::WaitUntilProcessStartsRunning( const wchar_t process_name[]) { int timer = 0; while ((base::GetProcessCount(process_name, NULL) == 0) && (timer < 60000)) { - Sleep(200); + PlatformThread::Sleep(200); timer = timer + 200; } ASSERT_NE(0, base::GetProcessCount(process_name, NULL)); @@ -349,7 +455,7 @@ void ChromeMiniInstaller::WaitUntilProcessStopsRunning( printf("\nWaiting for this process to end... %ls\n", process_name); while ((base::GetProcessCount(process_name, NULL) > 0) && (timer < 60000)) { - Sleep(200); + PlatformThread::Sleep(200); timer = timer + 200; } ASSERT_EQ(0, base::GetProcessCount(process_name, NULL)); diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.h b/chrome/test/mini_installer_test/chrome_mini_installer.h index b258794..eddcce8 100644 --- a/chrome/test/mini_installer_test/chrome_mini_installer.h +++ b/chrome/test/mini_installer_test/chrome_mini_installer.h @@ -31,7 +31,11 @@ class ChromeMiniInstaller { void InstallMetaInstaller(); // Installs Chrome Mini Installer. - void InstallMiniInstaller(bool over_install = false); + void InstallMiniInstaller(bool over_install = false, + const wchar_t exe_name[] = L""); + + // This will test the standalone installer. + void InstallStandaloneIntaller(); // Uninstalls Chrome. void UnInstall(); @@ -43,6 +47,7 @@ class ChromeMiniInstaller { // This variable holds the install type. // Install type can be either system or user level. std::wstring install_type_; + bool standalone_installer; // Closes First Run UI dialog. void CloseFirstRunUIDialog(bool over_install); @@ -70,11 +75,17 @@ class ChromeMiniInstaller { HKEY GetRootRegistryKey(); // Get path for mini_installer.exe. - std::wstring GetMiniInstallerExePath(); + std::wstring GetInstallerExePath(const wchar_t installer_name[]); // This method gets the shortcut path from start menu based on install type. std::wstring GetStartMenuShortcutPath(); + // This method will get the standalone installer filename. + bool GetStandaloneInstallerFileName(std::wstring* file_name); + + // This method will get the version number from the filename. + bool GetStandaloneVersion(std::wstring* version); + // Get path for uninstall. std::wstring GetUninstallPath(); @@ -87,6 +98,9 @@ class ChromeMiniInstaller { // Launches the chrome installer and waits for it to end. void LaunchInstaller(std::wstring install_path, const wchar_t process_name[]); + // This method will create a command line to run apply tag. + bool GetCommandForTagging(std::wstring *return_command); + // Verifies if Chrome launches after install. void VerifyChromeLaunch(); @@ -94,6 +108,9 @@ class ChromeMiniInstaller { bool VerifyOverInstall(std::wstring reg_key_value_before_overinstall, std::wstring reg_key_value_after_overinstall); + // This method will verify if the installed build is correct. + bool VerifyStandaloneInstall(); + // Waits until the given process starts running void WaitUntilProcessStartsRunning(const wchar_t process_name[]); diff --git a/chrome/test/mini_installer_test/mini_installer_test_constants.cc b/chrome/test/mini_installer_test/mini_installer_test_constants.cc index adafddd..e5372f27 100644 --- a/chrome/test/mini_installer_test/mini_installer_test_constants.cc +++ b/chrome/test/mini_installer_test/mini_installer_test_constants.cc @@ -19,19 +19,26 @@ const wchar_t kChromeFirstRunUI[] = L"Welcome to Chromium"; const wchar_t kChromeLaunchShortcut[] = L"Chromium.lnk"; const wchar_t kChromeUninstallShortcut[] = L"Uninstall Chromium.lnk"; #endif - const wchar_t kBrowserAppName[] = L"Google - Google Chrome"; const wchar_t kBrowserTabName[] = L"New Tab - Google Chrome"; const wchar_t kChromeMiniInstallerExecutable[] = L"mini_installer.exe"; const wchar_t kChromeMetaInstallerExecutable[] = L"chrome_installer.exe"; const wchar_t kChromeSetupExecutable[] = L"setup.exe"; const wchar_t kIEExecutable[] = L"iexplore.exe"; -const wchar_t kInstallerWindow[] = L"Google App Installer"; +const wchar_t kInstallerWindow[] = L"Chrome Installer"; const wchar_t kSystemInstall[] = L"system"; const wchar_t kUserInstall[] = L"user"; +const wchar_t kStandaloneInstaller[] = L"ChromeSetupTest.exe"; +const wchar_t kGoogleUpdateExecutable[] = L"GoogleUpdate.exe"; // Google Chrome meta installer location. -const wchar_t kChromeMetaInstallerExeLocation[] = +const wchar_t kChromeMetaInstallerExe[] = L"\\\\172.23.44.61\\shared\\chrome_autotest\\beta_build\\ChromeSetup.exe"; +const wchar_t kChromeStandAloneInstallerLocation[] = + L"\\\\172.24.6.7\\shares\\googleclient\\nightly\\builds\\Win-OmahaInstallers\\latest\\opt\\"; +const wchar_t kChromeApplyTagExe[] = + L"\\\\172.23.44.61\\shared\\chrome_autotest\\ApplyTag.exe"; +const wchar_t kChromeApplyTagParameters[] = + L"\"appguid={8A69D345-D564-463C-AFF1-A69D9E530F96}&appname=Chrome&needsadmin=false\""; } diff --git a/chrome/test/mini_installer_test/mini_installer_test_constants.h b/chrome/test/mini_installer_test/mini_installer_test_constants.h index 8eec09e..febad8b 100644 --- a/chrome/test/mini_installer_test/mini_installer_test_constants.h +++ b/chrome/test/mini_installer_test/mini_installer_test_constants.h @@ -12,9 +12,10 @@ namespace mini_installer_constants { // Path and process names extern const wchar_t kChromeAppDir[]; extern const wchar_t kChromeSetupExecutable[]; -extern const wchar_t kIEExecutable[]; extern const wchar_t kChromeMiniInstallerExecutable[]; extern const wchar_t kChromeMetaInstallerExecutable[]; +extern const wchar_t kGoogleUpdateExecutable[]; +extern const wchar_t kIEExecutable[]; // Window names. extern const wchar_t kBrowserAppName[]; @@ -29,10 +30,14 @@ extern const wchar_t kChromeUninstallShortcut[]; // Chrome install types extern const wchar_t kSystemInstall[]; +extern const wchar_t kStandaloneInstaller[]; extern const wchar_t kUserInstall[]; // Google Chrome meta installer location. -extern const wchar_t kChromeMetaInstallerExeLocation[]; +extern const wchar_t kChromeApplyTagExe[]; +extern const wchar_t kChromeMetaInstallerExe[]; +extern const wchar_t kChromeStandAloneInstallerLocation[]; +extern const wchar_t kChromeApplyTagParameters[]; } #endif // CHROME_TEST_MINI_INSTALLER_TEST_MINI_INSTALLER_TEST_CONSTANTS_H__ diff --git a/chrome/test/mini_installer_test/test.cc b/chrome/test/mini_installer_test/test.cc index 22b108e..7c12c7a 100644 --- a/chrome/test/mini_installer_test/test.cc +++ b/chrome/test/mini_installer_test/test.cc @@ -1,6 +1,7 @@ // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +#include "base/platform_thread.h" #include "base/win_util.h" #include "chrome/installer/util/install_util.h" #include "chrome/test/mini_installer_test/mini_installer_test_constants.h" @@ -11,7 +12,7 @@ namespace { class MiniInstallTest : public testing::Test { protected: - virtual void SetUp() { + void CleanTheSystem() { ChromeMiniInstaller userinstall(mini_installer_constants::kUserInstall); userinstall.UnInstall(); if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { @@ -20,14 +21,21 @@ class MiniInstallTest : public testing::Test { systeminstall.UnInstall(); } } + virtual void SetUp() { + CleanTheSystem(); + } virtual void TearDown() { - ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); - installer.CloseProcesses(installer_util::kChromeExe); + PlatformThread::Sleep(2000); + CleanTheSystem(); } }; }; +TEST_F(MiniInstallTest, StandaloneInstallerTest) { + ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); + installer.InstallStandaloneIntaller(); +} TEST_F(MiniInstallTest, MiniInstallerOverChromeMetaInstallerTest) { ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); installer.OverInstall(); @@ -36,13 +44,15 @@ TEST_F(MiniInstallTest, MiniInstallerOverChromeMetaInstallerTest) { TEST_F(MiniInstallTest, MiniInstallerSystemInstallTest) { if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA) { ChromeMiniInstaller installer(mini_installer_constants::kSystemInstall); - installer.InstallMiniInstaller(); + installer.InstallMiniInstaller(false, + mini_installer_constants::kChromeMiniInstallerExecutable); } } TEST_F(MiniInstallTest, MiniInstallerUserInstallTest) { ChromeMiniInstaller installer(mini_installer_constants::kUserInstall); - installer.InstallMiniInstaller(); + installer.InstallMiniInstaller(false, + mini_installer_constants::kChromeMiniInstallerExecutable); } TEST(InstallUtilTests, MiniInstallTestValidWindowsVersion) { |