OSDN Git Service

Test stack/acl/btm_acl::on_acl_br_edr_{success,failed}
authorChris Manton <cmanton@google.com>
Sun, 10 Jan 2021 23:39:36 +0000 (15:39 -0800)
committerChris Manton <cmanton@google.com>
Tue, 19 Jan 2021 21:32:29 +0000 (13:32 -0800)
Try not to re-converge divergent code paths

Bug: 163134718
Tag: #refactor
Test: compile & verify basic functions working

Change-Id: Ic8a795369972bb38e5ab9bb51c9e735c382680e4

stack/test/btm/stack_btm_test.cc

index 701edbb..1273b89 100644 (file)
@@ -87,7 +87,7 @@ using testing::Test;
 class StackBtmTest : public Test {
  public:
  protected:
-  void SetUp() override {}
+  void SetUp() override { mock_function_count_map.clear(); }
   void TearDown() override {}
 };
 
@@ -101,7 +101,7 @@ TEST_F(StackBtmTest, DynamicLifecycle) {
   delete btm;
 }
 
-TEST_F(StackBtmTest, InformBtmOnConnection) {
+TEST_F(StackBtmTest, InformClientOnConnectionSuccess) {
   MOCK_bluetooth_shim_is_gd_acl_enabled_ = true;
 
   get_btm_client_interface().lifecycle.btm_init();
@@ -115,4 +115,18 @@ TEST_F(StackBtmTest, InformBtmOnConnection) {
   get_btm_client_interface().lifecycle.btm_free();
 }
 
+TEST_F(StackBtmTest, NoInformClientOnConnectionFail) {
+  MOCK_bluetooth_shim_is_gd_acl_enabled_ = true;
+
+  get_btm_client_interface().lifecycle.btm_init();
+
+  RawAddress bda({0x11, 0x22, 0x33, 0x44, 0x55, 0x66});
+
+  btm_acl_connected(bda, 2, HCI_ERR_NO_CONNECTION, false);
+  ASSERT_EQ(static_cast<size_t>(0),
+            mock_function_count_map.count("BTA_dm_acl_up"));
+
+  get_btm_client_interface().lifecycle.btm_free();
+}
+
 }  // namespace