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

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: more code review 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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 89
73 void PostQuitTask() { 90 void PostQuitTask() {
74 loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 91 loop_->PostTask(FROM_HERE, MessageLoop::QuitClosure());
75 loop_->Run(); 92 loop_->Run();
76 } 93 }
77 94
78 protected: 95 protected:
79 virtual void SetUp() { 96 virtual void SetUp() {
80 frame_observer_.reset(new MockFrameObserver(&wait_event_)); 97 frame_observer_.reset(new MockFrameObserver(&wait_event_));
81 loop_.reset(new MessageLoopForUI()); 98 loop_.reset(new MessageLoopForUI());
99 #if defined(OS_ANDROID)
100 media::VideoCaptureDeviceAndroid::RegisterVideoCaptureDevice(
101 base::android::AttachCurrentThread());
102 #endif
82 } 103 }
83 104
84 virtual void TearDown() { 105 virtual void TearDown() {
85 } 106 }
86 107
87 #if defined(OS_WIN) 108 #if defined(OS_WIN)
88 base::win::ScopedCOMInitializer initialize_com_; 109 base::win::ScopedCOMInitializer initialize_com_;
89 #endif 110 #endif
90 base::WaitableEvent wait_event_; 111 base::WaitableEvent wait_event_;
91 scoped_ptr<MockFrameObserver> frame_observer_; 112 scoped_ptr<MockFrameObserver> frame_observer_;
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
281 device->Allocate(1280, 720, 30, frame_observer_.get()); 302 device->Allocate(1280, 720, 30, frame_observer_.get());
282 303
283 device->Start(); 304 device->Start();
284 // Get captured video frames. 305 // Get captured video frames.
285 PostQuitTask(); 306 PostQuitTask();
286 EXPECT_TRUE(wait_event_.TimedWait(TestTimeouts::action_max_timeout())); 307 EXPECT_TRUE(wait_event_.TimedWait(TestTimeouts::action_max_timeout()));
287 device->DeAllocate(); 308 device->DeAllocate();
288 } 309 }
289 310
290 }; // namespace media 311 }; // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698