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

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

Issue 10916235: Record policy usage statistics every 24 hours. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fixed compilation Created 8 years, 3 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "base/callback.h" 5 #include "base/callback.h"
6 #include "base/compiler_specific.h" 6 #include "base/compiler_specific.h"
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop.h" 9 #include "base/message_loop.h"
10 #include "base/single_thread_task_runner.h"
11 #include "chrome/browser/policy/cloud_policy_refresh_scheduler.h" 10 #include "chrome/browser/policy/cloud_policy_refresh_scheduler.h"
12 #include "chrome/browser/policy/mock_cloud_policy_client.h" 11 #include "chrome/browser/policy/mock_cloud_policy_client.h"
13 #include "chrome/browser/policy/mock_cloud_policy_store.h" 12 #include "chrome/browser/policy/mock_cloud_policy_store.h"
13 #include "chrome/browser/policy/test_task_runner.h"
14 #include "chrome/browser/prefs/browser_prefs.h" 14 #include "chrome/browser/prefs/browser_prefs.h"
15 #include "chrome/common/pref_names.h" 15 #include "chrome/common/pref_names.h"
16 #include "chrome/test/base/testing_pref_service.h" 16 #include "chrome/test/base/testing_pref_service.h"
17 #include "testing/gmock/include/gmock/gmock.h" 17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 namespace em = enterprise_management; 20 namespace em = enterprise_management;
21 21
22 using testing::DoAll; 22 using testing::DoAll;
23 using testing::Return; 23 using testing::Return;
24 using testing::SaveArg; 24 using testing::SaveArg;
25 using testing::_; 25 using testing::_;
26 26
27 namespace policy { 27 namespace policy {
28 28
29 namespace { 29 namespace {
30
31 const int64 kPolicyRefreshRate = 4 * 60 * 60 * 1000; 30 const int64 kPolicyRefreshRate = 4 * 60 * 60 * 1000;
32
33 class TestTaskRunner : public base::TaskRunner {
34 public:
35 TestTaskRunner() {}
36
37 virtual bool RunsTasksOnCurrentThread() const OVERRIDE { return true; }
38 MOCK_METHOD3(PostDelayedTask, bool(const tracked_objects::Location&,
39 const base::Closure&,
40 base::TimeDelta));
41
42 protected:
43 virtual ~TestTaskRunner() {}
44
45 private:
46 DISALLOW_COPY_AND_ASSIGN(TestTaskRunner);
47 };
48
49 } // namespace 31 } // namespace
50 32
51 class CloudPolicyRefreshSchedulerTest : public testing::Test { 33 class CloudPolicyRefreshSchedulerTest : public testing::Test {
52 protected: 34 protected:
53 CloudPolicyRefreshSchedulerTest() 35 CloudPolicyRefreshSchedulerTest()
54 : task_runner_(new TestTaskRunner()), 36 : task_runner_(new TestTaskRunner()),
55 network_change_notifier_(net::NetworkChangeNotifier::CreateMock()) { 37 network_change_notifier_(net::NetworkChangeNotifier::CreateMock()) {
56 chrome::RegisterLocalState(&prefs_); 38 chrome::RegisterLocalState(&prefs_);
57 prefs_.SetInteger(prefs::kUserPolicyRefreshRate, kPolicyRefreshRate); 39 prefs_.SetInteger(prefs::kUserPolicyRefreshRate, kPolicyRefreshRate);
58 } 40 }
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 EXPECT_EQ(base::TimeDelta(), last_delay_); 271 EXPECT_EQ(base::TimeDelta(), last_delay_);
290 EXPECT_TRUE(last_callback_.is_null()); 272 EXPECT_TRUE(last_callback_.is_null());
291 } 273 }
292 } 274 }
293 275
294 INSTANTIATE_TEST_CASE_P(CloudPolicyRefreshSchedulerClientErrorTest, 276 INSTANTIATE_TEST_CASE_P(CloudPolicyRefreshSchedulerClientErrorTest,
295 CloudPolicyRefreshSchedulerClientErrorTest, 277 CloudPolicyRefreshSchedulerClientErrorTest,
296 testing::ValuesIn(kClientErrorTestCases)); 278 testing::ValuesIn(kClientErrorTestCases));
297 279
298 } // namespace policy 280 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/policy/browser_policy_connector.cc ('k') | chrome/browser/policy/mock_policy_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698