OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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/ref_counted.h" | 5 #include "base/memory/ref_counted.h" |
6 #include "base/run_loop.h" | 6 #include "base/run_loop.h" |
7 #include "media/base/video_frame.h" | 7 #include "media/base/video_frame.h" |
8 #include "media/mojo/common/media_type_converters.h" | 8 #include "media/mojo/common/media_type_converters.h" |
9 #include "services/video_capture/device_media_to_mojo_adapter.h" | 9 #include "services/video_capture/device_media_to_mojo_adapter.h" |
| 10 #include "services/video_capture/public/interfaces/constants.mojom.h" |
10 #include "services/video_capture/public/interfaces/device_factory.mojom.h" | 11 #include "services/video_capture/public/interfaces/device_factory.mojom.h" |
11 #include "services/video_capture/test/fake_device_test.h" | 12 #include "services/video_capture/test/fake_device_test.h" |
12 #include "services/video_capture/test/mock_receiver.h" | 13 #include "services/video_capture/test/mock_receiver.h" |
13 | 14 |
14 using testing::_; | 15 using testing::_; |
15 using testing::AtLeast; | 16 using testing::AtLeast; |
16 using testing::Invoke; | 17 using testing::Invoke; |
17 using testing::InvokeWithoutArgs; | 18 using testing::InvokeWithoutArgs; |
18 | 19 |
19 namespace { | 20 namespace { |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
131 } | 132 } |
132 })); | 133 })); |
133 | 134 |
134 fake_device_proxy_->Start(requestable_settings_, std::move(receiver_proxy)); | 135 fake_device_proxy_->Start(requestable_settings_, std::move(receiver_proxy)); |
135 wait_loop.Run(); | 136 wait_loop.Run(); |
136 | 137 |
137 ASSERT_LT(num_buffers_created, num_frames_arrived); | 138 ASSERT_LT(num_buffers_created, num_frames_arrived); |
138 ASSERT_LE(num_buffers_created, kMaxBufferPoolBuffers); | 139 ASSERT_LE(num_buffers_created, kMaxBufferPoolBuffers); |
139 } | 140 } |
140 | 141 |
| 142 // Tests that the service requests to be closed when the last client disconnects |
| 143 // while using a device. |
| 144 TEST_F(FakeVideoCaptureDeviceTest, |
| 145 ServiceQuitsWhenClientDisconnectsWhileUsingDevice) { |
| 146 base::RunLoop wait_loop; |
| 147 EXPECT_CALL(*service_state_observer_, OnServiceStopped(_)) |
| 148 .WillOnce(Invoke([&wait_loop](const service_manager::Identity& identity) { |
| 149 if (identity.name() == mojom::kServiceName) |
| 150 wait_loop.Quit(); |
| 151 })); |
| 152 |
| 153 mojom::ReceiverPtr receiver_proxy; |
| 154 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy)); |
| 155 fake_device_proxy_->Start(requestable_settings_, std::move(receiver_proxy)); |
| 156 |
| 157 fake_device_proxy_.reset(); |
| 158 factory_.reset(); |
| 159 factory_provider_.reset(); |
| 160 |
| 161 wait_loop.Run(); |
| 162 } |
| 163 |
141 } // namespace video_capture | 164 } // namespace video_capture |
OLD | NEW |