1 /* 2 * Copyright (c) 2022 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 16 #include <gtest/gtest.h> 17 18 #include "identify_funcs.h" 19 20 extern "C" { 21 extern LinkedList *g_contextList; 22 extern void DestroyContextNode(void *data); 23 } 24 25 namespace OHOS { 26 namespace UserIam { 27 namespace UserAuth { 28 using namespace testing; 29 using namespace testing::ext; 30 31 class IdentifyFuncsTest : public testing::Test { 32 public: SetUpTestCase()33 static void SetUpTestCase() {}; 34 TearDownTestCase()35 static void TearDownTestCase() {}; 36 SetUp()37 void SetUp() {}; 38 TearDown()39 void TearDown() {}; 40 }; 41 42 HWTEST_F(IdentifyFuncsTest, TestDoIdentify, TestSize.Level0) 43 { 44 IdentifyParam param = {}; 45 EXPECT_EQ(DoIdentify(param, nullptr), RESULT_BAD_PARAM); 46 } 47 48 HWTEST_F(IdentifyFuncsTest, TestDoUpdateIdentify_001, TestSize.Level0) 49 { 50 uint64_t contextId = 1235; 51 EXPECT_EQ(DoUpdateIdentify(contextId, nullptr, nullptr, nullptr, nullptr), RESULT_BAD_PARAM); 52 } 53 54 HWTEST_F(IdentifyFuncsTest, TestDoUpdateIdentify_002, TestSize.Level0) 55 { 56 uint64_t contextId = 1235; 57 Buffer *scheduleResult = CreateBufferBySize(10); 58 int32_t userId = 32156; 59 UserAuthTokenHal token = {}; 60 int32_t result = 0; 61 g_contextList = CreateLinkedList(DestroyContextNode); 62 EXPECT_NE(g_contextList, nullptr); 63 UserAuthContext context = {}; 64 context.contextId = contextId; 65 g_contextList->insert(g_contextList, static_cast<void *>(&context)); 66 EXPECT_EQ(DoUpdateIdentify(contextId, scheduleResult, &userId, &token, &result), RESULT_GENERAL_ERROR); 67 } 68 } // namespace UserAuth 69 } // namespace UserIam 70 } // namespace OHOS 71