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

Side by Side Diff: services/video_capture/test/service_test.h

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 #ifndef SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_TEST_SERVICE_TEST_H_ 5 #ifndef SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_TEST_SERVICE_TEST_H_
6 #define SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_TEST_SERVICE_TEST_H_ 6 #define SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_TEST_SERVICE_TEST_H_
7 7
8 #include "base/run_loop.h"
8 #include "base/test/mock_callback.h" 9 #include "base/test/mock_callback.h"
10 #include "mojo/public/cpp/bindings/binding.h"
9 #include "services/service_manager/public/cpp/service_test.h" 11 #include "services/service_manager/public/cpp/service_test.h"
12 #include "services/service_manager/public/interfaces/service_manager.mojom.h"
10 #include "services/video_capture/public/interfaces/service.mojom.h" 13 #include "services/video_capture/public/interfaces/service.mojom.h"
11 #include "testing/gmock/include/gmock/gmock.h" 14 #include "testing/gmock/include/gmock/gmock.h"
12 15
13 namespace video_capture { 16 namespace video_capture {
14 17
18 class ServiceManagerListenerImpl
19 : public service_manager::mojom::ServiceManagerListener {
20 public:
21 ServiceManagerListenerImpl(
22 service_manager::mojom::ServiceManagerListenerRequest request,
23 base::RunLoop* loop);
24 ~ServiceManagerListenerImpl() override;
25
26 // mojom::ServiceManagerListener:
mcasas 2017/04/26 22:12:31 s/:/implementation.
chfremer 2017/04/26 23:33:36 Done.
27 void OnInit(std::vector<service_manager::mojom::RunningServiceInfoPtr>
28 instances) override {
29 loop_->Quit();
30 }
31 void OnServiceCreated(
32 service_manager::mojom::RunningServiceInfoPtr instance) override {}
33 void OnServiceStarted(const service_manager::Identity& identity,
34 uint32_t pid) override {}
35 void OnServiceFailedToStart(
36 const service_manager::Identity& identity) override {}
37
38 MOCK_METHOD1(OnServiceStopped,
39 void(const service_manager::Identity& identity));
40
41 private:
42 mojo::Binding<service_manager::mojom::ServiceManagerListener> binding_;
43 base::RunLoop* loop_;
44 };
45
15 // Basic test fixture that sets up a connection to the fake device factory. 46 // Basic test fixture that sets up a connection to the fake device factory.
16 class ServiceTest : public service_manager::test::ServiceTest { 47 class ServiceTest : public service_manager::test::ServiceTest {
17 public: 48 public:
18 ServiceTest(); 49 ServiceTest();
19 ~ServiceTest() override; 50 ~ServiceTest() override;
20 51
21 void SetUp() override; 52 void SetUp() override;
22 53
23 protected: 54 protected:
24 mojom::ServicePtr service_; 55 mojom::ServicePtr service_;
25 mojom::DeviceFactoryPtr factory_; 56 mojom::DeviceFactoryPtr factory_;
26 base::MockCallback<mojom::DeviceFactory::GetDeviceInfosCallback> 57 base::MockCallback<mojom::DeviceFactory::GetDeviceInfosCallback>
27 device_info_receiver_; 58 device_info_receiver_;
59 std::unique_ptr<ServiceManagerListenerImpl> service_state_observer_;
28 }; 60 };
29 61
30 } // namespace video_capture 62 } // namespace video_capture
31 63
32 #endif // SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_TEST_SERVICE_TEST_H_ 64 #endif // SERVICES_VIDEO_CAPTURE_VIDEO_CAPTURE_TEST_SERVICE_TEST_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698