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

Side by Side Diff: chrome/browser/policy/user_policy_cache_unittest.cc

Issue 7744039: Switch ChromeTestSuite to the same convention as ContentTestSuite: (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: more fixing Created 9 years, 4 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/policy/user_policy_cache.h" 5 #include "chrome/browser/policy/user_policy_cache.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <string> 8 #include <string>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
11 #include "base/message_loop.h" 11 #include "base/message_loop.h"
12 #include "base/scoped_temp_dir.h" 12 #include "base/scoped_temp_dir.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/policy/configuration_policy_provider.h" 14 #include "chrome/browser/policy/configuration_policy_provider.h"
15 #include "chrome/browser/policy/proto/cloud_policy.pb.h" 15 #include "chrome/browser/policy/proto/cloud_policy.pb.h"
16 #include "chrome/browser/policy/proto/device_management_backend.pb.h" 16 #include "chrome/browser/policy/proto/device_management_backend.pb.h"
17 #include "chrome/browser/policy/proto/device_management_local.pb.h" 17 #include "chrome/browser/policy/proto/device_management_local.pb.h"
18 #include "chrome/browser/policy/proto/old_generic_format.pb.h" 18 #include "chrome/browser/policy/proto/old_generic_format.pb.h"
19 #include "chrome/test/base/testing_browser_process_test.h"
20 #include "content/browser/browser_thread.h" 19 #include "content/browser/browser_thread.h"
21 #include "testing/gmock/include/gmock/gmock.h" 20 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
23 22
24 using testing::_; 23 using testing::_;
25 24
26 namespace policy { 25 namespace policy {
27 26
28 // Decodes a CloudPolicySettings object into two maps with mandatory and 27 // Decodes a CloudPolicySettings object into two maps with mandatory and
29 // recommended settings, respectively. The implementation is generated code 28 // recommended settings, respectively. The implementation is generated code
30 // in policy/cloud_policy_generated.cc. 29 // in policy/cloud_policy_generated.cc.
31 void DecodePolicy(const em::CloudPolicySettings& policy, 30 void DecodePolicy(const em::CloudPolicySettings& policy,
32 PolicyMap* mandatory, PolicyMap* recommended); 31 PolicyMap* mandatory, PolicyMap* recommended);
33 32
34 // The implementations of these methods are in cloud_policy_generated.cc. 33 // The implementations of these methods are in cloud_policy_generated.cc.
35 Value* DecodeIntegerValue(google::protobuf::int64 value); 34 Value* DecodeIntegerValue(google::protobuf::int64 value);
36 ListValue* DecodeStringList(const em::StringList& string_list); 35 ListValue* DecodeStringList(const em::StringList& string_list);
37 36
38 class MockCloudPolicyCacheBaseObserver 37 class MockCloudPolicyCacheBaseObserver
39 : public CloudPolicyCacheBase::Observer { 38 : public CloudPolicyCacheBase::Observer {
40 public: 39 public:
41 MockCloudPolicyCacheBaseObserver() {} 40 MockCloudPolicyCacheBaseObserver() {}
42 virtual ~MockCloudPolicyCacheBaseObserver() {} 41 virtual ~MockCloudPolicyCacheBaseObserver() {}
43 MOCK_METHOD1(OnCacheUpdate, void(CloudPolicyCacheBase*)); 42 MOCK_METHOD1(OnCacheUpdate, void(CloudPolicyCacheBase*));
44 void OnCacheGoingAway(CloudPolicyCacheBase*) {} 43 void OnCacheGoingAway(CloudPolicyCacheBase*) {}
45 }; 44 };
46 45
47 // Tests the device management policy cache. 46 // Tests the device management policy cache.
48 class UserPolicyCacheTest : public TestingBrowserProcessTest { 47 class UserPolicyCacheTest : public testing::Test {
49 protected: 48 protected:
50 UserPolicyCacheTest() 49 UserPolicyCacheTest()
51 : loop_(MessageLoop::TYPE_UI), 50 : loop_(MessageLoop::TYPE_UI),
52 ui_thread_(BrowserThread::UI, &loop_), 51 ui_thread_(BrowserThread::UI, &loop_),
53 file_thread_(BrowserThread::FILE, &loop_) {} 52 file_thread_(BrowserThread::FILE, &loop_) {}
54 53
55 void SetUp() { 54 void SetUp() {
56 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 55 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
57 } 56 }
58 57
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 // If new-style policy comes in, it should override old-style policy. 386 // If new-style policy comes in, it should override old-style policy.
388 policy = CreateHomepagePolicy("http://www.example.com", 387 policy = CreateHomepagePolicy("http://www.example.com",
389 base::Time::NowFromSystemTime(), 388 base::Time::NowFromSystemTime(),
390 em::PolicyOptions::RECOMMENDED); 389 em::PolicyOptions::RECOMMENDED);
391 SetPolicy(&cache, policy, true); 390 SetPolicy(&cache, policy, true);
392 EXPECT_TRUE(expected.Equals(recommended_policy(cache))); 391 EXPECT_TRUE(expected.Equals(recommended_policy(cache)));
393 EXPECT_TRUE(empty.Equals(mandatory_policy(cache))); 392 EXPECT_TRUE(empty.Equals(mandatory_policy(cache)));
394 } 393 }
395 394
396 } // namespace policy 395 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698