Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(149)

Side by Side Diff: chrome/installer/mini_installer/configuration_test.cc

Issue 1285473002: Revert of Return Windows error code when create-process fails. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/installer/mini_installer/configuration.h" 5 #include "chrome/installer/mini_installer/configuration.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "chrome/installer/mini_installer/appid.h" 10 #include "chrome/installer/mini_installer/appid.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 using mini_installer::Configuration; 13 using mini_installer::Configuration;
14 14
15 class TestConfiguration : public Configuration { 15 class TestConfiguration : public Configuration {
16 public: 16 public:
17 explicit TestConfiguration(const wchar_t* command_line) : Configuration() { 17 explicit TestConfiguration(const wchar_t* command_line) : Configuration() {
18 Initialize(command_line); 18 Initialize(command_line);
19 } 19 }
20 explicit TestConfiguration(const wchar_t* command_line,
21 LONG ret, const wchar_t* value)
22 : Configuration(),
23 open_registry_key_result_(true),
24 read_registry_value_result_(ret),
25 read_registry_value_(value) {
26 Initialize(command_line);
27 }
28 void SetRegistryResults(bool openkey, LONG ret, const wchar_t* value) {
29 }
30 private: 20 private:
31 bool open_registry_key_result_;
32 LONG read_registry_value_result_;
33 const wchar_t* read_registry_value_ = L"";
34
35 void Initialize(const wchar_t* command_line) { 21 void Initialize(const wchar_t* command_line) {
36 Clear(); 22 Clear();
37 ASSERT_TRUE(ParseCommandLine(command_line)); 23 ASSERT_TRUE(ParseCommandLine(command_line));
38 } 24 }
39 bool ReadClientStateRegistryValue(
40 const HKEY root_key, const wchar_t* app_guid,
41 LONG* retval, ValueString& value) override {
42 *retval = read_registry_value_result_;
43 value.assign(read_registry_value_);
44 return open_registry_key_result_;
45 }
46 }; 25 };
47 26
48 // Test that the operation type is CLEANUP iff --cleanup is on the cmdline. 27 // Test that the operation type is CLEANUP iff --cleanup is on the cmdline.
49 TEST(MiniInstallerConfigurationTest, Operation) { 28 TEST(MiniInstallerConfigurationTest, Operation) {
50 EXPECT_EQ(Configuration::INSTALL_PRODUCT, 29 EXPECT_EQ(Configuration::INSTALL_PRODUCT,
51 TestConfiguration(L"spam.exe").operation()); 30 TestConfiguration(L"spam.exe").operation());
52 EXPECT_EQ(Configuration::INSTALL_PRODUCT, 31 EXPECT_EQ(Configuration::INSTALL_PRODUCT,
53 TestConfiguration(L"spam.exe --clean").operation()); 32 TestConfiguration(L"spam.exe --clean").operation());
54 EXPECT_EQ(Configuration::INSTALL_PRODUCT, 33 EXPECT_EQ(Configuration::INSTALL_PRODUCT,
55 TestConfiguration(L"spam.exe --cleanupthis").operation()); 34 TestConfiguration(L"spam.exe --cleanupthis").operation());
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 TestConfiguration(kCommandLines[i]).command_line()); 66 TestConfiguration(kCommandLines[i]).command_line());
88 } 67 }
89 } 68 }
90 69
91 TEST(MiniInstallerConfigurationTest, ChromeAppGuid) { 70 TEST(MiniInstallerConfigurationTest, ChromeAppGuid) {
92 EXPECT_TRUE(std::wstring(google_update::kAppGuid) == 71 EXPECT_TRUE(std::wstring(google_update::kAppGuid) ==
93 TestConfiguration(L"spam.exe").chrome_app_guid()); 72 TestConfiguration(L"spam.exe").chrome_app_guid());
94 EXPECT_TRUE(std::wstring(google_update::kAppGuid) == 73 EXPECT_TRUE(std::wstring(google_update::kAppGuid) ==
95 TestConfiguration(L"spam.exe --chrome").chrome_app_guid()); 74 TestConfiguration(L"spam.exe --chrome").chrome_app_guid());
96 EXPECT_TRUE(std::wstring(google_update::kAppGuid) == 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) ==
97 TestConfiguration(L"spam.exe --chrome-frame").chrome_app_guid()); 79 TestConfiguration(L"spam.exe --chrome-frame").chrome_app_guid());
98 EXPECT_TRUE(std::wstring(google_update::kSxSAppGuid) == 80 EXPECT_TRUE(std::wstring(google_update::kSxSAppGuid) ==
99 TestConfiguration(L"spam.exe --chrome-sxs").chrome_app_guid()); 81 TestConfiguration(L"spam.exe --chrome-sxs").chrome_app_guid());
100 EXPECT_TRUE(std::wstring(google_update::kMultiInstallAppGuid) ==
101 TestConfiguration(L"spam.exe --multi-install --chrome")
102 .chrome_app_guid());
103 EXPECT_TRUE(std::wstring(google_update::kMultiInstallAppGuid) ==
104 TestConfiguration(L"spam.exe --multi-install --chrome",
105 ERROR_INVALID_FUNCTION, L"")
106 .chrome_app_guid());
107 EXPECT_TRUE(std::wstring(google_update::kAppGuid) ==
108 TestConfiguration(L"spam.exe --multi-install --chrome",
109 ERROR_FILE_NOT_FOUND, L"")
110 .chrome_app_guid());
111 EXPECT_TRUE(std::wstring(google_update::kAppGuid) ==
112 TestConfiguration(L"spam.exe --multi-install --chrome",
113 ERROR_SUCCESS, L"foo-bar")
114 .chrome_app_guid());
115 EXPECT_TRUE(std::wstring(google_update::kMultiInstallAppGuid) ==
116 TestConfiguration(L"spam.exe --multi-install --chrome",
117 ERROR_SUCCESS, L"foo-multi")
118 .chrome_app_guid());
119 } 82 }
120 83
121 TEST(MiniInstallerConfigurationTest, HasChrome) { 84 TEST(MiniInstallerConfigurationTest, HasChrome) {
122 EXPECT_TRUE(TestConfiguration(L"spam.exe").has_chrome()); 85 EXPECT_TRUE(TestConfiguration(L"spam.exe").has_chrome());
123 EXPECT_TRUE(TestConfiguration(L"spam.exe --chrome").has_chrome()); 86 EXPECT_TRUE(TestConfiguration(L"spam.exe --chrome").has_chrome());
124 EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install --chrome") 87 EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install --chrome")
125 .has_chrome()); 88 .has_chrome());
126 EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome-frame").has_chrome()); 89 EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome-frame").has_chrome());
127 EXPECT_FALSE(TestConfiguration(L"spam.exe --multi-install").has_chrome()); 90 EXPECT_FALSE(TestConfiguration(L"spam.exe --multi-install").has_chrome());
128 } 91 }
(...skipping 21 matching lines...) Expand all
150 .is_multi_install()); 113 .is_multi_install());
151 EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install") 114 EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install")
152 .is_multi_install()); 115 .is_multi_install());
153 } 116 }
154 117
155 TEST(MiniInstallerConfigurationTest, IsSystemLevel) { 118 TEST(MiniInstallerConfigurationTest, IsSystemLevel) {
156 EXPECT_FALSE(TestConfiguration(L"spam.exe").is_system_level()); 119 EXPECT_FALSE(TestConfiguration(L"spam.exe").is_system_level());
157 EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome").is_system_level()); 120 EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome").is_system_level());
158 EXPECT_TRUE(TestConfiguration(L"spam.exe --system-level").is_system_level()); 121 EXPECT_TRUE(TestConfiguration(L"spam.exe --system-level").is_system_level());
159 } 122 }
OLDNEW
« no previous file with comments | « chrome/installer/mini_installer/configuration.cc ('k') | chrome/installer/mini_installer/mini_installer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698