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