OLD | NEW |
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/run_loop.h" | 5 #include "base/run_loop.h" |
6 #include "services/video_capture/test/fake_device_descriptor_test.h" | 6 #include "services/video_capture/test/fake_device_descriptor_test.h" |
7 #include "services/video_capture/test/mock_receiver.h" | 7 #include "services/video_capture/test/mock_receiver.h" |
8 | 8 |
9 using testing::_; | 9 using testing::_; |
10 using testing::InvokeWithoutArgs; | 10 using testing::InvokeWithoutArgs; |
11 | 11 |
12 namespace video_capture { | 12 namespace video_capture { |
13 | 13 |
14 class MockCreateDeviceProxyCallback { | 14 class MockCreateDeviceProxyCallback { |
15 public: | 15 public: |
16 MOCK_METHOD1(Run, void(mojom::DeviceAccessResultCode result_code)); | 16 MOCK_METHOD1(Run, void(mojom::DeviceAccessResultCode result_code)); |
17 }; | 17 }; |
18 | 18 |
| 19 // This alias ensures test output is easily attributed to this service's tests. |
| 20 // TODO(rockot/chfremer): Consider just renaming the type. |
| 21 using FakeVideoCaptureDeviceDescriptorTest = FakeDeviceDescriptorTest; |
| 22 |
19 // Tests that when requesting a second proxy for a device without closing the | 23 // Tests that when requesting a second proxy for a device without closing the |
20 // first one, the service revokes access to the first one by closing the | 24 // first one, the service revokes access to the first one by closing the |
21 // connection. | 25 // connection. |
22 TEST_F(FakeDeviceDescriptorTest, DISABLED_AccessIsRevokedOnSecondAccess) { | 26 TEST_F(FakeVideoCaptureDeviceDescriptorTest, |
| 27 DISABLED_AccessIsRevokedOnSecondAccess) { |
23 mojom::DevicePtr device_proxy_1; | 28 mojom::DevicePtr device_proxy_1; |
24 bool device_access_1_revoked = false; | 29 bool device_access_1_revoked = false; |
25 MockCreateDeviceProxyCallback create_device_proxy_callback_1; | 30 MockCreateDeviceProxyCallback create_device_proxy_callback_1; |
26 EXPECT_CALL(create_device_proxy_callback_1, | 31 EXPECT_CALL(create_device_proxy_callback_1, |
27 Run(mojom::DeviceAccessResultCode::SUCCESS)) | 32 Run(mojom::DeviceAccessResultCode::SUCCESS)) |
28 .Times(1); | 33 .Times(1); |
29 factory_->CreateDevice( | 34 factory_->CreateDevice( |
30 fake_device_descriptor_.device_id, mojo::MakeRequest(&device_proxy_1), | 35 fake_device_descriptor_.device_id, mojo::MakeRequest(&device_proxy_1), |
31 base::Bind(&MockCreateDeviceProxyCallback::Run, | 36 base::Bind(&MockCreateDeviceProxyCallback::Run, |
32 base::Unretained(&create_device_proxy_callback_1))); | 37 base::Unretained(&create_device_proxy_callback_1))); |
(...skipping 15 matching lines...) Expand all Loading... |
48 base::Unretained(&create_device_proxy_callback_2))); | 53 base::Unretained(&create_device_proxy_callback_2))); |
49 device_proxy_2.set_connection_error_handler( | 54 device_proxy_2.set_connection_error_handler( |
50 base::Bind([](bool* access_revoked) { *access_revoked = true; }, | 55 base::Bind([](bool* access_revoked) { *access_revoked = true; }, |
51 &device_access_2_revoked)); | 56 &device_access_2_revoked)); |
52 wait_loop.Run(); | 57 wait_loop.Run(); |
53 ASSERT_TRUE(device_access_1_revoked); | 58 ASSERT_TRUE(device_access_1_revoked); |
54 ASSERT_FALSE(device_access_2_revoked); | 59 ASSERT_FALSE(device_access_2_revoked); |
55 } | 60 } |
56 | 61 |
57 // Tests that a second proxy requested for a device can be used successfully. | 62 // Tests that a second proxy requested for a device can be used successfully. |
58 TEST_F(FakeDeviceDescriptorTest, DISABLED_CanUseSecondRequestedProxy) { | 63 TEST_F(FakeVideoCaptureDeviceDescriptorTest, |
| 64 DISABLED_CanUseSecondRequestedProxy) { |
59 mojom::DevicePtr device_proxy_1; | 65 mojom::DevicePtr device_proxy_1; |
60 factory_->CreateDevice( | 66 factory_->CreateDevice( |
61 fake_device_descriptor_.device_id, mojo::MakeRequest(&device_proxy_1), | 67 fake_device_descriptor_.device_id, mojo::MakeRequest(&device_proxy_1), |
62 base::Bind([](mojom::DeviceAccessResultCode result_code) {})); | 68 base::Bind([](mojom::DeviceAccessResultCode result_code) {})); |
63 | 69 |
64 base::RunLoop wait_loop; | 70 base::RunLoop wait_loop; |
65 mojom::DevicePtr device_proxy_2; | 71 mojom::DevicePtr device_proxy_2; |
66 factory_->CreateDevice( | 72 factory_->CreateDevice( |
67 fake_device_descriptor_.device_id, mojo::MakeRequest(&device_proxy_2), | 73 fake_device_descriptor_.device_id, mojo::MakeRequest(&device_proxy_2), |
68 base::Bind( | 74 base::Bind( |
(...skipping 16 matching lines...) Expand all Loading... |
85 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) | 91 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) |
86 .WillRepeatedly( | 92 .WillRepeatedly( |
87 InvokeWithoutArgs([&wait_loop_2]() { wait_loop_2.Quit(); })); | 93 InvokeWithoutArgs([&wait_loop_2]() { wait_loop_2.Quit(); })); |
88 | 94 |
89 device_proxy_2->Start(arbitrary_requested_settings, | 95 device_proxy_2->Start(arbitrary_requested_settings, |
90 std::move(receiver_proxy)); | 96 std::move(receiver_proxy)); |
91 wait_loop_2.Run(); | 97 wait_loop_2.Run(); |
92 } | 98 } |
93 | 99 |
94 } // namespace video_capture | 100 } // namespace video_capture |
OLD | NEW |