Index: services/video_capture/test/service_unittest.cc |
diff --git a/services/video_capture/test/service_unittest.cc b/services/video_capture/test/service_unittest.cc |
index 8b4b4bf3c7b7bf873e6bca6a490f9d3af9da358a..58aa118fa7c5dd0d642be1c282bbd48ae7ef181d 100644 |
--- a/services/video_capture/test/service_unittest.cc |
+++ b/services/video_capture/test/service_unittest.cc |
@@ -5,6 +5,7 @@ |
#include "base/memory/ref_counted.h" |
#include "base/run_loop.h" |
#include "base/test/mock_callback.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/service_test.h" |
@@ -67,4 +68,22 @@ TEST_F(VideoCaptureServiceTest, ErrorCodeOnCreateDeviceForInvalidDescriptor) { |
wait_loop.Run(); |
} |
+// Tests that the service requests to be closed when the last client disconnects |
+// after not having done anything other than obtaining a connection to the |
+// fake device factory. |
+TEST_F(VideoCaptureServiceTest, ServiceQuitsWhenNoClientConnected) { |
+ 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(); |
+ })); |
+ |
+ // Exercise: Disconnect from service by discarding our references to it. |
+ factory_.reset(); |
+ service_.reset(); |
+ |
+ wait_loop.Run(); |
+} |
+ |
} // namespace video_capture |