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

Unified 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 side-by-side diff with in-line comments
Download patch
« net/test/fake_time_system.h ('K') | « net/test/fake_time_system.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: net/test/fake_time_system_unittest.cc
diff --git a/net/test/fake_time_system_unittest.cc b/net/test/fake_time_system_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..bb866bbcb3223ce34681cc7458cf849b3306ca12
--- /dev/null
+++ b/net/test/fake_time_system_unittest.cc
@@ -0,0 +1,65 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/location.h"
+#include "base/bind.h"
+#include "net/test/fake_time_system.h"
+#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+using ::testing::Mock;
+using ::testing::StrictMock;
+
+namespace net {
+namespace {
+
+class MockTask {
+ public:
+ MockTask() {}
+ ~MockTask() {}
+
+ MOCK_METHOD0(Run1, void());
+ MOCK_METHOD0(Run2, void());
+ MOCK_METHOD0(Run3, void());
+};
+
+TEST(FakeTimeSystemTest, RunPendingTasks) {
+ scoped_refptr<FakeTimeSystem> fake_time_system = new FakeTimeSystem();
+ base::Time default_time = base::Time::FromDoubleT(1234.0);
+ StrictMock<MockTask> task;
+
+ fake_time_system->SetNow(default_time);
+ fake_time_system->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&MockTask::Run2, base::Unretained(&task)),
+ base::TimeDelta::FromSeconds(5));
+
+ fake_time_system->SetNow(default_time + base::TimeDelta::FromSeconds(2));
+ fake_time_system->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&MockTask::Run3, base::Unretained(&task)),
+ base::TimeDelta::FromSeconds(5));
+
+ fake_time_system->PostTask(
+ FROM_HERE,
+ base::Bind(&MockTask::Run1, base::Unretained(&task)));
+
+ EXPECT_CALL(task, Run1());
+ fake_time_system->RunPendingTasks();
+ Mock::VerifyAndClear(&task);
+
+ fake_time_system->SetNow(default_time + base::TimeDelta::FromSeconds(5));
+ EXPECT_CALL(task, Run2());
+ fake_time_system->RunPendingTasks();
+ Mock::VerifyAndClear(&task);
+
+ fake_time_system->SetNow(default_time + base::TimeDelta::FromSeconds(7));
+ EXPECT_CALL(task, Run3());
+ fake_time_system->RunPendingTasks();
+ Mock::VerifyAndClear(&task);
+}
+
+} // namespace
+
+} // namespace net
« 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