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

Side by Side Diff: base/nix/xdg_util_unittest.cc

Issue 632103004: Cleanup: Better constify some strings in base. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix bad refactoring Created 6 years, 2 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 | « base/metrics/field_trial_unittest.cc ('k') | base/prefs/overlay_user_pref_store_unittest.cc » ('j') | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "base/nix/xdg_util.h" 5 #include "base/nix/xdg_util.h"
6 6
7 #include "base/environment.h" 7 #include "base/environment.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 using ::testing::_; 11 using ::testing::_;
12 using ::testing::Return; 12 using ::testing::Return;
13 using ::testing::SetArgumentPointee; 13 using ::testing::SetArgumentPointee;
14 using ::testing::StrEq; 14 using ::testing::StrEq;
15 15
16 namespace base { 16 namespace base {
17 namespace nix { 17 namespace nix {
18 18
19 namespace { 19 namespace {
20 20
21 class MockEnvironment : public Environment { 21 class MockEnvironment : public Environment {
22 public: 22 public:
23 MOCK_METHOD2(GetVar, bool(const char*, std::string* result)); 23 MOCK_METHOD2(GetVar, bool(const char*, std::string* result));
24 MOCK_METHOD2(SetVar, bool(const char*, const std::string& new_value)); 24 MOCK_METHOD2(SetVar, bool(const char*, const std::string& new_value));
25 MOCK_METHOD1(UnSetVar, bool(const char*)); 25 MOCK_METHOD1(UnSetVar, bool(const char*));
26 }; 26 };
27 27
28 const char* kGnome = "gnome"; 28 const char* const kGnome = "gnome";
29 const char* kKDE4 = "kde4"; 29 const char* const kKDE4 = "kde4";
30 const char* kKDE = "kde"; 30 const char* const kKDE = "kde";
31 const char* kXFCE = "xfce"; 31 const char* const kXFCE = "xfce";
32 32
33 } // namespace 33 } // namespace
34 34
35 TEST(XDGUtilTest, GetDesktopEnvironmentGnome) { 35 TEST(XDGUtilTest, GetDesktopEnvironmentGnome) {
36 MockEnvironment getter; 36 MockEnvironment getter;
37 EXPECT_CALL(getter, GetVar(_, _)).WillRepeatedly(Return(false)); 37 EXPECT_CALL(getter, GetVar(_, _)).WillRepeatedly(Return(false));
38 EXPECT_CALL(getter, GetVar(StrEq("DESKTOP_SESSION"), _)) 38 EXPECT_CALL(getter, GetVar(StrEq("DESKTOP_SESSION"), _))
39 .WillOnce(DoAll(SetArgumentPointee<1>(kGnome), Return(true))); 39 .WillOnce(DoAll(SetArgumentPointee<1>(kGnome), Return(true)));
40 40
41 EXPECT_EQ(DESKTOP_ENVIRONMENT_GNOME, 41 EXPECT_EQ(DESKTOP_ENVIRONMENT_GNOME,
(...skipping 25 matching lines...) Expand all
67 EXPECT_CALL(getter, GetVar(_, _)).WillRepeatedly(Return(false)); 67 EXPECT_CALL(getter, GetVar(_, _)).WillRepeatedly(Return(false));
68 EXPECT_CALL(getter, GetVar(StrEq("DESKTOP_SESSION"), _)) 68 EXPECT_CALL(getter, GetVar(StrEq("DESKTOP_SESSION"), _))
69 .WillOnce(DoAll(SetArgumentPointee<1>(kXFCE), Return(true))); 69 .WillOnce(DoAll(SetArgumentPointee<1>(kXFCE), Return(true)));
70 70
71 EXPECT_EQ(DESKTOP_ENVIRONMENT_XFCE, 71 EXPECT_EQ(DESKTOP_ENVIRONMENT_XFCE,
72 GetDesktopEnvironment(&getter)); 72 GetDesktopEnvironment(&getter));
73 } 73 }
74 74
75 } // namespace nix 75 } // namespace nix
76 } // namespace base 76 } // namespace base
OLDNEW
« no previous file with comments | « base/metrics/field_trial_unittest.cc ('k') | base/prefs/overlay_user_pref_store_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698