OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <memory> | 5 #include <memory> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "chrome/browser/chromeos/arc/arc_policy_bridge.h" | 10 #include "chrome/browser/chromeos/arc/arc_policy_bridge.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 using testing::ReturnRef; | 23 using testing::ReturnRef; |
24 | 24 |
25 class ArcPolicyBridgeTest : public testing::Test { | 25 class ArcPolicyBridgeTest : public testing::Test { |
26 public: | 26 public: |
27 ArcPolicyBridgeTest() {} | 27 ArcPolicyBridgeTest() {} |
28 | 28 |
29 void SetUp() override { | 29 void SetUp() override { |
30 bridge_service_.reset(new FakeArcBridgeService()); | 30 bridge_service_.reset(new FakeArcBridgeService()); |
31 policy_bridge_.reset( | 31 policy_bridge_.reset( |
32 new ArcPolicyBridge(bridge_service_.get(), &policy_service_)); | 32 new ArcPolicyBridge(bridge_service_.get(), &policy_service_)); |
| 33 policy_bridge_->OverrideIsManagedForTesting(true); |
33 | 34 |
34 EXPECT_CALL(policy_service_, | 35 EXPECT_CALL(policy_service_, |
35 GetPolicies(policy::PolicyNamespace( | 36 GetPolicies(policy::PolicyNamespace( |
36 policy::POLICY_DOMAIN_CHROME, std::string()))) | 37 policy::POLICY_DOMAIN_CHROME, std::string()))) |
37 .WillRepeatedly(ReturnRef(policy_map_)); | 38 .WillRepeatedly(ReturnRef(policy_map_)); |
38 } | 39 } |
39 | 40 |
40 protected: | 41 protected: |
41 class PolicyStringRunnable | 42 class PolicyStringRunnable |
42 : public ArcPolicyBridge::GetPoliciesCallback::Runnable { | 43 : public ArcPolicyBridge::GetPoliciesCallback::Runnable { |
(...skipping 20 matching lines...) Expand all Loading... |
63 | 64 |
64 private: | 65 private: |
65 std::unique_ptr<arc::FakeArcBridgeService> bridge_service_; | 66 std::unique_ptr<arc::FakeArcBridgeService> bridge_service_; |
66 std::unique_ptr<arc::ArcPolicyBridge> policy_bridge_; | 67 std::unique_ptr<arc::ArcPolicyBridge> policy_bridge_; |
67 policy::PolicyMap policy_map_; | 68 policy::PolicyMap policy_map_; |
68 policy::MockPolicyService policy_service_; | 69 policy::MockPolicyService policy_service_; |
69 | 70 |
70 DISALLOW_COPY_AND_ASSIGN(ArcPolicyBridgeTest); | 71 DISALLOW_COPY_AND_ASSIGN(ArcPolicyBridgeTest); |
71 }; | 72 }; |
72 | 73 |
| 74 TEST_F(ArcPolicyBridgeTest, UnmanagedTest) { |
| 75 policy_bridge()->OverrideIsManagedForTesting(false); |
| 76 policy_bridge()->GetPolicies(PolicyStringCallback(nullptr)); |
| 77 } |
| 78 |
73 TEST_F(ArcPolicyBridgeTest, EmptyPolicyTest) { | 79 TEST_F(ArcPolicyBridgeTest, EmptyPolicyTest) { |
74 // No policy is set, result should be empty. | 80 // No policy is set, result should be empty. |
75 policy_bridge()->GetPolicies(PolicyStringCallback("{}")); | 81 policy_bridge()->GetPolicies(PolicyStringCallback("{}")); |
76 } | 82 } |
77 | 83 |
78 TEST_F(ArcPolicyBridgeTest, ArcPolicyTest) { | 84 TEST_F(ArcPolicyBridgeTest, ArcPolicyTest) { |
79 policy_map().Set( | 85 policy_map().Set( |
80 policy::key::kArcPolicy, policy::POLICY_LEVEL_MANDATORY, | 86 policy::key::kArcPolicy, policy::POLICY_LEVEL_MANDATORY, |
81 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, | 87 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, |
82 new base::StringValue( | 88 new base::StringValue( |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 "\"lockTaskAllowed\":false," | 220 "\"lockTaskAllowed\":false," |
215 "\"packageName\":\"com.google.android.apps.youtube.kids\"," | 221 "\"packageName\":\"com.google.android.apps.youtube.kids\"," |
216 "\"permissionGrants\":[]" | 222 "\"permissionGrants\":[]" |
217 "}]," | 223 "}]," |
218 "\"cameraDisabled\":true," | 224 "\"cameraDisabled\":true," |
219 "\"defaultPermissionPolicy\":\"GRANT\"" | 225 "\"defaultPermissionPolicy\":\"GRANT\"" |
220 "}")); | 226 "}")); |
221 } | 227 } |
222 | 228 |
223 } // namespace arc | 229 } // namespace arc |
OLD | NEW |