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

Side by Side Diff: content/renderer/media/webrtc/video_destination_handler_unittest.cc

Issue 631903003: Move VideoDestinationHandler processing to the IO-thread. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 6 years, 2 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 (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 <string> 5 #include <string>
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "base/run_loop.h" 8 #include "base/run_loop.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/child/child_process.h" 10 #include "content/child/child_process.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 base::MessageLoop* io_message_loop() const { 50 base::MessageLoop* io_message_loop() const {
51 return child_process_->io_message_loop(); 51 return child_process_->io_message_loop();
52 } 52 }
53 53
54 protected: 54 protected:
55 scoped_ptr<ChildProcess> child_process_; 55 scoped_ptr<ChildProcess> child_process_;
56 scoped_ptr<MockMediaStreamRegistry> registry_; 56 scoped_ptr<MockMediaStreamRegistry> registry_;
57 }; 57 };
58 58
59 TEST_F(VideoDestinationHandlerTest, Open) { 59 TEST_F(VideoDestinationHandlerTest, Open) {
60 FrameWriterInterface* frame_writer = NULL; 60 VideoDestinationHandler::FrameWriterCallback frame_writer;
61
61 // Unknow url will return false. 62 // Unknow url will return false.
62 EXPECT_FALSE(VideoDestinationHandler::Open(registry_.get(), 63 EXPECT_FALSE(VideoDestinationHandler::Open(registry_.get(),
63 kUnknownStreamUrl, &frame_writer)); 64 kUnknownStreamUrl, &frame_writer));
64 EXPECT_TRUE(VideoDestinationHandler::Open(registry_.get(), 65 EXPECT_TRUE(VideoDestinationHandler::Open(registry_.get(),
65 kTestStreamUrl, &frame_writer)); 66 kTestStreamUrl, &frame_writer));
66 // The |frame_writer| is a proxy and is owned by whoever call Open.
67 delete frame_writer;
68 } 67 }
69 68
70 TEST_F(VideoDestinationHandlerTest, PutFrame) { 69 TEST_F(VideoDestinationHandlerTest, PutFrame) {
71 FrameWriterInterface* frame_writer = NULL; 70 VideoDestinationHandler::FrameWriterCallback frame_writer;
72 EXPECT_TRUE(VideoDestinationHandler::Open(registry_.get(), 71 EXPECT_TRUE(VideoDestinationHandler::Open(registry_.get(),
73 kTestStreamUrl, &frame_writer)); 72 kTestStreamUrl, &frame_writer));
74 ASSERT_TRUE(frame_writer); 73 ASSERT_FALSE(frame_writer.is_null());
75 74
76 // Verify the video track has been added. 75 // Verify the video track has been added.
77 const blink::WebMediaStream test_stream = registry_->test_stream(); 76 const blink::WebMediaStream test_stream = registry_->test_stream();
78 blink::WebVector<blink::WebMediaStreamTrack> video_tracks; 77 blink::WebVector<blink::WebMediaStreamTrack> video_tracks;
79 test_stream.videoTracks(video_tracks); 78 test_stream.videoTracks(video_tracks);
80 ASSERT_EQ(1u, video_tracks.size()); 79 ASSERT_EQ(1u, video_tracks.size());
81 80
82 // Verify the native video track has been added. 81 // Verify the native video track has been added.
83 MediaStreamVideoTrack* native_track = 82 MediaStreamVideoTrack* native_track =
84 MediaStreamVideoTrack::GetVideoTrack(video_tracks[0]); 83 MediaStreamVideoTrack::GetVideoTrack(video_tracks[0]);
85 ASSERT_TRUE(native_track != NULL); 84 ASSERT_TRUE(native_track != NULL);
86 85
87 MockMediaStreamVideoSink sink; 86 MockMediaStreamVideoSink sink;
88 native_track->AddSink(&sink, sink.GetDeliverFrameCB()); 87 native_track->AddSink(&sink, sink.GetDeliverFrameCB());
89 scoped_refptr<PPB_ImageData_Impl> image( 88 scoped_refptr<PPB_ImageData_Impl> image(
90 new PPB_ImageData_Impl(instance()->pp_instance(), 89 new PPB_ImageData_Impl(instance()->pp_instance(),
91 PPB_ImageData_Impl::ForTest())); 90 PPB_ImageData_Impl::ForTest()));
92 image->Init(PP_IMAGEDATAFORMAT_BGRA_PREMUL, 640, 360, true); 91 image->Init(PP_IMAGEDATAFORMAT_BGRA_PREMUL, 640, 360, true);
93 { 92 {
94 base::RunLoop run_loop; 93 base::RunLoop run_loop;
95 base::Closure quit_closure = run_loop.QuitClosure(); 94 base::Closure quit_closure = run_loop.QuitClosure();
96 95
97 EXPECT_CALL(sink, OnVideoFrame()).WillOnce( 96 EXPECT_CALL(sink, OnVideoFrame()).WillOnce(
98 RunClosure(quit_closure)); 97 RunClosure(quit_closure));
99 frame_writer->PutFrame(image.get(), 10); 98 frame_writer.Run(image.get(), 10);
100 run_loop.Run(); 99 run_loop.Run();
101 } 100 }
102 // TODO(perkj): Verify that the track output I420 when
103 // https://codereview.chromium.org/213423006/ is landed.
104 EXPECT_EQ(1, sink.number_of_frames()); 101 EXPECT_EQ(1, sink.number_of_frames());
105 native_track->RemoveSink(&sink); 102 native_track->RemoveSink(&sink);
106
107 // The |frame_writer| is a proxy and is owned by whoever call Open.
108 delete frame_writer;
109 } 103 }
110 104
111 } // namespace content 105 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/webrtc/video_destination_handler.cc ('k') | content/renderer/pepper/pepper_video_destination_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698