OLD | NEW |
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 #include "base/message_loop.h" | 5 #include "base/message_loop.h" |
6 #include "content/common/child_process.h" | 6 #include "content/common/child_process.h" |
7 #include "content/common/media/video_capture_messages.h" | 7 #include "content/common/media/video_capture_messages.h" |
8 #include "content/renderer/media/video_capture_impl.h" | 8 #include "content/renderer/media/video_capture_impl.h" |
9 #include "testing/gmock/include/gmock/gmock.h" | 9 #include "testing/gmock/include/gmock/gmock.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureClient); | 56 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureClient); |
57 }; | 57 }; |
58 | 58 |
59 class VideoCaptureImplTest : public ::testing::Test { | 59 class VideoCaptureImplTest : public ::testing::Test { |
60 public: | 60 public: |
61 class MockVideoCaptureImpl : public VideoCaptureImpl { | 61 class MockVideoCaptureImpl : public VideoCaptureImpl { |
62 public: | 62 public: |
63 MockVideoCaptureImpl(const media::VideoCaptureSessionId id, | 63 MockVideoCaptureImpl(const media::VideoCaptureSessionId id, |
64 scoped_refptr<base::MessageLoopProxy> ml_proxy, | 64 scoped_refptr<base::MessageLoopProxy> ml_proxy, |
65 VideoCaptureMessageFilter* filter) | 65 VideoCaptureMessageFilter* filter) |
66 : VideoCaptureImpl(id, ml_proxy, filter) { | 66 : VideoCaptureImpl(id, ml_proxy.get(), filter) {} |
67 } | |
68 virtual ~MockVideoCaptureImpl() {} | 67 virtual ~MockVideoCaptureImpl() {} |
69 | 68 |
70 // Override Send() to mimic device to send events. | 69 // Override Send() to mimic device to send events. |
71 virtual void Send(IPC::Message* message) OVERRIDE { | 70 virtual void Send(IPC::Message* message) OVERRIDE { |
72 CHECK(message); | 71 CHECK(message); |
73 | 72 |
74 // In this method, messages are sent to the according handlers as if | 73 // In this method, messages are sent to the according handlers as if |
75 // we are the device. | 74 // we are the device. |
76 bool handled = true; | 75 bool handled = true; |
77 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureImpl, *message) | 76 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureImpl, *message) |
(...skipping 26 matching lines...) Expand all Loading... |
104 | 103 |
105 VideoCaptureImplTest() { | 104 VideoCaptureImplTest() { |
106 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); | 105 message_loop_.reset(new base::MessageLoop(base::MessageLoop::TYPE_IO)); |
107 message_loop_proxy_ = | 106 message_loop_proxy_ = |
108 base::MessageLoopProxy::current().get(); | 107 base::MessageLoopProxy::current().get(); |
109 child_process_.reset(new ChildProcess()); | 108 child_process_.reset(new ChildProcess()); |
110 | 109 |
111 message_filter_ = new MockVideoCaptureMessageFilter; | 110 message_filter_ = new MockVideoCaptureMessageFilter; |
112 session_id_ = 1; | 111 session_id_ = 1; |
113 | 112 |
114 video_capture_impl_ = new MockVideoCaptureImpl(session_id_, | 113 video_capture_impl_ = new MockVideoCaptureImpl( |
115 message_loop_proxy_, | 114 session_id_, message_loop_proxy_, message_filter_.get()); |
116 message_filter_); | |
117 | 115 |
118 video_capture_impl_->device_id_ = 2; | 116 video_capture_impl_->device_id_ = 2; |
119 } | 117 } |
120 | 118 |
121 virtual ~VideoCaptureImplTest() { | 119 virtual ~VideoCaptureImplTest() { |
122 delete video_capture_impl_; | 120 delete video_capture_impl_; |
123 } | 121 } |
124 | 122 |
125 protected: | 123 protected: |
126 scoped_ptr<base::MessageLoop> message_loop_; | 124 scoped_ptr<base::MessageLoop> message_loop_; |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 .WillOnce(Return()); | 291 .WillOnce(Return()); |
294 EXPECT_CALL(*client2, OnRemoved(_)) | 292 EXPECT_CALL(*client2, OnRemoved(_)) |
295 .WillOnce(Return()); | 293 .WillOnce(Return()); |
296 | 294 |
297 video_capture_impl_->StopCapture(client1.get()); | 295 video_capture_impl_->StopCapture(client1.get()); |
298 video_capture_impl_->StopCapture(client2.get()); | 296 video_capture_impl_->StopCapture(client2.get()); |
299 message_loop_->RunUntilIdle(); | 297 message_loop_->RunUntilIdle(); |
300 } | 298 } |
301 | 299 |
302 } // namespace content | 300 } // namespace content |
OLD | NEW |