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 "coauth_funcs.h" 19 20 extern "C" { 21 extern LinkedList *g_poolList; 22 extern ResultCode InitResourcePool(void); 23 } 24 25 namespace OHOS { 26 namespace UserIam { 27 namespace UserAuth { 28 using namespace testing; 29 using namespace testing::ext; 30 31 class CoAuthFuncsTest : 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(CoAuthFuncsTest, TestRegisterExecutor, TestSize.Level0) 43 { 44 EXPECT_EQ(RegisterExecutor(nullptr, nullptr), RESULT_BAD_PARAM); 45 g_poolList = nullptr; 46 ExecutorInfoHal info = {}; 47 uint64_t index = 0; 48 EXPECT_EQ(RegisterExecutor(&info, &index), RESULT_NEED_INIT); 49 } 50 51 HWTEST_F(CoAuthFuncsTest, TestUnregisterExecutorToPool, TestSize.Level0) 52 { 53 g_poolList = nullptr; 54 uint64_t index = 3226; 55 EXPECT_EQ(UnregisterExecutorToPool(index), RESULT_NEED_INIT); 56 InitResourcePool(); 57 ExecutorInfoHal info = {}; 58 info.authType = 1; 59 info.executorRole = VERIFIER; 60 EXPECT_EQ(RegisterExecutor(&info, &index), RESULT_SUCCESS); 61 EXPECT_EQ(UnregisterExecutorToPool(index), RESULT_SUCCESS); 62 } 63 } // namespace UserAuth 64 } // namespace UserIam 65 } // namespace OHOS 66