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

Side by Side 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 unified diff | Download patch
OLDNEW
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 "base/test/mock_callback.h" 7 #include "base/test/mock_callback.h"
8 #include "services/video_capture/public/interfaces/constants.mojom.h"
8 #include "services/video_capture/public/interfaces/device_factory.mojom.h" 9 #include "services/video_capture/public/interfaces/device_factory.mojom.h"
9 #include "services/video_capture/test/service_test.h" 10 #include "services/video_capture/test/service_test.h"
10 11
11 using testing::Exactly; 12 using testing::Exactly;
12 using testing::_; 13 using testing::_;
13 using testing::Invoke; 14 using testing::Invoke;
14 using testing::InvokeWithoutArgs; 15 using testing::InvokeWithoutArgs;
15 16
16 namespace video_capture { 17 namespace video_capture {
17 18
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND)) 61 Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND))
61 .Times(1) 62 .Times(1)
62 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); })); 63 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); }));
63 factory_->GetDeviceInfos(device_info_receiver_.Get()); 64 factory_->GetDeviceInfos(device_info_receiver_.Get());
64 factory_->CreateDevice(invalid_device_id, 65 factory_->CreateDevice(invalid_device_id,
65 mojo::MakeRequest(&fake_device_proxy), 66 mojo::MakeRequest(&fake_device_proxy),
66 create_device_proxy_callback.Get()); 67 create_device_proxy_callback.Get());
67 wait_loop.Run(); 68 wait_loop.Run();
68 } 69 }
69 70
71 // Tests that the service requests to be closed when the last client disconnects
72 // after not having done anything other than obtaining a connection to the
73 // fake device factory.
74 TEST_F(VideoCaptureServiceTest, ServiceQuitsWhenNoClientConnected) {
75 base::RunLoop wait_loop;
76 EXPECT_CALL(*service_state_observer_, OnServiceStopped(_))
77 .WillOnce(Invoke([&wait_loop](const service_manager::Identity& identity) {
78 if (identity.name() == mojom::kServiceName)
79 wait_loop.Quit();
80 }));
81
82 // Exercise: Disconnect from service by discarding our references to it.
83 factory_.reset();
84 service_.reset();
85
86 wait_loop.Run();
87 }
88
70 } // namespace video_capture 89 } // namespace video_capture
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698