OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/policy/user_policy_cache.h" | 5 #include "chrome/browser/policy/user_policy_cache.h" |
6 | 6 |
7 #include <limits> | 7 #include <limits> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| 11 #include "base/files/scoped_temp_dir.h" |
11 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
12 #include "base/scoped_temp_dir.h" | |
13 #include "base/values.h" | 13 #include "base/values.h" |
14 #include "chrome/browser/policy/proto/cloud_policy.pb.h" | 14 #include "chrome/browser/policy/proto/cloud_policy.pb.h" |
15 #include "chrome/browser/policy/proto/device_management_backend.pb.h" | 15 #include "chrome/browser/policy/proto/device_management_backend.pb.h" |
16 #include "chrome/browser/policy/proto/device_management_local.pb.h" | 16 #include "chrome/browser/policy/proto/device_management_local.pb.h" |
17 #include "chrome/browser/policy/proto/old_generic_format.pb.h" | 17 #include "chrome/browser/policy/proto/old_generic_format.pb.h" |
18 #include "content/public/test/test_browser_thread.h" | 18 #include "content/public/test/test_browser_thread.h" |
19 #include "policy/policy_constants.h" | 19 #include "policy/policy_constants.h" |
20 #include "testing/gmock/include/gmock/gmock.h" | 20 #include "testing/gmock/include/gmock/gmock.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 21 #include "testing/gtest/include/gtest/gtest.h" |
22 | 22 |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 } | 121 } |
122 | 122 |
123 FilePath test_file() { | 123 FilePath test_file() { |
124 return temp_dir_.path().AppendASCII("UserPolicyCacheTest"); | 124 return temp_dir_.path().AppendASCII("UserPolicyCacheTest"); |
125 } | 125 } |
126 | 126 |
127 MessageLoop loop_; | 127 MessageLoop loop_; |
128 MockCloudPolicyCacheBaseObserver observer_; | 128 MockCloudPolicyCacheBaseObserver observer_; |
129 | 129 |
130 private: | 130 private: |
131 ScopedTempDir temp_dir_; | 131 base::ScopedTempDir temp_dir_; |
132 content::TestBrowserThread ui_thread_; | 132 content::TestBrowserThread ui_thread_; |
133 content::TestBrowserThread file_thread_; | 133 content::TestBrowserThread file_thread_; |
134 }; | 134 }; |
135 | 135 |
136 TEST_F(UserPolicyCacheTest, DecodePolicy) { | 136 TEST_F(UserPolicyCacheTest, DecodePolicy) { |
137 em::CloudPolicySettings settings; | 137 em::CloudPolicySettings settings; |
138 settings.mutable_homepagelocation()->set_homepagelocation("chromium.org"); | 138 settings.mutable_homepagelocation()->set_homepagelocation("chromium.org"); |
139 settings.mutable_javascriptenabled()->set_javascriptenabled(true); | 139 settings.mutable_javascriptenabled()->set_javascriptenabled(true); |
140 settings.mutable_javascriptenabled()->mutable_policy_options()->set_mode( | 140 settings.mutable_javascriptenabled()->mutable_policy_options()->set_mode( |
141 em::PolicyOptions::MANDATORY); | 141 em::PolicyOptions::MANDATORY); |
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 UserPolicyCache cache(test_file(), true /* wait_for_policy_fetch */); | 444 UserPolicyCache cache(test_file(), true /* wait_for_policy_fetch */); |
445 EXPECT_FALSE(cache.IsReady()); | 445 EXPECT_FALSE(cache.IsReady()); |
446 cache.SetFetchingDone(); | 446 cache.SetFetchingDone(); |
447 EXPECT_FALSE(cache.IsReady()); | 447 EXPECT_FALSE(cache.IsReady()); |
448 cache.Load(); | 448 cache.Load(); |
449 loop_.RunAllPending(); | 449 loop_.RunAllPending(); |
450 EXPECT_TRUE(cache.IsReady()); | 450 EXPECT_TRUE(cache.IsReady()); |
451 } | 451 } |
452 | 452 |
453 } // namespace policy | 453 } // namespace policy |
OLD | NEW |