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

Unified Diff: chrome/browser/policy/device_management_policy_cache_unittest.cc

Issue 6520008: Device policy infrastructure (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 10 months 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: chrome/browser/policy/device_management_policy_cache_unittest.cc
diff --git a/chrome/browser/policy/device_management_policy_cache_unittest.cc b/chrome/browser/policy/device_management_policy_cache_unittest.cc
index d888389bdca68e931b38c408ac187554879d1553..4e53895c211ce2ffaed284b670a1216f84654c83 100644
--- a/chrome/browser/policy/device_management_policy_cache_unittest.cc
+++ b/chrome/browser/policy/device_management_policy_cache_unittest.cc
@@ -1,9 +1,7 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
Mattias Nissler (ping if slow) 2011/02/15 10:15:16 seems like this file should have been removed?
Jakob Kummerow 2011/02/21 12:12:15 Done in the other CL (that this one is based on).
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#include "chrome/browser/policy/cloud_policy_cache.h"
-
#include <limits>
#include <string>
@@ -12,6 +10,7 @@
#include "base/scoped_temp_dir.h"
#include "base/values.h"
#include "chrome/browser/browser_thread.h"
+#include "chrome/browser/policy/cloud_policy_cache.h"
#include "chrome/browser/policy/proto/device_management_constants.h"
#include "chrome/browser/policy/proto/device_management_local.pb.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -75,7 +74,10 @@ class DeviceManagementPolicyCacheTest
return temp_dir_.path().AppendASCII("DeviceManagementPolicyCacheTest");
}
- protected:
+ const DictionaryValue* device_policy(const CloudPolicyCache& cache) {
+ return cache.device_policy_.get();
+ }
+
MessageLoop loop_;
private:
@@ -87,17 +89,15 @@ class DeviceManagementPolicyCacheTest
TEST_F(DeviceManagementPolicyCacheTest, Empty) {
CloudPolicyCache cache(test_file());
DictionaryValue empty;
- scoped_ptr<Value> policy(cache.GetDevicePolicy());
- EXPECT_TRUE(empty.Equals(policy.get()));
+ EXPECT_TRUE(empty.Equals(device_policy(cache)));
EXPECT_EQ(base::Time(), cache.last_policy_refresh_time());
}
TEST_F(DeviceManagementPolicyCacheTest, LoadNoFile) {
CloudPolicyCache cache(test_file());
- cache.LoadPolicyFromFile();
+ cache.LoadFromFile();
DictionaryValue empty;
- scoped_ptr<Value> policy(cache.GetDevicePolicy());
- EXPECT_TRUE(empty.Equals(policy.get()));
+ EXPECT_TRUE(empty.Equals(device_policy(cache)));
EXPECT_EQ(base::Time(), cache.last_policy_refresh_time());
}
@@ -106,10 +106,9 @@ TEST_F(DeviceManagementPolicyCacheTest, RejectFuture) {
WritePolicy(policy_response, base::Time::NowFromSystemTime() +
base::TimeDelta::FromMinutes(5));
CloudPolicyCache cache(test_file());
- cache.LoadPolicyFromFile();
+ cache.LoadFromFile();
DictionaryValue empty;
- scoped_ptr<Value> policy(cache.GetDevicePolicy());
- EXPECT_TRUE(empty.Equals(policy.get()));
+ EXPECT_TRUE(empty.Equals(device_policy(cache)));
EXPECT_EQ(base::Time(), cache.last_policy_refresh_time());
}
@@ -117,10 +116,9 @@ TEST_F(DeviceManagementPolicyCacheTest, LoadWithFile) {
em::DevicePolicyResponse policy_response;
WritePolicy(policy_response, base::Time::NowFromSystemTime());
CloudPolicyCache cache(test_file());
- cache.LoadPolicyFromFile();
+ cache.LoadFromFile();
DictionaryValue empty;
- scoped_ptr<Value> policy(cache.GetDevicePolicy());
- EXPECT_TRUE(empty.Equals(policy.get()));
+ EXPECT_TRUE(empty.Equals(device_policy(cache)));
EXPECT_NE(base::Time(), cache.last_policy_refresh_time());
EXPECT_GE(base::Time::Now(), cache.last_policy_refresh_time());
}
@@ -130,12 +128,11 @@ TEST_F(DeviceManagementPolicyCacheTest, LoadWithData) {
AddStringPolicy(&policy, "HomepageLocation", "http://www.example.com");
WritePolicy(policy, base::Time::NowFromSystemTime());
CloudPolicyCache cache(test_file());
- cache.LoadPolicyFromFile();
+ cache.LoadFromFile();
DictionaryValue expected;
expected.Set("HomepageLocation",
Value::CreateStringValue("http://www.example.com"));
- scoped_ptr<Value> policy_value(cache.GetDevicePolicy());
- EXPECT_TRUE(expected.Equals(policy_value.get()));
+ EXPECT_TRUE(expected.Equals(device_policy(cache)));
}
TEST_F(DeviceManagementPolicyCacheTest, SetDevicePolicy) {
@@ -149,8 +146,7 @@ TEST_F(DeviceManagementPolicyCacheTest, SetDevicePolicy) {
DictionaryValue expected;
expected.Set("HomepageLocation",
Value::CreateStringValue("http://www.example.com"));
- scoped_ptr<Value> policy_value(cache.GetDevicePolicy());
- EXPECT_TRUE(expected.Equals(policy_value.get()));
+ EXPECT_TRUE(expected.Equals(device_policy(cache)));
}
TEST_F(DeviceManagementPolicyCacheTest, ResetPolicy) {
@@ -162,13 +158,11 @@ TEST_F(DeviceManagementPolicyCacheTest, ResetPolicy) {
DictionaryValue expected;
expected.Set("HomepageLocation",
Value::CreateStringValue("http://www.example.com"));
- scoped_ptr<Value> policy_value(cache.GetDevicePolicy());
- EXPECT_TRUE(expected.Equals(policy_value.get()));
+ EXPECT_TRUE(expected.Equals(device_policy(cache)));
EXPECT_TRUE(cache.SetDevicePolicy(em::DevicePolicyResponse()));
- policy_value.reset(cache.GetDevicePolicy());
DictionaryValue empty;
- EXPECT_TRUE(empty.Equals(policy_value.get()));
+ EXPECT_TRUE(empty.Equals(device_policy(cache)));
}
TEST_F(DeviceManagementPolicyCacheTest, PersistPolicy) {
@@ -183,12 +177,11 @@ TEST_F(DeviceManagementPolicyCacheTest, PersistPolicy) {
EXPECT_TRUE(file_util::PathExists(test_file()));
CloudPolicyCache cache(test_file());
- cache.LoadPolicyFromFile();
+ cache.LoadFromFile();
DictionaryValue expected;
expected.Set("HomepageLocation",
Value::CreateStringValue("http://www.example.com"));
- scoped_ptr<Value> policy_value(cache.GetDevicePolicy());
- EXPECT_TRUE(expected.Equals(policy_value.get()));
+ EXPECT_TRUE(expected.Equals(device_policy(cache)));
}
TEST_F(DeviceManagementPolicyCacheTest, FreshPolicyOverride) {
@@ -202,12 +195,11 @@ TEST_F(DeviceManagementPolicyCacheTest, FreshPolicyOverride) {
"http://www.chromium.org");
EXPECT_TRUE(cache.SetDevicePolicy(updated_policy));
- cache.LoadPolicyFromFile();
+ cache.LoadFromFile();
DictionaryValue expected;
expected.Set("HomepageLocation",
Value::CreateStringValue("http://www.chromium.org"));
- scoped_ptr<Value> policy_value(cache.GetDevicePolicy());
- EXPECT_TRUE(expected.Equals(policy_value.get()));
+ EXPECT_TRUE(expected.Equals(device_policy(cache)));
}
// Tests proper decoding of policy values.

Powered by Google App Engine
This is Rietveld 408576698