• 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 "nfc_service.h"
19 #include <unistd.h>
20 #include "app_data_parser.h"
21 #include "common_event_handler.h"
22 #include "loghelper.h"
23 #include "nfc_controller.h"
24 #include "nfc_polling_params.h"
25 #include "nfc_sdk_common.h"
26 #include "nfc_watch_dog.h"
27 #include "nfcc_host.h"
28 #include "want.h"
29 #include "utils/preferences/nfc_pref_impl.h"
30 #include "tag_session.h"
31 
32 namespace OHOS {
33 namespace NFC {
34 namespace TEST {
35 using namespace testing::ext;
36 using namespace OHOS::NFC;
37 class NfcServiceTest : public testing::Test {
38 public:
39     static void SetUpTestCase();
40     static void TearDownTestCase();
41     void SetUp();
42     void TearDown();
43 };
44 
SetUpTestCase()45 void NfcServiceTest::SetUpTestCase()
46 {
47     std::cout << " SetUpTestCase NfcServiceTest." << std::endl;
48 }
49 
TearDownTestCase()50 void NfcServiceTest::TearDownTestCase()
51 {
52     std::cout << " TearDownTestCase NfcServiceTest." << std::endl;
53 }
54 
SetUp()55 void NfcServiceTest::SetUp()
56 {
57     std::cout << " SetUp NfcServiceTest." << std::endl;
58 }
59 
TearDown()60 void NfcServiceTest::TearDown()
61 {
62     std::cout << " TearDown NfcServiceTest." << std::endl;
63 }
64 
65 /**
66  * @tc.name: IsForegroundEnabled001
67  * @tc.desc: Test NfcService IsForegroundEnabled.
68  * @tc.type: FUNC
69  */
70 HWTEST_F(NfcServiceTest, IsForegroundEnabled001, TestSize.Level1)
71 {
72     std::shared_ptr<NFC::NfcService> nfcService = std::make_shared<NFC::NfcService>();
73     bool enable = nfcService->IsForegroundEnabled();
74     ASSERT_TRUE(enable == false);
75 }
76 /**
77  * @tc.name: DisableForegroundByDeathRcpt001
78  * @tc.desc: Test NfcService DisableForegroundByDeathRcpt.
79  * @tc.type: FUNC
80  */
81 HWTEST_F(NfcServiceTest, DisableForegroundByDeathRcpt001, TestSize.Level1)
82 {
83     std::shared_ptr<NFC::NfcService> nfcService = std::make_shared<NFC::NfcService>();
84     bool disable = nfcService->DisableForegroundByDeathRcpt();
85     ASSERT_TRUE(disable == true);
86 }
87 /**
88  * @tc.name: DisableForegroundDispatch001
89  * @tc.desc: Test NfcService DisableForegroundDispatch.
90  * @tc.type: FUNC
91  */
92 HWTEST_F(NfcServiceTest, DisableForegroundDispatch001, TestSize.Level1)
93 {
94     AppExecFwk::ElementName element;
95     std::shared_ptr<NFC::NfcService> nfcService = std::make_shared<NFC::NfcService>();
96     bool disable = nfcService->DisableForegroundDispatch(element);
97     ASSERT_TRUE(disable == true);
98 }
99 /**
100  * @tc.name: EnableForegroundDispatch001
101  * @tc.desc: Test NfcService EnableForegroundDispatch.
102  * @tc.type: FUNC
103  */
104 HWTEST_F(NfcServiceTest, EnableForegroundDispatch001, TestSize.Level1)
105 {
106     AppExecFwk::ElementName element;
107     std::vector<uint32_t> discTech = {1, 2, 4, 5, 10};
108     const sptr<KITS::IForegroundCallback> callback = nullptr;
109     std::shared_ptr<NFC::NfcService> nfcService = std::make_shared<NFC::NfcService>();
110     bool enable = nfcService->EnableForegroundDispatch(element, discTech, callback);
111     ASSERT_TRUE(enable == false);
112 }
113 }
114 }
115 }