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 "hce_cmd_callback_stub.h"
19 #include "nfc_sdk_common.h"
20 #include "nfc_service_ipc_interface_code.h"
21
22 namespace OHOS {
23 namespace NFC {
24 namespace TEST {
25 using namespace testing::ext;
26 using namespace OHOS::NFC::KITS;
27 class HceCmdCallbackStubTest : public testing::Test {
28 public:
29 static void SetUpTestCase();
30 static void TearDownTestCase();
31 void SetUp();
32 void TearDown();
33 };
34
SetUpTestCase()35 void HceCmdCallbackStubTest::SetUpTestCase()
36 {
37 std::cout << " SetUpTestCase HceCmdCallbackStubTest." << std::endl;
38 }
39
TearDownTestCase()40 void HceCmdCallbackStubTest::TearDownTestCase()
41 {
42 std::cout << " TearDownTestCase HceCmdCallbackStubTest." << std::endl;
43 }
44
SetUp()45 void HceCmdCallbackStubTest::SetUp()
46 {
47 std::cout << " SetUp HceCmdCallbackStubTest." << std::endl;
48 }
49
TearDown()50 void HceCmdCallbackStubTest::TearDown()
51 {
52 std::cout << " TearDown HceCmdCallbackStubTest." << std::endl;
53 }
54
55 /**
56 * @tc.name: RegHceCmdCallback001
57 * @tc.desc: Test HceCmdCallbackStubTest RegHceCmdCallback.
58 * @tc.type: FUNC
59 */
60 HWTEST_F(HceCmdCallbackStubTest, RegHceCmdCallback001, TestSize.Level1)
61 {
62 const sptr<IHceCmdCallback> callback = nullptr;
63 std::string type = "";
64 HCE::HceCmdCallbackStub& hceCmdCallbackStub = HCE::HceCmdCallbackStub::GetInstance();
65 KITS::ErrorCode regHceCmdCallback = hceCmdCallbackStub.RegHceCmdCallback(callback, type);
66 ASSERT_TRUE(regHceCmdCallback == KITS::ERR_NFC_PARAMETERS);
67 }
68
69 /**
70 * @tc.name: OnRemoteRequest001
71 * @tc.desc: Test HceCmdCallbackStubTest OnRemoteRequest.
72 * @tc.type: FUNC
73 */
74 HWTEST_F(HceCmdCallbackStubTest, OnRemoteRequest001, TestSize.Level1)
75 {
76 uint32_t code = static_cast<uint32_t>(NfcServiceIpcInterfaceCode::COMMAND_ON_NOTIFY);
77 MessageParcel data;
78 MessageParcel reply;
79 MessageOption option;
80 HCE::HceCmdCallbackStub& hceCmdCallbackStub = HCE::HceCmdCallbackStub::GetInstance();
81 int onRemoteRequest = hceCmdCallbackStub.OnRemoteRequest(code, data, reply, option);
82 ASSERT_TRUE(onRemoteRequest == ERR_NFC_PARAMETERS);
83 }
84 }
85 }
86 }