Index: services/video_capture/test/fake_device_unittest.cc |
diff --git a/services/video_capture/test/fake_device_unittest.cc b/services/video_capture/test/fake_device_unittest.cc |
index ee2d651830e5a4b8c954e65b7062267e970b594c..58dcd18405e3cbd1cee9739b5e1d7279630e5306 100644 |
--- a/services/video_capture/test/fake_device_unittest.cc |
+++ b/services/video_capture/test/fake_device_unittest.cc |
@@ -7,6 +7,7 @@ |
#include "media/base/video_frame.h" |
#include "media/mojo/common/media_type_converters.h" |
#include "services/video_capture/device_media_to_mojo_adapter.h" |
+#include "services/video_capture/public/interfaces/constants.mojom.h" |
#include "services/video_capture/public/interfaces/device_factory.mojom.h" |
#include "services/video_capture/test/fake_device_test.h" |
#include "services/video_capture/test/mock_receiver.h" |
@@ -138,4 +139,26 @@ TEST_F(FakeVideoCaptureDeviceTest, BuffersGetReused) { |
ASSERT_LE(num_buffers_created, kMaxBufferPoolBuffers); |
} |
+// Tests that the service requests to be closed when the last client disconnects |
+// while using a device. |
+TEST_F(FakeVideoCaptureDeviceTest, |
+ ServiceQuitsWhenClientDisconnectsWhileUsingDevice) { |
+ base::RunLoop wait_loop; |
+ EXPECT_CALL(*service_state_observer_, OnServiceStopped(_)) |
+ .WillOnce(Invoke([&wait_loop](const service_manager::Identity& identity) { |
+ if (identity.name() == mojom::kServiceName) |
+ wait_loop.Quit(); |
+ })); |
+ |
+ mojom::ReceiverPtr receiver_proxy; |
+ MockReceiver receiver(mojo::MakeRequest(&receiver_proxy)); |
+ fake_device_proxy_->Start(requestable_settings_, std::move(receiver_proxy)); |
+ |
+ fake_device_proxy_.reset(); |
+ factory_.reset(); |
+ factory_provider_.reset(); |
+ |
+ wait_loop.Run(); |
+} |
+ |
} // namespace video_capture |