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

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

Issue 11860002: Add video capture on Android. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: catch only IOException Created 7 years, 10 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 | « media/video/capture/android/video_capture_device_android.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/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 "media/video/capture/video_capture_types.h" 12 #include "media/video/capture/video_capture_types.h"
13 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
14 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
15 15
16 #if defined(OS_WIN) 16 #if defined(OS_WIN)
17 #include "base/win/scoped_com_initializer.h" 17 #include "base/win/scoped_com_initializer.h"
18 #endif 18 #endif
19 19
20 #if defined(OS_ANDROID)
21 #include "base/android/jni_android.h"
22 #include "media/video/capture/android/video_capture_device_android.h"
23 #endif
24
20 #if defined(OS_MACOSX) 25 #if defined(OS_MACOSX)
21 // Mac/QTKit will always give you the size you ask for and this case will fail. 26 // Mac/QTKit will always give you the size you ask for and this case will fail.
22 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize 27 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize
23 // We will always get ARGB from the Mac/QTKit implementation. 28 // We will always get ARGB from the Mac/QTKit implementation.
24 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg 29 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg
25 #elif defined(OS_WIN) 30 #elif defined(OS_WIN)
26 #define MAYBE_AllocateBadSize AllocateBadSize 31 #define MAYBE_AllocateBadSize AllocateBadSize
27 // Windows currently uses DirectShow to convert from MJPEG and a raw format is 32 // Windows currently uses DirectShow to convert from MJPEG and a raw format is
28 // always delivered. 33 // always delivered.
29 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg 34 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg
35 #elif defined(OS_ANDROID)
36 // TODO(wjia): enable those tests on Android.
37 // On Android, native camera (JAVA) delivers frames on UI thread which is the
38 // main thread for tests. This results in no frame received by
39 // VideoCaptureAndroid.
40 #define CaptureVGA DISABLED_CaptureVGA
41 #define Capture720p DISABLED_Capture720p
42 #define MAYBE_AllocateBadSize DISABLED_AllocateBadSize
43 #define ReAllocateCamera DISABLED_ReAllocateCamera
44 #define DeAllocateCameraWhileRunning DISABLED_DeAllocateCameraWhileRunning
45 #define DeAllocateCameraWhileRunning DISABLED_DeAllocateCameraWhileRunning
46 #define MAYBE_CaptureMjpeg DISABLED_CaptureMjpeg
30 #else 47 #else
31 #define MAYBE_AllocateBadSize AllocateBadSize 48 #define MAYBE_AllocateBadSize AllocateBadSize
32 #define MAYBE_CaptureMjpeg CaptureMjpeg 49 #define MAYBE_CaptureMjpeg CaptureMjpeg
33 #endif 50 #endif
34 51
35 using ::testing::_; 52 using ::testing::_;
36 using ::testing::AnyNumber; 53 using ::testing::AnyNumber;
37 using ::testing::Return; 54 using ::testing::Return;
38 using ::testing::AtLeast; 55 using ::testing::AtLeast;
39 56
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
77 94
78 void PostQuitTask() { 95 void PostQuitTask() {
79 loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 96 loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
80 loop_->Run(); 97 loop_->Run();
81 } 98 }
82 99
83 protected: 100 protected:
84 virtual void SetUp() { 101 virtual void SetUp() {
85 frame_observer_.reset(new MockFrameObserver(&wait_event_)); 102 frame_observer_.reset(new MockFrameObserver(&wait_event_));
86 loop_.reset(new MessageLoopForUI()); 103 loop_.reset(new MessageLoopForUI());
104 #if defined(OS_ANDROID)
105 media::VideoCaptureDeviceAndroid::RegisterVideoCaptureDevice(
106 base::android::AttachCurrentThread());
107 #endif
87 } 108 }
88 109
89 virtual void TearDown() { 110 virtual void TearDown() {
90 } 111 }
91 112
92 #if defined(OS_WIN) 113 #if defined(OS_WIN)
93 base::win::ScopedCOMInitializer initialize_com_; 114 base::win::ScopedCOMInitializer initialize_com_;
94 #endif 115 #endif
95 base::WaitableEvent wait_event_; 116 base::WaitableEvent wait_event_;
96 scoped_ptr<MockFrameObserver> frame_observer_; 117 scoped_ptr<MockFrameObserver> frame_observer_;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 device->Allocate(1280, 720, 30, frame_observer_.get()); 307 device->Allocate(1280, 720, 30, frame_observer_.get());
287 308
288 device->Start(); 309 device->Start();
289 // Get captured video frames. 310 // Get captured video frames.
290 PostQuitTask(); 311 PostQuitTask();
291 EXPECT_TRUE(wait_event_.TimedWait(TestTimeouts::action_max_timeout())); 312 EXPECT_TRUE(wait_event_.TimedWait(TestTimeouts::action_max_timeout()));
292 device->DeAllocate(); 313 device->DeAllocate();
293 } 314 }
294 315
295 }; // namespace media 316 }; // namespace media
OLDNEW
« no previous file with comments | « media/video/capture/android/video_capture_device_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698