Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / remoting / host / policy_hack / policy_watcher_unittest.cc
index 729a7bb..0ed1a55 100644 (file)
@@ -75,6 +75,13 @@ class PolicyWatcherTest : public testing::Test {
                                  true);
     gnubby_auth_false_.SetBoolean(PolicyWatcher::kHostAllowGnubbyAuthPolicyName,
                                  false);
+    relay_true_.SetBoolean(PolicyWatcher::kRelayPolicyName, true);
+    relay_false_.SetBoolean(PolicyWatcher::kRelayPolicyName, false);
+    port_range_full_.SetString(PolicyWatcher::kUdpPortRangePolicyName,
+                               kPortRange);
+    port_range_empty_.SetString(PolicyWatcher::kUdpPortRangePolicyName,
+                                std::string());
+
 #if !defined(NDEBUG)
     SetDefaults(nat_false_overridden_others_default_);
     nat_false_overridden_others_default_.SetBoolean(
@@ -99,6 +106,7 @@ class PolicyWatcherTest : public testing::Test {
   }
 
   static const char* kHostDomain;
+  static const char* kPortRange;
   base::MessageLoop message_loop_;
   scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
   MockPolicyCallback mock_policy_callback_;
@@ -126,10 +134,16 @@ class PolicyWatcherTest : public testing::Test {
   base::DictionaryValue pairing_false_;
   base::DictionaryValue gnubby_auth_true_;
   base::DictionaryValue gnubby_auth_false_;
+  base::DictionaryValue relay_true_;
+  base::DictionaryValue relay_false_;
+  base::DictionaryValue port_range_full_;
+  base::DictionaryValue port_range_empty_;
 
  private:
   void SetDefaults(base::DictionaryValue& dict) {
     dict.SetBoolean(PolicyWatcher::kNatPolicyName, true);
+    dict.SetBoolean(PolicyWatcher::kRelayPolicyName, true);
+    dict.SetString(PolicyWatcher::kUdpPortRangePolicyName, "");
     dict.SetBoolean(PolicyWatcher::kHostRequireTwoFactorPolicyName, false);
     dict.SetString(PolicyWatcher::kHostDomainPolicyName, std::string());
     dict.SetBoolean(PolicyWatcher::kHostMatchUsernamePolicyName, false);
@@ -150,6 +164,7 @@ class PolicyWatcherTest : public testing::Test {
 };
 
 const char* PolicyWatcherTest::kHostDomain = "google.com";
+const char* PolicyWatcherTest::kPortRange = "12400-12409";
 
 MATCHER_P(IsPolicies, dict, "") {
   return arg->Equals(dict);
@@ -355,5 +370,37 @@ TEST_F(PolicyWatcherTest, GnubbyAuth) {
   StopWatching();
 }
 
+TEST_F(PolicyWatcherTest, Relay) {
+  testing::InSequence sequence;
+  EXPECT_CALL(mock_policy_callback_,
+              OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_)));
+  EXPECT_CALL(mock_policy_callback_,
+              OnPolicyUpdatePtr(IsPolicies(&relay_false_)));
+  EXPECT_CALL(mock_policy_callback_,
+              OnPolicyUpdatePtr(IsPolicies(&relay_true_)));
+
+  StartWatching();
+  policy_watcher_->SetPolicies(&empty_);
+  policy_watcher_->SetPolicies(&relay_false_);
+  policy_watcher_->SetPolicies(&relay_true_);
+  StopWatching();
+}
+
+TEST_F(PolicyWatcherTest, UdpPortRange) {
+  testing::InSequence sequence;
+  EXPECT_CALL(mock_policy_callback_,
+              OnPolicyUpdatePtr(IsPolicies(&nat_true_others_default_)));
+  EXPECT_CALL(mock_policy_callback_,
+              OnPolicyUpdatePtr(IsPolicies(&port_range_full_)));
+  EXPECT_CALL(mock_policy_callback_,
+              OnPolicyUpdatePtr(IsPolicies(&port_range_empty_)));
+
+  StartWatching();
+  policy_watcher_->SetPolicies(&empty_);
+  policy_watcher_->SetPolicies(&port_range_full_);
+  policy_watcher_->SetPolicies(&port_range_empty_);
+  StopWatching();
+}
+
 }  // namespace policy_hack
 }  // namespace remoting