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

Side by Side Diff: content/renderer/media/media_recorder_handler_unittest.cc

Issue 1351473006: WebmMuxer-MediaRecorderHandler: thread hopping and data ownership (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: StringPiece passed by value Created 5 years, 3 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 #include "base/run_loop.h" 5 #include "base/run_loop.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/child/child_process.h" 7 #include "content/child/child_process.h"
8 #include "content/renderer/media/media_recorder_handler.h" 8 #include "content/renderer/media/media_recorder_handler.h"
9 #include "content/renderer/media/mock_media_stream_registry.h" 9 #include "content/renderer/media/mock_media_stream_registry.h"
10 #include "media/base/video_frame.h" 10 #include "media/base/video_frame.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 bool recording() const { return media_recorder_handler_->recording_; } 50 bool recording() const { return media_recorder_handler_->recording_; }
51 bool hasVideoRecorders() const { 51 bool hasVideoRecorders() const {
52 return !media_recorder_handler_->video_recorders_.empty(); 52 return !media_recorder_handler_->video_recorders_.empty();
53 } 53 }
54 54
55 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame) { 55 void OnVideoFrameForTesting(const scoped_refptr<media::VideoFrame>& frame) {
56 media_recorder_handler_->OnVideoFrameForTesting(frame, 56 media_recorder_handler_->OnVideoFrameForTesting(frame,
57 base::TimeTicks::Now()); 57 base::TimeTicks::Now());
58 } 58 }
59 59
60 // The Class under test. Needs to be scoped_ptr to force its destruction.
61 scoped_ptr<MediaRecorderHandler> media_recorder_handler_;
62
63 // A ChildProcess and a MessageLoopForUI are both needed to fool the Tracks 60 // A ChildProcess and a MessageLoopForUI are both needed to fool the Tracks
64 // and Sources in |registry_| into believing they are on the right threads. 61 // and Sources in |registry_| into believing they are on the right threads.
65 const base::MessageLoopForUI message_loop_; 62 const base::MessageLoopForUI message_loop_;
66 const ChildProcess child_process_; 63 const ChildProcess child_process_;
67 MockMediaStreamRegistry registry_; 64 MockMediaStreamRegistry registry_;
68 65
66 // The Class under test. Needs to be scoped_ptr to force its destruction.
67 scoped_ptr<MediaRecorderHandler> media_recorder_handler_;
68
69 private: 69 private:
70 DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandlerTest); 70 DISALLOW_COPY_AND_ASSIGN(MediaRecorderHandlerTest);
71 }; 71 };
72 72
73 // Checks that canSupportMimeType() works as expected. 73 // Checks that canSupportMimeType() works as expected.
74 // TODO(mcasas): revisit this when canSupportMimeType() is fully implemented. 74 // TODO(mcasas): revisit this when canSupportMimeType() is fully implemented.
75 TEST_F(MediaRecorderHandlerTest, CanSupportMimeType) { 75 TEST_F(MediaRecorderHandlerTest, CanSupportMimeType) {
76 const WebString good_mime_type(base::UTF8ToUTF16("video/vp8")); 76 const WebString good_mime_type(base::UTF8ToUTF16("video/vp8"));
77 EXPECT_TRUE(media_recorder_handler_->canSupportMimeType(good_mime_type)); 77 EXPECT_TRUE(media_recorder_handler_->canSupportMimeType(good_mime_type));
78 78
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 } 149 }
150 150
151 media_recorder_handler_->stop(); 151 media_recorder_handler_->stop();
152 152
153 // Expect a last call on destruction, with size 0 and |lastInSlice| true. 153 // Expect a last call on destruction, with size 0 and |lastInSlice| true.
154 EXPECT_CALL(*this, writeData(nullptr, 0, true)).Times(1); 154 EXPECT_CALL(*this, writeData(nullptr, 0, true)).Times(1);
155 media_recorder_handler_.reset(); 155 media_recorder_handler_.reset();
156 } 156 }
157 157
158 } // namespace content 158 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_recorder_handler.cc ('k') | content/renderer/media/video_track_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698