summaryrefslogtreecommitdiffstats
path: root/chrome/test/mini_installer_test
diff options
context:
space:
mode:
authoranantha@chromium.org <anantha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-11 22:20:05 +0000
committeranantha@chromium.org <anantha@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-11 22:20:05 +0000
commit23bd81e08bf59f02ad164caa42ea1b18807c2420 (patch)
tree333f2520ccab2ef4b272ecd340ce4468597c0b57 /chrome/test/mini_installer_test
parente66385a4b5aea92cb535d29240b1e784b970513f (diff)
downloadchromium_src-23bd81e08bf59f02ad164caa42ea1b18807c2420.zip
chromium_src-23bd81e08bf59f02ad164caa42ea1b18807c2420.tar.gz
chromium_src-23bd81e08bf59f02ad164caa42ea1b18807c2420.tar.bz2
Added another command line option to run the tests after profile backup.
Also, Changed the hardcoded build labels (1.0, 2.0) to (2.0, 3.0). Review URL: http://codereview.chromium.org/118463 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@18214 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/test/mini_installer_test')
-rw-r--r--chrome/test/mini_installer_test/chrome_mini_installer.cc12
-rw-r--r--chrome/test/mini_installer_test/chrome_mini_installer.h12
-rw-r--r--chrome/test/mini_installer_test/mini_installer_test.vcproj2
-rw-r--r--chrome/test/mini_installer_test/mini_installer_test_constants.cc6
-rw-r--r--chrome/test/mini_installer_test/mini_installer_test_constants.h2
-rw-r--r--chrome/test/mini_installer_test/run_all_unittests.cc62
-rw-r--r--chrome/test/mini_installer_test/test.cc17
7 files changed, 83 insertions, 30 deletions
diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.cc b/chrome/test/mini_installer_test/chrome_mini_installer.cc
index 769875b..a7c2ed1 100644
--- a/chrome/test/mini_installer_test/chrome_mini_installer.cc
+++ b/chrome/test/mini_installer_test/chrome_mini_installer.cc
@@ -224,7 +224,7 @@ void ChromeMiniInstaller::OverInstall() {
// Handles uninstall confirm dialog.
// Waits until setup.exe ends.
// Checks if registry key exist even after uninstall.
-// Deletes App dir.
+// Deletes User Data dir.
// Closes feedback form.
void ChromeMiniInstaller::UnInstall() {
printf("\n\nVerifying if Chrome is installed...\n\n");
@@ -253,7 +253,7 @@ void ChromeMiniInstaller::UnInstall() {
mini_installer_constants::kChromeSetupExecutable);
printf("\n\nUninstall Checks:\n\n");
ASSERT_FALSE(CheckRegistryKeyOnUninstall(dist->GetVersionKey()));
- DeleteAppFolder();
+ DeleteUserDataFolder();
FindChromeShortcut();
CloseProcesses(mini_installer_constants::kIEExecutable);
ASSERT_EQ(0,
@@ -365,11 +365,12 @@ bool ChromeMiniInstaller::CheckRegistryKeyOnUninstall(
return CheckRegistryKey(key_path);
}
-// Deletes App folder after uninstall.
-void ChromeMiniInstaller::DeleteAppFolder() {
+// Deletes User data folder after uninstall.
+void ChromeMiniInstaller::DeleteUserDataFolder() {
std::wstring path = GetChromeInstallDirectoryLocation();
file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir);
file_util::UpOneDirectory(&path);
+ file_util::AppendToPath(&path, mini_installer_constants::kChromeUserDataDir);
printf("Deleting this path after uninstall%ls\n", path.c_str());
if (file_util::PathExists(path))
ASSERT_TRUE(file_util::Delete(path.c_str(), true));
@@ -468,7 +469,8 @@ bool ChromeMiniInstaller::GetInstaller(const wchar_t* pattern,
std::wstring chrome_diff_installer(
mini_installer_constants::kChromeDiffInstallerLocation);
chrome_diff_installer.append(L"*");
- if (!GetLatestFile(chrome_diff_installer.c_str(), build_channel_.c_str(), &list))
+ if (!GetLatestFile(chrome_diff_installer.c_str(),
+ build_channel_.c_str(), &list))
return false;
int list_size = (list.size())-1;
while (list_size > 0) {
diff --git a/chrome/test/mini_installer_test/chrome_mini_installer.h b/chrome/test/mini_installer_test/chrome_mini_installer.h
index 2c54ce6..e43c4f0 100644
--- a/chrome/test/mini_installer_test/chrome_mini_installer.h
+++ b/chrome/test/mini_installer_test/chrome_mini_installer.h
@@ -48,6 +48,10 @@ class ChromeMiniInstaller {
// Closes specified process.
void CloseProcesses(const std::wstring& executable_name);
+ // This method returns path to either program files
+ // or documents and setting based on the install type.
+ std::wstring GetChromeInstallDirectoryLocation();
+
// Installs the latest full installer.
void InstallFullInstaller(bool over_install);
@@ -104,16 +108,12 @@ class ChromeMiniInstaller {
// Checks for registry key on uninstall.
bool CheckRegistryKeyOnUninstall(const std::wstring& key_path);
- // Deletes App folder after uninstall.
- void DeleteAppFolder();
+ // Deletes User Data folder after uninstall.
+ void DeleteUserDataFolder();
// This method verifies Chrome shortcut.
void FindChromeShortcut();
- // This method returns path to either program files
- // or documents and setting based on the install type.
- std::wstring GetChromeInstallDirectoryLocation();
-
// This method will create a command line to run apply tag.
bool GetCommandForTagging(std::wstring *return_command);
diff --git a/chrome/test/mini_installer_test/mini_installer_test.vcproj b/chrome/test/mini_installer_test/mini_installer_test.vcproj
index e993140..82ef73f 100644
--- a/chrome/test/mini_installer_test/mini_installer_test.vcproj
+++ b/chrome/test/mini_installer_test/mini_installer_test.vcproj
@@ -159,7 +159,7 @@
>
</File>
<File
- RelativePath="..\..\installer\util\run_all_unittests.cc"
+ RelativePath=".\run_all_unittests.cc"
>
</File>
<File
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 3617b57..c76125b 100644
--- a/chrome/test/mini_installer_test/mini_installer_test_constants.cc
+++ b/chrome/test/mini_installer_test/mini_installer_test_constants.cc
@@ -26,6 +26,8 @@ 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 kChromeUserDataDir[] = L"User Data";
+const wchar_t kChromeUserDataBackupDir[] = L"User Data Copy";
const wchar_t kIEExecutable[] = L"iexplore.exe";
const wchar_t kInstallerWindow[] = L"Chrome Installer";
const wchar_t kSystemInstall[] = L"system";
@@ -35,8 +37,8 @@ const wchar_t kGoogleUpdateExecutable[] = L"GoogleUpdate.exe";
const wchar_t kUntaggedInstallerPattern[] = L"ChromeStandaloneSetup_";
const wchar_t kDiffInstallerPattern[] = L"_from_";
const wchar_t kFullInstallerPattern[] = L"_chrome_installer";
-const wchar_t kDevChannelBuild[] = L"2.0.";
-const wchar_t kStableChannelBuild[] = L"1.0.";
+const wchar_t kDevChannelBuild[] = L"3.0.";
+const wchar_t kStableChannelBuild[] = L"2.0.";
const wchar_t kFullInstall[] = L"Full";
const wchar_t kDiffInstall[] = L"Diff";
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 c312a69..61097c4 100644
--- a/chrome/test/mini_installer_test/mini_installer_test_constants.h
+++ b/chrome/test/mini_installer_test/mini_installer_test_constants.h
@@ -15,6 +15,8 @@ extern const wchar_t kChromeSetupExecutable[];
extern const wchar_t kChromeMiniInstallerExecutable[];
extern const wchar_t kChromeMetaInstallerExecutable[];
extern const wchar_t kGoogleUpdateExecutable[];
+extern const wchar_t kChromeUserDataDir[];
+extern const wchar_t kChromeUserDataBackupDir[];
extern const wchar_t kIEExecutable[];
// Window names.
diff --git a/chrome/test/mini_installer_test/run_all_unittests.cc b/chrome/test/mini_installer_test/run_all_unittests.cc
new file mode 100644
index 0000000..03ab03b
--- /dev/null
+++ b/chrome/test/mini_installer_test/run_all_unittests.cc
@@ -0,0 +1,62 @@
+// Copyright (c) 2006-2009 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/command_line.h"
+#include "base/file_util.h"
+#include "base/test_suite.h"
+#include "chrome/test/mini_installer_test/mini_installer_test_constants.h"
+#include "chrome_mini_installer.h"
+
+void BackUpProfile() {
+ if (base::GetProcessCount(L"chrome.exe", NULL) > 0) {
+ printf("Chrome is currently running and cannot backup the profile."
+ "Please close Chrome and run the tests again.\n");
+ exit(1);
+ }
+ ChromeMiniInstaller installer(mini_installer_constants::kUserInstall,
+ mini_installer_constants::kDevChannelBuild);
+ std::wstring path = installer.GetChromeInstallDirectoryLocation();
+ file_util::AppendToPath(&path, mini_installer_constants::kChromeAppDir);
+ file_util::UpOneDirectory(&path);
+ std::wstring backup_path = path;
+ // Will hold User Data path that needs to be backed-up.
+ file_util::AppendToPath(&path,
+ mini_installer_constants::kChromeUserDataDir);
+ // Will hold new backup path to save the profile.
+ file_util::AppendToPath(&backup_path,
+ mini_installer_constants::kChromeUserDataBackupDir);
+ // Will check if User Data profile is available.
+ if (file_util::PathExists(path)) {
+ // Will check if User Data is already backed up.
+ // If yes, will delete and create new one.
+ if (file_util::PathExists(backup_path))
+ file_util::Delete(backup_path.c_str(), true);
+ file_util::CopyDirectory(path, backup_path, true);
+ } else {
+ printf("Chrome is not installed. Will not take any backup\n");
+ }
+}
+
+int main(int argc, char** argv) {
+ // Check command line to decide if the tests should continue
+ // with cleaning the system or make a backup before continuing.
+ CommandLine::Init(argc, argv);
+ const CommandLine& command_line = *CommandLine::ForCurrentProcess();
+ if (command_line.HasSwitch(L"clean")) {
+ printf("Current version of Chrome will be uninstalled "
+ "from all levels before proceeding with tests.\n");
+ } else if (command_line.HasSwitch(L"backup")) {
+ BackUpProfile();
+ } else {
+ printf("This test needs command line Arguments.\n");
+ printf("Usage: mini_installer_tests.exe -{clean|backup}\n");
+ printf("Note: -clean arg will uninstall your chrome at all levels"
+ " and also delete profile.\n"
+ "-backup arg will make a copy of User Data before uninstalling"
+ " your chrome at all levels. The copy will be named as"
+ " User Data Copy.\n");
+ exit(1);
+ }
+ return TestSuite(argc, argv).Run();
+}
diff --git a/chrome/test/mini_installer_test/test.cc b/chrome/test/mini_installer_test/test.cc
index 09c7b66..2cd1661 100644
--- a/chrome/test/mini_installer_test/test.cc
+++ b/chrome/test/mini_installer_test/test.cc
@@ -1,7 +1,6 @@
// 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/command_line.h"
#include "base/platform_thread.h"
#include "base/win_util.h"
#include "chrome/installer/util/install_util.h"
@@ -13,20 +12,6 @@
namespace {
class MiniInstallTest : public testing::Test {
protected:
- void CheckArgs() {
- // Check command line to decide if the tests should continue
- // with cleaning the system.
- const CommandLine& command_line = *CommandLine::ForCurrentProcess();
- if (command_line.HasSwitch(L"clean")) {
- CleanTheSystem();
- } else {
- printf("This test needs command line Arguments.\n");
- printf("Usage: mini_installer_tests.exe -clean\n");
- printf("Note: -clean arg will uninstall your chrome at all levels"
- "and also delete profile.\n");
- exit(1);
- }
- }
void CleanTheSystem() {
ChromeMiniInstaller userinstall(mini_installer_constants::kUserInstall,
mini_installer_constants::kDevChannelBuild);
@@ -39,7 +24,7 @@ class MiniInstallTest : public testing::Test {
}
}
virtual void SetUp() {
- CheckArgs();
+ CleanTheSystem();
}
virtual void TearDown() {
PlatformThread::Sleep(2000);