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

Side by Side Diff: services/video_capture/test/service_unittest.cc

Issue 2813343002: [Mojo Video Capture] Switch to using Mojo structs in media/capture/mojo (Closed)
Patch Set: Removed extraneous AtLeast 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
« no previous file with comments | « services/video_capture/test/service_test.h ('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 "base/test/mock_callback.h" 7 #include "base/test/mock_callback.h"
8 #include "services/video_capture/public/interfaces/device_factory.mojom.h" 8 #include "services/video_capture/public/interfaces/device_factory.mojom.h"
9 #include "services/video_capture/test/service_test.h" 9 #include "services/video_capture/test/service_test.h"
10 10
11 using testing::Exactly; 11 using testing::Exactly;
12 using testing::_; 12 using testing::_;
13 using testing::Invoke; 13 using testing::Invoke;
14 using testing::InvokeWithoutArgs; 14 using testing::InvokeWithoutArgs;
15 15
16 namespace video_capture { 16 namespace video_capture {
17 17
18 // This alias ensures test output is easily attributed to this service's tests. 18 // This alias ensures test output is easily attributed to this service's tests.
19 // TODO(rockot/chfremer): Consider just renaming the type. 19 // TODO(rockot/chfremer): Consider just renaming the type.
20 using VideoCaptureServiceTest = ServiceTest; 20 using VideoCaptureServiceTest = ServiceTest;
21 21
22 // Tests that an answer arrives from the service when calling 22 // Tests that an answer arrives from the service when calling
23 // EnumerateDeviceDescriptors(). 23 // GetDeviceInfos().
24 TEST_F(VideoCaptureServiceTest, 24 TEST_F(VideoCaptureServiceTest, DISABLED_GetDeviceInfosCallbackArrives) {
25 DISABLED_EnumerateDeviceDescriptorsCallbackArrives) {
26 base::RunLoop wait_loop; 25 base::RunLoop wait_loop;
27 EXPECT_CALL(descriptor_receiver_, Run(_)) 26 EXPECT_CALL(device_info_receiver_, Run(_))
28 .Times(Exactly(1)) 27 .Times(Exactly(1))
29 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); })); 28 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); }));
30 29
31 factory_->EnumerateDeviceDescriptors(descriptor_receiver_.Get()); 30 factory_->GetDeviceInfos(device_info_receiver_.Get());
32 wait_loop.Run(); 31 wait_loop.Run();
33 } 32 }
34 33
35 TEST_F(VideoCaptureServiceTest, DISABLED_FakeDeviceFactoryEnumeratesOneDevice) { 34 TEST_F(VideoCaptureServiceTest, DISABLED_FakeDeviceFactoryEnumeratesOneDevice) {
36 base::RunLoop wait_loop; 35 base::RunLoop wait_loop;
37 size_t num_devices_enumerated = 0; 36 size_t num_devices_enumerated = 0;
38 EXPECT_CALL(descriptor_receiver_, Run(_)) 37 EXPECT_CALL(device_info_receiver_, Run(_))
39 .Times(Exactly(1)) 38 .Times(Exactly(1))
40 .WillOnce(Invoke([&wait_loop, &num_devices_enumerated]( 39 .WillOnce(
41 const std::vector<media::VideoCaptureDeviceDescriptor>& descriptors) { 40 Invoke([&wait_loop, &num_devices_enumerated](
42 num_devices_enumerated = descriptors.size(); 41 const std::vector<media::VideoCaptureDeviceInfo>& infos) {
43 wait_loop.Quit(); 42 num_devices_enumerated = infos.size();
44 })); 43 wait_loop.Quit();
44 }));
45 45
46 factory_->EnumerateDeviceDescriptors(descriptor_receiver_.Get()); 46 factory_->GetDeviceInfos(device_info_receiver_.Get());
47 wait_loop.Run(); 47 wait_loop.Run();
48 ASSERT_EQ(1u, num_devices_enumerated); 48 ASSERT_EQ(1u, num_devices_enumerated);
49 } 49 }
50 50
51 // Tests that VideoCaptureDeviceFactory::CreateDeviceProxy() returns an error 51 // Tests that VideoCaptureDeviceFactory::CreateDeviceProxy() returns an error
52 // code when trying to create a device for an invalid descriptor. 52 // code when trying to create a device for an invalid descriptor.
53 TEST_F(VideoCaptureServiceTest, 53 TEST_F(VideoCaptureServiceTest,
54 DISABLED_ErrorCodeOnCreateDeviceForInvalidDescriptor) { 54 DISABLED_ErrorCodeOnCreateDeviceForInvalidDescriptor) {
55 const std::string invalid_device_id = "invalid"; 55 const std::string invalid_device_id = "invalid";
56 base::RunLoop wait_loop; 56 base::RunLoop wait_loop;
57 mojom::DevicePtr fake_device_proxy; 57 mojom::DevicePtr fake_device_proxy;
58 base::MockCallback<mojom::DeviceFactory::CreateDeviceCallback> 58 base::MockCallback<mojom::DeviceFactory::CreateDeviceCallback>
59 create_device_proxy_callback; 59 create_device_proxy_callback;
60 EXPECT_CALL(create_device_proxy_callback, 60 EXPECT_CALL(create_device_proxy_callback,
61 Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND)) 61 Run(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND))
62 .Times(1) 62 .Times(1)
63 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); })); 63 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); }));
64 factory_->CreateDevice(invalid_device_id, 64 factory_->CreateDevice(invalid_device_id,
65 mojo::MakeRequest(&fake_device_proxy), 65 mojo::MakeRequest(&fake_device_proxy),
66 create_device_proxy_callback.Get()); 66 create_device_proxy_callback.Get());
67 wait_loop.Run(); 67 wait_loop.Run();
68 } 68 }
69 69
70 } // namespace video_capture 70 } // namespace video_capture
OLDNEW
« no previous file with comments | « services/video_capture/test/service_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698