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

Unified Diff: base/test/test_pending_task.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.h ('k') | base/test/test_pending_task_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/test_pending_task.cc
diff --git a/base/test/test_pending_task.cc b/base/test/test_pending_task.cc
index cb8412c4a559689c20ab4fb4d2103e1bfd1a3b28..f5ae5a198946f1840c1ba5828c4ac8ab2ef497fc 100644
--- a/base/test/test_pending_task.cc
+++ b/base/test/test_pending_task.cc
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include <string>
+
#include "base/test/test_pending_task.h"
namespace base {
@@ -32,4 +34,44 @@ bool TestPendingTask::ShouldRunBefore(const TestPendingTask& other) const {
TestPendingTask::~TestPendingTask() {}
+void TestPendingTask::AsValueInto(base::debug::TracedValue* state) const {
+ state->SetInteger("run_at", GetTimeToRun().ToInternalValue());
+ state->SetString("posting_function", location.ToString());
+ state->SetInteger("post_time", post_time.ToInternalValue());
+ state->SetInteger("delay", delay.ToInternalValue());
+ switch (nestability) {
+ case NESTABLE:
+ state->SetString("nestability", "NESTABLE");
+ break;
+ case NON_NESTABLE:
+ state->SetString("nestability", "NON_NESTABLE");
+ break;
+ }
+ state->SetInteger("delay", delay.ToInternalValue());
+}
+
+scoped_refptr<base::debug::ConvertableToTraceFormat> TestPendingTask::AsValue()
+ const {
+ scoped_refptr<base::debug::TracedValue> state =
+ new base::debug::TracedValue();
+ AsValueInto(state);
+ return state;
+}
+
+std::string TestPendingTask::ToString() const {
+ std::string output("TestPendingTask(");
+ AsValue()->AppendAsTraceFormat(&output);
+ output += ")";
+ return output;
+}
+
+std::ostream& operator<<(std::ostream& os, const TestPendingTask& task) {
+ PrintTo(task, &os);
+ return os;
+}
+
+void PrintTo(const TestPendingTask& task, std::ostream* os) {
+ *os << task.ToString();
+}
+
} // namespace base
« no previous file with comments | « base/test/test_pending_task.h ('k') | base/test/test_pending_task_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698