From dc4b285d1e2737afa3ea974a397844349df3586a Mon Sep 17 00:00:00 2001 From: fanchenxuan Date: Tue, 22 Oct 2024 11:35:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9EDT=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: fanchenxuan --- .clang-format | 64 +++++++++++++++++++ AppScope/app.json | 4 +- AppScope/app.json5 | 4 +- entry/src/ohosTest/ets/test/Ability.test.ets | 50 +++++++++++++++ entry/src/ohosTest/ets/test/List.test.ets | 22 +++++++ entry/src/ohosTest/ets/test/index.test.ets | 31 +++++++++ entry/src/ohosTest/module.json5 | 26 ++++++++ hvigor/hvigor-config.json5 | 4 +- oh-package-lock.json5 | 11 +++- oh-package.json5 | 1 + permissionmanager/.gitignore | 3 +- permissionmanager/src/main/module.json | 4 +- permissionmanager/src/main/module.json5 | 4 +- .../src/ohosTest/ets/test/Ability.test.ets | 50 +++++++++++++++ .../src/ohosTest/ets/test/List.test.ets | 22 +++++++ .../src/ohosTest/ets/test/utils.test.ets | 47 ++++++++++++++ permissionmanager/src/ohosTest/module.json5 | 26 ++++++++ 17 files changed, 362 insertions(+), 11 deletions(-) create mode 100644 .clang-format create mode 100644 entry/src/ohosTest/ets/test/Ability.test.ets create mode 100644 entry/src/ohosTest/ets/test/List.test.ets create mode 100644 entry/src/ohosTest/ets/test/index.test.ets create mode 100644 entry/src/ohosTest/module.json5 create mode 100644 permissionmanager/src/ohosTest/ets/test/Ability.test.ets create mode 100644 permissionmanager/src/ohosTest/ets/test/List.test.ets create mode 100644 permissionmanager/src/ohosTest/ets/test/utils.test.ets create mode 100644 permissionmanager/src/ohosTest/module.json5 diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..ec09519 --- /dev/null +++ b/.clang-format @@ -0,0 +1,64 @@ +Language: Cpp +# BasedOnStyle: LLVM +ColumnLimit: 120 +SortIncludes: false +TabWidth: 4 +IndentWidth: 4 +UseTab: Never +AccessModifierOffset: -4 +ContinuationIndentWidth: 4 +IndentCaseBlocks: false +IndentCaseLabels: false +IndentGotoLabels: true +IndentWrappedFunctionNames: false +SortUsingDeclarations: false +NamespaceIndentation: None +SpaceAfterCStyleCast: false +SpaceAfterLogicalNot: false +SpaceAfterTemplateKeyword: true +SpaceBeforeAssignmentOperators: true +SpaceBeforeCaseColon: false +SpaceBeforeCpp11BracedList: false +SpaceBeforeCtorInitializerColon: true +SpaceBeforeInheritanceColon: true +SpaceBeforeRangeBasedForLoopColon: true +SpaceBeforeSquareBrackets: false +SpaceInEmptyBlock: false +SpaceInEmptyParentheses: false +SpacesInAngles: false +SpacesInCStyleCastParentheses: false +SpacesInConditionalStatement: false +SpacesInParentheses: false +SpacesInSquareBrackets: false +AlignTrailingComments: true +AlignAfterOpenBracket: true +AllowShortCaseLabelsOnASingleLine: false +AllowShortEnumsOnASingleLine: true +AllowShortFunctionsOnASingleLine: All +AllowShortIfStatementsOnASingleLine: Never +AllowShortLambdasOnASingleLine: All +AllowShortLoopsOnASingleLine: false +AlwaysBreakTemplateDeclarations: MultiLine +BinPackArguments: true +BinPackParameters: true +BreakBeforeTernaryOperators: true +BreakConstructorInitializers: BeforeColon +BreakInheritanceList: BeforeColon +BreakStringLiterals: true +InsertBraces: false +IndentExternBlock: NoIndent +BreakBeforeBraces: Custom +BraceWrapping: + AfterCaseLabel: false + AfterClass: false + AfterControlStatement: Never + AfterEnum: false + AfterFunction: false + AfterNamespace: false + AfterStruct: false + AfterUnion: false + AfterExternBlock: false + BeforeCatch: false + BeforeElse: false +ReflowComments: true +MaxEmptyLinesToKeep: 2 \ No newline at end of file diff --git a/AppScope/app.json b/AppScope/app.json index 8cad5bd..90788d5 100644 --- a/AppScope/app.json +++ b/AppScope/app.json @@ -4,8 +4,8 @@ "app": { "bundleName": "com.ohos.permissionmanager", "vendor": "example", - "versionCode": 1000071, - "versionName": "1.7.1", + "versionCode": 1000072, + "versionName": "1.7.2", "icon": "$media:app_icon", "label": "$string:app_name", "minAPIVersion": 14, diff --git a/AppScope/app.json5 b/AppScope/app.json5 index 0c9451b..dd542c6 100644 --- a/AppScope/app.json5 +++ b/AppScope/app.json5 @@ -16,8 +16,8 @@ "app": { "bundleName": "com.ohos.permissionmanager", "vendor": "example", - "versionCode": 1000071, - "versionName": "1.7.1", + "versionCode": 1000072, + "versionName": "1.7.2", "icon": "$media:app_icon", "label": "$string:app_name", "minAPIVersion": 14, 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 0000000..a8ff110 --- /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 0000000..8a041d1 --- /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 0000000..024f225 --- /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 0000000..944ed99 --- /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 4cbdf16..8197a1f 100644 --- a/hvigor/hvigor-config.json5 +++ b/hvigor/hvigor-config.json5 @@ -14,8 +14,8 @@ */ { - "hvigorVersion": "3.0.2", + "hvigorVersion": "5.8.5", "dependencies": { - "@ohos/hvigor-ohos-plugin": "3.0.2" + "@ohos/hvigor-ohos-plugin": "5.8.5" } } diff --git a/oh-package-lock.json5 b/oh-package-lock.json5 index 17c8ea4..04107a1 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 756269c..a7fa446 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 4f9a973..23f4a26 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 c89e9e7..b7dc81a 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 6c52a16..7665e0f 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 0000000..a8ff110 --- /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 0000000..a98c00c --- /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 0000000..4efc9ac --- /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 0000000..2c2b488 --- /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 + } +} -- Gitee