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

Side by Side Diff: net/test/fake_time_system_unittest.cc

Issue 15733008: Multicast DNS implementation (initial) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@mdns_implementation2
Patch Set: Created 7 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
« net/test/fake_time_system.h ('K') | « net/test/fake_time_system.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 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 "base/location.h"
6 #include "base/bind.h"
7 #include "net/test/fake_time_system.h"
8 #include "testing/gtest/include/gtest/gtest.h"
9 #include "testing/gmock/include/gmock/gmock.h"
10
11 using ::testing::Mock;
12 using ::testing::StrictMock;
13
14 namespace net {
15 namespace {
16
17 class MockTask {
18 public:
19 MockTask() {}
20 ~MockTask() {}
21
22 MOCK_METHOD0(Run1, void());
23 MOCK_METHOD0(Run2, void());
24 MOCK_METHOD0(Run3, void());
25 };
26
27 TEST(FakeTimeSystemTest, RunPendingTasks) {
28 scoped_refptr<FakeTimeSystem> fake_time_system = new FakeTimeSystem();
29 base::Time default_time = base::Time::FromDoubleT(1234.0);
30 StrictMock<MockTask> task;
31
32 fake_time_system->SetNow(default_time);
33 fake_time_system->PostDelayedTask(
34 FROM_HERE,
35 base::Bind(&MockTask::Run2, base::Unretained(&task)),
36 base::TimeDelta::FromSeconds(5));
37
38 fake_time_system->SetNow(default_time + base::TimeDelta::FromSeconds(2));
39 fake_time_system->PostDelayedTask(
40 FROM_HERE,
41 base::Bind(&MockTask::Run3, base::Unretained(&task)),
42 base::TimeDelta::FromSeconds(5));
43
44 fake_time_system->PostTask(
45 FROM_HERE,
46 base::Bind(&MockTask::Run1, base::Unretained(&task)));
47
48 EXPECT_CALL(task, Run1());
49 fake_time_system->RunPendingTasks();
50 Mock::VerifyAndClear(&task);
51
52 fake_time_system->SetNow(default_time + base::TimeDelta::FromSeconds(5));
53 EXPECT_CALL(task, Run2());
54 fake_time_system->RunPendingTasks();
55 Mock::VerifyAndClear(&task);
56
57 fake_time_system->SetNow(default_time + base::TimeDelta::FromSeconds(7));
58 EXPECT_CALL(task, Run3());
59 fake_time_system->RunPendingTasks();
60 Mock::VerifyAndClear(&task);
61 }
62
63 } // namespace
64
65 } // namespace net
OLDNEW
« net/test/fake_time_system.h ('K') | « net/test/fake_time_system.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698