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 "query_app_info_callback_stub.h" 19 20 namespace OHOS { 21 namespace NFC { 22 namespace TEST { 23 using namespace testing::ext; 24 using namespace OHOS::NFC; 25 class QueryAppInfoCallbackStubTest : public testing::Test { 26 public: 27 static void SetUpTestCase(); 28 static void TearDownTestCase(); 29 void SetUp(); 30 void TearDown(); 31 }; 32 SetUpTestCase()33 void QueryAppInfoCallbackStubTest::SetUpTestCase() 34 { 35 std::cout << " SetUpTestCase QueryAppInfoCallbackStubTest." << std::endl; 36 } 37 TearDownTestCase()38 void QueryAppInfoCallbackStubTest::TearDownTestCase() 39 { 40 std::cout << " TearDownTestCase QueryAppInfoCallbackStubTest." << std::endl; 41 } 42 SetUp()43 void QueryAppInfoCallbackStubTest::SetUp() 44 { 45 std::cout << " SetUp QueryAppInfoCallbackStubTest." << std::endl; 46 } 47 TearDown()48 void QueryAppInfoCallbackStubTest::TearDown() 49 { 50 std::cout << " TearDown QueryAppInfoCallbackStubTest." << std::endl; 51 } 52 53 #ifdef VENDOR_APPLICATIONS_ENABLED 54 /** 55 * @tc.name: OnRemoteRequest001 56 * @tc.desc: Test QueryAppInfoCallbackStubTest OnRemoteRequest. 57 * @tc.type: FUNC 58 */ 59 HWTEST_F(QueryAppInfoCallbackStubTest, OnRemoteRequest001, TestSize.Level1) 60 { 61 uint32_t code = 0; 62 MessageParcel data; 63 MessageParcel reply; 64 MessageOption option; 65 std::shared_ptr<QueryAppInfoCallbackStub> queryAppInfoCallbackStub = std::make_shared<QueryAppInfoCallbackStub>(); 66 int onRemoteRequest = queryAppInfoCallbackStub->OnRemoteRequest(code, data, reply, option); 67 ASSERT_TRUE(onRemoteRequest == KITS::ERR_NFC_PARAMETERS); 68 } 69 70 /** 71 * @tc.name: RegisterQueryTagAppCallback001 72 * @tc.desc: Test QueryAppInfoCallbackStubTest RegisterQueryTagAppCallback. 73 * @tc.type: FUNC 74 */ 75 HWTEST_F(QueryAppInfoCallbackStubTest, RegisterQueryTagAppCallback001, TestSize.Level1) 76 { 77 QueryApplicationByVendor tagCallback = nullptr; 78 std::shared_ptr<QueryAppInfoCallbackStub> queryAppInfoCallbackStub = std::make_shared<QueryAppInfoCallbackStub>(); 79 KITS::ErrorCode ret = queryAppInfoCallbackStub->RegisterQueryTagAppCallback(tagCallback); 80 ASSERT_TRUE(ret == KITS::ERR_NFC_PARAMETERS); 81 } 82 83 /** 84 * @tc.name: RegisterQueryHceAppCallback001 85 * @tc.desc: Test QueryAppInfoCallbackStubTest RegisterQueryHceAppCallback. 86 * @tc.type: FUNC 87 */ 88 HWTEST_F(QueryAppInfoCallbackStubTest, RegisterQueryHceAppCallback001, TestSize.Level1) 89 { 90 QueryHceAppByVendor hceCallback = nullptr; 91 std::shared_ptr<QueryAppInfoCallbackStub> queryAppInfoCallbackStub = std::make_shared<QueryAppInfoCallbackStub>(); 92 KITS::ErrorCode ret = queryAppInfoCallbackStub->RegisterQueryHceAppCallback(hceCallback); 93 ASSERT_TRUE(ret == KITS::ERR_NFC_PARAMETERS); 94 } 95 #endif 96 } 97 } 98 }