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

Side by Side Diff: chrome/browser/metrics/metrics_reporting_scheduler_unittest.cc

Issue 294693002: Moved metrics_reporting_scheduler* to //components/metrics. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Hopefully synced this time. Created 6 years, 7 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
(Empty)
1 // Copyright 2013 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.
4
5 #include "chrome/browser/metrics/metrics_reporting_scheduler.h"
6
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"
12
13 class MetricsReportingSchedulerTest : public testing::Test {
14 public:
15 MetricsReportingSchedulerTest() : callback_call_count_(0) {}
16 virtual ~MetricsReportingSchedulerTest() {}
17
18 base::Closure GetCallback() {
19 return base::Bind(&MetricsReportingSchedulerTest::SchedulerCallback,
20 base::Unretained(this));
21 }
22
23 int callback_call_count() const { return callback_call_count_; }
24
25 private:
26 void SchedulerCallback() {
27 ++callback_call_count_;
28 }
29
30 int callback_call_count_;
31
32 base::MessageLoopForUI message_loop_;
33
34 DISALLOW_COPY_AND_ASSIGN(MetricsReportingSchedulerTest);
35 };
36
37
38 TEST_F(MetricsReportingSchedulerTest, InitTaskCompleteBeforeTimer) {
39 MetricsReportingScheduler scheduler(GetCallback());
40 scheduler.SetUploadIntervalForTesting(base::TimeDelta());
41 scheduler.InitTaskComplete();
42 scheduler.Start();
43 EXPECT_EQ(0, callback_call_count());
44
45 base::RunLoop().RunUntilIdle();
46 EXPECT_EQ(1, callback_call_count());
47 }
48
49 TEST_F(MetricsReportingSchedulerTest, InitTaskCompleteAfterTimer) {
50 MetricsReportingScheduler scheduler(GetCallback());
51 scheduler.SetUploadIntervalForTesting(base::TimeDelta());
52 scheduler.Start();
53 base::RunLoop().RunUntilIdle();
54 EXPECT_EQ(0, callback_call_count());
55
56 scheduler.InitTaskComplete();
57 EXPECT_EQ(1, callback_call_count());
58 }
OLDNEW
« no previous file with comments | « chrome/browser/metrics/metrics_reporting_scheduler.cc ('k') | chrome/browser/metrics/metrics_service.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698