OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/file_path.h> | 5 #include <base/file_path.h> |
6 #include <chrome/browser/policy/policy_path_parser.h> | 6 #include <chrome/browser/policy/policy_path_parser.h> |
7 | 7 |
8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
9 | 9 |
10 namespace policy { | 10 namespace policy { |
11 | 11 |
(...skipping 14 matching lines...) Expand all Loading... |
26 FilePath::StringType no_vars_result = | 26 FilePath::StringType no_vars_result = |
27 path_parser::ExpandPathVariables(no_vars); | 27 path_parser::ExpandPathVariables(no_vars); |
28 ASSERT_EQ(no_vars_result, no_vars); | 28 ASSERT_EQ(no_vars_result, no_vars); |
29 | 29 |
30 // This is unknown variable and shouldn't be substituted. | 30 // This is unknown variable and shouldn't be substituted. |
31 FilePath::StringType unknown_vars(FILE_PATH_LITERAL("//$C/${buggy}")); | 31 FilePath::StringType unknown_vars(FILE_PATH_LITERAL("//$C/${buggy}")); |
32 FilePath::StringType unknown_vars_result = | 32 FilePath::StringType unknown_vars_result = |
33 path_parser::ExpandPathVariables(unknown_vars); | 33 path_parser::ExpandPathVariables(unknown_vars); |
34 ASSERT_EQ(unknown_vars_result, unknown_vars); | 34 ASSERT_EQ(unknown_vars_result, unknown_vars); |
35 | 35 |
| 36 // Trim quotes around, but not inside paths. Test against bug 80211. |
| 37 FilePath::StringType no_quotes(FILE_PATH_LITERAL("//$C/\"a\"/$path")); |
| 38 FilePath::StringType single_quotes(FILE_PATH_LITERAL("'//$C/\"a\"/$path'")); |
| 39 FilePath::StringType double_quotes(FILE_PATH_LITERAL("\"//$C/\"a\"/$path\"")); |
| 40 FilePath::StringType quotes_result = |
| 41 path_parser::ExpandPathVariables(single_quotes); |
| 42 ASSERT_EQ(quotes_result, no_quotes); |
| 43 quotes_result = path_parser::ExpandPathVariables(double_quotes); |
| 44 ASSERT_EQ(quotes_result, no_quotes); |
| 45 |
36 // Both should have been substituted. | 46 // Both should have been substituted. |
37 FilePath::StringType vars(FILE_PATH_LITERAL("${user_name}${machine_name}")); | 47 FilePath::StringType vars(FILE_PATH_LITERAL("${user_name}${machine_name}")); |
38 FilePath::StringType vars_result = path_parser::ExpandPathVariables(vars); | 48 FilePath::StringType vars_result = path_parser::ExpandPathVariables(vars); |
39 ASSERT_EQ(vars_result.find(FILE_PATH_LITERAL("${user_name}")), | 49 ASSERT_EQ(vars_result.find(FILE_PATH_LITERAL("${user_name}")), |
40 FilePath::StringType::npos); | 50 FilePath::StringType::npos); |
41 ASSERT_EQ(vars_result.find(FILE_PATH_LITERAL("${machine_name}")), | 51 ASSERT_EQ(vars_result.find(FILE_PATH_LITERAL("${machine_name}")), |
42 FilePath::StringType::npos); | 52 FilePath::StringType::npos); |
43 | 53 |
44 // Should substitute only one instance. | 54 // Should substitute only one instance. |
45 vars = FILE_PATH_LITERAL("${machine_name}${machine_name}"); | 55 vars = FILE_PATH_LITERAL("${machine_name}${machine_name}"); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
86 FILE_PATH_LITERAL("${global_app_data}")); | 96 FILE_PATH_LITERAL("${global_app_data}")); |
87 CheckForSubstitution(FILE_PATH_LITERAL("//$C/${program_files}"), | 97 CheckForSubstitution(FILE_PATH_LITERAL("//$C/${program_files}"), |
88 FILE_PATH_LITERAL("${program_files}")); | 98 FILE_PATH_LITERAL("${program_files}")); |
89 CheckForSubstitution(FILE_PATH_LITERAL("//$C/${windows}"), | 99 CheckForSubstitution(FILE_PATH_LITERAL("//$C/${windows}"), |
90 FILE_PATH_LITERAL("${windows}")); | 100 FILE_PATH_LITERAL("${windows}")); |
91 } | 101 } |
92 | 102 |
93 #endif // OS_WIN | 103 #endif // OS_WIN |
94 | 104 |
95 } // namespace policy | 105 } // namespace policy |
OLD | NEW |