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 // Tests that when requesting a second proxy for a device without closing the | 19 // 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 | 20 // first one, the service revokes access to the first one by closing the |
21 // connection. | 21 // connection. |
22 TEST_F(FakeDeviceDescriptorTest, AccessIsRevokedOnSecondAccess) { | 22 TEST_F(FakeDeviceDescriptorTest, DISABLED_AccessIsRevokedOnSecondAccess) { |
23 mojom::DevicePtr device_proxy_1; | 23 mojom::DevicePtr device_proxy_1; |
24 bool device_access_1_revoked = false; | 24 bool device_access_1_revoked = false; |
25 MockCreateDeviceProxyCallback create_device_proxy_callback_1; | 25 MockCreateDeviceProxyCallback create_device_proxy_callback_1; |
26 EXPECT_CALL(create_device_proxy_callback_1, | 26 EXPECT_CALL(create_device_proxy_callback_1, |
27 Run(mojom::DeviceAccessResultCode::SUCCESS)) | 27 Run(mojom::DeviceAccessResultCode::SUCCESS)) |
28 .Times(1); | 28 .Times(1); |
29 factory_->CreateDevice( | 29 factory_->CreateDevice( |
30 fake_device_descriptor_.device_id, mojo::GetProxy(&device_proxy_1), | 30 fake_device_descriptor_.device_id, mojo::GetProxy(&device_proxy_1), |
31 base::Bind(&MockCreateDeviceProxyCallback::Run, | 31 base::Bind(&MockCreateDeviceProxyCallback::Run, |
32 base::Unretained(&create_device_proxy_callback_1))); | 32 base::Unretained(&create_device_proxy_callback_1))); |
(...skipping 15 matching lines...) Expand all Loading... |
48 base::Unretained(&create_device_proxy_callback_2))); | 48 base::Unretained(&create_device_proxy_callback_2))); |
49 device_proxy_2.set_connection_error_handler( | 49 device_proxy_2.set_connection_error_handler( |
50 base::Bind([](bool* access_revoked) { *access_revoked = true; }, | 50 base::Bind([](bool* access_revoked) { *access_revoked = true; }, |
51 &device_access_2_revoked)); | 51 &device_access_2_revoked)); |
52 wait_loop.Run(); | 52 wait_loop.Run(); |
53 ASSERT_TRUE(device_access_1_revoked); | 53 ASSERT_TRUE(device_access_1_revoked); |
54 ASSERT_FALSE(device_access_2_revoked); | 54 ASSERT_FALSE(device_access_2_revoked); |
55 } | 55 } |
56 | 56 |
57 // Tests that a second proxy requested for a device can be used successfully. | 57 // Tests that a second proxy requested for a device can be used successfully. |
58 TEST_F(FakeDeviceDescriptorTest, CanUseSecondRequestedProxy) { | 58 TEST_F(FakeDeviceDescriptorTest, DISABLED_CanUseSecondRequestedProxy) { |
59 mojom::DevicePtr device_proxy_1; | 59 mojom::DevicePtr device_proxy_1; |
60 factory_->CreateDevice( | 60 factory_->CreateDevice( |
61 fake_device_descriptor_.device_id, mojo::GetProxy(&device_proxy_1), | 61 fake_device_descriptor_.device_id, mojo::GetProxy(&device_proxy_1), |
62 base::Bind([](mojom::DeviceAccessResultCode result_code) {})); | 62 base::Bind([](mojom::DeviceAccessResultCode result_code) {})); |
63 | 63 |
64 base::RunLoop wait_loop; | 64 base::RunLoop wait_loop; |
65 mojom::DevicePtr device_proxy_2; | 65 mojom::DevicePtr device_proxy_2; |
66 factory_->CreateDevice( | 66 factory_->CreateDevice( |
67 fake_device_descriptor_.device_id, mojo::GetProxy(&device_proxy_2), | 67 fake_device_descriptor_.device_id, mojo::GetProxy(&device_proxy_2), |
68 base::Bind( | 68 base::Bind( |
(...skipping 16 matching lines...) Expand all Loading... |
85 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) | 85 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) |
86 .WillRepeatedly( | 86 .WillRepeatedly( |
87 InvokeWithoutArgs([&wait_loop_2]() { wait_loop_2.Quit(); })); | 87 InvokeWithoutArgs([&wait_loop_2]() { wait_loop_2.Quit(); })); |
88 | 88 |
89 device_proxy_2->Start(arbitrary_requested_settings, | 89 device_proxy_2->Start(arbitrary_requested_settings, |
90 std::move(receiver_proxy)); | 90 std::move(receiver_proxy)); |
91 wait_loop_2.Run(); | 91 wait_loop_2.Run(); |
92 } | 92 } |
93 | 93 |
94 } // namespace video_capture | 94 } // namespace video_capture |
OLD | NEW |