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

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

Issue 10095011: Remove flaky unit test VideoCaptureTest::AllocateSameCameraTwice (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Readded DISABLED_MAYBE_AllocateBadSize Created 8 years, 8 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/message_loop.h" 6 #include "base/message_loop.h"
7 #include "base/synchronization/waitable_event.h" 7 #include "base/synchronization/waitable_event.h"
8 #include "base/test/test_timeouts.h" 8 #include "base/test/test_timeouts.h"
9 #include "base/threading/thread.h" 9 #include "base/threading/thread.h"
10 #include "media/video/capture/fake_video_capture_device.h" 10 #include "media/video/capture/fake_video_capture_device.h"
11 #include "media/video/capture/video_capture_device.h" 11 #include "media/video/capture/video_capture_device.h"
12 #include "testing/gmock/include/gmock/gmock.h" 12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 13 #include "testing/gtest/include/gtest/gtest.h"
14 14
15 #if defined(OS_MACOSX) 15 #if defined(OS_MACOSX)
16 // The camera is 'locked' by the application once started on Mac OS X, not when
17 // allocated as for Windows and Linux, and this test case will fail.
18 #define MAYBE_AllocateSameCameraTwice DISABLED_AllocateSameCameraTwice
19 #else
20 #define MAYBE_AllocateSameCameraTwice AllocateSameCameraTwice
21 #endif
22
23 #if defined(OS_MACOSX)
24 // Mac/QTKit will always give you the size you ask for and this case will fail. 16 // Mac/QTKit will always give you the size you ask for and this case will fail.
25 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize 17 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize
26 #else 18 #else
27 #define MAYBE_AllocateBadSize AllocateBadSize 19 #define MAYBE_AllocateBadSize AllocateBadSize
28 #endif 20 #endif
29 21
30 using ::testing::_; 22 using ::testing::_;
31 using ::testing::AnyNumber; 23 using ::testing::AnyNumber;
32 using ::testing::Return; 24 using ::testing::Return;
33 using ::testing::AtLeast; 25 using ::testing::AtLeast;
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
143 device->Allocate(1280, 720, 30, frame_observer_.get()); 135 device->Allocate(1280, 720, 30, frame_observer_.get());
144 device->Start(); 136 device->Start();
145 // Get captured video frames. 137 // Get captured video frames.
146 PostQuitTask(); 138 PostQuitTask();
147 EXPECT_TRUE(wait_event_.TimedWait(base::TimeDelta::FromMilliseconds( 139 EXPECT_TRUE(wait_event_.TimedWait(base::TimeDelta::FromMilliseconds(
148 TestTimeouts::action_max_timeout_ms()))); 140 TestTimeouts::action_max_timeout_ms())));
149 device->Stop(); 141 device->Stop();
150 device->DeAllocate(); 142 device->DeAllocate();
151 } 143 }
152 144
153 TEST_F(VideoCaptureDeviceTest, MAYBE_AllocateSameCameraTwice) {
154 VideoCaptureDevice::GetDeviceNames(&names_);
155 if (!names_.size()) {
156 LOG(WARNING) << "No camera available. Exiting test.";
157 return;
158 }
159 scoped_ptr<VideoCaptureDevice> device1(
160 VideoCaptureDevice::Create(names_.front()));
161 ASSERT_TRUE(device1.get() != NULL);
162
163 scoped_ptr<VideoCaptureDevice> device2(
164 VideoCaptureDevice::Create(names_.front()));
165 ASSERT_TRUE(device2.get() != NULL);
166
167 // 1. Get info about the new resolution on the first allocated camera
168 EXPECT_CALL(*frame_observer_, OnFrameInfo(640, 480, 30));
169
170 device1->Allocate(640, 480, 30, frame_observer_.get());
171
172 // 2. Error when trying to allocate the same camera again.
173 EXPECT_CALL(*frame_observer_, OnErr());
174 device2->Allocate(640, 480, 30, frame_observer_.get());
175
176 device1->DeAllocate();
177 device2->DeAllocate();
178 }
179
180 TEST_F(VideoCaptureDeviceTest, MAYBE_AllocateBadSize) { 145 TEST_F(VideoCaptureDeviceTest, MAYBE_AllocateBadSize) {
181 VideoCaptureDevice::GetDeviceNames(&names_); 146 VideoCaptureDevice::GetDeviceNames(&names_);
182 if (!names_.size()) { 147 if (!names_.size()) {
183 LOG(WARNING) << "No camera available. Exiting test."; 148 LOG(WARNING) << "No camera available. Exiting test.";
184 return; 149 return;
185 } 150 }
186 scoped_ptr<VideoCaptureDevice> device( 151 scoped_ptr<VideoCaptureDevice> device(
187 VideoCaptureDevice::Create(names_.front())); 152 VideoCaptureDevice::Create(names_.front()));
188 ASSERT_TRUE(device.get() != NULL); 153 ASSERT_TRUE(device.get() != NULL);
189 154
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 device->Allocate(640, 480, 30, frame_observer_.get()); 242 device->Allocate(640, 480, 30, frame_observer_.get());
278 243
279 device->Start(); 244 device->Start();
280 EXPECT_TRUE(wait_event_.TimedWait(base::TimeDelta::FromMilliseconds( 245 EXPECT_TRUE(wait_event_.TimedWait(base::TimeDelta::FromMilliseconds(
281 TestTimeouts::action_max_timeout_ms()))); 246 TestTimeouts::action_max_timeout_ms())));
282 device->Stop(); 247 device->Stop();
283 device->DeAllocate(); 248 device->DeAllocate();
284 } 249 }
285 250
286 }; // namespace media 251 }; // 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