• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024-2025 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 <dlfcn.h>
17 #include <gtest/gtest.h>
18 #include "photo_editor_extension_module_loader.h"
19 #include "runtime.h"
20 
21 namespace OHOS {
22 namespace AbilityRuntime {
23 using namespace testing::ext;
24 
25 class PhotoEditorExtensionModuleLoaderTest : public testing::Test {
26 public:
27     static void SetUpTestCase(void);
28     static void TearDownTestCase(void);
29     void SetUp();
30     void TearDown();
31 };
32 
SetUpTestCase(void)33 void PhotoEditorExtensionModuleLoaderTest::SetUpTestCase(void)
34 {}
35 
TearDownTestCase(void)36 void PhotoEditorExtensionModuleLoaderTest::TearDownTestCase(void)
37 {}
38 
SetUp(void)39 void PhotoEditorExtensionModuleLoaderTest::SetUp(void)
40 {}
41 
TearDown(void)42 void PhotoEditorExtensionModuleLoaderTest::TearDown(void)
43 {}
44 
45 /**
46  * @tc.number: PhotoEditorExtensionModuleLoader_0100
47  * @tc.name: OHOS_EXTENSION_GetExtensionModule
48  * @tc.desc: Verify OHOS_EXTENSION_GetExtensionModule succeeded.
49  */
50 HWTEST_F(PhotoEditorExtensionModuleLoaderTest, PhotoEditorExtensionModuleLoader_0100, Function | MediumTest | Level1)
51 {
52     GTEST_LOG_(INFO) << "PhotoEditorExtensionModuleLoader_0100 start";
53     std::unique_ptr<Runtime> runtime;
54     auto extension = PhotoEditorExtensionModuleLoader::GetInstance().Create(runtime);
55     void *handle = dlopen("/system/lib/extensionability/libphoto_editor_extension_module.z.so", RTLD_LAZY);
56     dlclose(handle);
57     EXPECT_TRUE(extension != nullptr);
58     GTEST_LOG_(INFO) << "PhotoEditorExtensionModuleLoader_0100 end";
59 }
60 
61 /**
62  * @tc.number: PhotoEditorExtensionModuleLoader_0200
63  * @tc.name: Create
64  * @tc.desc: Verify Create succeeded.
65  */
66 HWTEST_F(PhotoEditorExtensionModuleLoaderTest, PhotoEditorExtensionModuleLoader_0200, Function | MediumTest | Level1)
67 {
68     GTEST_LOG_(INFO) << "PhotoEditorExtensionModuleLoader_0200 start";
69     std::unique_ptr<Runtime> runtime;
70     auto extension = PhotoEditorExtensionModuleLoader::GetInstance().Create(runtime);
71     EXPECT_TRUE(extension != nullptr);
72     GTEST_LOG_(INFO) << "PhotoEditorExtensionModuleLoader_0200 end";
73 }
74 
75 /**
76  * @tc.number: PhotoEditorExtensionModuleLoader_0300
77  * @tc.name: GetParams
78  * @tc.desc: Verify GetParams succeeded.
79  */
80 HWTEST_F(PhotoEditorExtensionModuleLoaderTest, PhotoEditorExtensionModuleLoader_0300, Function | MediumTest | Level1)
81 {
82     GTEST_LOG_(INFO) << "PhotoEditorExtensionModuleLoader_0300 start";
83     auto params = PhotoEditorExtensionModuleLoader::GetInstance().GetParams();
84 
85     std::string key = "type";
86     auto finder = params.find(key);
87     if (finder != params.end()) {
88         EXPECT_STREQ(finder->second.c_str(), "23");
89     }
90 
91     key = "name";
92     auto iter = params.find(key);
93     if (iter != params.end()) {
94         EXPECT_STREQ(iter->second.c_str(), "PhotoEditorExtensionAbility");
95     }
96     GTEST_LOG_(INFO) << "PhotoEditorExtensionModuleLoader_0300 end";
97 }
98 } // namespace AbilityRuntime
99 } // namespace OHOS
100