blob: 9f2dc9f2b3323791ac1f988587b7eb8186e6744c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright (c) 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/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);
FilePath path =
FilePath::FromWStringHack(installer.GetChromeInstallDirectoryLocation());
path = path.Append(mini_installer_constants::kChromeAppDir).DirName();
FilePath backup_path = path;
// Will hold User Data path that needs to be backed-up.
path = path.Append(mini_installer_constants::kChromeUserDataDir);
// Will hold new backup path to save the profile.
backup_path = path.Append(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, 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("clean")) {
printf("Current version of Chrome will be uninstalled "
"from all levels before proceeding with tests.\n");
} else if (command_line.HasSwitch("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();
}
|