| Index: services/video_capture/video_capture_service_unittest.cc
|
| diff --git a/services/video_capture/service_unittest.cc b/services/video_capture/video_capture_service_unittest.cc
|
| similarity index 59%
|
| rename from services/video_capture/service_unittest.cc
|
| rename to services/video_capture/video_capture_service_unittest.cc
|
| index c3abcf76f74ed0243e09d0c0a72d27bacd4585ef..cf9e8753b74eb430abd3dd06902ab964c40ca422 100644
|
| --- a/services/video_capture/service_unittest.cc
|
| +++ b/services/video_capture/video_capture_service_unittest.cc
|
| @@ -4,10 +4,8 @@
|
|
|
| #include "base/memory/ref_counted.h"
|
| #include "base/run_loop.h"
|
| -#include "services/shell/public/cpp/service_test.h"
|
| #include "services/video_capture/public/interfaces/video_capture_device_factory.mojom.h"
|
| -#include "services/video_capture/public/interfaces/video_capture_service.mojom.h"
|
| -#include "testing/gmock/include/gmock/gmock.h"
|
| +#include "services/video_capture/video_capture_service_test.h"
|
|
|
| using testing::Exactly;
|
| using testing::_;
|
| @@ -16,37 +14,6 @@ using testing::InvokeWithoutArgs;
|
|
|
| namespace video_capture {
|
|
|
| -class MockDeviceDescriptorReceiver {
|
| - public:
|
| - // Use forwarding method to work around gmock not supporting move-only types.
|
| - void HandleEnumerateDeviceDescriptorsCallback(
|
| - std::vector<mojom::VideoCaptureDeviceDescriptorPtr> descriptors) {
|
| - OnEnumerateDeviceDescriptorsCallback(descriptors);
|
| - }
|
| -
|
| - MOCK_METHOD1(
|
| - OnEnumerateDeviceDescriptorsCallback,
|
| - void(const std::vector<mojom::VideoCaptureDeviceDescriptorPtr>&));
|
| -};
|
| -
|
| -class VideoCaptureServiceTest : public shell::test::ServiceTest {
|
| - public:
|
| - VideoCaptureServiceTest()
|
| - : shell::test::ServiceTest("exe:video_capture_unittests") {}
|
| - ~VideoCaptureServiceTest() override {}
|
| -
|
| - void SetUp() override {
|
| - ServiceTest::SetUp();
|
| - connector()->ConnectToInterface("mojo:video_capture", &service_);
|
| - service_->ConnectToFakeDeviceFactory(mojo::GetProxy(&factory_));
|
| - }
|
| -
|
| - protected:
|
| - mojom::VideoCaptureServicePtr service_;
|
| - mojom::VideoCaptureDeviceFactoryPtr factory_;
|
| - MockDeviceDescriptorReceiver descriptor_receiver_;
|
| -};
|
| -
|
| // Tests that an answer arrives from the service when calling
|
| // EnumerateDeviceDescriptors().
|
| TEST_F(VideoCaptureServiceTest, EnumerateDeviceDescriptorsCallbackArrives) {
|
| @@ -80,4 +47,26 @@ TEST_F(VideoCaptureServiceTest, FakeDeviceFactoryEnumeratesOneDevice) {
|
| ASSERT_EQ(1u, num_devices_enumerated);
|
| }
|
|
|
| +// Tests that VideoCaptureDeviceFactory::CreateDeviceProxy() returns an error
|
| +// code when trying to create a device for an invalid descriptor.
|
| +TEST_F(VideoCaptureServiceTest, ErrorCodeOnCreateDeviceForInvalidDescriptor) {
|
| + auto invalid_descriptor = mojom::VideoCaptureDeviceDescriptor::New();
|
| + invalid_descriptor->device_id = "invalid";
|
| + invalid_descriptor->model_id = "invalid";
|
| + base::RunLoop wait_loop;
|
| + mojom::VideoCaptureDeviceProxyPtr fake_device_proxy;
|
| + mojom::DeviceAccessResultCode result_code;
|
| + factory_->CreateDeviceProxy(
|
| + std::move(invalid_descriptor), mojo::GetProxy(&fake_device_proxy),
|
| + base::Bind(
|
| + [](base::RunLoop* wait_loop, mojom::DeviceAccessResultCode* target,
|
| + mojom::DeviceAccessResultCode result_code) {
|
| + *target = result_code;
|
| + wait_loop->Quit();
|
| + },
|
| + &wait_loop, &result_code));
|
| + wait_loop.Run();
|
| + ASSERT_EQ(mojom::DeviceAccessResultCode::ERROR_DEVICE_NOT_FOUND, result_code);
|
| +}
|
| +
|
| } // namespace video_capture
|
|
|