OLD | NEW |
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 "chrome/browser/shell_integration.h" | 5 #include "chrome/browser/shell_integration.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 | 8 |
9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
(...skipping 14 matching lines...) Expand all Loading... |
25 #endif // defined(OS_LINUX) | 25 #endif // defined(OS_LINUX) |
26 | 26 |
27 #define FPL FILE_PATH_LITERAL | 27 #define FPL FILE_PATH_LITERAL |
28 | 28 |
29 #if defined(OS_LINUX) | 29 #if defined(OS_LINUX) |
30 namespace { | 30 namespace { |
31 | 31 |
32 // Provides mock environment variables values based on a stored map. | 32 // Provides mock environment variables values based on a stored map. |
33 class MockEnvVarGetter : public base::EnvVarGetter { | 33 class MockEnvVarGetter : public base::EnvVarGetter { |
34 public: | 34 public: |
35 MockEnvVarGetter() { | 35 MockEnvVarGetter() {} |
36 } | |
37 | 36 |
38 void Set(const std::string& name, const std::string& value) { | 37 void Set(const std::string& name, const std::string& value) { |
39 variables_[name] = value; | 38 variables_[name] = value; |
40 } | 39 } |
41 | 40 |
42 virtual bool GetEnv(const char* variable_name, std::string* result) { | 41 virtual bool GetEnv(const char* variable_name, std::string* result) { |
43 if (ContainsKey(variables_, variable_name)) { | 42 if (ContainsKey(variables_, variable_name)) { |
44 *result = variables_[variable_name]; | 43 *result = variables_[variable_name]; |
45 return true; | 44 return true; |
46 } | 45 } |
47 | 46 |
48 return false; | 47 return false; |
49 } | 48 } |
50 | 49 |
51 virtual bool SetEnv(const char* variable_name, const std::string& new_value) { | 50 virtual bool SetEnv(const char* variable_name, const std::string& new_value) { |
52 NOTIMPLEMENTED(); | 51 ADD_FAILURE(); |
53 return false; | 52 return false; |
54 } | 53 } |
55 | 54 |
| 55 virtual bool UnSetEnv(const char* variable_name) { |
| 56 ADD_FAILURE(); |
| 57 return false; |
| 58 } |
| 59 |
56 private: | 60 private: |
57 std::map<std::string, std::string> variables_; | 61 std::map<std::string, std::string> variables_; |
58 | 62 |
59 DISALLOW_COPY_AND_ASSIGN(MockEnvVarGetter); | 63 DISALLOW_COPY_AND_ASSIGN(MockEnvVarGetter); |
60 }; | 64 }; |
61 | 65 |
62 } // namespace | 66 } // namespace |
63 | 67 |
64 TEST(ShellIntegrationTest, GetDesktopShortcutTemplate) { | 68 TEST(ShellIntegrationTest, GetDesktopShortcutTemplate) { |
65 #if defined(GOOGLE_CHROME_BUILD) | 69 #if defined(GOOGLE_CHROME_BUILD) |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
305 // Non-default profile path should get chrome::kBrowserAppID joined with | 309 // Non-default profile path should get chrome::kBrowserAppID joined with |
306 // profile info. | 310 // profile info. |
307 FilePath profile_path(FILE_PATH_LITERAL("root")); | 311 FilePath profile_path(FILE_PATH_LITERAL("root")); |
308 profile_path = profile_path.Append(FILE_PATH_LITERAL("udd")); | 312 profile_path = profile_path.Append(FILE_PATH_LITERAL("udd")); |
309 profile_path = profile_path.Append(FILE_PATH_LITERAL("User Data - Test")); | 313 profile_path = profile_path.Append(FILE_PATH_LITERAL("User Data - Test")); |
310 EXPECT_EQ(BrowserDistribution::GetDistribution()->GetBrowserAppId() + | 314 EXPECT_EQ(BrowserDistribution::GetDistribution()->GetBrowserAppId() + |
311 L".udd.UserDataTest", | 315 L".udd.UserDataTest", |
312 ShellIntegration::GetChromiumAppId(profile_path)); | 316 ShellIntegration::GetChromiumAppId(profile_path)); |
313 } | 317 } |
314 #endif | 318 #endif |
OLD | NEW |