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

Unified Diff: base/test/test_pending_task_unittest.cc

Issue 491743002: Adding tracing and gtest pretty printing support to TestPendingTask. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/::std/std Created 6 years, 4 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
« no previous file with comments | « base/test/test_pending_task.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/test_pending_task_unittest.cc
diff --git a/base/test/test_pending_task_unittest.cc b/base/test/test_pending_task_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..4a6bd242880acc2de94bb1217e2eb00dfd21cc9c
--- /dev/null
+++ b/base/test/test_pending_task_unittest.cc
@@ -0,0 +1,55 @@
+// Copyright (c) 2012 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/test/test_pending_task.h"
+
+#include "base/bind.h"
+#include "base/debug/trace_event.h"
+#include "testing/gmock/include/gmock/gmock.h"
+#include "testing/gtest/include/gtest/gtest-spi.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace {
+
+TEST(TestPendingTaskTest, TraceSupport) {
+ base::TestPendingTask task;
+
+ // Check that TestPendingTask can be sent to the trace subsystem.
+ TRACE_EVENT1("test", "TestPendingTask::TraceSupport", "task", task.AsValue());
+
+ // Just a basic check that the trace output has *something* in it.
+ EXPECT_THAT(task.AsValue()->ToString(), ::testing::HasSubstr("post_time"));
+}
+
+TEST(TestPendingTaskTest, ToString) {
+ base::TestPendingTask task;
+
+ // Just a basic check that ToString has *something* in it.
+ EXPECT_THAT(task.ToString(), ::testing::StartsWith("TestPendingTask("));
+}
+
+TEST(TestPendingTaskTest, GTestPrettyPrint) {
+ base::TestPendingTask task;
+
+ // Check that gtest is calling the TestPendingTask's PrintTo method.
+ EXPECT_THAT(::testing::PrintToString(task),
+ ::testing::StartsWith("TestPendingTask("));
+
+ // Check that pretty printing works with the gtest iostreams operator.
+ EXPECT_NONFATAL_FAILURE(EXPECT_TRUE(false) << task, "TestPendingTask(");
+}
+
+TEST(TestPendingTaskTest, ShouldRunBefore) {
+ base::TestPendingTask task_first;
+ task_first.delay = base::TimeDelta::FromMilliseconds(1);
+ base::TestPendingTask task_after;
+ task_after.delay = base::TimeDelta::FromMilliseconds(2);
+
+ EXPECT_FALSE(task_after.ShouldRunBefore(task_first))
+ << task_after << ".ShouldRunBefore(" << task_first << ")\n";
+ EXPECT_TRUE(task_first.ShouldRunBefore(task_after))
+ << task_first << ".ShouldRunBefore(" << task_after << ")\n";
+}
+
+} // namespace
« no previous file with comments | « base/test/test_pending_task.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698