Index: chrome/browser/chromeos/policy/policy_util_unittest.cc |
diff --git a/chrome/browser/chromeos/policy/policy_util_unittest.cc b/chrome/browser/chromeos/policy/policy_util_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..afedc8ca78904459b24c26535f62ae58a64f1085 |
--- /dev/null |
+++ b/chrome/browser/chromeos/policy/policy_util_unittest.cc |
@@ -0,0 +1,55 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/chromeos/policy/policy_util.h" |
+ |
+#include "policy/proto/device_management_backend.pb.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace em = enterprise_management; |
+ |
+namespace policy { |
+ |
+class PolicyUtilTest : public testing::Test { |
+ public: |
+ em::PolicyData policy_data_; |
+}; |
+ |
+TEST_F(PolicyUtilTest, LegacyPolicyData) { |
+ // Legacy PolicyData does not have |management_mode|. |
+ policy_data_.clear_management_mode(); |
+ |
+ // PolicyData with no |request_token| is local owned. |
+ policy_data_.clear_request_token(); |
+ EXPECT_FALSE(PolicyUtil::IsConsumerManaged(policy_data_)); |
+ EXPECT_FALSE(PolicyUtil::IsEnterpriseManaged(policy_data_)); |
+ EXPECT_TRUE(PolicyUtil::IsLocalOwned(policy_data_)); |
+ |
+ // PolicyData with |request_token| is enterprise-managed. |
+ policy_data_.set_request_token("fake_request_token"); |
+ EXPECT_FALSE(PolicyUtil::IsConsumerManaged(policy_data_)); |
+ EXPECT_TRUE(PolicyUtil::IsEnterpriseManaged(policy_data_)); |
+ EXPECT_FALSE(PolicyUtil::IsLocalOwned(policy_data_)); |
+} |
+ |
+TEST_F(PolicyUtilTest, PolicyDataWithManagementMode) { |
+ policy_data_.set_request_token("fake_request_token"); |
+ |
+ policy_data_.set_management_mode(em::PolicyData::CONSUMER_MANAGED); |
+ EXPECT_TRUE(PolicyUtil::IsConsumerManaged(policy_data_)); |
+ EXPECT_FALSE(PolicyUtil::IsEnterpriseManaged(policy_data_)); |
+ EXPECT_FALSE(PolicyUtil::IsLocalOwned(policy_data_)); |
+ |
+ policy_data_.set_management_mode(em::PolicyData::ENTERPRISE_MANAGED); |
+ EXPECT_FALSE(PolicyUtil::IsConsumerManaged(policy_data_)); |
+ EXPECT_TRUE(PolicyUtil::IsEnterpriseManaged(policy_data_)); |
+ EXPECT_FALSE(PolicyUtil::IsLocalOwned(policy_data_)); |
+ |
+ policy_data_.set_management_mode(em::PolicyData::LOCAL_OWNER); |
+ EXPECT_FALSE(PolicyUtil::IsConsumerManaged(policy_data_)); |
+ EXPECT_FALSE(PolicyUtil::IsEnterpriseManaged(policy_data_)); |
+ EXPECT_TRUE(PolicyUtil::IsLocalOwned(policy_data_)); |
+} |
+ |
+} // namespace policy |