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

Unified Diff: services/video_capture/test/service_unittest.cc

Issue 2824883005: [Mojo Video Capture] Stop service when last client disconnects. (Closed)
Patch Set: Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698