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

Side by Side Diff: media/video/capture/video_capture_device_unittest.cc

Issue 7757002: Disables camera hardware dependent tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 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 | « 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/memory/scoped_ptr.h" 5 #include "base/memory/scoped_ptr.h"
6 #include "base/synchronization/waitable_event.h" 6 #include "base/synchronization/waitable_event.h"
7 #include "base/test/test_timeouts.h"
7 #include "base/threading/thread.h" 8 #include "base/threading/thread.h"
8 #include "media/video/capture/fake_video_capture_device.h" 9 #include "media/video/capture/fake_video_capture_device.h"
9 #include "media/video/capture/video_capture_device.h" 10 #include "media/video/capture/video_capture_device.h"
10 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 using ::testing::_; 14 using ::testing::_;
14 using ::testing::AnyNumber; 15 using ::testing::AnyNumber;
15 using ::testing::Return; 16 using ::testing::Return;
16 using ::testing::AtLeast; 17 using ::testing::AtLeast;
17 18
18 namespace media { 19 namespace media {
19 const int kWaitTime = 3000;
20 20
21 class MockFrameObserver: public media::VideoCaptureDevice::EventHandler { 21 class MockFrameObserver: public media::VideoCaptureDevice::EventHandler {
22 public: 22 public:
23 MOCK_METHOD0(OnErr, void()); 23 MOCK_METHOD0(OnErr, void());
24 MOCK_METHOD3(OnFrameInfo, void(int width, int height, int frame_rate)); 24 MOCK_METHOD3(OnFrameInfo, void(int width, int height, int frame_rate));
25 25
26 explicit MockFrameObserver(base::WaitableEvent* wait_event) 26 explicit MockFrameObserver(base::WaitableEvent* wait_event)
27 : wait_event_(wait_event) {} 27 : wait_event_(wait_event) {}
28 28
29 virtual void OnError() OVERRIDE { 29 virtual void OnError() OVERRIDE {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 }; 62 };
63 63
64 TEST_F(VideoCaptureDeviceTest, OpenInvalidDevice) { 64 TEST_F(VideoCaptureDeviceTest, OpenInvalidDevice) {
65 VideoCaptureDevice::Name device_name; 65 VideoCaptureDevice::Name device_name;
66 device_name.device_name = "jibberish"; 66 device_name.device_name = "jibberish";
67 device_name.unique_id = "jibberish"; 67 device_name.unique_id = "jibberish";
68 VideoCaptureDevice* device = VideoCaptureDevice::Create(device_name); 68 VideoCaptureDevice* device = VideoCaptureDevice::Create(device_name);
69 EXPECT_TRUE(device == NULL); 69 EXPECT_TRUE(device == NULL);
70 } 70 }
71 71
72 TEST_F(VideoCaptureDeviceTest, CaptureVGA) { 72 // TODO(perkj): This test is disabled due to stability problem with certain
73 // cameras. http://www.crbug.com/94134
74 // Also we don't want to run the test on try-bots since there is no camera
scherkus (not reviewing) 2011/08/29 16:22:28 nit: these comments about not running on try bots
perkj_chrome 2011/08/29 16:50:22 Done.
75 // available.
76 TEST_F(VideoCaptureDeviceTest, DISABLED_CaptureVGA) {
73 VideoCaptureDevice::GetDeviceNames(&names_); 77 VideoCaptureDevice::GetDeviceNames(&names_);
74 // Make sure there are more than 0 cameras. 78 // Make sure there are more than 0 cameras.
scherkus (not reviewing) 2011/08/29 16:22:28 other tests have this comment removed -- want to f
perkj_chrome 2011/08/29 16:50:22 Done.
75 if (!names_.size()) { 79 if (!names_.size()) {
76 LOG(WARNING) << "No camera available. Exiting test."; 80 LOG(WARNING) << "No camera available. Exiting test.";
77 return; 81 return;
78 } 82 }
79 83
80 scoped_ptr<VideoCaptureDevice> device( 84 scoped_ptr<VideoCaptureDevice> device(
81 VideoCaptureDevice::Create(names_.front())); 85 VideoCaptureDevice::Create(names_.front()));
82 ASSERT_FALSE(device.get() == NULL); 86 ASSERT_FALSE(device.get() == NULL);
83 87
84 // Get info about the new resolution. 88 // Get info about the new resolution.
85 EXPECT_CALL(*frame_observer_, OnFrameInfo(640, 480, 30)) 89 EXPECT_CALL(*frame_observer_, OnFrameInfo(640, 480, 30))
86 .Times(1); 90 .Times(1);
87 91
88 EXPECT_CALL(*frame_observer_, OnErr()) 92 EXPECT_CALL(*frame_observer_, OnErr())
89 .Times(0); 93 .Times(0);
90 94
91 device->Allocate(640, 480, 30, frame_observer_.get()); 95 device->Allocate(640, 480, 30, frame_observer_.get());
92 device->Start(); 96 device->Start();
93 // Wait for 3s or for captured frame. 97 // Wait for 3s or for captured frame.
94 EXPECT_TRUE(wait_event_.TimedWait( 98 EXPECT_TRUE(wait_event_.TimedWait(base::TimeDelta::FromMilliseconds(
95 base::TimeDelta::FromMilliseconds(kWaitTime))); 99 TestTimeouts::action_max_timeout_ms())));
96 device->Stop(); 100 device->Stop();
97 device->DeAllocate(); 101 device->DeAllocate();
98 } 102 }
99 103
100 TEST_F(VideoCaptureDeviceTest, Capture720p) { 104 // TODO(perkj): This test is disabled due to stability problem with certain
105 // cameras. http://www.crbug.com/94134
106 // Also we don't want to run the test on try-bots since there is no camera
107 // available.
108 TEST_F(VideoCaptureDeviceTest, DISABLED_Capture720p) {
101 VideoCaptureDevice::GetDeviceNames(&names_); 109 VideoCaptureDevice::GetDeviceNames(&names_);
102 // Make sure there are more than 0 cameras. 110 // Make sure there are more than 0 cameras.
scherkus (not reviewing) 2011/08/29 16:22:28 ditto on both comments
perkj_chrome 2011/08/29 16:50:22 Done.
103 if (!names_.size()) { 111 if (!names_.size()) {
104 LOG(WARNING) << "No camera available. Exiting test."; 112 LOG(WARNING) << "No camera available. Exiting test.";
105 return; 113 return;
106 } 114 }
107 115
108 scoped_ptr<VideoCaptureDevice> device( 116 scoped_ptr<VideoCaptureDevice> device(
109 VideoCaptureDevice::Create(names_.front())); 117 VideoCaptureDevice::Create(names_.front()));
110 ASSERT_FALSE(device.get() == NULL); 118 ASSERT_FALSE(device.get() == NULL);
111 119
112 // Get info about the new resolution. 120 // Get info about the new resolution.
113 // We don't care about the resulting resolution or frame rate as it might 121 // We don't care about the resulting resolution or frame rate as it might
114 // be different from one machine to the next. 122 // be different from one machine to the next.
115 EXPECT_CALL(*frame_observer_, OnFrameInfo(_, _, _)) 123 EXPECT_CALL(*frame_observer_, OnFrameInfo(_, _, _))
116 .Times(1); 124 .Times(1);
117 125
118 EXPECT_CALL(*frame_observer_, OnErr()) 126 EXPECT_CALL(*frame_observer_, OnErr())
119 .Times(0); 127 .Times(0);
120 128
121 device->Allocate(1280, 720, 30, frame_observer_.get()); 129 device->Allocate(1280, 720, 30, frame_observer_.get());
122 device->Start(); 130 device->Start();
123 // Get captured video frames. 131 // Get captured video frames.
124 EXPECT_TRUE(wait_event_.TimedWait( 132 EXPECT_TRUE(wait_event_.TimedWait(base::TimeDelta::FromMilliseconds(
125 base::TimeDelta::FromMilliseconds(kWaitTime))); 133 TestTimeouts::action_max_timeout_ms())));
126 device->Stop(); 134 device->Stop();
127 device->DeAllocate(); 135 device->DeAllocate();
128 } 136 }
129 137
130 TEST_F(VideoCaptureDeviceTest, AllocateSameCameraTwice) { 138 // TODO(perkj): This test is disabled due to stability problem with certain
139 // cameras. http://www.crbug.com/94134
140 // Also we don't want to run the test on try-bots since there is no camera
scherkus (not reviewing) 2011/08/29 16:22:28 ditto
perkj_chrome 2011/08/29 16:50:22 Done.
141 // available.
142 TEST_F(VideoCaptureDeviceTest, DISABLED_AllocateSameCameraTwice) {
131 VideoCaptureDevice::GetDeviceNames(&names_); 143 VideoCaptureDevice::GetDeviceNames(&names_);
132 if (!names_.size()) { 144 if (!names_.size()) {
133 LOG(WARNING) << "No camera available. Exiting test."; 145 LOG(WARNING) << "No camera available. Exiting test.";
134 return; 146 return;
135 } 147 }
136 scoped_ptr<VideoCaptureDevice> device1( 148 scoped_ptr<VideoCaptureDevice> device1(
137 VideoCaptureDevice::Create(names_.front())); 149 VideoCaptureDevice::Create(names_.front()));
138 ASSERT_TRUE(device1.get() != NULL); 150 ASSERT_TRUE(device1.get() != NULL);
139 151
140 scoped_ptr<VideoCaptureDevice> device2( 152 scoped_ptr<VideoCaptureDevice> device2(
141 VideoCaptureDevice::Create(names_.front())); 153 VideoCaptureDevice::Create(names_.front()));
142 ASSERT_TRUE(device2.get() != NULL); 154 ASSERT_TRUE(device2.get() != NULL);
143 155
144 // 1. Get info about the new resolution on the first allocated camera 156 // 1. Get info about the new resolution on the first allocated camera
145 EXPECT_CALL(*frame_observer_, OnFrameInfo(640, 480, 30)); 157 EXPECT_CALL(*frame_observer_, OnFrameInfo(640, 480, 30));
146 158
147 device1->Allocate(640, 480, 30, frame_observer_.get()); 159 device1->Allocate(640, 480, 30, frame_observer_.get());
148 160
149 // 2. Error when trying to allocate the same camera again. 161 // 2. Error when trying to allocate the same camera again.
150 EXPECT_CALL(*frame_observer_, OnErr()); 162 EXPECT_CALL(*frame_observer_, OnErr());
151 device2->Allocate(640, 480, 30, frame_observer_.get()); 163 device2->Allocate(640, 480, 30, frame_observer_.get());
152 164
153 device1->DeAllocate(); 165 device1->DeAllocate();
154 device2->DeAllocate(); 166 device2->DeAllocate();
155 } 167 }
156 168
157 TEST_F(VideoCaptureDeviceTest, AllocateBadSize) { 169 // TODO(perkj): This test is disabled due to stability problem with certain
170 // cameras. http://www.crbug.com/94134
171 // Also we don't want to run the test on try-bots since there is no camera
scherkus (not reviewing) 2011/08/29 16:22:28 ditto
perkj_chrome 2011/08/29 16:50:22 Done.
172 // available.
173 TEST_F(VideoCaptureDeviceTest, DISABLED_AllocateBadSize) {
158 VideoCaptureDevice::GetDeviceNames(&names_); 174 VideoCaptureDevice::GetDeviceNames(&names_);
159 if (!names_.size()) { 175 if (!names_.size()) {
160 LOG(WARNING) << "No camera available. Exiting test."; 176 LOG(WARNING) << "No camera available. Exiting test.";
161 return; 177 return;
162 } 178 }
163 scoped_ptr<VideoCaptureDevice> device( 179 scoped_ptr<VideoCaptureDevice> device(
164 VideoCaptureDevice::Create(names_.front())); 180 VideoCaptureDevice::Create(names_.front()));
165 ASSERT_TRUE(device.get() != NULL); 181 ASSERT_TRUE(device.get() != NULL);
166 182
167 EXPECT_CALL(*frame_observer_, OnErr()) 183 EXPECT_CALL(*frame_observer_, OnErr())
168 .Times(0); 184 .Times(0);
169 185
170 // get info about the new resolution 186 // get info about the new resolution
171 EXPECT_CALL(*frame_observer_, OnFrameInfo(640, 480 , _)) 187 EXPECT_CALL(*frame_observer_, OnFrameInfo(640, 480 , _))
172 .Times(AtLeast(1)); 188 .Times(AtLeast(1));
173 189
174 device->Allocate(637, 472, 35, frame_observer_.get()); 190 device->Allocate(637, 472, 35, frame_observer_.get());
175 device->DeAllocate(); 191 device->DeAllocate();
176 } 192 }
177 193
178 TEST_F(VideoCaptureDeviceTest, ReAllocateCamera) { 194 // TODO(perkj): This test is disabled due to stability problem with certain
195 // cameras. http://www.crbug.com/94134
196 // Also we don't want to run the test on try-bots since there is no camera
197 // available.
scherkus (not reviewing) 2011/08/29 16:22:28 ditto
perkj_chrome 2011/08/29 16:50:22 Done.
198 TEST_F(VideoCaptureDeviceTest, DISABLED_ReAllocateCamera) {
179 VideoCaptureDevice::GetDeviceNames(&names_); 199 VideoCaptureDevice::GetDeviceNames(&names_);
180 if (!names_.size()) { 200 if (!names_.size()) {
181 LOG(WARNING) << "No camera available. Exiting test."; 201 LOG(WARNING) << "No camera available. Exiting test.";
182 return; 202 return;
183 } 203 }
184 scoped_ptr<VideoCaptureDevice> device( 204 scoped_ptr<VideoCaptureDevice> device(
185 VideoCaptureDevice::Create(names_.front())); 205 VideoCaptureDevice::Create(names_.front()));
186 ASSERT_TRUE(device.get() != NULL); 206 ASSERT_TRUE(device.get() != NULL);
187 EXPECT_CALL(*frame_observer_, OnErr()) 207 EXPECT_CALL(*frame_observer_, OnErr())
188 .Times(0); 208 .Times(0);
189 // get info about the new resolution 209 // get info about the new resolution
190 EXPECT_CALL(*frame_observer_, OnFrameInfo(640, 480, _)); 210 EXPECT_CALL(*frame_observer_, OnFrameInfo(640, 480, _));
191 211
192 EXPECT_CALL(*frame_observer_, OnFrameInfo(320, 240, _)); 212 EXPECT_CALL(*frame_observer_, OnFrameInfo(320, 240, _));
193 213
194 device->Allocate(640, 480, 30, frame_observer_.get()); 214 device->Allocate(640, 480, 30, frame_observer_.get());
195 device->Start(); 215 device->Start();
196 // Nothing shall happen. 216 // Nothing shall happen.
197 device->Allocate(1280, 1024, 30, frame_observer_.get()); 217 device->Allocate(1280, 1024, 30, frame_observer_.get());
198 device->DeAllocate(); 218 device->DeAllocate();
199 // Allocate new size 320, 240 219 // Allocate new size 320, 240
200 device->Allocate(320, 240, 30, frame_observer_.get()); 220 device->Allocate(320, 240, 30, frame_observer_.get());
201 221
202 device->Start(); 222 device->Start();
203 // Get captured video frames. 223 // Get captured video frames.
204 EXPECT_TRUE(wait_event_.TimedWait( 224 EXPECT_TRUE(wait_event_.TimedWait(base::TimeDelta::FromMilliseconds(
205 base::TimeDelta::FromMilliseconds(kWaitTime))); 225 TestTimeouts::action_max_timeout_ms())));
206 device->Stop(); 226 device->Stop();
207 device->DeAllocate(); 227 device->DeAllocate();
208 } 228 }
209 229
210 TEST_F(VideoCaptureDeviceTest, DeAllocateCameraWhileRunning) { 230 // TODO(perkj): This test is disabled due to stability problem with certain
231 // cameras. http://www.crbug.com/94134
232 // Also we don't want to run the test on try-bots since there is no camera
233 // available.
scherkus (not reviewing) 2011/08/29 16:22:28 ditto
perkj_chrome 2011/08/29 16:50:22 Done.
234 TEST_F(VideoCaptureDeviceTest, DISABLED_DeAllocateCameraWhileRunning) {
211 VideoCaptureDevice::GetDeviceNames(&names_); 235 VideoCaptureDevice::GetDeviceNames(&names_);
212 if (!names_.size()) { 236 if (!names_.size()) {
213 LOG(WARNING) << "No camera available. Exiting test."; 237 LOG(WARNING) << "No camera available. Exiting test.";
214 return; 238 return;
215 } 239 }
216 scoped_ptr<VideoCaptureDevice> device( 240 scoped_ptr<VideoCaptureDevice> device(
217 VideoCaptureDevice::Create(names_.front())); 241 VideoCaptureDevice::Create(names_.front()));
218 ASSERT_TRUE(device.get() != NULL); 242 ASSERT_TRUE(device.get() != NULL);
219 243
220 EXPECT_CALL(*frame_observer_, OnErr()) 244 EXPECT_CALL(*frame_observer_, OnErr())
221 .Times(0); 245 .Times(0);
222 // Get info about the new resolution. 246 // Get info about the new resolution.
223 EXPECT_CALL(*frame_observer_, OnFrameInfo(640, 480, 30)); 247 EXPECT_CALL(*frame_observer_, OnFrameInfo(640, 480, 30));
224 248
225 device->Allocate(640, 480, 30, frame_observer_.get()); 249 device->Allocate(640, 480, 30, frame_observer_.get());
226 250
227 device->Start(); 251 device->Start();
228 // Get captured video frames. 252 // Get captured video frames.
229 EXPECT_TRUE(wait_event_.TimedWait( 253 EXPECT_TRUE(wait_event_.TimedWait(base::TimeDelta::FromMilliseconds(
230 base::TimeDelta::FromMilliseconds(kWaitTime))); 254 TestTimeouts::action_max_timeout_ms())));
231 device->DeAllocate(); 255 device->DeAllocate();
232 } 256 }
233 257
234 TEST_F(VideoCaptureDeviceTest, TestFakeCapture) { 258 TEST_F(VideoCaptureDeviceTest, TestFakeCapture) {
235 VideoCaptureDevice::Names names; 259 VideoCaptureDevice::Names names;
236 260
237 FakeVideoCaptureDevice::GetDeviceNames(&names); 261 FakeVideoCaptureDevice::GetDeviceNames(&names);
238 262
239 ASSERT_GT(static_cast<int>(names.size()), 0); 263 ASSERT_GT(static_cast<int>(names.size()), 0);
240 264
241 scoped_ptr<VideoCaptureDevice> device( 265 scoped_ptr<VideoCaptureDevice> device(
242 FakeVideoCaptureDevice::Create(names.front())); 266 FakeVideoCaptureDevice::Create(names.front()));
243 ASSERT_TRUE(device.get() != NULL); 267 ASSERT_TRUE(device.get() != NULL);
244 268
245 // Get info about the new resolution. 269 // Get info about the new resolution.
246 EXPECT_CALL(*frame_observer_, OnFrameInfo(640, 480, 30)) 270 EXPECT_CALL(*frame_observer_, OnFrameInfo(640, 480, 30))
247 .Times(1); 271 .Times(1);
248 272
249 EXPECT_CALL(*frame_observer_, OnErr()) 273 EXPECT_CALL(*frame_observer_, OnErr())
250 .Times(0); 274 .Times(0);
251 275
252 device->Allocate(640, 480, 30, frame_observer_.get()); 276 device->Allocate(640, 480, 30, frame_observer_.get());
253 277
254 device->Start(); 278 device->Start();
255 EXPECT_TRUE(wait_event_.TimedWait( 279 EXPECT_TRUE(wait_event_.TimedWait(base::TimeDelta::FromMilliseconds(
256 base::TimeDelta::FromMilliseconds(kWaitTime))); 280 TestTimeouts::action_max_timeout_ms())));
257 device->Stop(); 281 device->Stop();
258 device->DeAllocate(); 282 device->DeAllocate();
259 } 283 }
260 284
261 }; // namespace media 285 }; // namespace media
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