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

Unified Diff: base/linux_util_unittest.cc

Issue 1572042: GTK: Improve xfce detection. (Closed)
Patch Set: Add unit tests Created 10 years, 8 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 side-by-side diff with in-line comments
Download patch
« base/linux_util.cc ('K') | « base/linux_util.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/linux_util_unittest.cc
diff --git a/base/linux_util_unittest.cc b/base/linux_util_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..d904080742ee56461b2b56474c0e0dbda94cbd0c
--- /dev/null
+++ b/base/linux_util_unittest.cc
@@ -0,0 +1,69 @@
+// Copyright (c) 2010 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/linux_util.h"
+
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+#include "base/env_var.h"
+
+using ::testing::_;
+using ::testing::Return;
+using ::testing::SetArgumentPointee;
+using ::testing::StrEq;
+
+class MockEnvVarGetter : public base::EnvVarGetter {
+ public:
+ MOCK_METHOD2(GetEnv, bool(const char*, std::string* result));
Evan Martin 2010/04/15 19:31:00 Whoa, you just blew my mind.
+};
+
+namespace {
+
+const char* kGnome = "gnome";
+const char* kKDE4 = "kde4";
+const char* kKDE = "kde";
+const char* kXFCE = "xfce";
+
+} // namespace
+
+TEST(LinuxUtilTest, GetDesktopEnvironmentGnome) {
+ MockEnvVarGetter getter;
+ EXPECT_CALL(getter, GetEnv(_, _)).WillRepeatedly(Return(false));
+ EXPECT_CALL(getter, GetEnv(StrEq("DESKTOP_SESSION"), _))
+ .WillOnce(DoAll(SetArgumentPointee<1>(kGnome), Return(true)));
+
+ EXPECT_EQ(base::DESKTOP_ENVIRONMENT_GNOME,
+ base::GetDesktopEnvironment(&getter));
+}
+
+TEST(LinuxUtilTest, GetDesktopEnvironmentKDE4) {
+ MockEnvVarGetter getter;
+ EXPECT_CALL(getter, GetEnv(_, _)).WillRepeatedly(Return(false));
+ EXPECT_CALL(getter, GetEnv(StrEq("DESKTOP_SESSION"), _))
+ .WillOnce(DoAll(SetArgumentPointee<1>(kKDE4), Return(true)));
+
+ EXPECT_EQ(base::DESKTOP_ENVIRONMENT_KDE4,
+ base::GetDesktopEnvironment(&getter));
+}
+
+TEST(LinuxUtilTest, GetDesktopEnvironmentKDE3) {
+ MockEnvVarGetter getter;
+ EXPECT_CALL(getter, GetEnv(_, _)).WillRepeatedly(Return(false));
+ EXPECT_CALL(getter, GetEnv(StrEq("DESKTOP_SESSION"), _))
+ .WillOnce(DoAll(SetArgumentPointee<1>(kKDE), Return(true)));
+
+ EXPECT_EQ(base::DESKTOP_ENVIRONMENT_KDE3,
+ base::GetDesktopEnvironment(&getter));
+}
+
+TEST(LinuxUtilTest, GetDesktopEnvironmentXFCE) {
+ MockEnvVarGetter getter;
+ EXPECT_CALL(getter, GetEnv(_, _)).WillRepeatedly(Return(false));
+ EXPECT_CALL(getter, GetEnv(StrEq("DESKTOP_SESSION"), _))
+ .WillOnce(DoAll(SetArgumentPointee<1>(kXFCE), Return(true)));
+
+ EXPECT_EQ(base::DESKTOP_ENVIRONMENT_XFCE,
+ base::GetDesktopEnvironment(&getter));
+}
« base/linux_util.cc ('K') | « base/linux_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698