1 /* 2 * Copyright (c) 2022 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "gtest/gtest.h" 17 18 #include "adapter_bt_utils.h" 19 20 // negative numbers to make sure it's illegal 21 #define ILLEGAL_OHOS_BT_STATUS (-1) 22 23 using namespace testing::ext; 24 25 namespace OHOS { 26 27 /** 28 * @tc.name: AdapterBtUtilsTest_ConvertStatus 29 * @tc.desc: test bt status convert to dsoftbu status 30 * @tc.type: FUNC 31 * @tc.require: 1 32 */ 33 HWTEST(AdapterBtUtilsTest, ConvertStatus, TestSize.Level3) 34 { 35 auto status = BleOhosStatusToSoftBus(OHOS_BT_STATUS_SUCCESS); 36 EXPECT_EQ(status, SOFTBUS_BT_STATUS_SUCCESS); 37 38 status = BleOhosStatusToSoftBus(OHOS_BT_STATUS_FAIL); 39 EXPECT_EQ(status, SOFTBUS_BT_STATUS_FAIL); 40 41 status = BleOhosStatusToSoftBus(OHOS_BT_STATUS_NOT_READY); 42 EXPECT_EQ(status, SOFTBUS_BT_STATUS_NOT_READY); 43 44 status = BleOhosStatusToSoftBus(OHOS_BT_STATUS_NOMEM); 45 EXPECT_EQ(status, SOFTBUS_BT_STATUS_NOMEM); 46 47 status = BleOhosStatusToSoftBus(OHOS_BT_STATUS_BUSY); 48 EXPECT_EQ(status, SOFTBUS_BT_STATUS_BUSY); 49 50 status = BleOhosStatusToSoftBus(OHOS_BT_STATUS_DONE); 51 EXPECT_EQ(status, SOFTBUS_BT_STATUS_DONE); 52 53 status = BleOhosStatusToSoftBus(OHOS_BT_STATUS_UNSUPPORTED); 54 EXPECT_EQ(status, SOFTBUS_BT_STATUS_UNSUPPORTED); 55 56 status = BleOhosStatusToSoftBus(OHOS_BT_STATUS_PARM_INVALID); 57 EXPECT_EQ(status, SOFTBUS_BT_STATUS_PARM_INVALID); 58 59 status = BleOhosStatusToSoftBus(OHOS_BT_STATUS_UNHANDLED); 60 EXPECT_EQ(status, SOFTBUS_BT_STATUS_UNHANDLED); 61 62 status = BleOhosStatusToSoftBus(OHOS_BT_STATUS_AUTH_FAILURE); 63 EXPECT_EQ(status, SOFTBUS_BT_STATUS_AUTH_FAILURE); 64 65 status = BleOhosStatusToSoftBus(OHOS_BT_STATUS_RMT_DEV_DOWN); 66 EXPECT_EQ(status, SOFTBUS_BT_STATUS_RMT_DEV_DOWN); 67 68 status = BleOhosStatusToSoftBus(OHOS_BT_STATUS_AUTH_REJECTED); 69 EXPECT_EQ(status, SOFTBUS_BT_STATUS_AUTH_REJECTED); 70 71 status = BleOhosStatusToSoftBus((BtStatus)ILLEGAL_OHOS_BT_STATUS); 72 EXPECT_EQ(status, SOFTBUS_BT_STATUS_FAIL); 73 } 74 75 } // namespace OHOS