1*84e33947SAndroid Build Coastguard Worker /*
2*84e33947SAndroid Build Coastguard Worker * Copyright (C) 2023 The Android Open Source Project
3*84e33947SAndroid Build Coastguard Worker *
4*84e33947SAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*84e33947SAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*84e33947SAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*84e33947SAndroid Build Coastguard Worker *
8*84e33947SAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
9*84e33947SAndroid Build Coastguard Worker *
10*84e33947SAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*84e33947SAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*84e33947SAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*84e33947SAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*84e33947SAndroid Build Coastguard Worker * limitations under the License.
15*84e33947SAndroid Build Coastguard Worker */
16*84e33947SAndroid Build Coastguard Worker
17*84e33947SAndroid Build Coastguard Worker #include "gtest/gtest.h"
18*84e33947SAndroid Build Coastguard Worker
19*84e33947SAndroid Build Coastguard Worker #include <string.h>
20*84e33947SAndroid Build Coastguard Worker
21*84e33947SAndroid Build Coastguard Worker #include "chre/util/system/ble_util.h"
22*84e33947SAndroid Build Coastguard Worker
TEST(BleUtil,PopulateTxPower)23*84e33947SAndroid Build Coastguard Worker TEST(BleUtil, PopulateTxPower) {
24*84e33947SAndroid Build Coastguard Worker chreBleAdvertisingReport report;
25*84e33947SAndroid Build Coastguard Worker memset(&report, 0, sizeof(report));
26*84e33947SAndroid Build Coastguard Worker report.txPower = CHRE_BLE_TX_POWER_NONE;
27*84e33947SAndroid Build Coastguard Worker report.eventTypeAndDataStatus = CHRE_BLE_EVENT_TYPE_FLAG_LEGACY;
28*84e33947SAndroid Build Coastguard Worker int8_t txPower = -11;
29*84e33947SAndroid Build Coastguard Worker uint8_t data[3] = {0x02, 0x0A, static_cast<uint8_t>(txPower)};
30*84e33947SAndroid Build Coastguard Worker report.data = data;
31*84e33947SAndroid Build Coastguard Worker report.dataLength = 3;
32*84e33947SAndroid Build Coastguard Worker chre::populateLegacyAdvertisingReportFields(report);
33*84e33947SAndroid Build Coastguard Worker EXPECT_EQ(report.txPower, txPower);
34*84e33947SAndroid Build Coastguard Worker }
35