• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "app_data_parser.h"
19 
20 namespace OHOS {
21 namespace NFC {
22 namespace TEST {
23 using namespace testing::ext;
24 using namespace OHOS::NFC;
25 const std::string ACTION_TAG_FOUND = "ohos.nfc.tag.action.TAG_FOUND";
26 const std::string ACTION_HOST_APDU_SERVICE = "ohos.nfc.cardemulation.action.HOST_APDU_SERVICE";
27 class AppDataParserTest : public testing::Test {
28 public:
29     static void SetUpTestCase();
30     static void TearDownTestCase();
31     void SetUp();
32     void TearDown();
33 public:
34     static constexpr const auto TECH_MASK = 4;
35 };
36 
SetUpTestCase()37 void AppDataParserTest::SetUpTestCase()
38 {
39     std::cout << " SetUpTestCase AppDataParserTest." << std::endl;
40 }
41 
TearDownTestCase()42 void AppDataParserTest::TearDownTestCase()
43 {
44     std::cout << " TearDownTestCase AppDataParserTest." << std::endl;
45 }
46 
SetUp()47 void AppDataParserTest::SetUp()
48 {
49     std::cout << " SetUp AppDataParserTest." << std::endl;
50 }
51 
TearDown()52 void AppDataParserTest::TearDown()
53 {
54     std::cout << " TearDown AppDataParserTest." << std::endl;
55 }
56 
57 /**
58  * @tc.name: GetTechMask001
59  * @tc.desc: Test AppDataParser GetTechMask.
60  * @tc.type: FUNC
61  */
62 HWTEST_F(AppDataParserTest, GetTechMask001, TestSize.Level1)
63 {
64     AppDataParser parser = AppDataParser::GetInstance();
65     parser.HandleAppAddOrChangedEvent(nullptr);
66 
67     parser.HandleAppRemovedEvent(nullptr);
68 
69     parser.InitAppList();
70 
71     // no given tag technologies
72     std::vector<int> discTechList;
73     ASSERT_TRUE(parser.GetDispatchTagAppsByTech(discTechList).size() == 0);
74 
75     // no app installed, or has app installed to matched with the given tag technologies.
76     discTechList.push_back(static_cast<int>(KITS::TagTechnology::NFC_A_TECH));
77     discTechList.push_back(static_cast<int>(KITS::TagTechnology::NFC_ISODEP_TECH));
78     ASSERT_TRUE(parser.GetDispatchTagAppsByTech(discTechList).size() >= 0);
79 }
80 
81 }
82 }
83 }