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

Side by Side Diff: services/video_capture/video_capture_service_unittest.cc

Issue 2244773002: Video Capture Mojo (1.4c): Handle Subsequent Access (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@FillServicePart2
Patch Set: rockot's comments Created 4 years, 3 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
« no previous file with comments | « services/video_capture/video_capture_device_proxy_impl.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "services/video_capture/public/interfaces/video_capture_device_factory. mojom.h" 7 #include "services/video_capture/public/interfaces/video_capture_device_factory. mojom.h"
8 #include "services/video_capture/video_capture_service_test.h" 8 #include "services/video_capture/video_capture_service_test.h"
9 9
10 using testing::Exactly; 10 using testing::Exactly;
11 using testing::_; 11 using testing::_;
12 using testing::Invoke; 12 using testing::Invoke;
13 using testing::InvokeWithoutArgs; 13 using testing::InvokeWithoutArgs;
14 14
15 namespace video_capture { 15 namespace video_capture {
16 16
17 class MockCreateDeviceProxyCallback {
18 public:
19 MOCK_METHOD1(Run, void(mojom::DeviceAccessResultCode result_code));
20 };
21
17 // Tests that an answer arrives from the service when calling 22 // Tests that an answer arrives from the service when calling
18 // EnumerateDeviceDescriptors(). 23 // EnumerateDeviceDescriptors().
19 TEST_F(VideoCaptureServiceTest, EnumerateDeviceDescriptorsCallbackArrives) { 24 TEST_F(VideoCaptureServiceTest, EnumerateDeviceDescriptorsCallbackArrives) {
20 base::RunLoop wait_loop; 25 base::RunLoop wait_loop;
21 EXPECT_CALL(descriptor_receiver_, OnEnumerateDeviceDescriptorsCallback(_)) 26 EXPECT_CALL(descriptor_receiver_, OnEnumerateDeviceDescriptorsCallback(_))
22 .Times(Exactly(1)) 27 .Times(Exactly(1))
23 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); })); 28 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); }));
24 29
25 factory_->EnumerateDeviceDescriptors(base::Bind( 30 factory_->EnumerateDeviceDescriptors(base::Bind(
26 &MockDeviceDescriptorReceiver::HandleEnumerateDeviceDescriptorsCallback, 31 &MockDeviceDescriptorReceiver::HandleEnumerateDeviceDescriptorsCallback,
(...skipping 21 matching lines...) Expand all
48 } 53 }
49 54
50 // Tests that VideoCaptureDeviceFactory::CreateDeviceProxy() returns an error 55 // Tests that VideoCaptureDeviceFactory::CreateDeviceProxy() returns an error
51 // code when trying to create a device for an invalid descriptor. 56 // code when trying to create a device for an invalid descriptor.
52 TEST_F(VideoCaptureServiceTest, ErrorCodeOnCreateDeviceForInvalidDescriptor) { 57 TEST_F(VideoCaptureServiceTest, ErrorCodeOnCreateDeviceForInvalidDescriptor) {
53 auto invalid_descriptor = mojom::VideoCaptureDeviceDescriptor::New(); 58 auto invalid_descriptor = mojom::VideoCaptureDeviceDescriptor::New();
54 invalid_descriptor->device_id = "invalid"; 59 invalid_descriptor->device_id = "invalid";
55 invalid_descriptor->model_id = "invalid"; 60 invalid_descriptor->model_id = "invalid";
56 base::RunLoop wait_loop; 61 base::RunLoop wait_loop;
57 mojom::VideoCaptureDeviceProxyPtr fake_device_proxy; 62 mojom::VideoCaptureDeviceProxyPtr fake_device_proxy;
58 mojom::DeviceAccessResultCode result_code; 63 MockCreateDeviceProxyCallback create_device_proxy_callback;
64 EXPECT_CALL(create_device_proxy_callback,
65 Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND))
66 .Times(1)
67 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); }));
59 factory_->CreateDeviceProxy( 68 factory_->CreateDeviceProxy(
60 std::move(invalid_descriptor), mojo::GetProxy(&fake_device_proxy), 69 std::move(invalid_descriptor), mojo::GetProxy(&fake_device_proxy),
61 base::Bind( 70 base::Bind(&MockCreateDeviceProxyCallback::Run,
62 [](base::RunLoop* wait_loop, mojom::DeviceAccessResultCode* target, 71 base::Unretained(&create_device_proxy_callback)));
63 mojom::DeviceAccessResultCode result_code) {
64 *target = result_code;
65 wait_loop->Quit();
66 },
67 &wait_loop, &result_code));
68 wait_loop.Run(); 72 wait_loop.Run();
69 ASSERT_EQ(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND, result_code);
70 } 73 }
71 74
72 } // namespace video_capture 75 } // namespace video_capture
OLDNEW
« no previous file with comments | « services/video_capture/video_capture_device_proxy_impl.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698