diff options
Diffstat (limited to 'chrome/browser/policy/policy_path_parser_unittest.cc')
-rw-r--r-- | chrome/browser/policy/policy_path_parser_unittest.cc | 52 |
1 files changed, 45 insertions, 7 deletions
diff --git a/chrome/browser/policy/policy_path_parser_unittest.cc b/chrome/browser/policy/policy_path_parser_unittest.cc index 633ef78..f8e816e 100644 --- a/chrome/browser/policy/policy_path_parser_unittest.cc +++ b/chrome/browser/policy/policy_path_parser_unittest.cc @@ -20,13 +20,43 @@ class PolicyPathParserTests : public testing::Test { } }; -#if defined(OS_MACOSX) -// http://crbug.com/327520 -#define MAYBE_AllPlatformVariables DISABLED_AllPlatformVariables -#else -#define MAYBE_AllPlatformVariables AllPlatformVariables -#endif -TEST_F(PolicyPathParserTests, MAYBE_AllPlatformVariables) { +namespace path_parser { + +// The test needs access to a routine that is not exposed via the public header. +void ReplaceVariableInPathWithValue( + const base::FilePath::StringType& variable, + const policy::path_parser::internal::GetValueCallback& value_callback, + base::FilePath::StringType* path); + +} // namespace path_parser; + +bool GetBuggy(base::FilePath::StringType* value) { + *value = base::FilePath::StringType(FILE_PATH_LITERAL("ok")); + return true; +} + +TEST_F(PolicyPathParserTests, ReplaceVariableInPathWithValue) { + // This is custom variable with custom callback. It should replace ${buggy} + // with ok. + base::FilePath::StringType custom_vars(FILE_PATH_LITERAL("//$C/${buggy}")); + base::FilePath::StringType custom_vars_expected(FILE_PATH_LITERAL("//$C/ok")); + base::FilePath::StringType buggy(FILE_PATH_LITERAL("${buggy}")); + + path_parser::ReplaceVariableInPathWithValue( + buggy, base::Bind(&GetBuggy), &custom_vars); + ASSERT_EQ(custom_vars, custom_vars_expected); + + // There is no ${buggy} in input, so it should remain unchanged. + base::FilePath::StringType custom2_vars(FILE_PATH_LITERAL("//$C/ok")); + base::FilePath::StringType custom2_vars_expected( + FILE_PATH_LITERAL("//$C/ok")); + + path_parser::ReplaceVariableInPathWithValue( + buggy, base::Bind(&GetBuggy), &custom2_vars); + ASSERT_EQ(custom2_vars, custom2_vars_expected); +} + +TEST_F(PolicyPathParserTests, CommonExpandPathVariables) { // No vars whatsoever no substitution should occur. base::FilePath::StringType no_vars(FILE_PATH_LITERAL("//$C/shares")); base::FilePath::StringType no_vars_result = @@ -50,7 +80,15 @@ TEST_F(PolicyPathParserTests, MAYBE_AllPlatformVariables) { ASSERT_EQ(quotes_result, no_quotes); quotes_result = path_parser::ExpandPathVariables(double_quotes); ASSERT_EQ(quotes_result, no_quotes); +} +#if defined(OS_MACOSX) +// http://crbug.com/327520 +#define MAYBE_AllPlatformVariables DISABLED_AllPlatformVariables +#else +#define MAYBE_AllPlatformVariables AllPlatformVariables +#endif +TEST_F(PolicyPathParserTests, MAYBE_AllPlatformVariables) { // Both should have been substituted. base::FilePath::StringType vars( FILE_PATH_LITERAL("${user_name}${machine_name}")); |