| OLD | NEW |
| 1 // Copyright (c) 2011 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/files/file_path.h" | 5 #include "base/files/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 |
| 12 class PolicyPathParserTests : public testing::Test { | 12 class PolicyPathParserTests : public testing::Test { |
| 13 protected: | 13 protected: |
| 14 void CheckForSubstitution(base::FilePath::StringType test_string, | 14 void CheckForSubstitution(base::FilePath::StringType test_string, |
| 15 base::FilePath::StringType var_name) { | 15 base::FilePath::StringType var_name) { |
| 16 base::FilePath::StringType var(test_string); | 16 base::FilePath::StringType var(test_string); |
| 17 base::FilePath::StringType var_result = | 17 base::FilePath::StringType var_result = |
| 18 path_parser::ExpandPathVariables(var); | 18 path_parser::ExpandPathVariables(var); |
| 19 ASSERT_EQ(var_result.find(var_name), base::FilePath::StringType::npos); | 19 ASSERT_EQ(var_result.find(var_name), base::FilePath::StringType::npos); |
| 20 } | 20 } |
| 21 }; | 21 }; |
| 22 | 22 |
| 23 // TODO(pastarmovj): Modify test or change the logic after investigating why it | 23 // TODO(pastarmovj): Modify test or change the logic after investigating why it |
| 24 // is flaky. Please only redisable after it has had a chance to run for a few | 24 // is flaky. Please only redisable after it has had a chance to run for a few |
| 25 // times. See bug http://crbug.com/327520 for context. | 25 // times. See bug http://crbug.com/327520 for context. |
| 26 TEST_F(PolicyPathParserTests, AllPlatformVariables) { | 26 // TODO(pastarmovj): Disabling on Mac OS X as the test is flaky. See |
| 27 // crbug.com/458590 for details. |
| 28 #if defined(OS_MACOSX) |
| 29 #define MAYBE_AllPlatformVariables DISABLED_AllPlatformVariables |
| 30 #else |
| 31 #define MAYBE_AllPlatformVariables AllPlatformVariables |
| 32 #endif |
| 33 TEST_F(PolicyPathParserTests, MAYBE_AllPlatformVariables) { |
| 27 // No vars whatsoever no substitution should occur. | 34 // No vars whatsoever no substitution should occur. |
| 28 base::FilePath::StringType no_vars(FILE_PATH_LITERAL("//$C/shares")); | 35 base::FilePath::StringType no_vars(FILE_PATH_LITERAL("//$C/shares")); |
| 29 base::FilePath::StringType no_vars_result = | 36 base::FilePath::StringType no_vars_result = |
| 30 path_parser::ExpandPathVariables(no_vars); | 37 path_parser::ExpandPathVariables(no_vars); |
| 31 ASSERT_EQ(no_vars_result, no_vars); | 38 ASSERT_EQ(no_vars_result, no_vars); |
| 32 | 39 |
| 33 // This is unknown variable and shouldn't be substituted. | 40 // This is unknown variable and shouldn't be substituted. |
| 34 base::FilePath::StringType unknown_vars(FILE_PATH_LITERAL("//$C/${buggy}")); | 41 base::FilePath::StringType unknown_vars(FILE_PATH_LITERAL("//$C/${buggy}")); |
| 35 base::FilePath::StringType unknown_vars_result = | 42 base::FilePath::StringType unknown_vars_result = |
| 36 path_parser::ExpandPathVariables(unknown_vars); | 43 path_parser::ExpandPathVariables(unknown_vars); |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 FILE_PATH_LITERAL("${windows}")); | 114 FILE_PATH_LITERAL("${windows}")); |
| 108 CheckForSubstitution(FILE_PATH_LITERAL("//$C/${client_name}"), | 115 CheckForSubstitution(FILE_PATH_LITERAL("//$C/${client_name}"), |
| 109 FILE_PATH_LITERAL("${client_name}")); | 116 FILE_PATH_LITERAL("${client_name}")); |
| 110 CheckForSubstitution(FILE_PATH_LITERAL("//$C/${session_name}"), | 117 CheckForSubstitution(FILE_PATH_LITERAL("//$C/${session_name}"), |
| 111 FILE_PATH_LITERAL("${session_name}")); | 118 FILE_PATH_LITERAL("${session_name}")); |
| 112 } | 119 } |
| 113 | 120 |
| 114 #endif // OS_WIN | 121 #endif // OS_WIN |
| 115 | 122 |
| 116 } // namespace policy | 123 } // namespace policy |
| OLD | NEW |