Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / chrome / installer / mini_installer / configuration_test.cc
blob27a3d80fc02191fce6feaeb9cb427a982bdfb7c3
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/installer/mini_installer/configuration.h"
7 #include <stdlib.h>
9 #include "base/basictypes.h"
10 #include "chrome/installer/mini_installer/appid.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 using mini_installer::Configuration;
15 class TestConfiguration : public Configuration {
16 public:
17 explicit TestConfiguration(const wchar_t* command_line) : Configuration() {
18 Initialize(command_line);
20 private:
21 void Initialize(const wchar_t* command_line) {
22 Clear();
23 ASSERT_TRUE(ParseCommandLine(command_line));
27 // Test that the operation type is CLEANUP iff --cleanup is on the cmdline.
28 TEST(MiniInstallerConfigurationTest, Operation) {
29 EXPECT_EQ(Configuration::INSTALL_PRODUCT,
30 TestConfiguration(L"spam.exe").operation());
31 EXPECT_EQ(Configuration::INSTALL_PRODUCT,
32 TestConfiguration(L"spam.exe --clean").operation());
33 EXPECT_EQ(Configuration::INSTALL_PRODUCT,
34 TestConfiguration(L"spam.exe --cleanupthis").operation());
36 EXPECT_EQ(Configuration::CLEANUP,
37 TestConfiguration(L"spam.exe --cleanup").operation());
38 EXPECT_EQ(Configuration::CLEANUP,
39 TestConfiguration(L"spam.exe --cleanup now").operation());
42 TEST(MiniInstallerConfigurationTest, Program) {
43 EXPECT_TRUE(NULL == mini_installer::Configuration().program());
44 EXPECT_TRUE(std::wstring(L"spam.exe") ==
45 TestConfiguration(L"spam.exe").program());
46 EXPECT_TRUE(std::wstring(L"spam.exe") ==
47 TestConfiguration(L"spam.exe --with args").program());
48 EXPECT_TRUE(std::wstring(L"c:\\blaz\\spam.exe") ==
49 TestConfiguration(L"c:\\blaz\\spam.exe --with args").program());
52 TEST(MiniInstallerConfigurationTest, ArgumentCount) {
53 EXPECT_EQ(1, TestConfiguration(L"spam.exe").argument_count());
54 EXPECT_EQ(2, TestConfiguration(L"spam.exe --foo").argument_count());
55 EXPECT_EQ(3, TestConfiguration(L"spam.exe --foo --bar").argument_count());
58 TEST(MiniInstallerConfigurationTest, CommandLine) {
59 static const wchar_t* const kCommandLines[] = {
60 L"",
61 L"spam.exe",
62 L"spam.exe --foo",
64 for (size_t i = 0; i < _countof(kCommandLines); ++i) {
65 EXPECT_TRUE(std::wstring(kCommandLines[i]) ==
66 TestConfiguration(kCommandLines[i]).command_line());
70 TEST(MiniInstallerConfigurationTest, ChromeAppGuid) {
71 EXPECT_TRUE(std::wstring(google_update::kAppGuid) ==
72 TestConfiguration(L"spam.exe").chrome_app_guid());
73 EXPECT_TRUE(std::wstring(google_update::kAppGuid) ==
74 TestConfiguration(L"spam.exe --chrome").chrome_app_guid());
75 EXPECT_TRUE(std::wstring(google_update::kAppGuid) ==
76 TestConfiguration(L"spam.exe --multi-install --chrome")
77 .chrome_app_guid());
78 EXPECT_TRUE(std::wstring(google_update::kAppGuid) ==
79 TestConfiguration(L"spam.exe --chrome-frame").chrome_app_guid());
80 EXPECT_TRUE(std::wstring(google_update::kSxSAppGuid) ==
81 TestConfiguration(L"spam.exe --chrome-sxs").chrome_app_guid());
84 TEST(MiniInstallerConfigurationTest, HasChrome) {
85 EXPECT_TRUE(TestConfiguration(L"spam.exe").has_chrome());
86 EXPECT_TRUE(TestConfiguration(L"spam.exe --chrome").has_chrome());
87 EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install --chrome")
88 .has_chrome());
89 EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome-frame").has_chrome());
90 EXPECT_FALSE(TestConfiguration(L"spam.exe --multi-install").has_chrome());
93 TEST(MiniInstallerConfigurationTest, HasChromeFrame) {
94 EXPECT_FALSE(TestConfiguration(L"spam.exe").has_chrome_frame());
95 EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome").has_chrome_frame());
96 EXPECT_FALSE(TestConfiguration(L"spam.exe --multi-install --chrome")
97 .has_chrome_frame());
98 EXPECT_TRUE(TestConfiguration(L"spam.exe --chrome-frame").has_chrome_frame());
99 EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install --chrome-frame")
100 .has_chrome_frame());
101 EXPECT_FALSE(TestConfiguration(L"spam.exe --multi-install")
102 .has_chrome_frame());
105 TEST(MiniInstallerConfigurationTest, IsMultiInstall) {
106 EXPECT_FALSE(TestConfiguration(L"spam.exe").is_multi_install());
107 EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome").is_multi_install());
108 EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install --chrome")
109 .is_multi_install());
110 EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome-frame")
111 .is_multi_install());
112 EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install --chrome-frame")
113 .is_multi_install());
114 EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install")
115 .is_multi_install());
118 TEST(MiniInstallerConfigurationTest, IsSystemLevel) {
119 EXPECT_FALSE(TestConfiguration(L"spam.exe").is_system_level());
120 EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome").is_system_level());
121 EXPECT_TRUE(TestConfiguration(L"spam.exe --system-level").is_system_level());