"rfcomm/rfc_ts_frames.cc",
"rfcomm/rfc_utils.cc",
"test/common/mock_btm_layer.cc",
+ "test/common/mock_btsnoop_module.cc",
"test/common/mock_btu_layer.cc",
"test/common/mock_l2cap_layer.cc",
"test/common/stack_test_packet_utils.cc",
--- /dev/null
+/******************************************************************************
+ *
+ * Copyright 2019 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at:
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ******************************************************************************/
+
+#include "hci/include/btsnoop.h"
+
+static void capture(const BT_HDR*, bool) { /* do nothing */
+}
+
+static void whitelist_l2c_channel(uint16_t, uint16_t,
+ uint16_t) { /* do nothing */
+}
+
+static void whitelist_rfc_dlci(uint16_t, uint8_t) { /* do nothing */
+}
+
+static void add_rfc_l2c_channel(uint16_t, uint16_t, uint16_t) { /* do nothing */
+}
+
+static void clear_l2cap_whitelist(uint16_t, uint16_t,
+ uint16_t) { /* do nothing */
+}
+
+static const btsnoop_t fake_snoop = {capture, whitelist_l2c_channel,
+ whitelist_rfc_dlci, add_rfc_l2c_channel,
+ clear_l2cap_whitelist};
+
+const btsnoop_t* btsnoop_get_interface() { return &fake_snoop; }
l2cap_interface = mock_l2cap_interface;
}
-uint16_t L2CA_Register(uint16_t psm, tL2CAP_APPL_INFO* p_cb_info) {
- VLOG(1) << __func__ << ": psm=" << psm << ", p_cb_info=" << p_cb_info;
- return l2cap_interface->Register(psm, p_cb_info);
+uint16_t L2CA_Register(uint16_t psm, tL2CAP_APPL_INFO* p_cb_info,
+ bool enable_snoop) {
+ VLOG(1) << __func__ << ": psm=" << psm << ", p_cb_info=" << p_cb_info
+ << ", enable_snoop=" << enable_snoop;
+ return l2cap_interface->Register(psm, p_cb_info, enable_snoop);
}
uint16_t L2CA_ConnectReq(uint16_t psm, const RawAddress& bd_addr) {
class L2capInterface {
public:
- virtual uint16_t Register(uint16_t psm, tL2CAP_APPL_INFO* p_cb_info) = 0;
+ virtual uint16_t Register(uint16_t psm, tL2CAP_APPL_INFO* p_cb_info,
+ bool enable_snoop) = 0;
virtual uint16_t ConnectRequest(uint16_t psm, const RawAddress& bd_addr) = 0;
virtual bool ConnectResponse(const RawAddress& bd_addr, uint8_t id,
uint16_t lcid, uint16_t result,
class MockL2capInterface : public L2capInterface {
public:
- MOCK_METHOD2(Register, uint16_t(uint16_t psm, tL2CAP_APPL_INFO* p_cb_info));
+ MOCK_METHOD3(Register, uint16_t(uint16_t psm, tL2CAP_APPL_INFO* p_cb_info,
+ bool enable_snoop));
MOCK_METHOD2(ConnectRequest,
uint16_t(uint16_t psm, const RawAddress& bd_addr));
MOCK_METHOD5(ConnectResponse,
#include "port_api.h"
#include "btm_int.h"
-#include "hci/include/btsnoop.h"
#include "rfc_int.h"
#include "mock_btm_layer.h"
#include "stack_rfcomm_test_utils.h"
#include "stack_test_packet_utils.h"
-static void capture(const BT_HDR*, bool) { /* do nothing */
-}
-static void whitelist_l2c_channel(uint16_t, uint16_t,
- uint16_t) { /* do nothing */
-}
-static void whitelist_rfc_dlci(uint16_t, uint8_t) { /* do nothing */
-}
-static void add_rfc_l2c_channel(uint16_t, uint16_t, uint16_t) { /* do nothing */
-}
-static void clear_l2cap_whitelist(uint16_t, uint16_t,
- uint16_t) { /* do nothing */
-}
-static const btsnoop_t fake_snoop = {capture, whitelist_l2c_channel,
- whitelist_rfc_dlci, add_rfc_l2c_channel,
- clear_l2cap_whitelist};
-const btsnoop_t* btsnoop_get_interface() { return &fake_snoop; }
-
std::string DumpByteBufferToString(uint8_t* p_data, size_t len) {
std::stringstream str;
str.setf(std::ios_base::hex, std::ios::basefield);
return str.str();
}
-uint16_t L2CA_Register(unsigned short, tL2CAP_APPL_INFO*, bool) { return 0; }
-
std::string DumpBtHdrToString(BT_HDR* p_hdr) {
uint8_t* p_hdr_data = p_hdr->data + p_hdr->offset;
return DumpByteBufferToString(p_hdr_data, p_hdr->len);
&btm_security_internal_interface_);
bluetooth::l2cap::SetMockInterface(&l2cap_interface_);
rfcomm_callback = &rfcomm_callback_;
- EXPECT_CALL(l2cap_interface_, Register(BT_PSM_RFCOMM, _))
+ EXPECT_CALL(l2cap_interface_, Register(BT_PSM_RFCOMM, _, _))
.WillOnce(
DoAll(SaveArgPointee<1>(&l2cap_appl_info_), Return(BT_PSM_RFCOMM)));
RFCOMM_Init();