| OLD | NEW |
| 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/run_loop.h" | 7 #include "base/run_loop.h" |
| 8 #include "content/child/child_process.h" | 8 #include "content/child/child_process.h" |
| 9 #include "content/public/test/mock_render_thread.h" | 9 #include "content/public/test/mock_render_thread.h" |
| 10 #include "content/renderer/media/media_stream.h" | 10 #include "content/renderer/media/media_stream.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 blink::WebVector<blink::WebMediaStreamTrack> video_tracks; | 74 blink::WebVector<blink::WebMediaStreamTrack> video_tracks; |
| 75 test_stream.videoTracks(video_tracks); | 75 test_stream.videoTracks(video_tracks); |
| 76 ASSERT_EQ(1u, video_tracks.size()); | 76 ASSERT_EQ(1u, video_tracks.size()); |
| 77 | 77 |
| 78 // Verify the native video track has been added. | 78 // Verify the native video track has been added. |
| 79 MediaStreamVideoTrack* native_track = | 79 MediaStreamVideoTrack* native_track = |
| 80 MediaStreamVideoTrack::GetVideoTrack(video_tracks[0]); | 80 MediaStreamVideoTrack::GetVideoTrack(video_tracks[0]); |
| 81 ASSERT_TRUE(native_track != NULL); | 81 ASSERT_TRUE(native_track != NULL); |
| 82 | 82 |
| 83 MockMediaStreamVideoSink sink; | 83 MockMediaStreamVideoSink sink; |
| 84 native_track->AddSink(&sink, sink.GetDeliverFrameCB()); | 84 native_track->AddSink(&sink, sink.GetDeliverFrameCB(), false); |
| 85 scoped_refptr<PPB_ImageData_Impl> image( | 85 scoped_refptr<PPB_ImageData_Impl> image(new PPB_ImageData_Impl( |
| 86 new PPB_ImageData_Impl(instance()->pp_instance(), | 86 instance()->pp_instance(), PPB_ImageData_Impl::ForTest())); |
| 87 PPB_ImageData_Impl::ForTest())); | |
| 88 image->Init(PP_IMAGEDATAFORMAT_BGRA_PREMUL, 640, 360, true); | 87 image->Init(PP_IMAGEDATAFORMAT_BGRA_PREMUL, 640, 360, true); |
| 89 { | 88 { |
| 90 base::RunLoop run_loop; | 89 base::RunLoop run_loop; |
| 91 base::Closure quit_closure = run_loop.QuitClosure(); | 90 base::Closure quit_closure = run_loop.QuitClosure(); |
| 92 | 91 |
| 93 EXPECT_CALL(sink, OnVideoFrame()).WillOnce(RunClosure(quit_closure)); | 92 EXPECT_CALL(sink, OnVideoFrame()).WillOnce(RunClosure(quit_closure)); |
| 94 frame_writer->PutFrame(image.get(), 10); | 93 frame_writer->PutFrame(image.get(), 10); |
| 95 run_loop.Run(); | 94 run_loop.Run(); |
| 96 // Run all pending tasks to let the the test clean up before the test ends. | 95 // Run all pending tasks to let the the test clean up before the test ends. |
| 97 // This is due to that | 96 // This is due to that |
| 98 // FrameWriterDelegate::FrameWriterDelegate::DeliverFrame use | 97 // FrameWriterDelegate::FrameWriterDelegate::DeliverFrame use |
| 99 // PostTaskAndReply to the IO thread and expects the reply to process | 98 // PostTaskAndReply to the IO thread and expects the reply to process |
| 100 // on the main render thread to clean up its resources. However, the | 99 // on the main render thread to clean up its resources. However, the |
| 101 // QuitClosure above ends before that. | 100 // QuitClosure above ends before that. |
| 102 base::MessageLoop::current()->RunUntilIdle(); | 101 base::MessageLoop::current()->RunUntilIdle(); |
| 103 } | 102 } |
| 104 EXPECT_EQ(1, sink.number_of_frames()); | 103 EXPECT_EQ(1, sink.number_of_frames()); |
| 105 native_track->RemoveSink(&sink); | 104 native_track->RemoveSink(&sink); |
| 106 | 105 |
| 107 // The |frame_writer| is a proxy and is owned by whoever call Open. | 106 // The |frame_writer| is a proxy and is owned by whoever call Open. |
| 108 delete frame_writer; | 107 delete frame_writer; |
| 109 } | 108 } |
| 110 | 109 |
| 111 } // namespace content | 110 } // namespace content |
| OLD | NEW |