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

Side by Side Diff: media/base/test_helpers.h

Issue 2914603002: Replace deprecated base::NonThreadSafe in media in favor of SequenceChecker. (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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
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 <stddef.h> 8 #include <stddef.h>
9 #include <memory> 9 #include <memory>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ref_counted.h" 13 #include "base/memory/ref_counted.h"
14 #include "base/sequence_checker.h"
14 #include "base/strings/string_number_conversions.h" 15 #include "base/strings/string_number_conversions.h"
15 #include "base/threading/non_thread_safe.h"
16 #include "media/base/audio_parameters.h" 16 #include "media/base/audio_parameters.h"
17 #include "media/base/channel_layout.h" 17 #include "media/base/channel_layout.h"
18 #include "media/base/media_log.h" 18 #include "media/base/media_log.h"
19 #include "media/base/pipeline_status.h" 19 #include "media/base/pipeline_status.h"
20 #include "media/base/sample_format.h" 20 #include "media/base/sample_format.h"
21 #include "media/base/video_decoder_config.h" 21 #include "media/base/video_decoder_config.h"
22 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
23 #include "ui/gfx/geometry/size.h" 23 #include "ui/gfx/geometry/size.h"
24 24
25 namespace base { 25 namespace base {
26 class RunLoop; 26 class RunLoop;
27 class TimeDelta; 27 class TimeDelta;
28 } 28 }
29 29
30 namespace media { 30 namespace media {
31 31
32 class AudioBuffer; 32 class AudioBuffer;
33 class DecoderBuffer; 33 class DecoderBuffer;
34 34
35 // Return a callback that expects to be run once. 35 // Return a callback that expects to be run once.
36 base::Closure NewExpectedClosure(); 36 base::Closure NewExpectedClosure();
37 base::Callback<void(bool)> NewExpectedBoolCB(bool success); 37 base::Callback<void(bool)> NewExpectedBoolCB(bool success);
38 PipelineStatusCB NewExpectedStatusCB(PipelineStatus status); 38 PipelineStatusCB NewExpectedStatusCB(PipelineStatus status);
39 39
40 // Helper class for running a message loop until a callback has run. Useful for 40 // Helper class for running a message loop until a callback has run. Useful for
41 // testing classes that run on more than a single thread. 41 // testing classes that run on more than a single thread.
42 // 42 //
43 // Events are intended for single use and cannot be reset. 43 // Events are intended for single use and cannot be reset.
44 class WaitableMessageLoopEvent : public base::NonThreadSafe { 44 class WaitableMessageLoopEvent {
45 public: 45 public:
46 WaitableMessageLoopEvent(); 46 WaitableMessageLoopEvent();
47 explicit WaitableMessageLoopEvent(base::TimeDelta timeout); 47 explicit WaitableMessageLoopEvent(base::TimeDelta timeout);
48 ~WaitableMessageLoopEvent(); 48 ~WaitableMessageLoopEvent();
49 49
50 // Returns a thread-safe closure that will signal |this| when executed. 50 // Returns a thread-safe closure that will signal |this| when executed.
51 base::Closure GetClosure(); 51 base::Closure GetClosure();
52 PipelineStatusCB GetPipelineStatusCB(); 52 PipelineStatusCB GetPipelineStatusCB();
53 53
54 // Runs the current message loop until |this| has been signaled. 54 // Runs the current message loop until |this| has been signaled.
(...skipping 11 matching lines...) Expand all
66 66
67 private: 67 private:
68 void OnCallback(PipelineStatus status); 68 void OnCallback(PipelineStatus status);
69 void OnTimeout(); 69 void OnTimeout();
70 70
71 bool signaled_; 71 bool signaled_;
72 PipelineStatus status_; 72 PipelineStatus status_;
73 std::unique_ptr<base::RunLoop> run_loop_; 73 std::unique_ptr<base::RunLoop> run_loop_;
74 const base::TimeDelta timeout_; 74 const base::TimeDelta timeout_;
75 75
76 SEQUENCE_CHECKER(sequence_checker_);
77
76 DISALLOW_COPY_AND_ASSIGN(WaitableMessageLoopEvent); 78 DISALLOW_COPY_AND_ASSIGN(WaitableMessageLoopEvent);
77 }; 79 };
78 80
79 // Provides pre-canned VideoDecoderConfig. These types are used for tests that 81 // Provides pre-canned VideoDecoderConfig. These types are used for tests that
80 // don't care about detailed parameters of the config. 82 // don't care about detailed parameters of the config.
81 class TestVideoConfig { 83 class TestVideoConfig {
82 public: 84 public:
83 // Returns a configuration that is invalid. 85 // Returns a configuration that is invalid.
84 static VideoDecoderConfig Invalid(); 86 static VideoDecoderConfig Invalid();
85 87
(...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 return CONTAINS_STRING( 246 return CONTAINS_STRING(
245 arg, "Audio buffer splice at PTS=" + base::IntToString(splice_time_us) + 247 arg, "Audio buffer splice at PTS=" + base::IntToString(splice_time_us) +
246 "us. Trimmed tail of overlapped buffer (PTS=" + 248 "us. Trimmed tail of overlapped buffer (PTS=" +
247 base::IntToString(overlapped_start_us) + "us) by " + 249 base::IntToString(overlapped_start_us) + "us) by " +
248 base::IntToString(trim_duration_us)); 250 base::IntToString(trim_duration_us));
249 } 251 }
250 252
251 } // namespace media 253 } // namespace media
252 254
253 #endif // MEDIA_BASE_TEST_HELPERS_H_ 255 #endif // MEDIA_BASE_TEST_HELPERS_H_
OLDNEW
« no previous file with comments | « no previous file | media/base/test_helpers.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698