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

Side by Side Diff: services/video_capture/test/fake_device_descriptor_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
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;
(...skipping 14 matching lines...) Expand all
25 // connection. 25 // connection.
26 TEST_F(FakeVideoCaptureDeviceDescriptorTest, 26 TEST_F(FakeVideoCaptureDeviceDescriptorTest,
27 DISABLED_AccessIsRevokedOnSecondAccess) { 27 DISABLED_AccessIsRevokedOnSecondAccess) {
28 mojom::DevicePtr device_proxy_1; 28 mojom::DevicePtr device_proxy_1;
29 bool device_access_1_revoked = false; 29 bool device_access_1_revoked = false;
30 MockCreateDeviceProxyCallback create_device_proxy_callback_1; 30 MockCreateDeviceProxyCallback create_device_proxy_callback_1;
31 EXPECT_CALL(create_device_proxy_callback_1, 31 EXPECT_CALL(create_device_proxy_callback_1,
32 Run(mojom::DeviceAccessResultCode::SUCCESS)) 32 Run(mojom::DeviceAccessResultCode::SUCCESS))
33 .Times(1); 33 .Times(1);
34 factory_->CreateDevice( 34 factory_->CreateDevice(
35 fake_device_descriptor_.device_id, mojo::MakeRequest(&device_proxy_1), 35 fake_device_info_.descriptor.device_id,
36 mojo::MakeRequest(&device_proxy_1),
36 base::Bind(&MockCreateDeviceProxyCallback::Run, 37 base::Bind(&MockCreateDeviceProxyCallback::Run,
37 base::Unretained(&create_device_proxy_callback_1))); 38 base::Unretained(&create_device_proxy_callback_1)));
38 device_proxy_1.set_connection_error_handler( 39 device_proxy_1.set_connection_error_handler(
39 base::Bind([](bool* access_revoked) { *access_revoked = true; }, 40 base::Bind([](bool* access_revoked) { *access_revoked = true; },
40 &device_access_1_revoked)); 41 &device_access_1_revoked));
41 42
42 base::RunLoop wait_loop; 43 base::RunLoop wait_loop;
43 mojom::DevicePtr device_proxy_2; 44 mojom::DevicePtr device_proxy_2;
44 bool device_access_2_revoked = false; 45 bool device_access_2_revoked = false;
45 MockCreateDeviceProxyCallback create_device_proxy_callback_2; 46 MockCreateDeviceProxyCallback create_device_proxy_callback_2;
46 EXPECT_CALL(create_device_proxy_callback_2, 47 EXPECT_CALL(create_device_proxy_callback_2,
47 Run(mojom::DeviceAccessResultCode::SUCCESS)) 48 Run(mojom::DeviceAccessResultCode::SUCCESS))
48 .Times(1) 49 .Times(1)
49 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); })); 50 .WillOnce(InvokeWithoutArgs([&wait_loop]() { wait_loop.Quit(); }));
50 factory_->CreateDevice( 51 factory_->CreateDevice(
51 fake_device_descriptor_.device_id, mojo::MakeRequest(&device_proxy_2), 52 fake_device_info_.descriptor.device_id,
53 mojo::MakeRequest(&device_proxy_2),
52 base::Bind(&MockCreateDeviceProxyCallback::Run, 54 base::Bind(&MockCreateDeviceProxyCallback::Run,
53 base::Unretained(&create_device_proxy_callback_2))); 55 base::Unretained(&create_device_proxy_callback_2)));
54 device_proxy_2.set_connection_error_handler( 56 device_proxy_2.set_connection_error_handler(
55 base::Bind([](bool* access_revoked) { *access_revoked = true; }, 57 base::Bind([](bool* access_revoked) { *access_revoked = true; },
56 &device_access_2_revoked)); 58 &device_access_2_revoked));
57 wait_loop.Run(); 59 wait_loop.Run();
58 ASSERT_TRUE(device_access_1_revoked); 60 ASSERT_TRUE(device_access_1_revoked);
59 ASSERT_FALSE(device_access_2_revoked); 61 ASSERT_FALSE(device_access_2_revoked);
60 } 62 }
61 63
62 // 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.
63 TEST_F(FakeVideoCaptureDeviceDescriptorTest, 65 TEST_F(FakeVideoCaptureDeviceDescriptorTest,
64 DISABLED_CanUseSecondRequestedProxy) { 66 DISABLED_CanUseSecondRequestedProxy) {
65 mojom::DevicePtr device_proxy_1; 67 mojom::DevicePtr device_proxy_1;
66 factory_->CreateDevice( 68 factory_->CreateDevice(
67 fake_device_descriptor_.device_id, mojo::MakeRequest(&device_proxy_1), 69 fake_device_info_.descriptor.device_id,
70 mojo::MakeRequest(&device_proxy_1),
68 base::Bind([](mojom::DeviceAccessResultCode result_code) {})); 71 base::Bind([](mojom::DeviceAccessResultCode result_code) {}));
69 72
70 base::RunLoop wait_loop; 73 base::RunLoop wait_loop;
71 mojom::DevicePtr device_proxy_2; 74 mojom::DevicePtr device_proxy_2;
72 factory_->CreateDevice( 75 factory_->CreateDevice(
73 fake_device_descriptor_.device_id, mojo::MakeRequest(&device_proxy_2), 76 fake_device_info_.descriptor.device_id,
77 mojo::MakeRequest(&device_proxy_2),
74 base::Bind( 78 base::Bind(
75 [](base::RunLoop* wait_loop, 79 [](base::RunLoop* wait_loop,
76 mojom::DeviceAccessResultCode result_code) { wait_loop->Quit(); }, 80 mojom::DeviceAccessResultCode result_code) { wait_loop->Quit(); },
77 &wait_loop)); 81 &wait_loop));
78 wait_loop.Run(); 82 wait_loop.Run();
79 83
80 CaptureSettings arbitrary_requested_settings; 84 media::VideoCaptureParams arbitrary_requested_settings;
81 arbitrary_requested_settings.format.frame_size.SetSize(640, 480); 85 arbitrary_requested_settings.requested_format.frame_size.SetSize(640, 480);
82 arbitrary_requested_settings.format.frame_rate = 15; 86 arbitrary_requested_settings.requested_format.frame_rate = 15;
83 arbitrary_requested_settings.resolution_change_policy = 87 arbitrary_requested_settings.resolution_change_policy =
84 media::RESOLUTION_POLICY_FIXED_RESOLUTION; 88 media::RESOLUTION_POLICY_FIXED_RESOLUTION;
85 arbitrary_requested_settings.power_line_frequency = 89 arbitrary_requested_settings.power_line_frequency =
86 media::PowerLineFrequency::FREQUENCY_DEFAULT; 90 media::PowerLineFrequency::FREQUENCY_DEFAULT;
87 91
88 base::RunLoop wait_loop_2; 92 base::RunLoop wait_loop_2;
89 mojom::ReceiverPtr receiver_proxy; 93 mojom::ReceiverPtr receiver_proxy;
90 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy)); 94 MockReceiver receiver(mojo::MakeRequest(&receiver_proxy));
91 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_)) 95 EXPECT_CALL(receiver, OnIncomingCapturedVideoFramePtr(_))
92 .WillRepeatedly( 96 .WillRepeatedly(
93 InvokeWithoutArgs([&wait_loop_2]() { wait_loop_2.Quit(); })); 97 InvokeWithoutArgs([&wait_loop_2]() { wait_loop_2.Quit(); }));
94 98
95 device_proxy_2->Start(arbitrary_requested_settings, 99 device_proxy_2->Start(arbitrary_requested_settings,
96 std::move(receiver_proxy)); 100 std::move(receiver_proxy));
97 wait_loop_2.Run(); 101 wait_loop_2.Run();
98 } 102 }
99 103
100 } // namespace video_capture 104 } // namespace video_capture
OLDNEW
« no previous file with comments | « services/video_capture/test/fake_device_descriptor_test.cc ('k') | services/video_capture/test/fake_device_test.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698