Add a few more European timezones
[chromium-blink-merge.git] / components / metrics / metrics_reporting_scheduler_unittest.cc
blobee80cc74eac3edb90592ee96ab233000c5b89804
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "components/metrics/metrics_reporting_scheduler.h"
7 #include "base/basictypes.h"
8 #include "base/bind.h"
9 #include "base/message_loop/message_loop.h"
10 #include "base/run_loop.h"
11 #include "testing/gtest/include/gtest/gtest.h"
13 namespace metrics {
15 class MetricsReportingSchedulerTest : public testing::Test {
16 public:
17 MetricsReportingSchedulerTest() : callback_call_count_(0) {}
18 ~MetricsReportingSchedulerTest() override {}
20 base::Closure GetCallback() {
21 return base::Bind(&MetricsReportingSchedulerTest::SchedulerCallback,
22 base::Unretained(this));
25 int callback_call_count() const { return callback_call_count_; }
27 private:
28 void SchedulerCallback() {
29 ++callback_call_count_;
32 int callback_call_count_;
34 base::MessageLoopForUI message_loop_;
36 DISALLOW_COPY_AND_ASSIGN(MetricsReportingSchedulerTest);
40 TEST_F(MetricsReportingSchedulerTest, InitTaskCompleteBeforeTimer) {
41 MetricsReportingScheduler scheduler(GetCallback());
42 scheduler.SetUploadIntervalForTesting(base::TimeDelta());
43 scheduler.InitTaskComplete();
44 scheduler.Start();
45 EXPECT_EQ(0, callback_call_count());
47 base::RunLoop().RunUntilIdle();
48 EXPECT_EQ(1, callback_call_count());
51 TEST_F(MetricsReportingSchedulerTest, InitTaskCompleteAfterTimer) {
52 MetricsReportingScheduler scheduler(GetCallback());
53 scheduler.SetUploadIntervalForTesting(base::TimeDelta());
54 scheduler.Start();
55 base::RunLoop().RunUntilIdle();
56 EXPECT_EQ(0, callback_call_count());
58 scheduler.InitTaskComplete();
59 EXPECT_EQ(1, callback_call_count());
62 } // namespace metrics