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/media/video_capture_messages.h" | 6 #include "content/common/media/video_capture_messages.h" |
7 #include "content/renderer/media/video_capture_impl.h" | 7 #include "content/renderer/media/video_capture_impl.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
11 using ::testing::_; | 11 using ::testing::_; |
12 using ::testing::AtLeast; | 12 using ::testing::AtLeast; |
13 using ::testing::Return; | 13 using ::testing::Return; |
14 | 14 |
15 #define CAPABILITY_SMALL {176, 144, 30, media::VideoCaptureCapability::kI420, \ | 15 #define CAPABILITY_SMALL {176, 144, 30, media::VideoCaptureCapability::kI420, \ |
16 0, false } | 16 0, false } |
17 #define CAPABILITY_LARGE {320, 240, 30, media::VideoCaptureCapability::kI420, \ | 17 #define CAPABILITY_LARGE {320, 240, 30, media::VideoCaptureCapability::kI420, \ |
18 0, false } | 18 0, false } |
19 | 19 |
20 class MockVideoCaptureMessageFilter : public VideoCaptureMessageFilter { | 20 class MockVideoCaptureMessageFilter : public VideoCaptureMessageFilter { |
21 public: | 21 public: |
22 MockVideoCaptureMessageFilter() : VideoCaptureMessageFilter() {} | 22 MockVideoCaptureMessageFilter() : VideoCaptureMessageFilter() {} |
23 | 23 |
24 // Filter implementation. | 24 // Filter implementation. |
25 MOCK_METHOD1(Send, bool(IPC::Message* message)); | 25 MOCK_METHOD1(Send, bool(IPC::Message* message)); |
26 | 26 |
27 protected: | 27 protected: |
28 virtual ~MockVideoCaptureMessageFilter() {} | 28 virtual ~MockVideoCaptureMessageFilter() {} |
29 | 29 |
30 private: | 30 private: |
31 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureMessageFilter); | 31 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureMessageFilter); |
32 }; | 32 }; |
33 | 33 |
34 class MockVideoCaptureClient : public media::VideoCapture::EventHandler { | 34 class MockVideoCaptureClient : public media::VideoCapture::EventHandler { |
(...skipping 29 matching lines...) Expand all Loading... | |
64 } | 64 } |
65 virtual ~MockVideoCaptureImpl() {} | 65 virtual ~MockVideoCaptureImpl() {} |
66 | 66 |
67 // Override Send() to mimic device to send events. | 67 // Override Send() to mimic device to send events. |
68 void Send(IPC::Message* message) { | 68 void Send(IPC::Message* message) { |
69 CHECK(message); | 69 CHECK(message); |
70 | 70 |
71 // In this method, messages are sent to the according handlers as if | 71 // In this method, messages are sent to the according handlers as if |
72 // we are the device. | 72 // we are the device. |
73 bool handled = true; | 73 bool handled = true; |
74 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureImpl, *message) | 74 IPC_BEGIN_MESSAGE_MAP(MockVideoCaptureImpl, *message) |
zunger
2012/07/09 20:08:26
Do these helpers not want trailing semicolons for
wjia(left Chromium)
2012/07/10 17:32:28
That macro has a trailing semicolon. Please refer
| |
75 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Start, DeviceStartCapture) | 75 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Start, DeviceStartCapture) |
76 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Pause, DevicePauseCapture) | 76 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Pause, DevicePauseCapture) |
77 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, DeviceStopCapture) | 77 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_Stop, DeviceStopCapture) |
78 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, | 78 IPC_MESSAGE_HANDLER(VideoCaptureHostMsg_BufferReady, |
79 DeviceReceiveEmptyBuffer) | 79 DeviceReceiveEmptyBuffer) |
80 IPC_MESSAGE_UNHANDLED(handled = false) | 80 IPC_MESSAGE_UNHANDLED(handled = false) |
81 IPC_END_MESSAGE_MAP() | 81 IPC_END_MESSAGE_MAP() |
82 EXPECT_TRUE(handled); | 82 EXPECT_TRUE(handled); |
83 delete message; | 83 delete message; |
84 } | 84 } |
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
286 .WillOnce(Return()); | 286 .WillOnce(Return()); |
287 EXPECT_CALL(*client2, OnStopped(_)) | 287 EXPECT_CALL(*client2, OnStopped(_)) |
288 .WillOnce(Return()); | 288 .WillOnce(Return()); |
289 EXPECT_CALL(*client2, OnRemoved(_)) | 289 EXPECT_CALL(*client2, OnRemoved(_)) |
290 .WillOnce(Return()); | 290 .WillOnce(Return()); |
291 | 291 |
292 video_capture_impl_->StopCapture(client1.get()); | 292 video_capture_impl_->StopCapture(client1.get()); |
293 video_capture_impl_->StopCapture(client2.get()); | 293 video_capture_impl_->StopCapture(client2.get()); |
294 message_loop_->RunAllPending(); | 294 message_loop_->RunAllPending(); |
295 } | 295 } |
OLD | NEW |