1 /* 2 * Copyright (c) 2024 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 "cj_ability_context_object.h" 19 20 using namespace testing; 21 using namespace testing::ext; 22 23 namespace OHOS { 24 namespace AbilityRuntime { 25 class CjAbilityContextProxyTest : public testing::Test { 26 }; 27 28 int g_result = 0; 29 30 HWTEST_F(CjAbilityContextProxyTest, RegisterCJAbilityCallbacks_0100, TestSize.Level1) 31 { 32 RegisterCJAbilityCallbacks(nullptr); 33 void (*registerFunc)(CJAbilityCallbacks*) = [](CJAbilityCallbacks* cjAbilityCallbacks) __anon017054080102(CJAbilityCallbacks* cjAbilityCallbacks) 34 { 35 if (cjAbilityCallbacks != nullptr) g_result += 1; 36 cjAbilityCallbacks->invokeAbilityResultCallback = [](int64_t id, int32_t error, 37 CJAbilityResult* cjAbilityResult) {}; 38 cjAbilityCallbacks->invokePermissionRequestResultCallback = 39 [](int64_t id, int32_t error, CJPermissionRequestResult* cjPermissionRequestResult) {}; 40 cjAbilityCallbacks->invokeDialogRequestResultCallback = [](int64_t id, int32_t error, 41 CJDialogRequestResult* cjDialogRequestResult) {}; 42 }; 43 RegisterCJAbilityCallbacks(registerFunc); 44 RegisterCJAbilityCallbacks(registerFunc); 45 EXPECT_EQ(g_result, 1); 46 } 47 } 48 }