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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
// Copyright (c) 2011 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/basictypes.h"
#include "chrome/installer/mini_installer/appid.h"
#include "chrome/installer/mini_installer/configuration.h"
#include "testing/gtest/include/gtest/gtest.h"
using mini_installer::Configuration;
class TestConfiguration : public Configuration {
public:
explicit TestConfiguration(const wchar_t* command_line) : Configuration() {
Initialize(command_line);
}
private:
void Initialize(const wchar_t* command_line) {
ASSERT_TRUE(InitializeFromCommandLine(command_line));
}
};
// Test that the operation type is CLEANUP iff --cleanup is on the cmdline.
TEST(MiniInstallerConfigurationTest, Operation) {
EXPECT_EQ(Configuration::INSTALL_PRODUCT,
TestConfiguration(L"spam.exe").operation());
EXPECT_EQ(Configuration::INSTALL_PRODUCT,
TestConfiguration(L"spam.exe --clean").operation());
EXPECT_EQ(Configuration::INSTALL_PRODUCT,
TestConfiguration(L"spam.exe --cleanupthis").operation());
EXPECT_EQ(Configuration::CLEANUP,
TestConfiguration(L"spam.exe --cleanup").operation());
EXPECT_EQ(Configuration::CLEANUP,
TestConfiguration(L"spam.exe --cleanup now").operation());
}
TEST(MiniInstallerConfigurationTest, Program) {
EXPECT_TRUE(NULL == mini_installer::Configuration().program());
EXPECT_TRUE(std::wstring(L"spam.exe") ==
TestConfiguration(L"spam.exe").program());
EXPECT_TRUE(std::wstring(L"spam.exe") ==
TestConfiguration(L"spam.exe --with args").program());
EXPECT_TRUE(std::wstring(L"c:\\blaz\\spam.exe") ==
TestConfiguration(L"c:\\blaz\\spam.exe --with args").program());
}
TEST(MiniInstallerConfigurationTest, ArgumentCount) {
EXPECT_EQ(1, TestConfiguration(L"spam.exe").argument_count());
EXPECT_EQ(2, TestConfiguration(L"spam.exe --foo").argument_count());
EXPECT_EQ(3, TestConfiguration(L"spam.exe --foo --bar").argument_count());
}
TEST(MiniInstallerConfigurationTest, CommandLine) {
static const wchar_t* const kCommandLines[] = {
L"",
L"spam.exe",
L"spam.exe --foo",
};
for (size_t i = 0; i < arraysize(kCommandLines); ++i) {
EXPECT_TRUE(std::wstring(kCommandLines[i]) ==
TestConfiguration(kCommandLines[i]).command_line());
}
}
TEST(MiniInstallerConfigurationTest, ChromeAppGuid) {
EXPECT_TRUE(std::wstring(google_update::kAppGuid) ==
TestConfiguration(L"spam.exe").chrome_app_guid());
EXPECT_TRUE(std::wstring(google_update::kAppGuid) ==
TestConfiguration(L"spam.exe --chrome").chrome_app_guid());
EXPECT_TRUE(std::wstring(google_update::kAppGuid) ==
TestConfiguration(L"spam.exe --multi-install --chrome")
.chrome_app_guid());
EXPECT_TRUE(std::wstring(google_update::kAppGuid) ==
TestConfiguration(L"spam.exe --chrome-frame").chrome_app_guid());
EXPECT_TRUE(std::wstring(google_update::kSxSAppGuid) ==
TestConfiguration(L"spam.exe --chrome-sxs").chrome_app_guid());
}
TEST(MiniInstallerConfigurationTest, HasChrome) {
EXPECT_TRUE(TestConfiguration(L"spam.exe").has_chrome());
EXPECT_TRUE(TestConfiguration(L"spam.exe --chrome").has_chrome());
EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install --chrome")
.has_chrome());
EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome-frame").has_chrome());
EXPECT_FALSE(TestConfiguration(L"spam.exe --multi-install").has_chrome());
}
TEST(MiniInstallerConfigurationTest, HasChromeFrame) {
EXPECT_FALSE(TestConfiguration(L"spam.exe").has_chrome_frame());
EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome").has_chrome_frame());
EXPECT_FALSE(TestConfiguration(L"spam.exe --multi-install --chrome")
.has_chrome_frame());
EXPECT_TRUE(TestConfiguration(L"spam.exe --chrome-frame").has_chrome_frame());
EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install --chrome-frame")
.has_chrome_frame());
EXPECT_FALSE(TestConfiguration(L"spam.exe --multi-install")
.has_chrome_frame());
}
TEST(MiniInstallerConfigurationTest, IsMultiInstall) {
EXPECT_FALSE(TestConfiguration(L"spam.exe").is_multi_install());
EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome").is_multi_install());
EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install --chrome")
.is_multi_install());
EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome-frame")
.is_multi_install());
EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install --chrome-frame")
.is_multi_install());
EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install")
.is_multi_install());
}
TEST(MiniInstallerConfigurationTest, IsSystemLevel) {
EXPECT_FALSE(TestConfiguration(L"spam.exe").is_system_level());
EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome").is_system_level());
EXPECT_TRUE(TestConfiguration(L"spam.exe --system-level").is_system_level());
}
|