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

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

Issue 1864523002: Pass policy VideoCaptureAllowed to ARC (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove/add include<string> 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>
6 7
7 #include "base/macros.h" 8 #include "base/macros.h"
8 #include "base/values.h" 9 #include "base/values.h"
9 #include "chrome/browser/chromeos/arc/arc_policy_bridge.h" 10 #include "chrome/browser/chromeos/arc/arc_policy_bridge.h"
10 #include "components/arc/test/fake_arc_bridge_service.h" 11 #include "components/arc/test/fake_arc_bridge_service.h"
11 #include "components/policy/core/common/mock_policy_service.h" 12 #include "components/policy/core/common/mock_policy_service.h"
12 #include "components/policy/core/common/policy_map.h" 13 #include "components/policy/core/common/policy_map.h"
13 #include "components/policy/core/common/policy_namespace.h" 14 #include "components/policy/core/common/policy_namespace.h"
14 #include "components/policy/core/common/policy_types.h" 15 #include "components/policy/core/common/policy_types.h"
15 #include "mojo/public/cpp/bindings/string.h" 16 #include "mojo/public/cpp/bindings/string.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 62
62 private: 63 private:
63 std::unique_ptr<arc::FakeArcBridgeService> bridge_service_; 64 std::unique_ptr<arc::FakeArcBridgeService> bridge_service_;
64 std::unique_ptr<arc::ArcPolicyBridge> policy_bridge_; 65 std::unique_ptr<arc::ArcPolicyBridge> policy_bridge_;
65 policy::PolicyMap policy_map_; 66 policy::PolicyMap policy_map_;
66 policy::MockPolicyService policy_service_; 67 policy::MockPolicyService policy_service_;
67 68
68 DISALLOW_COPY_AND_ASSIGN(ArcPolicyBridgeTest); 69 DISALLOW_COPY_AND_ASSIGN(ArcPolicyBridgeTest);
69 }; 70 };
70 71
71 TEST_F(ArcPolicyBridgeTest, GetPoliciesTest) { 72 TEST_F(ArcPolicyBridgeTest, EmptyPolicyTest) {
72 PolicyStringCallback empty_callback("{}"); 73 // No policy is set, result should be empty.
73 policy_bridge()->GetPolicies(empty_callback); 74 policy_bridge()->GetPolicies(PolicyStringCallback("{}"));
74 policy_map().Set("HomepageLocation", policy::POLICY_LEVEL_MANDATORY, 75 }
75 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD, 76
76 new base::StringValue("http://chromium.org"), nullptr); 77 TEST_F(ArcPolicyBridgeTest, ArcApplicationPolicyTest) {
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("{\"application\": \"com.android.chrome\"}"), 81 new base::StringValue("{\"application\": \"com.android.chrome\"}"),
82 nullptr); 82 nullptr);
83 PolicyStringCallback chrome_callback( 83 policy_bridge()->GetPolicies(PolicyStringCallback(
84 "{\"ArcApplicationPolicy\":" 84 "{\"ArcApplicationPolicy\":"
85 "\"{\\\"application\\\": \\\"com.android.chrome\\\"}\"}"); 85 "\"{\\\"application\\\": \\\"com.android.chrome\\\"}\"}"));
86 policy_bridge()->GetPolicies(chrome_callback); 86 }
87
88 TEST_F(ArcPolicyBridgeTest, HompageLocationTest) {
89 // This policy will not be passed on, result should be empty.
90 policy_map().Set("HomepageLocation", policy::POLICY_LEVEL_MANDATORY,
91 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
92 new base::StringValue("http://chromium.org"), nullptr);
93 policy_bridge()->GetPolicies(PolicyStringCallback("{}"));
94 }
95
96 TEST_F(ArcPolicyBridgeTest, VideoCaptureAllowedTest) {
97 policy_map().Set("VideoCaptureAllowed", policy::POLICY_LEVEL_MANDATORY,
98 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
99 new base::FundamentalValue(false), nullptr);
100 policy_bridge()->GetPolicies(
101 PolicyStringCallback("{\"VideoCaptureAllowed\":false}"));
102 }
103
104 TEST_F(ArcPolicyBridgeTest, AllPoliciesTest) {
105 // Keep them in alphabetical order.
106 policy_map().Set(
107 "ArcApplicationPolicy", policy::POLICY_LEVEL_MANDATORY,
108 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
109 new base::StringValue("{\"application\": \"com.android.chrome\"}"),
110 nullptr);
111 policy_map().Set("HomepageLocation", policy::POLICY_LEVEL_MANDATORY,
112 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
113 new base::StringValue("http://chromium.org"), nullptr);
114 policy_map().Set("VideoCaptureAllowed", policy::POLICY_LEVEL_MANDATORY,
115 policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
116 new base::FundamentalValue(false), nullptr);
117 policy_bridge()->GetPolicies(PolicyStringCallback(
118 "{"
119 "\"ArcApplicationPolicy\":"
120 "\"{\\\"application\\\": \\\"com.android.chrome\\\"}\","
121 "\"VideoCaptureAllowed\":false"
122 "}"));
87 } 123 }
88 124
89 } // namespace arc 125 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698