diff --git a/.gitignore b/.gitignore index 8ebb4d40184ac48b0a50751ce3eb2921434bf1c5..eba8eebed6050ba610cf9a84eaf8ebbaf8999c55 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ **/build /.hvigor /oh_modules -/dependencies \ No newline at end of file +/dependencies +.clang-format \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/Ability.test.ets b/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a8ff110e5899c2d1727217919dd5badeacdfe061 --- /dev/null +++ b/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/List.test.ets b/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..8a041d16e9faa594cf6287b2a3a9a32215c0a9fe --- /dev/null +++ b/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,22 @@ +import indexTest from './index.test' +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); + indexTest() +} \ No newline at end of file diff --git a/entry/src/ohosTest/ets/test/index.test.ets b/entry/src/ohosTest/ets/test/index.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..024f225be3d56fefe59ad773dc4832157b2d8742 --- /dev/null +++ b/entry/src/ohosTest/ets/test/index.test.ets @@ -0,0 +1,31 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' + +export default function indexTest() { + describe('indexTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertEqual', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + let a = 'test' + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertEqual('test') + }) + }) +} \ No newline at end of file diff --git a/entry/src/ohosTest/module.json5 b/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..944ed99859bbc89eac2d57af2b3600881bb5a47c --- /dev/null +++ b/entry/src/ohosTest/module.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/hvigor/hvigor-config.json5 b/hvigor/hvigor-config.json5 index 4cbdf166749f9998ee13039dc7a13146be637ac3..8610f2b61e2051457a0a655b1a7beea381c626fd 100644 --- a/hvigor/hvigor-config.json5 +++ b/hvigor/hvigor-config.json5 @@ -15,7 +15,9 @@ { "hvigorVersion": "3.0.2", +// "modelVersion": "5.0.0", //本地IDE配置 "dependencies": { "@ohos/hvigor-ohos-plugin": "3.0.2" +// "@ohos/hvigor-ohos-plugin": "5.8.5" //本地IDE配置 } } diff --git a/oh-package-lock.json5 b/oh-package-lock.json5 index 17c8ea40dc14edee6c878d015f0372d4d79a0410..04107a17d23bcbaacf6cc4c790f67fdbd6f71c33 100644 --- a/oh-package-lock.json5 +++ b/oh-package-lock.json5 @@ -14,15 +14,22 @@ */ { - "lockfileVersion": 1, + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", "specifiers": { "@ohos/hypium@1.0.6": "@ohos/hypium@1.0.6" }, "packages": { "@ohos/hypium@1.0.6": { + "name": "@ohos/hypium", + "version": "1.0.6", + "integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==", "resolved": "https://repo.harmonyos.com/ohpm/@ohos/hypium/-/hypium-1.0.6.tgz", - "integrity": "sha512-bb3DWeWhYrFqj9mPFV3yZQpkm36kbcK+YYaeY9g292QKSjOdmhEIQR2ULPvyMsgSR4usOBf5nnYrDmaCCXirgQ==" + "shasum": "3f5fed65372633233264b3447705b0831dfe7ea1", + "registryType": "ohpm" } } } \ No newline at end of file diff --git a/oh-package.json5 b/oh-package.json5 index 756269cb19f15df976bb0699baffc4a8886d7262..a7fa44630f91c99b2a12a1acdd727cda3599bd28 100644 --- a/oh-package.json5 +++ b/oh-package.json5 @@ -14,6 +14,7 @@ */ { + "modelVersion": "5.0.0", "license": "ISC", "devDependencies": { "@ohos/hypium": "1.0.6" diff --git a/permissionmanager/.gitignore b/permissionmanager/.gitignore index 4f9a973815d0b5e49bc8547681a6b4bc7a178d12..23f4a26353f81f3b813f0e82c93c5685ba2d2cc4 100644 --- a/permissionmanager/.gitignore +++ b/permissionmanager/.gitignore @@ -1,3 +1,4 @@ /node_modules /.preview -/build \ No newline at end of file +/build +/.test \ No newline at end of file diff --git a/permissionmanager/src/main/module.json b/permissionmanager/src/main/module.json index c89e9e7bbcd993f96c069f98db1f8e6a58f780ba..b7dc81a6a05083cacd1a679224b400c17ef01959 100644 --- a/permissionmanager/src/main/module.json +++ b/permissionmanager/src/main/module.json @@ -103,7 +103,9 @@ "name": "ohos.permission.PERMISSION_USED_STATS" }, { - "name": "ohos.permission.GET_INSTALLED_BUNDLE_LIST" + "name": "ohos.permission.GET_INSTALLED_BUNDLE_LIST", + "reason": "$string:allow", + "usedScene": {} }, { "name": "ohos.permission.LISTEN_BUNDLE_CHANGE" diff --git a/permissionmanager/src/main/module.json5 b/permissionmanager/src/main/module.json5 index 6c52a168f59ccc0d27ef4f01e4a6a0535305f281..7665e0fe5c1b35ec0c8ab3a563dee160faabd006 100644 --- a/permissionmanager/src/main/module.json5 +++ b/permissionmanager/src/main/module.json5 @@ -115,7 +115,9 @@ "name": "ohos.permission.PERMISSION_USED_STATS" }, { - "name": "ohos.permission.GET_INSTALLED_BUNDLE_LIST" + "name": "ohos.permission.GET_INSTALLED_BUNDLE_LIST", + "reason": "$string:allow", + "usedScene": {} }, { "name": "ohos.permission.LISTEN_BUNDLE_CHANGE" diff --git a/permissionmanager/src/ohosTest/ets/test/Ability.test.ets b/permissionmanager/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a8ff110e5899c2d1727217919dd5badeacdfe061 --- /dev/null +++ b/permissionmanager/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function abilityTest() { + describe('ActsAbilityTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('assertContain', 0, () => { + // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. + hilog.info(0x0000, 'testTag', '%{public}s', 'it begin'); + let a = 'abc'; + let b = 'b'; + // Defines a variety of assertion methods, which are used to declare expected boolean conditions. + expect(a).assertContain(b); + expect(a).assertEqual(a); + }) + }) +} \ No newline at end of file diff --git a/permissionmanager/src/ohosTest/ets/test/List.test.ets b/permissionmanager/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..a98c00c1d23a80cca37ce7f8d1b0ecf2ec11445e --- /dev/null +++ b/permissionmanager/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import utilsTest from './utils.test'; +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); + utilsTest(); +} \ No newline at end of file diff --git a/permissionmanager/src/ohosTest/ets/test/utils.test.ets b/permissionmanager/src/ohosTest/ets/test/utils.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..4efc9acf639c9e1ab98368d6481c8d896f6a657a --- /dev/null +++ b/permissionmanager/src/ohosTest/ets/test/utils.test.ets @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect, TestType } from '@ohos/hypium'; +import { Log, getGroupIdByPermission } from '../../../main/ets/common/utils/utils'; + +export default function utilsTest() { + describe('utilsTest', () => { + // Defines a test suite. Two parameters are supported: test suite name and test suite function. + beforeAll(() => { + // Presets an action, which is performed only once before all test cases of the test suite start. + // This API supports only one parameter: preset action function. + }) + beforeEach(() => { + // Presets an action, which is performed before each unit test case starts. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: preset action function. + }) + afterEach(() => { + // Presets a clear action, which is performed after each unit test case ends. + // The number of execution times is the same as the number of test cases defined by **it**. + // This API supports only one parameter: clear action function. + }) + afterAll(() => { + // Presets a clear action, which is performed after all test cases of the test suite end. + // This API supports only one parameter: clear action function. + }) + it('UtilsTest_000', TestType.FUNCTION, () => { + Log.info(`UtilsTest_000 begin`); + let testUri = 'ohos.permission.MICROPHONE'; + let groupId = getGroupIdByPermission(testUri); + expect(groupId).assertEqual(2); + }) + }) +} \ No newline at end of file diff --git a/permissionmanager/src/ohosTest/module.json5 b/permissionmanager/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..2c2b488c2cbff34765f3f51799422a75891a6cce --- /dev/null +++ b/permissionmanager/src/ohosTest/module.json5 @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2024 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +{ + "module": { + "name": "permissionmanager_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet" + ], + "deliveryWithInstall": true, + "installationFree": false + } +}