OSDN Git Service

Add stack::test::btm::stack_back_test::InformBtmOnConnection
authorChris Manton <cmanton@google.com>
Sun, 29 Nov 2020 16:54:52 +0000 (08:54 -0800)
committerChris Manton <cmanton@google.com>
Thu, 3 Dec 2020 02:49:32 +0000 (02:49 +0000)
Bug: 173769100
Test: net_test_stack_btm
Tag: #refactor

Change-Id: I4a03378bf80369d575c45cfe61345d78cabf7da2

stack/test/btm/stack_btm_test.cc
stack/test/common/mock_main_shim.cc

index 92fc9b2..9d039dc 100644 (file)
@@ -26,6 +26,8 @@
 #include "osi/include/osi.h"
 #include "stack/btm/btm_int.h"
 #include "stack/btm/btm_int_types.h"
+#include "stack/include/acl_hci_link_interface.h"
+#include "types/raw_address.h"
 
 base::MessageLoop* get_main_message_loop() { return nullptr; }
 
@@ -67,6 +69,8 @@ const stack_config_t* stack_config_get_interface(void) {
 
 std::map<std::string, int> mock_function_count_map;
 
+bool MOCK_bluetooth_shim_is_gd_acl_enabled_;
+
 namespace {
 
 using testing::_;
@@ -97,4 +101,18 @@ TEST_F(StackBtmTest, DynamicLifecycle) {
   delete btm;
 }
 
+TEST_F(StackBtmTest, InformBtmOnConnection) {
+  MOCK_bluetooth_shim_is_gd_acl_enabled_ = true;
+
+  btm_init();
+
+  RawAddress bda({0x11, 0x22, 0x33, 0x44, 0x55, 0x66});
+
+  btm_acl_connected(bda, 2, HCI_SUCCESS, false);
+  ASSERT_EQ(static_cast<size_t>(1),
+            mock_function_count_map.count("BTA_dm_acl_up"));
+
+  btm_free();
+}
+
 }  // namespace
index b59ce65..ee6ef30 100644 (file)
@@ -34,13 +34,15 @@ extern std::map<std::string, int> mock_function_count_map;
 #define UNUSED_ATTR
 #endif
 
+extern bool MOCK_bluetooth_shim_is_gd_acl_enabled_;
+
 bool bluetooth::shim::is_any_gd_enabled() {
   mock_function_count_map[__func__]++;
   return false;
 }
 bool bluetooth::shim::is_gd_acl_enabled() {
   mock_function_count_map[__func__]++;
-  return false;
+  return MOCK_bluetooth_shim_is_gd_acl_enabled_;
 }
 bool bluetooth::shim::is_gd_advertising_enabled() {
   mock_function_count_map[__func__]++;