Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(519)

Unified Diff: components/policy/core/common/cloud/cloud_policy_constants_unittest.cc

Issue 742513006: Add ManagementMode enum and GetManagementMode(). (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add missing POLICY_EXPORT Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/policy/core/common/cloud/cloud_policy_constants.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/common/cloud/cloud_policy_constants_unittest.cc
diff --git a/components/policy/core/common/cloud/cloud_policy_constants_unittest.cc b/components/policy/core/common/cloud/cloud_policy_constants_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..456ed3d496a2ec310bb03bd40a7aee3b74610d60
--- /dev/null
+++ b/components/policy/core/common/cloud/cloud_policy_constants_unittest.cc
@@ -0,0 +1,48 @@
+// 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 "components/policy/core/common/cloud/cloud_policy_constants.h"
+
+#include "policy/proto/device_management_backend.pb.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace em = enterprise_management;
+
+namespace policy {
+
+class CloudPolicyConstantsTest : public testing::Test {
+ public:
+ em::PolicyData policy_data_;
+};
+
+TEST_F(CloudPolicyConstantsTest, GetManagementModeForLegacyPolicyData) {
+ // Legacy PolicyData does not have |management_mode|.
+ policy_data_.clear_management_mode();
+
+ // PolicyData with no |request_token| is locally owned.
+ policy_data_.clear_request_token();
+ EXPECT_EQ(MANAGEMENT_MODE_LOCAL_OWNER, GetManagementMode(policy_data_));
+
+ // PolicyData with |request_token| is enterprise-managed.
+ policy_data_.set_request_token("fake_request_token");
+ EXPECT_EQ(MANAGEMENT_MODE_ENTERPRISE_MANAGED,
+ GetManagementMode(policy_data_));
+}
+
+TEST_F(CloudPolicyConstantsTest,
+ GetManagementModeForPolicyDataWithManagementMode) {
+ policy_data_.set_request_token("fake_request_token");
+
+ policy_data_.set_management_mode(em::PolicyData::CONSUMER_MANAGED);
+ EXPECT_EQ(MANAGEMENT_MODE_CONSUMER_MANAGED, GetManagementMode(policy_data_));
+
+ policy_data_.set_management_mode(em::PolicyData::ENTERPRISE_MANAGED);
+ EXPECT_EQ(MANAGEMENT_MODE_ENTERPRISE_MANAGED,
+ GetManagementMode(policy_data_));
+
+ policy_data_.set_management_mode(em::PolicyData::LOCAL_OWNER);
+ EXPECT_EQ(MANAGEMENT_MODE_LOCAL_OWNER, GetManagementMode(policy_data_));
+}
+
+} // namespace policy
« no previous file with comments | « components/policy/core/common/cloud/cloud_policy_constants.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698