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, Hardware
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 "bundle_mgr_helper/vk_bundle_mgr_helper.h"
17
18 using namespace testing;
19 using namespace testing::ext;
20
21 namespace OHOS::Rosen {
22 class VkBundleMgrHelperTest : public testing::Test {
23 public:
SetUpTestCase()24 static void SetUpTestCase() {}
TearDownTestCase()25 static void TearDownTestCase() {}
SetUp()26 void SetUp() {}
TearDown()27 void TearDown() {}
28 };
29 /**
30 * @tc.name: Init001
31 * @tc.desc:
32 * @tc.type: FUNC
33 */
HWTEST_F(VkBundleMgrHelperTest, VkBundleMgrHelperTest, Level1)34 HWTEST_F(VkBundleMgrHelperTest, VkBundleMgrHelperTest, Level1)
35 {
36 AppExecFwk::BundleInfo bundleInfo;
37 auto vkBundleMgrHelper = DelayedSingleton<AppExecFwk::VKBundleMgrHelper>::GetInstance();
38 auto result = vkBundleMgrHelper->GetBundleInfoForSelf(
39 AppExecFwk::GetBundleInfoFlag::GET_BUNDLE_INFO_WITH_APPLICATION, bundleInfo);
40 EXPECT_NE(result, ERR_OK);
41
42 bool ret = InitBundleInfo(NULL);
43 EXPECT_EQ(ret, false);
44
45 string name = "\0";
46 ret = InitBundleInfo(const_cast<char*>(name.c_str()));
47 EXPECT_EQ(ret, false);
48
49 string fatalName = "randomFatalName";
50 ret = InitBundleInfo(const_cast<char*>(fatalName.c_str()));
51 EXPECT_EQ(ret, false);
52
53 ret = InitBundleInfo((const_cast<char*>(bundleInfo.name.c_str())));
54 EXPECT_EQ(ret, false);
55
56 char* path = GetDebugLayerLibPath();
57 EXPECT_NE(path, nullptr);
58 free(path);
59 }
60 }