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

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

Issue 2844813002: Revert of [Mojo Video Capture] Adapt video_capture service to refactored video capture stack (Closed)
Patch Set: Created 3 years, 7 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
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/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. 19 // This alias ensures test output is easily attributed to this service's tests.
20 // TODO(rockot/chfremer): Consider just renaming the type. 20 // TODO(rockot/chfremer): Consider just renaming the type.
21 using FakeVideoCaptureDeviceDescriptorTest = FakeDeviceDescriptorTest; 21 using FakeVideoCaptureDeviceDescriptorTest = FakeDeviceDescriptorTest;
22 22
23 // 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
24 // 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
25 // connection. 25 // connection.
26 TEST_F(FakeVideoCaptureDeviceDescriptorTest, AccessIsRevokedOnSecondAccess) { 26 TEST_F(FakeVideoCaptureDeviceDescriptorTest,
27 DISABLED_AccessIsRevokedOnSecondAccess) {
27 mojom::DevicePtr device_proxy_1; 28 mojom::DevicePtr device_proxy_1;
28 bool device_access_1_revoked = false; 29 bool device_access_1_revoked = false;
29 MockCreateDeviceProxyCallback create_device_proxy_callback_1; 30 MockCreateDeviceProxyCallback create_device_proxy_callback_1;
30 EXPECT_CALL(create_device_proxy_callback_1, 31 EXPECT_CALL(create_device_proxy_callback_1,
31 Run(mojom::DeviceAccessResultCode::SUCCESS)) 32 Run(mojom::DeviceAccessResultCode::SUCCESS))
32 .Times(1); 33 .Times(1);
33 factory_->CreateDevice( 34 factory_->CreateDevice(
34 fake_device_info_.descriptor.device_id, 35 fake_device_info_.descriptor.device_id,
35 mojo::MakeRequest(&device_proxy_1), 36 mojo::MakeRequest(&device_proxy_1),
36 base::Bind(&MockCreateDeviceProxyCallback::Run, 37 base::Bind(&MockCreateDeviceProxyCallback::Run,
(...skipping 17 matching lines...) Expand all
54 base::Unretained(&create_device_proxy_callback_2))); 55 base::Unretained(&create_device_proxy_callback_2)));
55 device_proxy_2.set_connection_error_handler( 56 device_proxy_2.set_connection_error_handler(
56 base::Bind([](bool* access_revoked) { *access_revoked = true; }, 57 base::Bind([](bool* access_revoked) { *access_revoked = true; },
57 &device_access_2_revoked)); 58 &device_access_2_revoked));
58 wait_loop.Run(); 59 wait_loop.Run();
59 ASSERT_TRUE(device_access_1_revoked); 60 ASSERT_TRUE(device_access_1_revoked);
60 ASSERT_FALSE(device_access_2_revoked); 61 ASSERT_FALSE(device_access_2_revoked);
61 } 62 }
62 63
63 // Tests that a second proxy requested for a device can be used successfully. 64 // Tests that a second proxy requested for a device can be used successfully.
64 TEST_F(FakeVideoCaptureDeviceDescriptorTest, CanUseSecondRequestedProxy) { 65 TEST_F(FakeVideoCaptureDeviceDescriptorTest,
66 DISABLED_CanUseSecondRequestedProxy) {
65 mojom::DevicePtr device_proxy_1; 67 mojom::DevicePtr device_proxy_1;
66 factory_->CreateDevice( 68 factory_->CreateDevice(
67 fake_device_info_.descriptor.device_id, 69 fake_device_info_.descriptor.device_id,
68 mojo::MakeRequest(&device_proxy_1), 70 mojo::MakeRequest(&device_proxy_1),
69 base::Bind([](mojom::DeviceAccessResultCode result_code) {})); 71 base::Bind([](mojom::DeviceAccessResultCode result_code) {}));
70 72
71 base::RunLoop wait_loop; 73 base::RunLoop wait_loop;
72 mojom::DevicePtr device_proxy_2; 74 mojom::DevicePtr device_proxy_2;
73 factory_->CreateDevice( 75 factory_->CreateDevice(
74 fake_device_info_.descriptor.device_id, 76 fake_device_info_.descriptor.device_id,
75 mojo::MakeRequest(&device_proxy_2), 77 mojo::MakeRequest(&device_proxy_2),
76 base::Bind( 78 base::Bind(
77 [](base::RunLoop* wait_loop, 79 [](base::RunLoop* wait_loop,
78 mojom::DeviceAccessResultCode result_code) { wait_loop->Quit(); }, 80 mojom::DeviceAccessResultCode result_code) { wait_loop->Quit(); },
79 &wait_loop)); 81 &wait_loop));
80 wait_loop.Run(); 82 wait_loop.Run();
81 83
82 media::VideoCaptureParams arbitrary_requested_settings; 84 media::VideoCaptureParams arbitrary_requested_settings;
83 arbitrary_requested_settings.requested_format.frame_size.SetSize(640, 480); 85 arbitrary_requested_settings.requested_format.frame_size.SetSize(640, 480);
84 arbitrary_requested_settings.requested_format.frame_rate = 15; 86 arbitrary_requested_settings.requested_format.frame_rate = 15;
85 arbitrary_requested_settings.resolution_change_policy = 87 arbitrary_requested_settings.resolution_change_policy =
86 media::RESOLUTION_POLICY_FIXED_RESOLUTION; 88 media::RESOLUTION_POLICY_FIXED_RESOLUTION;
87 arbitrary_requested_settings.power_line_frequency = 89 arbitrary_requested_settings.power_line_frequency =
88 media::PowerLineFrequency::FREQUENCY_DEFAULT; 90 media::PowerLineFrequency::FREQUENCY_DEFAULT;
89 91
90 base::RunLoop wait_loop_2; 92 base::RunLoop wait_loop_2;
91 mojom::ReceiverPtr receiver_proxy; 93 mojom::ReceiverPtr receiver_proxy;
92 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy)); 94 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy));
93 EXPECT_CALL(receiver, DoOnNewBufferHandle(_, _)); 95 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_))
94 EXPECT_CALL(receiver, DoOnFrameReadyInBuffer(_, _, _, _))
95 .WillRepeatedly( 96 .WillRepeatedly(
96 InvokeWithoutArgs([&wait_loop_2]() { wait_loop_2.Quit(); })); 97 InvokeWithoutArgs([&wait_loop_2]() { wait_loop_2.Quit(); }));
97 98
98 device_proxy_2->Start(arbitrary_requested_settings, 99 device_proxy_2->Start(arbitrary_requested_settings,
99 std::move(receiver_proxy)); 100 std::move(receiver_proxy));
100 wait_loop_2.Run(); 101 wait_loop_2.Run();
101 } 102 }
102 103
103 } // namespace video_capture 104 } // namespace video_capture
OLDNEW
« no previous file with comments | « services/video_capture/service_impl.cc ('k') | services/video_capture/test/fake_device_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698