diff options
author | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-16 17:10:02 +0000 |
---|---|---|
committer | robertshield@chromium.org <robertshield@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-09-16 17:10:02 +0000 |
commit | 9f16f9fb94d4f2a7963e759f3ca712df30d74fff (patch) | |
tree | e37457cf1568a36f007f5b7a751b7a1af95f8c4c /chrome/test/mini_installer_test/test.cc | |
parent | 3b27adfc7ed75f2b5501039895ea9ec05f7266df (diff) | |
download | chromium_src-9f16f9fb94d4f2a7963e759f3ca712df30d74fff.zip chromium_src-9f16f9fb94d4f2a7963e759f3ca712df30d74fff.tar.gz chromium_src-9f16f9fb94d4f2a7963e759f3ca712df30d74fff.tar.bz2 |
Add testing of the Chrome Frame user-mode installation to mini_installer_tests.exe.
Also do some miscellaneous cleanup and rejiggering such as removing test-only constants from chrome\common, adding more useful prints when tests fail, properly waiting for child processes to terminate and moving a timeout value to test_timeouts.cc in test_support_common.
BUG=53127
TEST=Chrome Frame user level installs are tested.
Review URL: http://codereview.chromium.org/3297026
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@59675 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/mini_installer_test/test.cc')
-rw-r--r-- | chrome/test/mini_installer_test/test.cc | 134 |
1 files changed, 66 insertions, 68 deletions
diff --git a/chrome/test/mini_installer_test/test.cc b/chrome/test/mini_installer_test/test.cc index 251c9cd..a98b429 100644 --- a/chrome/test/mini_installer_test/test.cc +++ b/chrome/test/mini_installer_test/test.cc @@ -3,17 +3,18 @@ // found in the LICENSE file. #include "base/command_line.h" +#include "base/file_path.h" #include "base/platform_thread.h" #include "base/scoped_ptr.h" #include "base/win_util.h" #include "chrome/common/chrome_switches.h" #include "chrome/installer/util/install_util.h" #include "chrome/installer/util/util_constants.h" +#include "chrome/test/mini_installer_test/chrome_mini_installer.h" #include "chrome/test/mini_installer_test/mini_installer_test_constants.h" #include "chrome/test/mini_installer_test/mini_installer_test_util.h" #include "testing/gtest/include/gtest/gtest.h" -#include "chrome_mini_installer.h" // Although the C++ style guide disallows use of namespace directive, use // here because this is not only a .cc file, but also a test. @@ -22,76 +23,74 @@ using namespace mini_installer_constants; namespace { class MiniInstallTest : public testing::Test { - protected: - // Whether these tests should be run regardless of our running platform. - bool force_tests_; - - // Decided if ChromeFrame tests should be run. - bool chrome_frame_; - - // Installers created in test fixture setup for convenience. - scoped_ptr<ChromeMiniInstaller> user_inst_, sys_inst_; - - public: - - static void CleanTheSystem() { - const CommandLine* cmd = CommandLine::ForCurrentProcess(); - if (cmd->HasSwitch(installer_util::switches::kChromeFrame)) { - ChromeMiniInstaller systeminstall(kSystemInstall, - cmd->HasSwitch(installer_util::switches::kChromeFrame)); - systeminstall.UnInstall(); - } else { - ChromeMiniInstaller userinstall(kUserInstall, - cmd->HasSwitch(installer_util::switches::kChromeFrame)); - userinstall.UnInstall(); - ChromeMiniInstaller systeminstall(kSystemInstall, - cmd->HasSwitch(installer_util::switches::kChromeFrame)); - systeminstall.UnInstall(); - } + public: + MiniInstallTest() : force_tests_(false), chrome_frame_(false) {} + + static void CleanTheSystem() { + const CommandLine* cmd = CommandLine::ForCurrentProcess(); + if (cmd->HasSwitch(installer_util::switches::kChromeFrame)) { + ChromeMiniInstaller systeminstall(kSystemInstall, + cmd->HasSwitch(installer_util::switches::kChromeFrame)); + systeminstall.UnInstall(); + } else { + ChromeMiniInstaller userinstall(kUserInstall, + cmd->HasSwitch(installer_util::switches::kChromeFrame)); + userinstall.UnInstall(); + ChromeMiniInstaller systeminstall(kSystemInstall, + cmd->HasSwitch(installer_util::switches::kChromeFrame)); + systeminstall.UnInstall(); } - - virtual void SetUp() { - // Parse test command-line arguments. - const CommandLine* cmd = CommandLine::ForCurrentProcess(); - std::wstring build = - cmd->GetSwitchValueNative(switches::kInstallerTestBuild); - if (build.empty()) - build = L"latest"; - force_tests_ = cmd->HasSwitch(switches::kInstallerTestForce); - chrome_frame_ = cmd->HasSwitch(installer_util::switches::kChromeFrame); - if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA || - force_tests_) { - CleanTheSystem(); - // Separate the test output from cleaning output - printf("\nBEGIN test----------------------------------------\n"); - - // Create a few differently configured installers that are used in - // the tests, for convenience. - if (chrome_frame_) { - sys_inst_.reset(new ChromeMiniInstaller(kSystemInstall, - chrome_frame_)); - sys_inst_->SetBuildUnderTest(build); - } else { - user_inst_.reset(new ChromeMiniInstaller(kUserInstall, - chrome_frame_)); - user_inst_->SetBuildUnderTest(build); - sys_inst_.reset(new ChromeMiniInstaller(kSystemInstall, - chrome_frame_)); - sys_inst_->SetBuildUnderTest(build); - } - } else { - printf("These tests don't run on this platform.\n"); - exit(0); - } - } - - static void TearDownTestCase() { - // Uninstall Chrome from the system after tests are run. + } + + virtual void SetUp() { + // Parse test command-line arguments. + const CommandLine* cmd = CommandLine::ForCurrentProcess(); + std::wstring build = + cmd->GetSwitchValueNative(switches::kInstallerTestBuild); + if (build.empty()) + build = L"latest"; + force_tests_ = cmd->HasSwitch(switches::kInstallerTestForce); + chrome_frame_ = cmd->HasSwitch(installer_util::switches::kChromeFrame); + if (win_util::GetWinVersion() < win_util::WINVERSION_VISTA || + force_tests_) { CleanTheSystem(); + // Separate the test output from cleaning output + printf("\nBEGIN test----------------------------------------\n"); + + // Create a few differently configured installers that are used in + // the tests, for convenience. + user_inst_.reset(new ChromeMiniInstaller(kUserInstall, + chrome_frame_)); + sys_inst_.reset(new ChromeMiniInstaller(kSystemInstall, + chrome_frame_)); + sys_inst_->SetBuildUnderTest(build); + user_inst_->SetBuildUnderTest(build); + + } else { + printf("These tests don't run on this platform.\n"); + exit(0); } -}; + } + + static void TearDownTestCase() { + // Uninstall Chrome from the system after tests are run. + CleanTheSystem(); + } + + protected: + // Whether these tests should be run regardless of our running platform. + bool force_tests_; + + // Decided if ChromeFrame tests should be run. + bool chrome_frame_; + + // Installers created in test fixture setup for convenience. + scoped_ptr<ChromeMiniInstaller> user_inst_; + scoped_ptr<ChromeMiniInstaller> sys_inst_; }; +} // namespace + #if defined(GOOGLE_CHROME_BUILD) // Could use a parameterized gtest to slim down this list of tests, but since // these tests will often be run manually, don't want to have obscure test @@ -177,8 +176,7 @@ TEST_F(MiniInstallTest, InstallMiniInstallerSys) { } TEST_F(MiniInstallTest, InstallMiniInstallerUser) { - if (!chrome_frame_) - user_inst_->Install(); + user_inst_->Install(); } TEST_F(MiniInstallTest, MiniInstallTestValidWindowsVersion) { |