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

Unified Diff: chrome/browser/policy/policy_path_parser_unittest.cc

Issue 214233003: Refactorise the policy_path_parser framework (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixes the review comments Created 6 years, 9 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
Index: chrome/browser/policy/policy_path_parser_unittest.cc
diff --git a/chrome/browser/policy/policy_path_parser_unittest.cc b/chrome/browser/policy/policy_path_parser_unittest.cc
index 633ef785d9c7ce3e082027a7401fdacde3c254dd..8fec18957de5df41b9d71c8e322a548c87ff4565 100644
--- a/chrome/browser/policy/policy_path_parser_unittest.cc
+++ b/chrome/browser/policy/policy_path_parser_unittest.cc
@@ -20,13 +20,41 @@ 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::GetValueFuncPtr& value_func_ptr,
+ 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, &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, &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 +78,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}"));

Powered by Google App Engine
This is Rietveld 408576698