| Index: remoting/host/policy_watcher_unittest.cc
|
| diff --git a/remoting/host/policy_watcher_unittest.cc b/remoting/host/policy_watcher_unittest.cc
|
| index 8fee57c758d16f031081aa047750574d912061a5..f180f8cf386cd5ae1d0ca55c90b9db30654e0133 100644
|
| --- a/remoting/host/policy_watcher_unittest.cc
|
| +++ b/remoting/host/policy_watcher_unittest.cc
|
| @@ -63,8 +63,6 @@ class PolicyWatcherTest : public testing::Test {
|
| policy_watcher_ =
|
| PolicyWatcher::CreateFromPolicyLoader(make_scoped_ptr(policy_loader_));
|
|
|
| - schema_ = policy::Schema::Wrap(policy::GetChromeSchemaData());
|
| -
|
| nat_true_.SetBoolean(policy::key::kRemoteAccessHostFirewallTraversal, true);
|
| nat_false_.SetBoolean(policy::key::kRemoteAccessHostFirewallTraversal,
|
| false);
|
| @@ -173,12 +171,10 @@ class PolicyWatcherTest : public testing::Test {
|
| base::RunLoop().RunUntilIdle();
|
| }
|
|
|
| - void SignalTransientErrorForTest() {
|
| - policy_watcher_->SignalTransientPolicyError();
|
| + const policy::Schema* GetPolicySchema() {
|
| + return policy_watcher_->GetPolicySchema();
|
| }
|
|
|
| - const policy::Schema* GetPolicySchema() { return &schema_; }
|
| -
|
| const base::DictionaryValue& GetDefaultValues() {
|
| return *(policy_watcher_->default_values_);
|
| }
|
| @@ -224,8 +220,6 @@ class PolicyWatcherTest : public testing::Test {
|
| base::DictionaryValue port_range_full_;
|
| base::DictionaryValue port_range_empty_;
|
|
|
| - policy::Schema schema_;
|
| -
|
| private:
|
| void SetDefaults(base::DictionaryValue& dict) {
|
| dict.SetBoolean(policy::key::kRemoteAccessHostFirewallTraversal, true);
|
| @@ -281,9 +275,8 @@ TEST_F(PolicyWatcherTest, NatFalse) {
|
| StartWatching();
|
| }
|
|
|
| -TEST_F(PolicyWatcherTest, NatOne) {
|
| - EXPECT_CALL(mock_policy_callback_,
|
| - OnPolicyUpdatePtr(IsPolicies(&nat_false_others_default_)));
|
| +TEST_F(PolicyWatcherTest, NatWrongType) {
|
| + EXPECT_CALL(mock_policy_callback_, OnPolicyError());
|
|
|
| SetPolicies(nat_one_);
|
| StartWatching();
|
| @@ -471,39 +464,6 @@ TEST_F(PolicyWatcherTest, UdpPortRange) {
|
| SetPolicies(port_range_empty_);
|
| }
|
|
|
| -const int kMaxTransientErrorRetries = 5;
|
| -
|
| -TEST_F(PolicyWatcherTest, SingleTransientErrorDoesntTriggerErrorCallback) {
|
| - EXPECT_CALL(mock_policy_callback_, OnPolicyError()).Times(0);
|
| -
|
| - StartWatching();
|
| - SignalTransientErrorForTest();
|
| -}
|
| -
|
| -TEST_F(PolicyWatcherTest, MultipleTransientErrorsTriggerErrorCallback) {
|
| - EXPECT_CALL(mock_policy_callback_, OnPolicyError());
|
| -
|
| - StartWatching();
|
| - for (int i = 0; i < kMaxTransientErrorRetries; i++) {
|
| - SignalTransientErrorForTest();
|
| - }
|
| -}
|
| -
|
| -TEST_F(PolicyWatcherTest, PolicyUpdateResetsTransientErrorsCounter) {
|
| - testing::InSequence s;
|
| - EXPECT_CALL(mock_policy_callback_, OnPolicyUpdatePtr(testing::_));
|
| - EXPECT_CALL(mock_policy_callback_, OnPolicyError()).Times(0);
|
| -
|
| - StartWatching();
|
| - for (int i = 0; i < (kMaxTransientErrorRetries - 1); i++) {
|
| - SignalTransientErrorForTest();
|
| - }
|
| - SetPolicies(nat_true_);
|
| - for (int i = 0; i < (kMaxTransientErrorRetries - 1); i++) {
|
| - SignalTransientErrorForTest();
|
| - }
|
| -}
|
| -
|
| TEST_F(PolicyWatcherTest, PolicySchemaAndPolicyWatcherShouldBeInSync) {
|
| // This test verifies that
|
| // 1) policy schema (generated out of policy_templates.json)
|
| @@ -545,6 +505,25 @@ TEST_F(PolicyWatcherTest, PolicySchemaAndPolicyWatcherShouldBeInSync) {
|
| EXPECT_THAT(actual_schema_keys, testing::ContainerEq(expected_schema_keys));
|
| }
|
|
|
| +TEST_F(PolicyWatcherTest, SchemaTypeCheck) {
|
| + const policy::Schema* schema = GetPolicySchema();
|
| + ASSERT_TRUE(schema->valid());
|
| +
|
| + // Check one, random "string" policy to see if the type propagated correctly
|
| + // from policy_templates.json file.
|
| + const policy::Schema string_schema =
|
| + schema->GetKnownProperty("RemoteAccessHostDomain");
|
| + EXPECT_TRUE(string_schema.valid());
|
| + EXPECT_EQ(string_schema.type(), base::Value::Type::TYPE_STRING);
|
| +
|
| + // And check one, random "boolean" policy to see if the type propagated
|
| + // correctly from policy_templates.json file.
|
| + const policy::Schema boolean_schema =
|
| + schema->GetKnownProperty("RemoteAccessHostRequireCurtain");
|
| + EXPECT_TRUE(boolean_schema.valid());
|
| + EXPECT_EQ(boolean_schema.type(), base::Value::Type::TYPE_BOOLEAN);
|
| +}
|
| +
|
| // Unit tests cannot instantiate PolicyWatcher on ChromeOS
|
| // (as this requires running inside a browser process).
|
| #ifndef OS_CHROMEOS
|
|
|