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

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: 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
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..b0c0870606acf99aa82bb50d1c8f443e9e366ea2
--- /dev/null
+++ b/components/policy/core/common/cloud/cloud_policy_constants_unittest.cc
@@ -0,0 +1,46 @@
+// 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 local owned.
bartfab (slow) 2014/11/28 13:56:54 Nit: s/local/locally/
davidyu 2014/11/29 01:50:14 Done.
+ policy_data_.clear_request_token();
+ EXPECT_EQ(MANAGEMENT_MODE_LOCAL, GetManagementMode(policy_data_));
+
+ // PolicyData with |request_token| is enterprise-managed.
+ policy_data_.set_request_token("fake_request_token");
+ EXPECT_EQ(MANAGEMENT_MODE_ENTERPRISE, 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, GetManagementMode(policy_data_));
+
+ policy_data_.set_management_mode(em::PolicyData::ENTERPRISE_MANAGED);
+ EXPECT_EQ(MANAGEMENT_MODE_ENTERPRISE, GetManagementMode(policy_data_));
+
+ policy_data_.set_management_mode(em::PolicyData::LOCAL_OWNER);
+ EXPECT_EQ(MANAGEMENT_MODE_LOCAL, GetManagementMode(policy_data_));
+}
+
+} // namespace policy

Powered by Google App Engine
This is Rietveld 408576698