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

Unified Diff: chrome/installer/mini_installer/configuration_test.cc

Issue 2595863002: Fix system-level detection in the mini_installer. (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/installer/mini_installer/configuration.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/mini_installer/configuration_test.cc
diff --git a/chrome/installer/mini_installer/configuration_test.cc b/chrome/installer/mini_installer/configuration_test.cc
index cd38950f408ecb78132d7a6afb8f5ccea432ab71..9844a9faceb9d848c6369d10d5734d41ccd59995 100644
--- a/chrome/installer/mini_installer/configuration_test.cc
+++ b/chrome/installer/mini_installer/configuration_test.cc
@@ -7,11 +7,34 @@
#include <stddef.h>
#include <stdlib.h>
+#include <memory>
+
+#include "base/environment.h"
#include "chrome/installer/mini_installer/appid.h"
#include "testing/gtest/include/gtest/gtest.h"
using mini_installer::Configuration;
+namespace {
+
+// A helper class to set the "GoogleUpdateIsMachine" environment variable.
+class ScopedGoogleUpdateIsMachine {
+ public:
+ explicit ScopedGoogleUpdateIsMachine(bool value)
+ : env_(base::Environment::Create()) {
+ env_->SetVar("GoogleUpdateIsMachine", value ? "1" : "0");
+ }
+
+ ~ScopedGoogleUpdateIsMachine() {
+ env_->UnSetVar("GoogleUpdateIsMachine");
+ }
+
+ private:
+ std::unique_ptr<base::Environment> env_;
+};
+
+} // namespace
+
class TestConfiguration : public Configuration {
public:
explicit TestConfiguration(const wchar_t* command_line)
@@ -160,4 +183,14 @@ 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());
+
+ {
+ ScopedGoogleUpdateIsMachine env_setter(false);
+ EXPECT_FALSE(TestConfiguration(L"spam.exe").is_system_level());
+ }
+
+ {
+ ScopedGoogleUpdateIsMachine env_setter(true);
+ EXPECT_TRUE(TestConfiguration(L"spam.exe").is_system_level());
+ }
}
« 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