1 /*
2 * Copyright (c) 2023 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 #include <gtest/gtest.h>
16 #include <thread>
17
18 #include "ndef_bt_data_parser.h"
19
20 namespace OHOS {
21 namespace NFC {
22 namespace TAG {
23 namespace TEST {
24 using namespace testing::ext;
25 using namespace OHOS::NFC;
26 class NdefBtDataParserTest : public testing::Test {
27 public:
28 static void SetUpTestCase();
29 static void TearDownTestCase();
30 void SetUp();
31 void TearDown();
32 };
33
SetUpTestCase()34 void NdefBtDataParserTest::SetUpTestCase()
35 {
36 std::cout << " SetUpTestCase NdefBtDataParserTest." << std::endl;
37 }
38
TearDownTestCase()39 void NdefBtDataParserTest::TearDownTestCase()
40 {
41 std::cout << " TearDownTestCase NdefBtDataParserTest." << std::endl;
42 }
43
SetUp()44 void NdefBtDataParserTest::SetUp()
45 {
46 std::cout << " SetUp NdefBtDataParserTest." << std::endl;
47 }
48
TearDown()49 void NdefBtDataParserTest::TearDown()
50 {
51 std::cout << " TearDown NdefBtDataParserTest." << std::endl;
52 }
53
54 /**
55 * @tc.name: CheckBtRecord001
56 * @tc.desc: Test NdefBtDataParserTest CheckBtRecord.
57 * @tc.type: FUNC
58 */
59 HWTEST_F(NdefBtDataParserTest, CheckBtRecord001, TestSize.Level1)
60 {
61 std::string msg = "";
62 std::shared_ptr<NdefBtDataParser> ndefBtDataParser = std::make_shared<NdefBtDataParser>();
63 std::shared_ptr<BtData> btData = ndefBtDataParser->CheckBtRecord(msg);
64 ASSERT_TRUE(btData != nullptr);
65 }
66
67 /**
68 * @tc.name: CheckBtRecord002
69 * @tc.desc: Test NdefBtDataParserTest CheckBtRecord.
70 * @tc.type: FUNC
71 */
72 HWTEST_F(NdefBtDataParserTest, CheckBtRecord002, TestSize.Level1)
73 {
74 std::string msg = "CheckBtRecord";
75 std::shared_ptr<NdefBtDataParser> ndefBtDataParser = std::make_shared<NdefBtDataParser>();
76 std::shared_ptr<BtData> btData = ndefBtDataParser->CheckBtRecord(msg);
77 ASSERT_TRUE(btData != nullptr);
78 }
79
80 /**
81 * @tc.name: CheckBtRecord003
82 * @tc.desc: Test NdefBtDataParserTest CheckBtRecord.
83 * @tc.type: FUNC
84 */
85 HWTEST_F(NdefBtDataParserTest, CheckBtRecord003, TestSize.Level1)
86 {
87 std::string msg = "D220566170706C69636174696F6E2F766E642E626C7565746F6F74682E65"
88 "702E6F6F625600BE17010E7F04050949435341040D14042C0B030B110C11"
89 "0E111E11001236FF027D0320010240005A45303031810800113000190103"
90 "021901010101020306047F0E0117BE020E52726364687A5238363739393532";
91 std::shared_ptr<NdefBtDataParser> ndefBtDataParser = std::make_shared<NdefBtDataParser>();
92 std::shared_ptr<BtData> btData = ndefBtDataParser->CheckBtRecord(msg);
93 ASSERT_TRUE(btData != nullptr);
94 }
95 } // namespace TEST
96 } // namespace TAG
97 } // namespace NFC
98 } // namespace OHOS