Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: chrome/browser/chromeos/arc/arc_policy_bridge_unittest.cc

Issue 1869783006: Revert of Pass policy VideoCaptureAllowed to ARC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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>
7 6
8 #include "base/macros.h" 7 #include "base/macros.h"
9 #include "base/values.h" 8 #include "base/values.h"
10 #include "chrome/browser/chromeos/arc/arc_policy_bridge.h" 9 #include "chrome/browser/chromeos/arc/arc_policy_bridge.h"
11 #include "components/arc/test/fake_arc_bridge_service.h" 10 #include "components/arc/test/fake_arc_bridge_service.h"
12 #include "components/policy/core/common/mock_policy_service.h" 11 #include "components/policy/core/common/mock_policy_service.h"
13 #include "components/policy/core/common/policy_map.h" 12 #include "components/policy/core/common/policy_map.h"
14 #include "components/policy/core/common/policy_namespace.h" 13 #include "components/policy/core/common/policy_namespace.h"
15 #include "components/policy/core/common/policy_types.h" 14 #include "components/policy/core/common/policy_types.h"
16 #include "mojo/public/cpp/bindings/string.h" 15 #include "mojo/public/cpp/bindings/string.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 61
63 private: 62 private:
64 std::unique_ptr<arc::FakeArcBridgeService> bridge_service_; 63 std::unique_ptr<arc::FakeArcBridgeService> bridge_service_;
65 std::unique_ptr<arc::ArcPolicyBridge> policy_bridge_; 64 std::unique_ptr<arc::ArcPolicyBridge> policy_bridge_;
66 policy::PolicyMap policy_map_; 65 policy::PolicyMap policy_map_;
67 policy::MockPolicyService policy_service_; 66 policy::MockPolicyService policy_service_;
68 67
69 DISALLOW_COPY_AND_ASSIGN(ArcPolicyBridgeTest); 68 DISALLOW_COPY_AND_ASSIGN(ArcPolicyBridgeTest);
70 }; 69 };
71 70
72 TEST_F(ArcPolicyBridgeTest, EmptyPolicyTest) { 71 TEST_F(ArcPolicyBridgeTest, GetPoliciesTest) {
73 // No policy is set, result should be empty. 72 PolicyStringCallback empty_callback("{}");
74 policy_bridge()->GetPolicies(PolicyStringCallback("{}")); 73 policy_bridge()->GetPolicies(empty_callback);
75 } 74 policy_map().Set("HomepageLocation", policy::POLICY_LEVEL_MANDATORY,
76 75 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
77 TEST_F(ArcPolicyBridgeTest, ArcApplicationPolicyTest) { 76 new base::StringValue("http://chromium.org"), nullptr);
77 policy_bridge()->GetPolicies(empty_callback);
78 policy_map().Set( 78 policy_map().Set(
79 "ArcApplicationPolicy", policy::POLICY_LEVEL_MANDATORY, 79 "ArcApplicationPolicy", policy::POLICY_LEVEL_MANDATORY,
80 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, 80 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
81 new base::StringValue( 81 new base::StringValue("{\"application\": \"com.android.chrome\"}"),
82 "{\"applications\":"
83 "[{\"packageName\":\"com.google.android.apps.youtube.kids\","
84 "\"installType\":\"REQUIRED\","
85 "\"lockTaskAllowed\":false,"
86 "\"permissionGrants\":[]"
87 "}],"
88 "\"defaultPermissionPolicy\":\"GRANT\""
89 "}"),
90 nullptr); 82 nullptr);
91 policy_bridge()->GetPolicies(PolicyStringCallback( 83 PolicyStringCallback chrome_callback(
92 "{\"applications\":" 84 "{\"ArcApplicationPolicy\":"
93 "[{\"installType\":\"REQUIRED\"," 85 "\"{\\\"application\\\": \\\"com.android.chrome\\\"}\"}");
94 "\"lockTaskAllowed\":false," 86 policy_bridge()->GetPolicies(chrome_callback);
95 "\"packageName\":\"com.google.android.apps.youtube.kids\","
96 "\"permissionGrants\":[]"
97 "}],"
98 "\"defaultPermissionPolicy\":\"GRANT\""
99 "}"));
100 }
101
102 TEST_F(ArcPolicyBridgeTest, HompageLocationTest) {
103 // This policy will not be passed on, result should be empty.
104 policy_map().Set("HomepageLocation", policy::POLICY_LEVEL_MANDATORY,
105 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
106 new base::StringValue("http://chromium.org"), nullptr);
107 policy_bridge()->GetPolicies(PolicyStringCallback("{}"));
108 }
109
110 TEST_F(ArcPolicyBridgeTest, VideoCaptureAllowedTest) {
111 policy_map().Set("VideoCaptureAllowed", policy::POLICY_LEVEL_MANDATORY,
112 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
113 new base::FundamentalValue(false), nullptr);
114 policy_bridge()->GetPolicies(
115 PolicyStringCallback("{\"cameraDisabled\":true}"));
116 }
117
118 TEST_F(ArcPolicyBridgeTest, AllPoliciesTest) {
119 // Keep them in alphabetical order.
120 policy_map().Set(
121 "ArcApplicationPolicy", policy::POLICY_LEVEL_MANDATORY,
122 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
123 new base::StringValue("{\"applications\":"
124 "[{\"packageName\":\"com.google.android.apps.youtube.kids\","
125 "\"installType\":\"REQUIRED\","
126 "\"lockTaskAllowed\":false,"
127 "\"permissionGrants\":[]"
128 "}],"
129 "\"defaultPermissionPolicy\":\"GRANT\"}"),
130 nullptr);
131 policy_map().Set("HomepageLocation", policy::POLICY_LEVEL_MANDATORY,
132 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
133 new base::StringValue("http://chromium.org"), nullptr);
134 policy_map().Set("VideoCaptureAllowed", policy::POLICY_LEVEL_MANDATORY,
135 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
136 new base::FundamentalValue(false), nullptr);
137 policy_bridge()->GetPolicies(PolicyStringCallback(
138 "{\"applications\":"
139 "[{\"installType\":\"REQUIRED\","
140 "\"lockTaskAllowed\":false,"
141 "\"packageName\":\"com.google.android.apps.youtube.kids\","
142 "\"permissionGrants\":[]"
143 "}],"
144 "\"cameraDisabled\":true,"
145 "\"defaultPermissionPolicy\":\"GRANT\""
146 "}"));
147 } 87 }
148 88
149 } // namespace arc 89 } // namespace arc
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/arc/arc_policy_bridge.cc ('k') | components/policy/resources/policy_templates.json » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698