1 /*
2 * Copyright 2024 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
18 #include <gmock/gmock.h>
19 #include <gtest/gtest.h>
20
21 #include "stack/btm/btm_dev.h"
22 #include "stack/btm/btm_sec_cb.h"
23 #include "stack/test/btm/btm_test_fixtures.h"
24 #include "test/mock/mock_main_shim_entry.h"
25
26 class StackBtmDevTest : public BtmWithMocksTest {
27 protected:
SetUp()28 void SetUp() override { BtmWithMocksTest::SetUp(); }
TearDown()29 void TearDown() override { BtmWithMocksTest::TearDown(); }
30 };
31
TEST_F(StackBtmDevTest,btm_sec_allocate_dev_rec__no_list)32 TEST_F(StackBtmDevTest, btm_sec_allocate_dev_rec__no_list) {
33 ASSERT_EQ(nullptr, btm_sec_allocate_dev_rec());
34 ::btm_sec_cb.Init(BTM_SEC_MODE_SC);
35 ::btm_sec_cb.Free();
36 ASSERT_EQ(nullptr, btm_sec_allocate_dev_rec());
37 }
38
TEST_F(StackBtmDevTest,btm_sec_allocate_dev_rec__with_list)39 TEST_F(StackBtmDevTest, btm_sec_allocate_dev_rec__with_list) {
40 ::btm_sec_cb.Init(BTM_SEC_MODE_SC);
41 ASSERT_NE(nullptr, btm_sec_allocate_dev_rec());
42 ::btm_sec_cb.Free();
43 }
44