| 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/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
| 10 #include "base/message_loop/message_loop.h" | 10 #include "base/message_loop/message_loop.h" |
| 11 #include "base/values.h" | 11 #include "base/values.h" |
| 12 #include "chrome/browser/chromeos/arc/policy/arc_policy_bridge.h" | 12 #include "chrome/browser/chromeos/arc/policy/arc_policy_bridge.h" |
| 13 #include "components/arc/test/fake_arc_bridge_service.h" | 13 #include "components/arc/test/fake_arc_bridge_service.h" |
| 14 #include "components/arc/test/fake_policy_instance.h" | 14 #include "components/arc/test/fake_policy_instance.h" |
| 15 #include "components/policy/core/common/mock_policy_service.h" | 15 #include "components/policy/core/common/mock_policy_service.h" |
| 16 #include "components/policy/core/common/policy_map.h" | 16 #include "components/policy/core/common/policy_map.h" |
| 17 #include "components/policy/core/common/policy_namespace.h" | 17 #include "components/policy/core/common/policy_namespace.h" |
| 18 #include "components/policy/core/common/policy_types.h" | 18 #include "components/policy/core/common/policy_types.h" |
| 19 #include "components/policy/policy_constants.h" | 19 #include "components/policy/policy_constants.h" |
| 20 #include "mojo/public/cpp/bindings/string.h" | 20 #include "mojo/public/cpp/bindings/string.h" |
| 21 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
| 22 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
| 23 | 23 |
| 24 namespace { | 24 namespace { |
| 25 | 25 |
| 26 char kFakeONC[] = | 26 constexpr char kFakeONC[] = |
| 27 "{\"NetworkConfigurations\":[" | 27 "{\"NetworkConfigurations\":[" |
| 28 "{\"GUID\":\"{485d6076-dd44-6b6d-69787465725f5040}\"," | 28 "{\"GUID\":\"{485d6076-dd44-6b6d-69787465725f5040}\"," |
| 29 "\"Type\":\"WiFi\"," | 29 "\"Type\":\"WiFi\"," |
| 30 "\"Name\":\"My WiFi Network\"," | 30 "\"Name\":\"My WiFi Network\"," |
| 31 "\"WiFi\":{" | 31 "\"WiFi\":{" |
| 32 "\"HexSSID\":\"737369642D6E6F6E65\"," // "ssid-none" | 32 "\"HexSSID\":\"737369642D6E6F6E65\"," // "ssid-none" |
| 33 "\"Security\":\"None\"}" | 33 "\"Security\":\"None\"}" |
| 34 "}" | 34 "}" |
| 35 "]," | 35 "]," |
| 36 "\"GlobalNetworkConfiguration\":{" | 36 "\"GlobalNetworkConfiguration\":{" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 61 | 61 |
| 62 void set_value(bool value) { value_ = value; } | 62 void set_value(bool value) { value_ = value; } |
| 63 | 63 |
| 64 private: | 64 private: |
| 65 bool value_ = false; | 65 bool value_ = false; |
| 66 | 66 |
| 67 DISALLOW_COPY_AND_ASSIGN(CheckedBoolean); | 67 DISALLOW_COPY_AND_ASSIGN(CheckedBoolean); |
| 68 }; | 68 }; |
| 69 | 69 |
| 70 void ExpectPolicyString(std::unique_ptr<CheckedBoolean> was_run, | 70 void ExpectPolicyString(std::unique_ptr<CheckedBoolean> was_run, |
| 71 mojo::String expected, | 71 const std::string& expected, |
| 72 mojo::String policies) { | 72 const std::string& policies) { |
| 73 EXPECT_EQ(expected, policies); | 73 EXPECT_EQ(expected, policies); |
| 74 was_run->set_value(true); | 74 was_run->set_value(true); |
| 75 } | 75 } |
| 76 | 76 |
| 77 arc::ArcPolicyBridge::GetPoliciesCallback PolicyStringCallback( | 77 arc::ArcPolicyBridge::GetPoliciesCallback PolicyStringCallback( |
| 78 mojo::String expected) { | 78 const std::string& expected) { |
| 79 std::unique_ptr<CheckedBoolean> was_run(new CheckedBoolean); | 79 std::unique_ptr<CheckedBoolean> was_run(new CheckedBoolean()); |
| 80 return base::Bind(&ExpectPolicyString, base::Passed(&was_run), | 80 return base::Bind(&ExpectPolicyString, base::Passed(&was_run), expected); |
| 81 base::Passed(&expected)); | |
| 82 } | 81 } |
| 83 | 82 |
| 84 } // namespace | 83 } // namespace |
| 85 | 84 |
| 86 using testing::_; | 85 using testing::_; |
| 87 using testing::ReturnRef; | 86 using testing::ReturnRef; |
| 88 | 87 |
| 89 namespace arc { | 88 namespace arc { |
| 90 | 89 |
| 91 class ArcPolicyBridgeTest : public testing::Test { | 90 class ArcPolicyBridgeTest : public testing::Test { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 TEST_F(ArcPolicyBridgeTest, PolicyInstanceUnmanagedTest) { | 337 TEST_F(ArcPolicyBridgeTest, PolicyInstanceUnmanagedTest) { |
| 339 policy_bridge()->OverrideIsManagedForTesting(false); | 338 policy_bridge()->OverrideIsManagedForTesting(false); |
| 340 policy_instance()->CallGetPolicies(PolicyStringCallback("")); | 339 policy_instance()->CallGetPolicies(PolicyStringCallback("")); |
| 341 } | 340 } |
| 342 | 341 |
| 343 TEST_F(ArcPolicyBridgeTest, PolicyInstanceManagedTest) { | 342 TEST_F(ArcPolicyBridgeTest, PolicyInstanceManagedTest) { |
| 344 policy_instance()->CallGetPolicies(PolicyStringCallback("{}")); | 343 policy_instance()->CallGetPolicies(PolicyStringCallback("{}")); |
| 345 } | 344 } |
| 346 | 345 |
| 347 } // namespace arc | 346 } // namespace arc |
| OLD | NEW |