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

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

Issue 2749543003: Reset TaskScheduler during PepperToVideoTrackAdapterTest tear down. (Closed)
Patch Set: Created 3 years, 9 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 | no next file » | 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) 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 <memory>
5 #include <string> 6 #include <string>
6 7
8 #include "base/memory/ptr_util.h"
7 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/task_scheduler/task_scheduler.h"
8 #include "content/child/child_process.h" 11 #include "content/child/child_process.h"
9 #include "content/public/test/mock_render_thread.h" 12 #include "content/public/test/mock_render_thread.h"
10 #include "content/renderer/media/media_stream.h" 13 #include "content/renderer/media/media_stream.h"
11 #include "content/renderer/media/media_stream_video_track.h" 14 #include "content/renderer/media/media_stream_video_track.h"
12 #include "content/renderer/media/mock_media_stream_registry.h" 15 #include "content/renderer/media/mock_media_stream_registry.h"
13 #include "content/renderer/media/mock_media_stream_video_sink.h" 16 #include "content/renderer/media/mock_media_stream_video_sink.h"
14 #include "content/renderer/media/pepper_to_video_track_adapter.h" 17 #include "content/renderer/media/pepper_to_video_track_adapter.h"
15 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" 18 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
16 #include "content/renderer/pepper/ppb_image_data_impl.h" 19 #include "content/renderer/pepper/ppb_image_data_impl.h"
17 #include "content/test/ppapi_unittest.h" 20 #include "content/test/ppapi_unittest.h"
(...skipping 17 matching lines...) Expand all
35 class PepperToVideoTrackAdapterTest : public PpapiUnittest { 38 class PepperToVideoTrackAdapterTest : public PpapiUnittest {
36 public: 39 public:
37 PepperToVideoTrackAdapterTest() : registry_(new MockMediaStreamRegistry()) { 40 PepperToVideoTrackAdapterTest() : registry_(new MockMediaStreamRegistry()) {
38 registry_->Init(kTestStreamUrl); 41 registry_->Init(kTestStreamUrl);
39 } 42 }
40 43
41 void TearDown() override { 44 void TearDown() override {
42 registry_.reset(); 45 registry_.reset();
43 blink::WebHeap::collectAllGarbageForTesting(); 46 blink::WebHeap::collectAllGarbageForTesting();
44 PpapiUnittest::TearDown(); 47 PpapiUnittest::TearDown();
48
49 child_process_.reset();
50
51 // Clear the TaskScheduler registered by the ChildProcess. ChildProcess does
52 // not clear the TaskScheduler itself because CONTINUE_ON_SHUTDOWN tasks are
53 // allowed to outlive it.
54 base::TaskScheduler::GetInstance()->JoinForTesting();
55 base::TaskScheduler::SetInstance(nullptr);
45 } 56 }
46 57
47 protected: 58 protected:
48 // A ChildProcess and a MessageLoop are both needed to fool the Tracks and
49 // Sources inside |registry_| into believing they are on the right threads.
50 const ChildProcess child_process_;
51 const MockRenderThread render_thread_;
52 std::unique_ptr<MockMediaStreamRegistry> registry_; 59 std::unique_ptr<MockMediaStreamRegistry> registry_;
60
61 // A ChildProcess is needed by content::PepperToVideoTrackAdapter::Open.
62 std::unique_ptr<ChildProcess> child_process_ =
63 base::MakeUnique<ChildProcess>();
53 }; 64 };
54 65
55 TEST_F(PepperToVideoTrackAdapterTest, Open) { 66 TEST_F(PepperToVideoTrackAdapterTest, Open) {
56 // |frame_writer| is a proxy and is owned by whoever call Open. 67 // |frame_writer| is a proxy and is owned by whoever call Open.
57 FrameWriterInterface* frame_writer = nullptr; 68 FrameWriterInterface* frame_writer = nullptr;
58 // Unknow url will return false. 69 // Unknow url will return false.
59 EXPECT_FALSE(PepperToVideoTrackAdapter::Open(registry_.get(), 70 EXPECT_FALSE(PepperToVideoTrackAdapter::Open(registry_.get(),
60 kUnknownStreamUrl, &frame_writer)); 71 kUnknownStreamUrl, &frame_writer));
61 EXPECT_TRUE(PepperToVideoTrackAdapter::Open(registry_.get(), 72 EXPECT_TRUE(PepperToVideoTrackAdapter::Open(registry_.get(),
62 kTestStreamUrl, &frame_writer)); 73 kTestStreamUrl, &frame_writer));
63 delete frame_writer; 74 delete frame_writer;
64 } 75 }
65 76
66 TEST_F(PepperToVideoTrackAdapterTest, PutFrame) { 77 TEST_F(PepperToVideoTrackAdapterTest, PutFrame) {
78 MockRenderThread render_thread;
67 FrameWriterInterface* frame_writer = NULL; 79 FrameWriterInterface* frame_writer = NULL;
68 EXPECT_TRUE(PepperToVideoTrackAdapter::Open(registry_.get(), 80 EXPECT_TRUE(PepperToVideoTrackAdapter::Open(registry_.get(),
69 kTestStreamUrl, &frame_writer)); 81 kTestStreamUrl, &frame_writer));
70 ASSERT_TRUE(frame_writer); 82 ASSERT_TRUE(frame_writer);
71 83
72 // Verify the video track has been added. 84 // Verify the video track has been added.
73 const blink::WebMediaStream test_stream = registry_->test_stream(); 85 const blink::WebMediaStream test_stream = registry_->test_stream();
74 blink::WebVector<blink::WebMediaStreamTrack> video_tracks; 86 blink::WebVector<blink::WebMediaStreamTrack> video_tracks;
75 test_stream.videoTracks(video_tracks); 87 test_stream.videoTracks(video_tracks);
76 ASSERT_EQ(1u, video_tracks.size()); 88 ASSERT_EQ(1u, video_tracks.size());
(...skipping 24 matching lines...) Expand all
101 base::RunLoop().RunUntilIdle(); 113 base::RunLoop().RunUntilIdle();
102 } 114 }
103 EXPECT_EQ(1, sink.number_of_frames()); 115 EXPECT_EQ(1, sink.number_of_frames());
104 native_track->RemoveSink(&sink); 116 native_track->RemoveSink(&sink);
105 117
106 // The |frame_writer| is a proxy and is owned by whoever call Open. 118 // The |frame_writer| is a proxy and is owned by whoever call Open.
107 delete frame_writer; 119 delete frame_writer;
108 } 120 }
109 121
110 } // namespace content 122 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698