1 /*
2 * Copyright 2018 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 #include <base/bind.h>
18 #include <base/logging.h>
19 #include <base/message_loop/message_loop.h>
20 #include <gmock/gmock.h>
21 #include <gtest/gtest.h>
22
23 #include "avrcp_internal.h"
24 #include "avrcp_test_helper.h"
25 #include "connection_handler.h"
26
27 using ::testing::_;
28 using ::testing::DoAll;
29 using ::testing::MockFunction;
30 using ::testing::NiceMock;
31 using ::testing::Return;
32 using ::testing::SaveArg;
33 using ::testing::SaveArgPointee;
34 using ::testing::SetArgPointee;
35 using ::testing::StrictMock;
36
37 namespace bluetooth {
38 namespace avrcp {
39
40 using device_ptr = std::shared_ptr<Device>;
41
42 class AvrcpConnectionHandlerTest : public testing::Test {
43 public:
SetUp()44 void SetUp() override {
45 ON_CALL(mock_avrcp_, Close(_)).WillByDefault(Return(0));
46 }
47
SetUpSdp(tAVRC_FIND_CBACK * sdp_cb,bool browsing,bool absolute_volume)48 void SetUpSdp(tAVRC_FIND_CBACK* sdp_cb, bool browsing, bool absolute_volume) {
49 EXPECT_CALL(mock_avrcp_, FindService(_, _, _, _))
50 .Times(1)
51 .WillOnce(DoAll(SaveArg<3>(sdp_cb), Return(0)));
52
53 static tSDP_DISC_ATTR fake_features;
54
55 fake_features = {
56 .p_next_attr = nullptr,
57 .attr_id = 0,
58 .attr_len_type = 0,
59 .attr_value = {.v = {.u16 = 0}},
60 };
61
62 if (browsing) fake_features.attr_value.v.u16 |= AVRC_SUPF_CT_BROWSE;
63 if (absolute_volume) fake_features.attr_value.v.u16 |= AVRC_SUPF_CT_CAT2;
64
65 EXPECT_CALL(mock_sdp_, FindAttributeInRec(_, _))
66 .Times(4)
67 .WillRepeatedly(Return(&fake_features));
68
69 EXPECT_CALL(mock_sdp_, FindServiceInDb(_, _, _))
70 .Times(2)
71 .WillOnce(Return((tSDP_DISC_REC*)0x01)) // Return any non null pointer
72 .WillOnce(Return((tSDP_DISC_REC*)0x01)); // Return any non null pointer
73
74 EXPECT_CALL(mock_sdp_, FindProfileVersionInRec(_, _, _))
75 .Times(2)
76 .WillRepeatedly(DoAll(SetArgPointee<2>(AVRC_REV_1_6), Return(true)));
77 }
78
79 protected:
80 ConnectionHandler* connection_handler_ = nullptr;
81
82 // We use NiceMock's here because each function of this code does quite a few
83 // operations. This way it is much easier to write a higher number of smaller
84 // tests without having a large amount of warnings.
85 NiceMock<MockFunction<void(device_ptr)>> device_cb;
86 NiceMock<MockAvrcpInterface> mock_avrcp_;
87 NiceMock<MockSdpInterface> mock_sdp_;
88 NiceMock<MockVolumeInterface> mock_volume_;
89 };
90
TEST_F(AvrcpConnectionHandlerTest,initializeTest)91 TEST_F(AvrcpConnectionHandlerTest, initializeTest) {
92 // Set an Expectation that Open will be called as an acceptor and save the
93 // connection callback once it is called
94 tAVRC_CONN_CB conn_cb;
95 EXPECT_CALL(mock_avrcp_, Open(_, _, RawAddress::kAny))
96 .Times(1)
97 .WillOnce(
98 DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)));
99
100 auto bound_callback = base::Bind(&MockFunction<void(device_ptr)>::Call,
101 base::Unretained(&device_cb));
102 ASSERT_TRUE(ConnectionHandler::Initialize(bound_callback, &mock_avrcp_,
103 &mock_sdp_, &mock_volume_));
104 connection_handler_ = ConnectionHandler::Get();
105
106 // Check that the callback was sent with us as the acceptor
107 ASSERT_EQ(conn_cb.conn, 1);
108
109 connection_handler_ = nullptr;
110 ConnectionHandler::CleanUp();
111 }
112
113 // Check that disconnecting without an active connection
TEST_F(AvrcpConnectionHandlerTest,notConnectedDisconnectTest)114 TEST_F(AvrcpConnectionHandlerTest, notConnectedDisconnectTest) {
115 // Set an Expectation that Open will be called twice as an acceptor and save
116 // the connection callback once it is called.
117 tAVRC_CONN_CB conn_cb;
118 EXPECT_CALL(mock_avrcp_, Open(_, _, RawAddress::kAny))
119 .Times(1)
120 .WillOnce(
121 DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)));
122
123 // Initialize the interface
124 auto bound_callback = base::Bind(&MockFunction<void(device_ptr)>::Call,
125 base::Unretained(&device_cb));
126 ASSERT_TRUE(ConnectionHandler::Initialize(bound_callback, &mock_avrcp_,
127 &mock_sdp_, &mock_volume_));
128 connection_handler_ = ConnectionHandler::Get();
129
130 // Call the callback with a message saying the connection has closed
131 conn_cb.ctrl_cback.Run(1, AVRC_CLOSE_IND_EVT, 0, &RawAddress::kAny);
132
133 connection_handler_ = nullptr;
134 ConnectionHandler::CleanUp();
135 };
136
137 // Test calling the connection callback after the handler is cleaned up
TEST_F(AvrcpConnectionHandlerTest,disconnectAfterCleanupTest)138 TEST_F(AvrcpConnectionHandlerTest, disconnectAfterCleanupTest) {
139 // Set an Expectation that Open will be called twice as an acceptor and save
140 // the connection callback once it is called.
141 tAVRC_CONN_CB conn_cb;
142 EXPECT_CALL(mock_avrcp_, Open(_, _, RawAddress::kAny))
143 .Times(1)
144 .WillOnce(
145 DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)));
146
147 // Initialize the interface
148 auto bound_callback = base::Bind(&MockFunction<void(device_ptr)>::Call,
149 base::Unretained(&device_cb));
150 ASSERT_TRUE(ConnectionHandler::Initialize(bound_callback, &mock_avrcp_,
151 &mock_sdp_, &mock_volume_));
152 connection_handler_ = ConnectionHandler::Get();
153
154 connection_handler_ = nullptr;
155 ConnectionHandler::CleanUp();
156
157 // Call the callback with a message saying the connection has closed
158 conn_cb.ctrl_cback.Run(1, AVRC_CLOSE_IND_EVT, 0, &RawAddress::kAny);
159 };
160
161 // Check that we can handle having a remote device connect to us, start SDP, and
162 // open another acceptor connection
TEST_F(AvrcpConnectionHandlerTest,remoteDeviceConnectionTest)163 TEST_F(AvrcpConnectionHandlerTest, remoteDeviceConnectionTest) {
164 // Set an Expectation that Open will be called twice as an acceptor and save
165 // the connection callback once it is called.
166 tAVRC_CONN_CB conn_cb;
167 EXPECT_CALL(mock_avrcp_, Open(_, _, RawAddress::kAny))
168 .Times(2)
169 .WillOnce(
170 DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)))
171 .WillOnce(
172 DoAll(SetArgPointee<0>(2), SaveArgPointee<1>(&conn_cb), Return(0)));
173
174 // Initialize the interface
175 auto bound_callback = base::Bind(&MockFunction<void(device_ptr)>::Call,
176 base::Unretained(&device_cb));
177 ASSERT_TRUE(ConnectionHandler::Initialize(bound_callback, &mock_avrcp_,
178 &mock_sdp_, &mock_volume_));
179 connection_handler_ = ConnectionHandler::Get();
180
181 // Check that the callback was sent with us as the acceptor
182 ASSERT_EQ(conn_cb.conn, 1);
183
184 // Set an Expectations that SDP will be performed
185 tAVRC_FIND_CBACK sdp_cb;
186 SetUpSdp(&sdp_cb, false, false);
187
188 // Set an expectation that a device will be created
189 EXPECT_CALL(device_cb, Call(_)).Times(1);
190
191 // Set an Expectation that OpenBrowse will be called in acceptor mode when the
192 // device connects.
193 EXPECT_CALL(mock_avrcp_, OpenBrowse(1, AVCT_ACP)).Times(1);
194
195 // Call the callback with a message saying that a remote device has connected
196 conn_cb.ctrl_cback.Run(1, AVRC_OPEN_IND_EVT, 0, &RawAddress::kAny);
197
198 // Run the SDP callback with status success
199 sdp_cb.Run(0);
200
201 connection_handler_ = nullptr;
202 ConnectionHandler::CleanUp();
203 }
204
205 // Check that when a device does not support absolute volume, that the
206 // handler reports that via the volume interface.
TEST_F(AvrcpConnectionHandlerTest,noAbsoluteVolumeTest)207 TEST_F(AvrcpConnectionHandlerTest, noAbsoluteVolumeTest) {
208 // Set an Expectation that Open will be called twice as an acceptor and save
209 // the connection callback once it is called.
210 tAVRC_CONN_CB conn_cb;
211 EXPECT_CALL(mock_avrcp_, Open(_, _, RawAddress::kAny))
212 .Times(2)
213 .WillOnce(
214 DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)))
215 .WillOnce(
216 DoAll(SetArgPointee<0>(2), SaveArgPointee<1>(&conn_cb), Return(0)));
217
218 // Initialize the interface
219 auto bound_callback = base::Bind(&MockFunction<void(device_ptr)>::Call,
220 base::Unretained(&device_cb));
221 ASSERT_TRUE(ConnectionHandler::Initialize(bound_callback, &mock_avrcp_,
222 &mock_sdp_, &mock_volume_));
223 connection_handler_ = ConnectionHandler::Get();
224
225 // Set an Expectations that SDP will be performed
226 tAVRC_FIND_CBACK sdp_cb;
227 SetUpSdp(&sdp_cb, false, false);
228
229 EXPECT_CALL(mock_volume_, DeviceConnected(RawAddress::kAny)).Times(1);
230
231 // Call the callback with a message saying that a remote device has connected
232 conn_cb.ctrl_cback.Run(1, AVRC_OPEN_IND_EVT, 0, &RawAddress::kAny);
233
234 // Run the SDP callback with status success
235 sdp_cb.Run(0);
236
237 connection_handler_ = nullptr;
238 ConnectionHandler::CleanUp();
239 }
240
241 // Check that when a device does support absolute volume, that the handler
242 // doesn't report it. Instead that will be left up to the device.
TEST_F(AvrcpConnectionHandlerTest,absoluteVolumeTest)243 TEST_F(AvrcpConnectionHandlerTest, absoluteVolumeTest) {
244 // Set an Expectation that Open will be called twice as an acceptor and save
245 // the connection callback once it is called.
246 tAVRC_CONN_CB conn_cb;
247 EXPECT_CALL(mock_avrcp_, Open(_, _, RawAddress::kAny))
248 .Times(2)
249 .WillOnce(
250 DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)))
251 .WillOnce(
252 DoAll(SetArgPointee<0>(2), SaveArgPointee<1>(&conn_cb), Return(0)));
253
254 // Initialize the interface
255 auto bound_callback = base::Bind(&MockFunction<void(device_ptr)>::Call,
256 base::Unretained(&device_cb));
257
258 StrictMock<MockVolumeInterface> strict_volume;
259 ASSERT_TRUE(ConnectionHandler::Initialize(bound_callback, &mock_avrcp_,
260 &mock_sdp_, &strict_volume));
261 connection_handler_ = ConnectionHandler::Get();
262
263 // Set an Expectations that SDP will be performed with absolute volume
264 // supported
265 tAVRC_FIND_CBACK sdp_cb;
266 SetUpSdp(&sdp_cb, false, true);
267
268 // Call the callback with a message saying that a remote device has connected
269 conn_cb.ctrl_cback.Run(1, AVRC_OPEN_IND_EVT, 0, &RawAddress::kAny);
270
271 // Run the SDP callback with status success
272 sdp_cb.Run(0);
273
274 connection_handler_ = nullptr;
275 ConnectionHandler::CleanUp();
276 }
277
TEST_F(AvrcpConnectionHandlerTest,disconnectTest)278 TEST_F(AvrcpConnectionHandlerTest, disconnectTest) {
279 // Set an Expectation that Open will be called twice as an acceptor and save
280 // the connection callback once it is called.
281 tAVRC_CONN_CB conn_cb;
282 EXPECT_CALL(mock_avrcp_, Open(_, _, RawAddress::kAny))
283 .Times(2)
284 .WillOnce(
285 DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)))
286 .WillOnce(DoAll(SetArgPointee<0>(2), Return(0)));
287
288 // Initialize the interface
289 auto bound_callback = base::Bind(&MockFunction<void(device_ptr)>::Call,
290 base::Unretained(&device_cb));
291 ASSERT_TRUE(ConnectionHandler::Initialize(bound_callback, &mock_avrcp_,
292 &mock_sdp_, &mock_volume_));
293 connection_handler_ = ConnectionHandler::Get();
294
295 // Call the callback with a message saying that a remote device has connected
296 conn_cb.ctrl_cback.Run(1, AVRC_OPEN_IND_EVT, 0, &RawAddress::kAny);
297
298 // Set up the expectation that Close will be called
299 EXPECT_CALL(mock_avrcp_, Close(1)).Times(1);
300
301 // Call the callback with a message saying that a remote device has
302 // disconnected
303 conn_cb.ctrl_cback.Run(1, AVRC_CLOSE_IND_EVT, 0, &RawAddress::kAny);
304
305 connection_handler_ = nullptr;
306 ConnectionHandler::CleanUp();
307 }
308
309 // Check that we can handle having a remote device connect to us, start SDP, and
310 // open another acceptor connection
TEST_F(AvrcpConnectionHandlerTest,multipleRemoteDeviceConnectionTest)311 TEST_F(AvrcpConnectionHandlerTest, multipleRemoteDeviceConnectionTest) {
312 // Set an Expectation that Open will be called three times as an acceptor and
313 // save the connection callback once it is called.
314 tAVRC_CONN_CB conn_cb;
315 EXPECT_CALL(mock_avrcp_, Open(_, _, RawAddress::kAny))
316 .Times(3)
317 .WillOnce(
318 DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)))
319 .WillOnce(
320 DoAll(SetArgPointee<0>(2), SaveArgPointee<1>(&conn_cb), Return(0)))
321 .WillOnce(
322 DoAll(SetArgPointee<0>(3), SaveArgPointee<1>(&conn_cb), Return(0)));
323
324 // Initialize the interface
325 auto bound_callback = base::Bind(&MockFunction<void(device_ptr)>::Call,
326 base::Unretained(&device_cb));
327 ASSERT_TRUE(ConnectionHandler::Initialize(bound_callback, &mock_avrcp_,
328 &mock_sdp_, &mock_volume_));
329 connection_handler_ = ConnectionHandler::Get();
330
331 // Check that the callback was sent with us as the acceptor
332 ASSERT_EQ(conn_cb.conn, 1);
333
334 // Set an Expectations that SDP will be performed
335 tAVRC_FIND_CBACK sdp_cb;
336 SetUpSdp(&sdp_cb, false, false);
337
338 // Set an expectation that a device will be created
339 EXPECT_CALL(device_cb, Call(_)).Times(1);
340
341 // Set an Expectation that OpenBrowse will be called in acceptor mode when the
342 // device connects on handle 1
343 EXPECT_CALL(mock_avrcp_, OpenBrowse(1, AVCT_ACP)).Times(1);
344
345 // Call the callback with a message saying that a remote device has connected
346 conn_cb.ctrl_cback.Run(1, AVRC_OPEN_IND_EVT, 0, &RawAddress::kAny);
347
348 // Run the SDP callback with status success
349 sdp_cb.Run(0);
350
351 // Set an Expectations that SDP will be performed again
352 SetUpSdp(&sdp_cb, false, false);
353
354 // Set an expectation that a device will be created again
355 EXPECT_CALL(device_cb, Call(_)).Times(1);
356
357 // Set an Expectation that OpenBrowse will be called in acceptor mode when the
358 // device connects on handle 2
359 EXPECT_CALL(mock_avrcp_, OpenBrowse(2, AVCT_ACP)).Times(1);
360
361 // Call the callback with a message saying that a remote device has connected
362 // with a different address
363 conn_cb.ctrl_cback.Run(2, AVRC_OPEN_IND_EVT, 0, &RawAddress::kEmpty);
364
365 // Run the SDP callback with status success
366 sdp_cb.Run(0);
367
368 connection_handler_ = nullptr;
369 ConnectionHandler::CleanUp();
370 }
371
TEST_F(AvrcpConnectionHandlerTest,cleanupTest)372 TEST_F(AvrcpConnectionHandlerTest, cleanupTest) {
373 // Set Up Expectations for Initialize
374 tAVRC_CONN_CB conn_cb;
375 EXPECT_CALL(mock_avrcp_, Open(_, _, _))
376 .WillOnce(
377 DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)))
378 .WillOnce(
379 DoAll(SetArgPointee<0>(2), SaveArgPointee<1>(&conn_cb), Return(0)))
380 .WillOnce(
381 DoAll(SetArgPointee<0>(3), SaveArgPointee<1>(&conn_cb), Return(0)));
382
383 // Initialize the interface
384 auto bound_callback = base::Bind(&MockFunction<void(device_ptr)>::Call,
385 base::Unretained(&device_cb));
386 ASSERT_TRUE(ConnectionHandler::Initialize(bound_callback, &mock_avrcp_,
387 &mock_sdp_, &mock_volume_));
388 connection_handler_ = ConnectionHandler::Get();
389
390 // Call the callback twice with a message saying that a remote device has
391 // connected
392 conn_cb.ctrl_cback.Run(1, AVRC_OPEN_IND_EVT, 0, &RawAddress::kAny);
393 conn_cb.ctrl_cback.Run(2, AVRC_OPEN_IND_EVT, 0, &RawAddress::kEmpty);
394
395 // Set an Expectation that Close will be called twice with handles 1 and 2
396 EXPECT_CALL(mock_avrcp_, Close(1));
397 EXPECT_CALL(mock_avrcp_, Close(2));
398
399 // Cleanup the object causing all open connections to be closed
400 connection_handler_ = nullptr;
401 ConnectionHandler::CleanUp();
402 }
403
TEST_F(AvrcpConnectionHandlerTest,connectToRemoteDeviceTest)404 TEST_F(AvrcpConnectionHandlerTest, connectToRemoteDeviceTest) {
405 // Initialize the interface
406 auto bound_callback = base::Bind(&MockFunction<void(device_ptr)>::Call,
407 base::Unretained(&device_cb));
408 ASSERT_TRUE(ConnectionHandler::Initialize(bound_callback, &mock_avrcp_,
409 &mock_sdp_, &mock_volume_));
410 connection_handler_ = ConnectionHandler::Get();
411
412 // Set an Expectation that SDP will be performed
413 tAVRC_FIND_CBACK sdp_cb;
414 SetUpSdp(&sdp_cb, false, false);
415
416 // Connect to the device which starts SDP
417 connection_handler_->ConnectDevice(RawAddress::kEmpty);
418
419 // Set an expectation that the handler will try to open an AVRCP connection
420 // after doing SDP
421 tAVRC_CONN_CB conn_cb;
422 EXPECT_CALL(mock_avrcp_, Open(_, _, RawAddress::kEmpty))
423 .Times(1)
424 .WillOnce(
425 DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)));
426
427 // Complete SDP
428 sdp_cb.Run(0);
429
430 // Check that the callback was sent with us as the initiator
431 ASSERT_EQ(conn_cb.conn, 0);
432
433 // Set an expectation that a device will be created
434 EXPECT_CALL(device_cb, Call(_)).Times(1);
435
436 // Set an Expectation that OpenBrowse will NOT be called since the SDP entry
437 // didn't list browsing as a feature
438 EXPECT_CALL(mock_avrcp_, OpenBrowse(_, _)).Times(0);
439
440 // Call the callback with a message saying that a remote device has connected
441 // with a different address
442 conn_cb.ctrl_cback.Run(2, AVRC_OPEN_IND_EVT, 0, &RawAddress::kEmpty);
443
444 // Cleanup the object causing all open connections to be closed
445 connection_handler_ = nullptr;
446 ConnectionHandler::CleanUp();
447 }
448
TEST_F(AvrcpConnectionHandlerTest,connectToBrowsableRemoteDeviceTest)449 TEST_F(AvrcpConnectionHandlerTest, connectToBrowsableRemoteDeviceTest) {
450 // Initialize the interface
451 auto bound_callback = base::Bind(&MockFunction<void(device_ptr)>::Call,
452 base::Unretained(&device_cb));
453 ASSERT_TRUE(ConnectionHandler::Initialize(bound_callback, &mock_avrcp_,
454 &mock_sdp_, &mock_volume_));
455 connection_handler_ = ConnectionHandler::Get();
456
457 // Set an Expectation that SDP will be performed
458 tAVRC_FIND_CBACK sdp_cb;
459 SetUpSdp(&sdp_cb, true, false);
460
461 // Connect to the device which starts SDP
462 connection_handler_->ConnectDevice(RawAddress::kEmpty);
463
464 // Set an expectation that the handler will try to open an AVRCP connection
465 // after doing SDP
466 tAVRC_CONN_CB conn_cb;
467 EXPECT_CALL(mock_avrcp_, Open(_, _, RawAddress::kEmpty))
468 .Times(1)
469 .WillOnce(
470 DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)));
471
472 // Complete SDP
473 sdp_cb.Run(0);
474
475 // Check that the callback was sent with us as the initiator
476 ASSERT_EQ(conn_cb.conn, 0);
477
478 // Set an expectation that a device will be created
479 EXPECT_CALL(device_cb, Call(_)).Times(1);
480
481 // Set an Expectation that OpenBrowse will be called since browsing is listed
482 // as supported in SDP
483 EXPECT_CALL(mock_avrcp_, OpenBrowse(1, AVCT_INT)).Times(1);
484
485 // Call the callback with a message saying that a remote device has connected
486 // with a different address
487 conn_cb.ctrl_cback.Run(1, AVRC_OPEN_IND_EVT, 0, &RawAddress::kEmpty);
488
489 // Cleanup the object causing all open connections to be closed
490 connection_handler_ = nullptr;
491 ConnectionHandler::CleanUp();
492 }
493
TEST_F(AvrcpConnectionHandlerTest,disconnectWhileDoingSdpTest)494 TEST_F(AvrcpConnectionHandlerTest, disconnectWhileDoingSdpTest) {
495 // Set an Expectation that Open will be called twice as an acceptor and save
496 // the connection callback once it is called.
497 tAVRC_CONN_CB conn_cb;
498 EXPECT_CALL(mock_avrcp_, Open(_, _, RawAddress::kAny))
499 .Times(2)
500 .WillOnce(
501 DoAll(SetArgPointee<0>(1), SaveArgPointee<1>(&conn_cb), Return(0)))
502 .WillOnce(DoAll(SetArgPointee<0>(2), Return(0)));
503
504 // Initialize the interface
505 auto bound_callback = base::Bind(&MockFunction<void(device_ptr)>::Call,
506 base::Unretained(&device_cb));
507 ASSERT_TRUE(ConnectionHandler::Initialize(bound_callback, &mock_avrcp_,
508 &mock_sdp_, &mock_volume_));
509 connection_handler_ = ConnectionHandler::Get();
510
511 // Set an Expectation that SDP will be performed
512 tAVRC_FIND_CBACK sdp_cb;
513 SetUpSdp(&sdp_cb, true, false);
514
515 // Call the callback with a message saying that a remote device has connected
516 conn_cb.ctrl_cback.Run(1, AVRC_OPEN_IND_EVT, 0, &RawAddress::kAny);
517
518 // Call the callback with a message saying that a remote device has
519 // disconnected
520 conn_cb.ctrl_cback.Run(1, AVRC_CLOSE_IND_EVT, 0, &RawAddress::kAny);
521
522 // Signal that SDP has completed
523 sdp_cb.Run(0);
524
525 connection_handler_ = nullptr;
526 ConnectionHandler::CleanUp();
527 }
528
529 } // namespace avrcp
530 } // namespace bluetooth
531