| Index: chrome/browser/chromeos/arc/arc_policy_bridge_unittest.cc
|
| diff --git a/chrome/browser/chromeos/arc/policy/arc_policy_bridge_unittest.cc b/chrome/browser/chromeos/arc/arc_policy_bridge_unittest.cc
|
| similarity index 80%
|
| copy from chrome/browser/chromeos/arc/policy/arc_policy_bridge_unittest.cc
|
| copy to chrome/browser/chromeos/arc/arc_policy_bridge_unittest.cc
|
| index 4aeadc0fbfcf181837bcffaba623b6bd8684c191..ee3daa8f6879459a04a04a8f26db792de91a8785 100644
|
| --- a/chrome/browser/chromeos/arc/policy/arc_policy_bridge_unittest.cc
|
| +++ b/chrome/browser/chromeos/arc/arc_policy_bridge_unittest.cc
|
| @@ -9,7 +9,7 @@
|
| #include "base/memory/ptr_util.h"
|
| #include "base/message_loop/message_loop.h"
|
| #include "base/values.h"
|
| -#include "chrome/browser/chromeos/arc/policy/arc_policy_bridge.h"
|
| +#include "chrome/browser/chromeos/arc/arc_policy_bridge.h"
|
| #include "components/arc/test/fake_arc_bridge_service.h"
|
| #include "components/arc/test/fake_policy_instance.h"
|
| #include "components/policy/core/common/mock_policy_service.h"
|
| @@ -23,7 +23,7 @@
|
|
|
| namespace {
|
|
|
| -constexpr char kFakeONC[] =
|
| +char kFakeONC[] =
|
| "{\"NetworkConfigurations\":["
|
| "{\"GUID\":\"{485d6076-dd44-6b6d-69787465725f5040}\","
|
| "\"Type\":\"WiFi\","
|
| @@ -51,10 +51,7 @@ constexpr char kFakeONC[] =
|
| "\"GUID\":\"{00f79111-51e0-e6e0-76b3b55450d80a1b}\"}"
|
| "]}";
|
|
|
| -constexpr char kPolicyCompliantResponse[] = "{ \"policyCompliant\": true }";
|
| -constexpr char kPolicyNonCompliantResponse[] = "{ \"policyCompliant\": false }";
|
| -
|
| -// Helper class to define callbacks that verify that they were run.
|
| +// Helper class to define a PolicyStringCallback which verifies that it was run.
|
| // Wraps a bool initially set to |false| and verifies that it's been set to
|
| // |true| before destruction.
|
| class CheckedBoolean {
|
| @@ -70,23 +67,18 @@ class CheckedBoolean {
|
| DISALLOW_COPY_AND_ASSIGN(CheckedBoolean);
|
| };
|
|
|
| -void ExpectString(std::unique_ptr<CheckedBoolean> was_run,
|
| - const std::string& expected,
|
| - const std::string& received) {
|
| - EXPECT_EQ(expected, received);
|
| +void ExpectPolicyString(std::unique_ptr<CheckedBoolean> was_run,
|
| + mojo::String expected,
|
| + mojo::String policies) {
|
| + EXPECT_EQ(expected, policies);
|
| was_run->set_value(true);
|
| }
|
|
|
| arc::ArcPolicyBridge::GetPoliciesCallback PolicyStringCallback(
|
| - const std::string& expected) {
|
| - std::unique_ptr<CheckedBoolean> was_run(new CheckedBoolean());
|
| - return base::Bind(&ExpectString, base::Passed(&was_run), expected);
|
| -}
|
| -
|
| -arc::ArcPolicyBridge::ReportComplianceCallback PolicyComplianceCallback(
|
| - const std::string& expected) {
|
| + mojo::String expected) {
|
| std::unique_ptr<CheckedBoolean> was_run(new CheckedBoolean);
|
| - return base::Bind(&ExpectString, base::Passed(&was_run), expected);
|
| + return base::Bind(&ExpectPolicyString, base::Passed(&was_run),
|
| + base::Passed(&expected));
|
| }
|
|
|
| } // namespace
|
| @@ -126,12 +118,12 @@ class ArcPolicyBridgeTest : public testing::Test {
|
| // Not an unused variable. Unit tests do not have a message loop by themselves
|
| // and mojo needs a message loop for communication.
|
| base::MessageLoop loop_;
|
| - std::unique_ptr<FakeArcBridgeService> bridge_service_;
|
| - std::unique_ptr<ArcPolicyBridge> policy_bridge_;
|
| + std::unique_ptr<arc::FakeArcBridgeService> bridge_service_;
|
| + std::unique_ptr<arc::ArcPolicyBridge> policy_bridge_;
|
| // Always keep policy_instance_ below bridge_service_, so that
|
| // policy_instance_ is destructed first. It needs to remove itself as
|
| // observer.
|
| - std::unique_ptr<FakePolicyInstance> policy_instance_;
|
| + std::unique_ptr<arc::FakePolicyInstance> policy_instance_;
|
| policy::PolicyMap policy_map_;
|
| policy::MockPolicyService policy_service_;
|
|
|
| @@ -186,7 +178,7 @@ TEST_F(ArcPolicyBridgeTest, DisableScreenshotsTest) {
|
| policy_map().Set(policy::key::kDisableScreenshots,
|
| policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
|
| policy::POLICY_SOURCE_CLOUD,
|
| - base::MakeUnique<base::FundamentalValue>(true), nullptr);
|
| + base::MakeUnique<base::Value>(true), nullptr);
|
| policy_bridge()->GetPolicies(
|
| PolicyStringCallback("{\"screenCaptureDisabled\":true}"));
|
| }
|
| @@ -195,7 +187,7 @@ TEST_F(ArcPolicyBridgeTest, VideoCaptureAllowedTest) {
|
| policy_map().Set(policy::key::kVideoCaptureAllowed,
|
| policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
|
| policy::POLICY_SOURCE_CLOUD,
|
| - base::MakeUnique<base::FundamentalValue>(false), nullptr);
|
| + base::MakeUnique<base::Value>(false), nullptr);
|
| policy_bridge()->GetPolicies(
|
| PolicyStringCallback("{\"cameraDisabled\":true}"));
|
| }
|
| @@ -204,7 +196,7 @@ TEST_F(ArcPolicyBridgeTest, AudioCaptureAllowedTest) {
|
| policy_map().Set(policy::key::kAudioCaptureAllowed,
|
| policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
|
| policy::POLICY_SOURCE_CLOUD,
|
| - base::MakeUnique<base::FundamentalValue>(false), nullptr);
|
| + base::MakeUnique<base::Value>(false), nullptr);
|
| policy_bridge()->GetPolicies(
|
| PolicyStringCallback("{\"unmuteMicrophoneDisabled\":true}"));
|
| }
|
| @@ -213,19 +205,19 @@ TEST_F(ArcPolicyBridgeTest, DefaultGeolocationSettingTest) {
|
| policy_map().Set(policy::key::kDefaultGeolocationSetting,
|
| policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
|
| policy::POLICY_SOURCE_CLOUD,
|
| - base::MakeUnique<base::FundamentalValue>(1), nullptr);
|
| + base::MakeUnique<base::Value>(1), nullptr);
|
| policy_bridge()->GetPolicies(
|
| PolicyStringCallback("{\"shareLocationDisabled\":false}"));
|
| policy_map().Set(policy::key::kDefaultGeolocationSetting,
|
| policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
|
| policy::POLICY_SOURCE_CLOUD,
|
| - base::MakeUnique<base::FundamentalValue>(2), nullptr);
|
| + base::MakeUnique<base::Value>(2), nullptr);
|
| policy_bridge()->GetPolicies(
|
| PolicyStringCallback("{\"shareLocationDisabled\":true}"));
|
| policy_map().Set(policy::key::kDefaultGeolocationSetting,
|
| policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
|
| policy::POLICY_SOURCE_CLOUD,
|
| - base::MakeUnique<base::FundamentalValue>(3), nullptr);
|
| + base::MakeUnique<base::Value>(3), nullptr);
|
| policy_bridge()->GetPolicies(
|
| PolicyStringCallback("{\"shareLocationDisabled\":false}"));
|
| }
|
| @@ -234,15 +226,15 @@ TEST_F(ArcPolicyBridgeTest, ExternalStorageDisabledTest) {
|
| policy_map().Set(policy::key::kExternalStorageDisabled,
|
| policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
|
| policy::POLICY_SOURCE_CLOUD,
|
| - base::MakeUnique<base::FundamentalValue>(true), nullptr);
|
| + base::MakeUnique<base::Value>(true), nullptr);
|
| policy_bridge()->GetPolicies(
|
| PolicyStringCallback("{\"mountPhysicalMediaDisabled\":true}"));
|
| }
|
|
|
| TEST_F(ArcPolicyBridgeTest, URLBlacklistTest) {
|
| base::ListValue blacklist;
|
| - blacklist.AppendString("www.blacklist1.com");
|
| - blacklist.AppendString("www.blacklist2.com");
|
| + blacklist.Append(new base::StringValue("www.blacklist1.com"));
|
| + blacklist.Append(new base::StringValue("www.blacklist2.com"));
|
| policy_map().Set(policy::key::kURLBlacklist, policy::POLICY_LEVEL_MANDATORY,
|
| policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
|
| blacklist.CreateDeepCopy(), nullptr);
|
| @@ -256,8 +248,8 @@ TEST_F(ArcPolicyBridgeTest, URLBlacklistTest) {
|
|
|
| TEST_F(ArcPolicyBridgeTest, URLWhitelistTest) {
|
| base::ListValue whitelist;
|
| - whitelist.AppendString("www.whitelist1.com");
|
| - whitelist.AppendString("www.whitelist2.com");
|
| + whitelist.Append(new base::StringValue("www.whitelist1.com"));
|
| + whitelist.Append(new base::StringValue("www.whitelist2.com"));
|
| policy_map().Set(policy::key::kURLWhitelist, policy::POLICY_LEVEL_MANDATORY,
|
| policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
|
| whitelist.CreateDeepCopy(), nullptr);
|
| @@ -274,8 +266,7 @@ TEST_F(ArcPolicyBridgeTest, CaCertificateTest) {
|
| policy_map().Set(
|
| policy::key::kArcCertificatesSyncMode, policy::POLICY_LEVEL_MANDATORY,
|
| policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
|
| - base::MakeUnique<base::FundamentalValue>(ArcCertsSyncMode::COPY_CA_CERTS),
|
| - nullptr);
|
| + base::MakeUnique<base::Value>(ArcCertsSyncMode::COPY_CA_CERTS), nullptr);
|
| policy_map().Set(policy::key::kOpenNetworkConfiguration,
|
| policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
|
| policy::POLICY_SOURCE_CLOUD,
|
| @@ -294,8 +285,7 @@ TEST_F(ArcPolicyBridgeTest, CaCertificateTest) {
|
| policy_map().Set(
|
| policy::key::kArcCertificatesSyncMode, policy::POLICY_LEVEL_MANDATORY,
|
| policy::POLICY_SCOPE_USER, policy::POLICY_SOURCE_CLOUD,
|
| - base::MakeUnique<base::FundamentalValue>(ArcCertsSyncMode::SYNC_DISABLED),
|
| - nullptr);
|
| + base::MakeUnique<base::Value>(ArcCertsSyncMode::SYNC_DISABLED), nullptr);
|
| policy_bridge()->GetPolicies(PolicyStringCallback("{}"));
|
| }
|
|
|
| @@ -303,7 +293,7 @@ TEST_F(ArcPolicyBridgeTest, DeveloperToolsDisabledTest) {
|
| policy_map().Set(policy::key::kDeveloperToolsDisabled,
|
| policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
|
| policy::POLICY_SOURCE_CLOUD,
|
| - base::MakeUnique<base::FundamentalValue>(true), nullptr);
|
| + base::MakeUnique<base::Value>(true), nullptr);
|
| policy_bridge()->GetPolicies(
|
| PolicyStringCallback("{\"debuggingFeaturesDisabled\":true}"));
|
| }
|
| @@ -328,7 +318,7 @@ TEST_F(ArcPolicyBridgeTest, MultiplePoliciesTest) {
|
| policy_map().Set(policy::key::kVideoCaptureAllowed,
|
| policy::POLICY_LEVEL_MANDATORY, policy::POLICY_SCOPE_USER,
|
| policy::POLICY_SOURCE_CLOUD,
|
| - base::MakeUnique<base::FundamentalValue>(false), nullptr);
|
| + base::MakeUnique<base::Value>(false), nullptr);
|
| policy_bridge()->GetPolicies(PolicyStringCallback(
|
| "{\"applications\":"
|
| "[{\"installType\":\"REQUIRED\","
|
| @@ -341,29 +331,6 @@ TEST_F(ArcPolicyBridgeTest, MultiplePoliciesTest) {
|
| "}"));
|
| }
|
|
|
| -// Disabled due to memory leak https://crbug.com/666371.
|
| -// TODO(poromov): Fix leak and re-enable.
|
| -TEST_F(ArcPolicyBridgeTest, DISABLED_EmptyReportComplianceTest) {
|
| - policy_bridge()->ReportCompliance(
|
| - "", PolicyComplianceCallback(kPolicyCompliantResponse));
|
| -}
|
| -
|
| -// Disabled due to memory leak https://crbug.com/666371.
|
| -// TODO(poromov): Fix leak and re-enable.
|
| -TEST_F(ArcPolicyBridgeTest, DISABLED_ParsableReportComplianceTest) {
|
| - policy_bridge()->ReportCompliance(
|
| - "{\"nonComplianceDetails\" : []}",
|
| - PolicyComplianceCallback(kPolicyCompliantResponse));
|
| -}
|
| -
|
| -// Disabled due to memory leak https://crbug.com/666371.
|
| -// TODO(poromov): Fix leak and re-enable.
|
| -TEST_F(ArcPolicyBridgeTest, DISABLED_NonParsableReportComplianceTest) {
|
| - policy_bridge()->ReportCompliance(
|
| - "\"nonComplianceDetails\" : [}",
|
| - PolicyComplianceCallback(kPolicyNonCompliantResponse));
|
| -}
|
| -
|
| // This and the following test send the policies through a mojo connection
|
| // between a PolicyInstance and the PolicyBridge.
|
| TEST_F(ArcPolicyBridgeTest, PolicyInstanceUnmanagedTest) {
|
|
|