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

Unified Diff: media/base/test_helpers.h

Issue 11316293: Replace WaitableEvents and ConditionalVariables in VideoRendererBase tests with MessageLoop. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix bustage Created 8 years 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 | « media/base/pipeline_unittest.cc ('k') | media/base/test_helpers.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/base/test_helpers.h
diff --git a/media/base/test_helpers.h b/media/base/test_helpers.h
new file mode 100644
index 0000000000000000000000000000000000000000..1c386948733499d09bdde7d71b1c1a83aea5ad21
--- /dev/null
+++ b/media/base/test_helpers.h
@@ -0,0 +1,57 @@
+// 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.
+
+#ifndef MEDIA_BASE_TEST_HELPERS_H_
+#define MEDIA_BASE_TEST_HELPERS_H_
+
+#include "base/callback.h"
+#include "media/base/pipeline_status.h"
+#include "testing/gmock/include/gmock/gmock.h"
+
+class MessageLoop;
+
+namespace media {
+
+// Return a callback that expects to be run once.
+base::Closure NewExpectedClosure();
+PipelineStatusCB NewExpectedStatusCB(PipelineStatus status);
+
+// Helper class for running a message loop until a callback has run. Useful for
+// testing classes that run on more than a single thread.
+//
+// Events are intended for single use and cannot be reset.
+class WaitableMessageLoopEvent {
+ public:
+ WaitableMessageLoopEvent();
+ ~WaitableMessageLoopEvent();
+
+ // Returns a thread-safe closure that will signal |this| when executed.
+ base::Closure GetClosure();
+ PipelineStatusCB GetPipelineStatusCB();
+
+ // Runs the current message loop until |this| has been signaled.
+ //
+ // Fails the test if the timeout is reached.
+ void RunAndWait();
+
+ // Runs the current message loop until |this| has been signaled and asserts
+ // that the |expected| status was received.
+ //
+ // Fails the test if the timeout is reached.
+ void RunAndWaitForStatus(PipelineStatus expected);
+
+ private:
+ void OnCallback(PipelineStatus status);
+ void OnTimeout();
+
+ MessageLoop* message_loop_;
+ bool signaled_;
+ PipelineStatus status_;
+
+ DISALLOW_COPY_AND_ASSIGN(WaitableMessageLoopEvent);
+};
+
+} // namespace media
+
+#endif // MEDIA_BASE_TEST_HELPERS_H_
« no previous file with comments | « media/base/pipeline_unittest.cc ('k') | media/base/test_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698