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

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

Issue 10451087: for readability review. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: modify comments Created 8 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « content/renderer/media/video_capture_impl.cc ('k') | 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) 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/media/video_capture_messages.h" 7 #include "content/common/media/video_capture_messages.h"
7 #include "content/renderer/media/video_capture_impl.h" 8 #include "content/renderer/media/video_capture_impl.h"
8 #include "testing/gmock/include/gmock/gmock.h" 9 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
10 11
11 using ::testing::_; 12 using ::testing::_;
12 using ::testing::AtLeast; 13 using ::testing::AtLeast;
13 using ::testing::Return; 14 using ::testing::Return;
14 15
15 #define CAPABILITY_SMALL {176, 144, 30, media::VideoCaptureCapability::kI420, \ 16 #define CAPABILITY_SMALL {176, 144, 30, media::VideoCaptureCapability::kI420, \
16 0, false } 17 0, false }
17 #define CAPABILITY_LARGE {320, 240, 30, media::VideoCaptureCapability::kI420, \ 18 #define CAPABILITY_LARGE {320, 240, 30, media::VideoCaptureCapability::kI420, \
18 0, false } 19 0, false }
19 20
20 class MockVideoCaptureMessageFilter : public VideoCaptureMessageFilter { 21 class MockVideoCaptureMessageFilter : public VideoCaptureMessageFilter {
21 public: 22 public:
22 MockVideoCaptureMessageFilter() : VideoCaptureMessageFilter() {} 23 MockVideoCaptureMessageFilter() : VideoCaptureMessageFilter() {}
23 24
24 // Filter implementation. 25 // Filter implementation.
25 MOCK_METHOD1(Send, bool(IPC::Message* message)); 26 MOCK_METHOD1(Send, bool(IPC::Message* message));
26 27
27 protected: 28 protected:
28 virtual ~MockVideoCaptureMessageFilter() {} 29 virtual ~MockVideoCaptureMessageFilter() {}
29 30
30 private: 31 private:
31 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureMessageFilter); 32 DISALLOW_COPY_AND_ASSIGN(MockVideoCaptureMessageFilter);
32 }; 33 };
33 34
34 class MockVideoCaptureClient : public media::VideoCapture::EventHandler { 35 class MockVideoCaptureClient : public media::VideoCapture::EventHandler {
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 OnStateChanged(video_capture::kStopped); 97 OnStateChanged(video_capture::kStopped);
97 } 98 }
98 99
99 void DeviceReceiveEmptyBuffer(int device_id, int buffer_id) {} 100 void DeviceReceiveEmptyBuffer(int device_id, int buffer_id) {}
100 }; 101 };
101 102
102 VideoCaptureImplTest() { 103 VideoCaptureImplTest() {
103 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); 104 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO));
104 message_loop_proxy_ = 105 message_loop_proxy_ =
105 base::MessageLoopProxy::current().get(); 106 base::MessageLoopProxy::current().get();
107 child_process_.reset(new ChildProcess());
106 108
107 message_filter_ = new MockVideoCaptureMessageFilter; 109 message_filter_ = new MockVideoCaptureMessageFilter;
108 session_id_ = 1; 110 session_id_ = 1;
109 111
110 video_capture_impl_ = new MockVideoCaptureImpl(session_id_, 112 video_capture_impl_ = new MockVideoCaptureImpl(session_id_,
111 message_loop_proxy_, 113 message_loop_proxy_,
112 message_filter_); 114 message_filter_);
113 115
114 video_capture_impl_->device_id_ = 2; 116 video_capture_impl_->device_id_ = 2;
115 } 117 }
116 118
117 virtual ~VideoCaptureImplTest() { 119 virtual ~VideoCaptureImplTest() {
118 delete video_capture_impl_; 120 delete video_capture_impl_;
119 } 121 }
120 122
121 protected: 123 protected:
122 scoped_ptr<MessageLoop> message_loop_; 124 scoped_ptr<MessageLoop> message_loop_;
123 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_; 125 scoped_refptr<base::MessageLoopProxy> message_loop_proxy_;
126 scoped_ptr<ChildProcess> child_process_;
124 scoped_refptr<MockVideoCaptureMessageFilter> message_filter_; 127 scoped_refptr<MockVideoCaptureMessageFilter> message_filter_;
125 media::VideoCaptureSessionId session_id_; 128 media::VideoCaptureSessionId session_id_;
126 MockVideoCaptureImpl* video_capture_impl_; 129 MockVideoCaptureImpl* video_capture_impl_;
127 130
128 private: 131 private:
129 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImplTest); 132 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImplTest);
130 }; 133 };
131 134
132 TEST_F(VideoCaptureImplTest, Simple) { 135 TEST_F(VideoCaptureImplTest, Simple) {
133 // Execute SetCapture() and StopCapture() for one client. 136 // Execute SetCapture() and StopCapture() for one client.
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 .WillOnce(Return()); 289 .WillOnce(Return());
287 EXPECT_CALL(*client2, OnStopped(_)) 290 EXPECT_CALL(*client2, OnStopped(_))
288 .WillOnce(Return()); 291 .WillOnce(Return());
289 EXPECT_CALL(*client2, OnRemoved(_)) 292 EXPECT_CALL(*client2, OnRemoved(_))
290 .WillOnce(Return()); 293 .WillOnce(Return());
291 294
292 video_capture_impl_->StopCapture(client1.get()); 295 video_capture_impl_->StopCapture(client1.get());
293 video_capture_impl_->StopCapture(client2.get()); 296 video_capture_impl_->StopCapture(client2.get());
294 message_loop_->RunAllPending(); 297 message_loop_->RunAllPending();
295 } 298 }
OLDNEW
« no previous file with comments | « content/renderer/media/video_capture_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698