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 "ohos_bt_gatt_client.h"
19
20 using namespace testing::ext;
21
22 namespace OHOS {
23 namespace Bluetooth {
24 class GattClientCTest : public testing::Test {
25 public:
26 static void SetUpTestCase(void);
27 static void TearDownTestCase(void);
28 void SetUp();
29 void TearDown();
30 };
31
32 static constexpr int BT_UUID_LEN = 2;
33 static constexpr int BT_UUID_1ST = 0xEE;
34 static constexpr int BT_UUID_2ND = 0xFD;
35
SetUpTestCase(void)36 void GattClientCTest::SetUpTestCase(void) {}
37
TearDownTestCase(void)38 void GattClientCTest::TearDownTestCase(void) {}
39
SetUp()40 void GattClientCTest::SetUp() {}
41
TearDown()42 void GattClientCTest::TearDown() {}
43
44 /*
45 * @tc.name: GattClientCTest_001
46 * @tc.desc: Test BleGattcSetPriority when clientId is not found
47 * @tc.type: FUNC
48 * @tc.require: issueI5V7QF
49 */
50 HWTEST_F(GattClientCTest, GattClientCTest_001, TestSize.Level1)
51 {
52 int clientId = 0;
53 BdAddr bdAddr;
54 BtGattPriority priority = OHOS_BT_GATT_PRIORITY_BALANCED;
55 int res = BleGattcSetPriority(clientId, &bdAddr, priority);
56 EXPECT_EQ(res, OHOS_BT_STATUS_FAIL);
57 }
58
59 /*
60 * @tc.name: GattClientCTest_002
61 * @tc.desc: Test BleGattcSetPriority after register GATT client with a specified application UUID
62 * @tc.type: FUNC
63 * @tc.require: issueI5V7QF
64 */
65 HWTEST_F(GattClientCTest, GattClientCTest_002, TestSize.Level1)
66 {
67 BtUuid appId;
68 char uuid[BT_UUID_LEN] = { BT_UUID_1ST, BT_UUID_2ND };
69 appId.uuidLen = BT_UUID_LEN;
70 appId.uuid = uuid;
71 int clientId = BleGattcRegister(appId);
72 BdAddr bdAddr;
73 BtGattPriority priority = OHOS_BT_GATT_PRIORITY_BALANCED;
74 int res = BleGattcSetPriority(clientId, &bdAddr, priority);
75 EXPECT_EQ(res, OHOS_BT_STATUS_FAIL);
76 BleGattcUnRegister(clientId);
77 }
78 } // namespace Bluetooth
79 } // namespace OHOS
80