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 <algorithm> | 5 #include <algorithm> |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "chrome/browser/policy/config_dir_policy_provider.h" | 10 #include "chrome/browser/policy/config_dir_policy_provider.h" |
11 #include "chrome/browser/policy/configuration_policy_pref_store.h" | 11 #include "chrome/browser/policy/configuration_policy_pref_store.h" |
12 #include "chrome/browser/policy/mock_configuration_policy_store.h" | 12 #include "chrome/browser/policy/mock_configuration_policy_store.h" |
13 #include "chrome/common/json_value_serializer.h" | 13 #include "chrome/common/json_value_serializer.h" |
14 #include "chrome/common/policy_constants.h" | 14 #include "chrome/common/policy_constants.h" |
15 #include "testing/gmock/include/gmock/gmock.h" | 15 #include "testing/gmock/include/gmock/gmock.h" |
16 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
17 | 17 |
18 using testing::Mock; | 18 using testing::Mock; |
19 | 19 |
20 namespace policy { | 20 namespace policy { |
21 | 21 |
22 // Shorter reload intervals for testing PolicyDirWatcher. | 22 // Shorter reload intervals for testing PolicyDirWatcher. |
23 const int kSettleIntervalSecondsForTesting = 0; | 23 const int kSettleIntervalSecondsForTesting = 0; |
24 const int kReloadIntervalMinutesForTesting = 1; | 24 const int kReloadIntervalMinutesForTesting = 1; |
25 | 25 |
26 template<typename BASE> | 26 template<typename BASE> |
27 class ConfigDirPolicyProviderTestBase : public BASE { | 27 class ConfigDirPolicyProviderTestBase : public BASE { |
28 protected: | 28 protected: |
29 ConfigDirPolicyProviderTestBase() | 29 ConfigDirPolicyProviderTestBase() |
30 : ui_thread_(ChromeThread::UI, &loop_), | 30 : ui_thread_(BrowserThread::UI, &loop_), |
31 file_thread_(ChromeThread::FILE, &loop_) {} | 31 file_thread_(BrowserThread::FILE, &loop_) {} |
32 | 32 |
33 virtual void SetUp() { | 33 virtual void SetUp() { |
34 // Determine the directory to use for testing. | 34 // Determine the directory to use for testing. |
35 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); | 35 ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &test_dir_)); |
36 test_dir_ = | 36 test_dir_ = |
37 test_dir_.Append(FILE_PATH_LITERAL("ConfigDirPolicyProviderTest")); | 37 test_dir_.Append(FILE_PATH_LITERAL("ConfigDirPolicyProviderTest")); |
38 | 38 |
39 // Make sure the directory is fresh. | 39 // Make sure the directory is fresh. |
40 file_util::Delete(test_dir_, true); | 40 file_util::Delete(test_dir_, true); |
41 file_util::CreateDirectory(test_dir_); | 41 file_util::CreateDirectory(test_dir_); |
(...skipping 12 matching lines...) Expand all Loading... |
54 const std::string& file_name) { | 54 const std::string& file_name) { |
55 std::string data; | 55 std::string data; |
56 JSONStringValueSerializer serializer(&data); | 56 JSONStringValueSerializer serializer(&data); |
57 serializer.Serialize(dict); | 57 serializer.Serialize(dict); |
58 FilePath file_path(test_dir_.AppendASCII(file_name)); | 58 FilePath file_path(test_dir_.AppendASCII(file_name)); |
59 ASSERT_TRUE(file_util::WriteFile(file_path, data.c_str(), data.size())); | 59 ASSERT_TRUE(file_util::WriteFile(file_path, data.c_str(), data.size())); |
60 } | 60 } |
61 | 61 |
62 FilePath test_dir_; | 62 FilePath test_dir_; |
63 MessageLoop loop_; | 63 MessageLoop loop_; |
64 ChromeThread ui_thread_; | 64 BrowserThread ui_thread_; |
65 ChromeThread file_thread_; | 65 BrowserThread file_thread_; |
66 }; | 66 }; |
67 | 67 |
68 // A mock provider that allows us to capture reload notifications. | 68 // A mock provider that allows us to capture reload notifications. |
69 class MockConfigDirPolicyProvider : public ConfigDirPolicyProvider { | 69 class MockConfigDirPolicyProvider : public ConfigDirPolicyProvider { |
70 public: | 70 public: |
71 explicit MockConfigDirPolicyProvider(const FilePath& config_dir_) | 71 explicit MockConfigDirPolicyProvider(const FilePath& config_dir_) |
72 : ConfigDirPolicyProvider( | 72 : ConfigDirPolicyProvider( |
73 ConfigurationPolicyPrefStore::GetChromePolicyValueMap(), | 73 ConfigurationPolicyPrefStore::GetChromePolicyValueMap(), |
74 config_dir_) { | 74 config_dir_) { |
75 } | 75 } |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 ConfigurationPolicyStore::kPolicyExtensionInstallDenyList, | 422 ConfigurationPolicyStore::kPolicyExtensionInstallDenyList, |
423 key::kExtensionInstallDenyList), | 423 key::kExtensionInstallDenyList), |
424 ValueTestParams::ForBooleanPolicy( | 424 ValueTestParams::ForBooleanPolicy( |
425 ConfigurationPolicyStore::kPolicyShowHomeButton, | 425 ConfigurationPolicyStore::kPolicyShowHomeButton, |
426 key::kShowHomeButton), | 426 key::kShowHomeButton), |
427 ValueTestParams::ForBooleanPolicy( | 427 ValueTestParams::ForBooleanPolicy( |
428 ConfigurationPolicyStore::kPolicyPrintingEnabled, | 428 ConfigurationPolicyStore::kPolicyPrintingEnabled, |
429 key::kPrintingEnabled))); | 429 key::kPrintingEnabled))); |
430 | 430 |
431 } // namespace policy | 431 } // namespace policy |
OLD | NEW |