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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « media/base/pipeline_unittest.cc ('k') | media/base/test_helpers.cc » ('j') | 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) 2012 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 #ifndef MEDIA_BASE_TEST_HELPERS_H_
6 #define MEDIA_BASE_TEST_HELPERS_H_
7
8 #include "base/callback.h"
9 #include "media/base/pipeline_status.h"
10 #include "testing/gmock/include/gmock/gmock.h"
11
12 class MessageLoop;
13
14 namespace media {
15
16 // Return a callback that expects to be run once.
17 base::Closure NewExpectedClosure();
18 PipelineStatusCB NewExpectedStatusCB(PipelineStatus status);
19
20 // Helper class for running a message loop until a callback has run. Useful for
21 // testing classes that run on more than a single thread.
22 //
23 // Events are intended for single use and cannot be reset.
24 class WaitableMessageLoopEvent {
25 public:
26 WaitableMessageLoopEvent();
27 ~WaitableMessageLoopEvent();
28
29 // Returns a thread-safe closure that will signal |this| when executed.
30 base::Closure GetClosure();
31 PipelineStatusCB GetPipelineStatusCB();
32
33 // Runs the current message loop until |this| has been signaled.
34 //
35 // Fails the test if the timeout is reached.
36 void RunAndWait();
37
38 // Runs the current message loop until |this| has been signaled and asserts
39 // that the |expected| status was received.
40 //
41 // Fails the test if the timeout is reached.
42 void RunAndWaitForStatus(PipelineStatus expected);
43
44 private:
45 void OnCallback(PipelineStatus status);
46 void OnTimeout();
47
48 MessageLoop* message_loop_;
49 bool signaled_;
50 PipelineStatus status_;
51
52 DISALLOW_COPY_AND_ASSIGN(WaitableMessageLoopEvent);
53 };
54
55 } // namespace media
56
57 #endif // MEDIA_BASE_TEST_HELPERS_H_
OLDNEW
« 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