OLD | NEW |
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 // Unit test for VideoCaptureManager. | 5 // Unit test for VideoCaptureManager. |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 MOCK_METHOD2(Aborted, void(MediaStreamType, int)); | 41 MOCK_METHOD2(Aborted, void(MediaStreamType, int)); |
42 }; // class MockMediaStreamProviderListener | 42 }; // class MockMediaStreamProviderListener |
43 | 43 |
44 // Needed as an input argument to StartCaptureForClient(). | 44 // Needed as an input argument to StartCaptureForClient(). |
45 class MockFrameObserver : public VideoCaptureControllerEventHandler { | 45 class MockFrameObserver : public VideoCaptureControllerEventHandler { |
46 public: | 46 public: |
47 MOCK_METHOD1(OnError, void(const VideoCaptureControllerID& id)); | 47 MOCK_METHOD1(OnError, void(const VideoCaptureControllerID& id)); |
48 | 48 |
49 virtual void OnBufferCreated(const VideoCaptureControllerID& id, | 49 virtual void OnBufferCreated(const VideoCaptureControllerID& id, |
50 base::SharedMemoryHandle handle, | 50 base::SharedMemoryHandle handle, |
51 int length, int buffer_id) OVERRIDE {} | 51 int length, int buffer_id) override {} |
52 virtual void OnBufferDestroyed(const VideoCaptureControllerID& id, | 52 virtual void OnBufferDestroyed(const VideoCaptureControllerID& id, |
53 int buffer_id) OVERRIDE {} | 53 int buffer_id) override {} |
54 virtual void OnBufferReady(const VideoCaptureControllerID& id, | 54 virtual void OnBufferReady(const VideoCaptureControllerID& id, |
55 int buffer_id, | 55 int buffer_id, |
56 const media::VideoCaptureFormat& format, | 56 const media::VideoCaptureFormat& format, |
57 const gfx::Rect& visible_rect, | 57 const gfx::Rect& visible_rect, |
58 base::TimeTicks timestamp) OVERRIDE {} | 58 base::TimeTicks timestamp) override {} |
59 virtual void OnMailboxBufferReady(const VideoCaptureControllerID& id, | 59 virtual void OnMailboxBufferReady(const VideoCaptureControllerID& id, |
60 int buffer_id, | 60 int buffer_id, |
61 const gpu::MailboxHolder& mailbox_holder, | 61 const gpu::MailboxHolder& mailbox_holder, |
62 const media::VideoCaptureFormat& format, | 62 const media::VideoCaptureFormat& format, |
63 base::TimeTicks timestamp) OVERRIDE {} | 63 base::TimeTicks timestamp) override {} |
64 virtual void OnEnded(const VideoCaptureControllerID& id) OVERRIDE {} | 64 virtual void OnEnded(const VideoCaptureControllerID& id) override {} |
65 | 65 |
66 void OnGotControllerCallback(VideoCaptureControllerID) {} | 66 void OnGotControllerCallback(VideoCaptureControllerID) {} |
67 }; | 67 }; |
68 | 68 |
69 // Test class | 69 // Test class |
70 class VideoCaptureManagerTest : public testing::Test { | 70 class VideoCaptureManagerTest : public testing::Test { |
71 public: | 71 public: |
72 VideoCaptureManagerTest() : next_client_id_(1) {} | 72 VideoCaptureManagerTest() : next_client_id_(1) {} |
73 virtual ~VideoCaptureManagerTest() {} | 73 virtual ~VideoCaptureManagerTest() {} |
74 | 74 |
75 protected: | 75 protected: |
76 virtual void SetUp() OVERRIDE { | 76 virtual void SetUp() override { |
77 listener_.reset(new MockMediaStreamProviderListener()); | 77 listener_.reset(new MockMediaStreamProviderListener()); |
78 message_loop_.reset(new base::MessageLoopForIO); | 78 message_loop_.reset(new base::MessageLoopForIO); |
79 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, | 79 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, |
80 message_loop_.get())); | 80 message_loop_.get())); |
81 vcm_ = new VideoCaptureManager(scoped_ptr<media::VideoCaptureDeviceFactory>( | 81 vcm_ = new VideoCaptureManager(scoped_ptr<media::VideoCaptureDeviceFactory>( |
82 new media::FakeVideoCaptureDeviceFactory())); | 82 new media::FakeVideoCaptureDeviceFactory())); |
83 video_capture_device_factory_ = | 83 video_capture_device_factory_ = |
84 static_cast<media::FakeVideoCaptureDeviceFactory*>( | 84 static_cast<media::FakeVideoCaptureDeviceFactory*>( |
85 vcm_->video_capture_device_factory()); | 85 vcm_->video_capture_device_factory()); |
86 const int32 kNumberOfFakeDevices = 2; | 86 const int32 kNumberOfFakeDevices = 2; |
87 video_capture_device_factory_->set_number_of_devices(kNumberOfFakeDevices); | 87 video_capture_device_factory_->set_number_of_devices(kNumberOfFakeDevices); |
88 vcm_->Register(listener_.get(), message_loop_->message_loop_proxy().get()); | 88 vcm_->Register(listener_.get(), message_loop_->message_loop_proxy().get()); |
89 frame_observer_.reset(new MockFrameObserver()); | 89 frame_observer_.reset(new MockFrameObserver()); |
90 } | 90 } |
91 | 91 |
92 virtual void TearDown() OVERRIDE {} | 92 virtual void TearDown() override {} |
93 | 93 |
94 void OnGotControllerCallback( | 94 void OnGotControllerCallback( |
95 VideoCaptureControllerID id, | 95 VideoCaptureControllerID id, |
96 base::Closure quit_closure, | 96 base::Closure quit_closure, |
97 bool expect_success, | 97 bool expect_success, |
98 const base::WeakPtr<VideoCaptureController>& controller) { | 98 const base::WeakPtr<VideoCaptureController>& controller) { |
99 if (expect_success) { | 99 if (expect_success) { |
100 ASSERT_TRUE(controller); | 100 ASSERT_TRUE(controller); |
101 ASSERT_TRUE(0 == controllers_.count(id)); | 101 ASSERT_TRUE(0 == controllers_.count(id)); |
102 controllers_[id] = controller.get(); | 102 controllers_[id] = controller.get(); |
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 483 |
484 // Wait to check callbacks before removing the listener | 484 // Wait to check callbacks before removing the listener |
485 message_loop_->RunUntilIdle(); | 485 message_loop_->RunUntilIdle(); |
486 vcm_->Unregister(); | 486 vcm_->Unregister(); |
487 } | 487 } |
488 | 488 |
489 // TODO(mcasas): Add a test to check consolidation of the supported formats | 489 // TODO(mcasas): Add a test to check consolidation of the supported formats |
490 // provided by the device when http://crbug.com/323913 is closed. | 490 // provided by the device when http://crbug.com/323913 is closed. |
491 | 491 |
492 } // namespace content | 492 } // namespace content |
OLD | NEW |