1/**
2 * Copyright (c) 2024-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
16import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'
17import abilityDelegatorRegistry from '@ohos.app.ability.abilityDelegatorRegistry';
18import HiSysEventConstant from '../../../../main/ets/common/constants/HiSysEventConstant';
19import getSelfBundleInfoUtils from '../../../../main/ets/common/utils/GetSelfBundleInfoUtils';
20import HiSysEventUtil from '../../../../main/ets/common/utils/HiSysEventUtil';
21import { RawFileUtil } from '../../../../main/ets/common/utils/RawFileUtil';
22import ResourceUtil from '../../../../main/ets/common/utils/ResourceUtil';
23import { StringUtil } from '../../../../main/ets/common/utils/StringUtil';
24import Logger from '../../../../main/ets/common/utils/Logger';
25import Constants from '../../../../main/ets/common/constants/ComConstant';
26import DataShareConstants from '../../../../main/ets/common/constants/DataShareConstant';
27import RouterConstant from '../../../../main/ets/common/constants/RouterConstant';
28
29export default function BundleInfoBeanTest() {
30  describe('CommonTest', () => {
31    // Defines a test suite. Two parameters are supported: test suite name and test suite function.
32    beforeAll(() => {
33      // Presets an action, which is performed only once before all test cases of the test suite start.
34      // This API supports only one parameter: preset action function.
35    })
36    beforeEach(() => {
37      // Presets an action, which is performed before each unit test case starts.
38      // The number of execution times is the same as the number of test cases defined by **it**.
39      // This API supports only one parameter: preset action function.
40    })
41    afterEach(() => {
42      // Presets a clear action, which is performed after each unit test case ends.
43      // The number of execution times is the same as the number of test cases defined by **it**.
44      // This API supports only one parameter: clear action function.
45    })
46    afterAll(() => {
47      // Presets a clear action, which is performed after all test cases of the test suite end.
48      // This API supports only one parameter: clear action function.
49    })
50    it('getSelfBundleInfoUtilsTest', 0, () => {
51      getSelfBundleInfoUtils.getVersionName()
52    })
53    it('HiSysEventUtilTest', 0, () => {
54      HiSysEventUtil.reportAccessClick('com.example.test');
55      HiSysEventUtil.reportLocationClick('LOCATION');
56      HiSysEventUtil.reportLocationFlagClick(1);
57      HiSysEventUtil.reportLocationFlagClick(0);
58      let eventParams: Record<string, string> = {
59        "PERMISSION_GROUP": 'ohos.permission.Location'
60      }
61      HiSysEventUtil.reportClick(HiSysEventConstant.PERMISSION_PAGE_LOCATION_EVENT_NAME, eventParams)
62
63    })
64    it('RawfileUtilTest', 0, () => {
65      RawFileUtil.getStringByFile(abilityDelegatorRegistry.getAbilityDelegator()
66        .getAppContext()
67        .resourceManager, 'test')
68      RawFileUtil.getRawFileByContext(getContext(), 'test')
69    })
70    it('ResourceUtilTest', 0, () => {
71      ResourceUtil.getResourceString(abilityDelegatorRegistry.getAbilityDelegator()
72        .getAppContext(), $r('app.media.ic_back'))
73      ResourceUtil.getBundleResourceManager('', abilityDelegatorRegistry.getAbilityDelegator().getAppContext())
74      expect(ResourceUtil.getBundleResourceManager('', null)).assertNull()
75      ResourceUtil.getBundleResourceManager('com.ohos.certmanager', abilityDelegatorRegistry.getAbilityDelegator()
76        .getAppContext())
77    })
78    it('StringUtilTest', 0, () => {
79      StringUtil.isEmpty('')
80      StringUtil.isEmpty('111')
81      StringUtil.isNotEmpty('')
82      StringUtil.isNotEmpty('111')
83    })
84    it('LoggerTest', 0, () => {
85      Logger.info('LOGGER_TEST', 'logger info test')
86      Logger.debug('LOGGER_TEST', 'logger debug test')
87      Logger.warn('LOGGER_TEST', 'logger warn test')
88      Logger.error('LOGGER_TEST', 'logger error test')
89    })
90    it('ConstantsTest', 0, () => {
91      expect(Constants.TITLE_BAR_HEIGHT).assertEqual(56)
92      expect(DataShareConstants.STORE_CONFIG.name).assertEqual('access.db')
93      expect(HiSysEventConstant.BUNDLE_NAME).assertEqual('com.ohos.certmanager')
94      expect(RouterConstant.INDEX_URL).assertEqual('pages/Index')
95    })
96
97  })
98}