| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_BASE_TEST_HELPERS_H_ | 5 #ifndef MEDIA_BASE_TEST_HELPERS_H_ |
| 6 #define MEDIA_BASE_TEST_HELPERS_H_ | 6 #define MEDIA_BASE_TEST_HELPERS_H_ |
| 7 | 7 |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "media/base/pipeline_status.h" | 9 #include "media/base/pipeline_status.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| 11 | 11 |
| 12 namespace base { |
| 12 class MessageLoop; | 13 class MessageLoop; |
| 14 } |
| 13 | 15 |
| 14 namespace media { | 16 namespace media { |
| 15 | 17 |
| 16 // Return a callback that expects to be run once. | 18 // Return a callback that expects to be run once. |
| 17 base::Closure NewExpectedClosure(); | 19 base::Closure NewExpectedClosure(); |
| 18 PipelineStatusCB NewExpectedStatusCB(PipelineStatus status); | 20 PipelineStatusCB NewExpectedStatusCB(PipelineStatus status); |
| 19 | 21 |
| 20 // Helper class for running a message loop until a callback has run. Useful for | 22 // 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. | 23 // testing classes that run on more than a single thread. |
| 22 // | 24 // |
| (...skipping 15 matching lines...) Expand all Loading... |
| 38 // Runs the current message loop until |this| has been signaled and asserts | 40 // Runs the current message loop until |this| has been signaled and asserts |
| 39 // that the |expected| status was received. | 41 // that the |expected| status was received. |
| 40 // | 42 // |
| 41 // Fails the test if the timeout is reached. | 43 // Fails the test if the timeout is reached. |
| 42 void RunAndWaitForStatus(PipelineStatus expected); | 44 void RunAndWaitForStatus(PipelineStatus expected); |
| 43 | 45 |
| 44 private: | 46 private: |
| 45 void OnCallback(PipelineStatus status); | 47 void OnCallback(PipelineStatus status); |
| 46 void OnTimeout(); | 48 void OnTimeout(); |
| 47 | 49 |
| 48 MessageLoop* message_loop_; | 50 base::MessageLoop* message_loop_; |
| 49 bool signaled_; | 51 bool signaled_; |
| 50 PipelineStatus status_; | 52 PipelineStatus status_; |
| 51 | 53 |
| 52 DISALLOW_COPY_AND_ASSIGN(WaitableMessageLoopEvent); | 54 DISALLOW_COPY_AND_ASSIGN(WaitableMessageLoopEvent); |
| 53 }; | 55 }; |
| 54 | 56 |
| 55 } // namespace media | 57 } // namespace media |
| 56 | 58 |
| 57 #endif // MEDIA_BASE_TEST_HELPERS_H_ | 59 #endif // MEDIA_BASE_TEST_HELPERS_H_ |
| OLD | NEW |