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

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

Issue 2595863002: Fix system-level detection in the mini_installer. (Closed)
Patch Set: Created 3 years, 12 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
« no previous file with comments | « chrome/installer/mini_installer/configuration.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 <stddef.h> 7 #include <stddef.h>
8 #include <stdlib.h> 8 #include <stdlib.h>
9 9
10 #include <memory>
11
12 #include "base/environment.h"
10 #include "chrome/installer/mini_installer/appid.h" 13 #include "chrome/installer/mini_installer/appid.h"
11 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
12 15
13 using mini_installer::Configuration; 16 using mini_installer::Configuration;
14 17
18 namespace {
19
20 // A helper class to set the "GoogleUpdateIsMachine" environment variable.
21 class ScopedGoogleUpdateIsMachine {
22 public:
23 explicit ScopedGoogleUpdateIsMachine(bool value)
24 : env_(base::Environment::Create()) {
25 env_->SetVar("GoogleUpdateIsMachine", value ? "1" : "0");
26 }
27
28 ~ScopedGoogleUpdateIsMachine() {
29 env_->UnSetVar("GoogleUpdateIsMachine");
30 }
31
32 private:
33 std::unique_ptr<base::Environment> env_;
34 };
35
36 } // namespace
37
15 class TestConfiguration : public Configuration { 38 class TestConfiguration : public Configuration {
16 public: 39 public:
17 explicit TestConfiguration(const wchar_t* command_line) 40 explicit TestConfiguration(const wchar_t* command_line)
18 : Configuration(), 41 : Configuration(),
19 open_registry_key_result_(false), 42 open_registry_key_result_(false),
20 read_registry_value_result_(0), 43 read_registry_value_result_(0),
21 read_registry_value_(L"") { 44 read_registry_value_(L"") {
22 Initialize(command_line); 45 Initialize(command_line);
23 } 46 }
24 explicit TestConfiguration(const wchar_t* command_line, 47 explicit TestConfiguration(const wchar_t* command_line,
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install --chrome-frame") 176 EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install --chrome-frame")
154 .is_multi_install()); 177 .is_multi_install());
155 EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install") 178 EXPECT_TRUE(TestConfiguration(L"spam.exe --multi-install")
156 .is_multi_install()); 179 .is_multi_install());
157 } 180 }
158 181
159 TEST(MiniInstallerConfigurationTest, IsSystemLevel) { 182 TEST(MiniInstallerConfigurationTest, IsSystemLevel) {
160 EXPECT_FALSE(TestConfiguration(L"spam.exe").is_system_level()); 183 EXPECT_FALSE(TestConfiguration(L"spam.exe").is_system_level());
161 EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome").is_system_level()); 184 EXPECT_FALSE(TestConfiguration(L"spam.exe --chrome").is_system_level());
162 EXPECT_TRUE(TestConfiguration(L"spam.exe --system-level").is_system_level()); 185 EXPECT_TRUE(TestConfiguration(L"spam.exe --system-level").is_system_level());
186
187 {
188 ScopedGoogleUpdateIsMachine env_setter(false);
189 EXPECT_FALSE(TestConfiguration(L"spam.exe").is_system_level());
190 }
191
192 {
193 ScopedGoogleUpdateIsMachine env_setter(true);
194 EXPECT_TRUE(TestConfiguration(L"spam.exe").is_system_level());
195 }
163 } 196 }
OLDNEW
« no previous file with comments | « chrome/installer/mini_installer/configuration.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698