diff --git a/CompilingAndBuilding/.clang-format b/CompilingAndBuilding/.clang-format new file mode 100644 index 0000000000000000000000000000000000000000..48439ed68073b99be118d374d1ebd43d04d4c4eb --- /dev/null +++ b/CompilingAndBuilding/.clang-format @@ -0,0 +1,64 @@ +Language: Cpp +# BasedOnStyle: LLVM +ColumnLimit: 120 +SortIncludes: CaseSensitive +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/CompilingAndBuilding/build-profile.json5 b/CompilingAndBuilding/build-profile.json5 index 9fc26a1e12af504f46212edd9ff1650bdca7dd15..415920ebb617f7cb86ec37eb4ef2e66ac5784d9c 100644 --- a/CompilingAndBuilding/build-profile.json5 +++ b/CompilingAndBuilding/build-profile.json5 @@ -1,4 +1,3 @@ -// FAQ:项目工程中怎样配置Native的版本 { "app": { "signingConfigs": [], @@ -46,6 +45,14 @@ { "name": "library2", "srcPath": "./library2", + }, + { + "name": "library3", + "srcPath": "./library3", + }, + { + "name": "react", + "srcPath": "./react" } ] } \ No newline at end of file diff --git a/CompilingAndBuilding/build-profile_demo.json5 b/CompilingAndBuilding/build-profile_demo.json5 index 53109823666ba61f4d2c660cc634864a0417c5ad..fe0b916daca65226ffac7ced4bbcfb23ea04dcd4 100644 --- a/CompilingAndBuilding/build-profile_demo.json5 +++ b/CompilingAndBuilding/build-profile_demo.json5 @@ -1,4 +1,4 @@ -//FAQ:如何定制构建多目标产物 +// FAQ:如何定制构建多目标产物 // [Start multi_objective_product] { "app": { diff --git a/CompilingAndBuilding/build-profile_ohmurl.json5 b/CompilingAndBuilding/build-profile_ohmurl.json5 index 2ee2f9ff3c0363674e571bf79b288624f01e00cf..1b5e1146a7c132582aff26c3e87bee8ba2dede34 100644 --- a/CompilingAndBuilding/build-profile_ohmurl.json5 +++ b/CompilingAndBuilding/build-profile_ohmurl.json5 @@ -29,20 +29,15 @@ } ] }, + //FAQ:编译报错“The useNormalizedOHMUrl settings of packages xxx and the project useNormalizedOHMUrl: xxx do not match” + // [Start build_profile_ohmurl_hsp] "modules": [ { - "name": "entry", - "srcPath": "./entry", - "targets": [ - { - "name": "default", - "applyToProducts": [ - "default" - ] - } - ] - }, + name: "hsp", // 引用的hsp包依赖 + srcPath: "../MyApplication_stageB/hsp", // 引用的hsp包的路径(绝对和相对都可以) + } ], + // [End build_profile_ohmurl_hsp] // [EndExclude build_profile_ohmurl] } // [End build_profile_ohmurl] \ No newline at end of file diff --git a/CompilingAndBuilding/cpp/CMakeLists.txt b/CompilingAndBuilding/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..fd2f94224288eb027dea382afe228aa91ea19b03 --- /dev/null +++ b/CompilingAndBuilding/cpp/CMakeLists.txt @@ -0,0 +1,5 @@ +//FAQ:静态共享包HAR如何引用另一个HAR包中的so文件 +// [Start importLibnativeSub] +target_link_directories(entry PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/) +target_link_libraries(entry PUBLIC libace_napi.z.so libc++.a libnativeSub.so) +// [End importLibnativeSub] \ No newline at end of file diff --git a/CompilingAndBuilding/entry/build-profile.json5 b/CompilingAndBuilding/entry/build-profile.json5 index 7875677ab73e13701ccbd1fb741e2d986f5625cc..4fb3981625e8a49a26742f337f0bb11d466e991b 100644 --- a/CompilingAndBuilding/entry/build-profile.json5 +++ b/CompilingAndBuilding/entry/build-profile.json5 @@ -5,9 +5,9 @@ // [Start external_native_options] "buildOption": { "externalNativeOptions": { - "path": "./src/main/cpp/CMakeLists.txt", + "path": "../cpp/CMakeLists.txt", "arguments": "-DCMAKE_JOB_POOL_COMPILE:STRING=compile -DCMAKE_JOB_POOL_LINK:STRING=link -DCMAKE_JOB_POOLS:STRING=compile=2;link=2", - "cppFlags": "", + "cppFlags": "" } }, // [End external_native_options] diff --git a/CompilingAndBuilding/entry/oh-package-lock.json5 b/CompilingAndBuilding/entry/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..757436a2d6e4b56a744866ce2323eb7bd2c33594 --- /dev/null +++ b/CompilingAndBuilding/entry/oh-package-lock.json5 @@ -0,0 +1,25 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "React@../react": "React@../react", + "library@../library": "library@../library" + }, + "packages": { + "React@../react": { + "name": "react", + "version": "1.0.0", + "resolved": "../react", + "registryType": "local" + }, + "library@../library": { + "name": "library", + "version": "1.0.0", + "resolved": "../library", + "registryType": "local" + } + } +} \ No newline at end of file diff --git a/CompilingAndBuilding/entry/oh-package.json5 b/CompilingAndBuilding/entry/oh-package.json5 index 248c3b7541a589682a250f86a6d3ecf7414d2d6a..5a9faf4b2c401dae3c79fb9137ab837540a968fb 100644 --- a/CompilingAndBuilding/entry/oh-package.json5 +++ b/CompilingAndBuilding/entry/oh-package.json5 @@ -2,9 +2,15 @@ "name": "entry", "version": "1.0.0", "description": "Please describe the basic information.", - "main": "", + // FAQ:如何解决三方包require语句报错 + // [Start mainPath] + "main": "./src/index.js", + // [Start mainPath] "author": "", "license": "", - "dependencies": {} + "dependencies": { + "React": "file:../react", + "library": "file:../library" + } } diff --git a/CompilingAndBuilding/entry/src/main/cpp/CMakeLists.txt b/CompilingAndBuilding/entry/src/index.js similarity index 100% rename from CompilingAndBuilding/entry/src/main/cpp/CMakeLists.txt rename to CompilingAndBuilding/entry/src/index.js diff --git a/CompilingAndBuilding/entry/src/main/ets/commpent/BreakPointType.ets b/CompilingAndBuilding/entry/src/main/ets/commpent/BreakPointType.ets new file mode 100644 index 0000000000000000000000000000000000000000..f89e3277036b18ed301a90a630b8e1404783b5b2 --- /dev/null +++ b/CompilingAndBuilding/entry/src/main/ets/commpent/BreakPointType.ets @@ -0,0 +1,23 @@ + +declare interface BreakpointTypeOption{ + xs?: T; + sm?: T; + md?: T; + lg?: T; + xl?: T; +} + +export class BreakpointType { + options:BreakpointTypeOption; + + public constructor(option: BreakpointTypeOption) { + this.options = option + } + + //FAQ:如何解决编译报错“Indexed access is not supported for fields(arkts-no-props-by-index)”的问题 + // [Start IndexedAccess] + getValue(breakpoint: string): T { + return Reflect.get(this.options, breakpoint) as T; + } + // [End IndexedAccess] +} \ No newline at end of file diff --git a/CompilingAndBuilding/entry/src/main/ets/pages/Index.ets b/CompilingAndBuilding/entry/src/main/ets/pages/Index.ets index 8e2d24ad42693fc877d51bb7820f0a9da68fa135..a88551883d28587d688f234ca12ef7f69c9d7e8c 100644 --- a/CompilingAndBuilding/entry/src/main/ets/pages/Index.ets +++ b/CompilingAndBuilding/entry/src/main/ets/pages/Index.ets @@ -1,3 +1,28 @@ +/* +* 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. +*/ + +/* +* FAQ:编译告警“The re-export name 'xx' need to be marked as type” +*/ +// [Start export_test] +import type {test} from "./test" //Here, add a type declaration +export {test} +let b : test = {a : 'index'} +// [End export_test] + + @Entry @Component struct Index { diff --git a/CompilingAndBuilding/entry/src/main/ets/pages/allFunction.ets b/CompilingAndBuilding/entry/src/main/ets/pages/allFunction.ets new file mode 100644 index 0000000000000000000000000000000000000000..e971255193ce409e554543dc574661353f091ba7 --- /dev/null +++ b/CompilingAndBuilding/entry/src/main/ets/pages/allFunction.ets @@ -0,0 +1,25 @@ +/* +* 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. +*/ + +/* +* FAQ:文件没有默认导出,但可以默认导入的场景说明 +*/ + +// [Start addFunction] +// 编译文件 +import allFunction from 'library' + +allFunction.sub(1,2) +// [End addFunction] \ No newline at end of file diff --git a/CompilingAndBuilding/entry/src/main/ets/pages/test.ets b/CompilingAndBuilding/entry/src/main/ets/pages/test.ets new file mode 100644 index 0000000000000000000000000000000000000000..7bdaa47a25f0c44002ddee3a9030f62893fd4b58 --- /dev/null +++ b/CompilingAndBuilding/entry/src/main/ets/pages/test.ets @@ -0,0 +1,34 @@ +/* +* 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. +*/ + +/* +* FAQ:文件没有默认导出,但可以默认导入的场景说明 +*/ +// [Start React] +import React from "react"; +React.useId() +// [End React] + +/* +* FAQ:编译告警“The re-export name 'xx' need to be marked as type” +*/ + +// [Start test] +// test.ets +export interface test { + a: string +} +let obj : test = {a : 'string'} +// [End test] diff --git a/CompilingAndBuilding/entry/src/main/module.json5 b/CompilingAndBuilding/entry/src/main/module.json5 index 1262df2a198b763c95ee9d557c11746b921bb775..45d96f4b39769c8ae18b16ae97cc93044fba3530 100644 --- a/CompilingAndBuilding/entry/src/main/module.json5 +++ b/CompilingAndBuilding/entry/src/main/module.json5 @@ -1,6 +1,5 @@ -//FAQ:编译报错“The reason and usedScene attributes are mandatory for user_grant permissions” -//FAQ:打包体积大如何配置优化包体积问题 -//[Start module_package] +// FAQ:打包体积大如何配置优化包体积问题 +// [Start module_package] { "module": { // [StartExclude module_package] @@ -52,7 +51,8 @@ ], } ], - //[Start user_grant_permissions] + // FAQ:编译报错“The reason and usedScene attributes are mandatory for user_grant permissions” + // [Start user_grant_permissions] "requestPermissions": [ { "name": "ohos.permission.READ_IMAGEVIDEO", @@ -65,7 +65,7 @@ } } ], - //[End user_grant_permissions] + // [End user_grant_permissions] // [EndExclude module_package] "compressNativeLibs": true // Package libs library in compressed storage format } diff --git a/CompilingAndBuilding/entry/src/rollup.config.js b/CompilingAndBuilding/entry/src/rollup.config.js new file mode 100644 index 0000000000000000000000000000000000000000..bc9faa22553327281dc08cb20cca9b2cff14ec49 --- /dev/null +++ b/CompilingAndBuilding/entry/src/rollup.config.js @@ -0,0 +1,25 @@ +/* +* 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. +*/ + +// FAQ:如何解决三方包require语句报错 +// [Start plugins] +plugins: [ + resolve({ + preferBuiltins: false, // true 或 false + mainFields: ['module', 'main'], + extensions + }) +]; +// [End plugins] \ No newline at end of file diff --git a/CompilingAndBuilding/entry/src/test.js b/CompilingAndBuilding/entry/src/test.js new file mode 100644 index 0000000000000000000000000000000000000000..8b118aac55489a00ed3c5c8cee4e4d5f354f85ff --- /dev/null +++ b/CompilingAndBuilding/entry/src/test.js @@ -0,0 +1,19 @@ +/* +* 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. +*/ + +// FAQ:如何解决三方包require语句报错 +// [Start moduleExports] +module.exports = {a: 1, b: 2} +// [End moduleExports] \ No newline at end of file diff --git a/CompilingAndBuilding/entry/src/use.js b/CompilingAndBuilding/entry/src/use.js new file mode 100644 index 0000000000000000000000000000000000000000..3a55f5611ff2d12ed0a719d039bb4609b061306d --- /dev/null +++ b/CompilingAndBuilding/entry/src/use.js @@ -0,0 +1,27 @@ +/* +* 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. +*/ + +// FAQ:如何解决三方包require语句报错 +// [Start requireTest] +let test = require("Module/src/test") +// [Start requireTest] + +// [Start requireModule] +let module = require("Module") +// [End requireModule] + +// [Start Buffer] +import {Buffer} from 'buffer/' +// [End Buffer] \ No newline at end of file diff --git a/CompilingAndBuilding/hvigor-config.json5 b/CompilingAndBuilding/hvigor-config.json5 index f8b8a3bcc0a4e00d89951c9730d8cc78b22886f6..f9fa2dab4dee81405e997b6b500109c48bbb365c 100644 --- a/CompilingAndBuilding/hvigor-config.json5 +++ b/CompilingAndBuilding/hvigor-config.json5 @@ -1,5 +1,5 @@ //FAQ:编译过程内存过高 -//[Start hvigor-config] +// [Start hvigor-config] { "modelVersion": "0.0.1", "dependencies": {}, @@ -14,4 +14,4 @@ "hvigor.enableMemoryCache": false } } -//[End hvigor-config] \ No newline at end of file +// [End hvigor-config] \ No newline at end of file diff --git a/CompilingAndBuilding/hvigor/hvigor-config_xx.json5 b/CompilingAndBuilding/hvigor/hvigor-config_xx.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a17e948ee6496b943233231e0a0d8a7f103ba862 --- /dev/null +++ b/CompilingAndBuilding/hvigor/hvigor-config_xx.json5 @@ -0,0 +1,9 @@ +// FAQ:构建报错"Cannot read properties of undefined(reading 'XXX')" +// [Start stacktrace] +{ + "debugging": { + "stacktrace": true + /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, +} +// [End stacktrace] \ No newline at end of file diff --git a/CompilingAndBuilding/library/Index.ets b/CompilingAndBuilding/library/Index.ets index 5a4d46fef3260aa85ae27a60c621f7e59d16b507..cadfac818cd29290e8a053f571dccb7bfe8b1df2 100644 --- a/CompilingAndBuilding/library/Index.ets +++ b/CompilingAndBuilding/library/Index.ets @@ -1,12 +1,18 @@ // FAQ:如何获取BuildProfile中的值 // [Start build_profile_1] import BuildProfile from './BuildProfile'; + // [End build_profile_1] // [Start build_profile_2] const HAR_VERSION: string = BuildProfile.HAR_VERSION; -const BUILD_MODE_NAME:string = BuildProfile.BUILD_MODE_NAME; -const DEBUG:boolean = BuildProfile.DEBUG; +const BUILD_MODE_NAME: string = BuildProfile.BUILD_MODE_NAME; +const DEBUG: boolean = BuildProfile.DEBUG; + // [End build_profile_2] -export { MainPage } from './src/main/ets/components/MainPage'; \ No newline at end of file +export default class allFunction { + static sub(a: number, b: number): number { + return a + b + } +} \ No newline at end of file diff --git a/CompilingAndBuilding/library/src/main/ets/components/MainPage.ets b/CompilingAndBuilding/library/src/main/ets/components/MainPage.ets index 9de5eb33fe973c00e1ddc28c9f079ace6d473711..fa9426a7a1090a6bce74e9c57f16f34ce729f5ad 100644 --- a/CompilingAndBuilding/library/src/main/ets/components/MainPage.ets +++ b/CompilingAndBuilding/library/src/main/ets/components/MainPage.ets @@ -1,3 +1,4 @@ + @Component export struct MainPage { @State message: string = 'Hello World'; diff --git a/CompilingAndBuilding/library/src/main/ets/components/index.d.ts b/CompilingAndBuilding/library/src/main/ets/components/index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..f28595c6d0ec95511af77f7037ff090ca3775b5a --- /dev/null +++ b/CompilingAndBuilding/library/src/main/ets/components/index.d.ts @@ -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. +*/ + +/* +* FAQ:文件没有默认导出,但可以默认导入的场景说明 +*/ + +// [Start exportAddFunction] +// 依赖包的声明文件 index.d.ts +declare const allFunction : { + sub: (a: number, b: number) => number +} +export = allFunction +// [End exportAddFunction] \ No newline at end of file diff --git a/CompilingAndBuilding/library/src/main/ets/components/index.js b/CompilingAndBuilding/library/src/main/ets/components/index.js new file mode 100644 index 0000000000000000000000000000000000000000..af09e900cc65322b223faae24221facf57a4c7da --- /dev/null +++ b/CompilingAndBuilding/library/src/main/ets/components/index.js @@ -0,0 +1,29 @@ +/* +* 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. +*/ + +/* +* FAQ:文件没有默认导出,但可以默认导入的场景说明 +*/ + +// [Start subFunction] +// 依赖包的实现文件 index.js +function sub(a, b) { + return a - b +} + + +var allFunction = { sub } +module.exports = allFuntion +// [End subFunction] \ No newline at end of file diff --git a/CompilingAndBuilding/library/src/main/ets/components/util.js b/CompilingAndBuilding/library/src/main/ets/components/util.js new file mode 100644 index 0000000000000000000000000000000000000000..9f73ed2a15daf0d0b7b801f05a1f684462bdbf2b --- /dev/null +++ b/CompilingAndBuilding/library/src/main/ets/components/util.js @@ -0,0 +1,7 @@ +// 依赖包的实现文件 index.js +function sub(a, b) { + return a - b +} + +var allFunction = { sub } +module.exports = allFuntion \ No newline at end of file diff --git a/CompilingAndBuilding/library1/build-profile.json5 b/CompilingAndBuilding/library1/build-profile.json5 index 1f863169709ba52bf0c9d72873b456dc7cd035ae..c07e8b0cdd1cbe4a52de0e77da49c961c3803656 100644 --- a/CompilingAndBuilding/library1/build-profile.json5 +++ b/CompilingAndBuilding/library1/build-profile.json5 @@ -1,5 +1,4 @@ //FAQ:编译打包CPU架构设置 -//FAQ:打包体积大如何配置优化包体积问题 { "apiType": "stageMode", "buildOption": { @@ -34,6 +33,7 @@ ] } }, + //FAQ:打包体积大如何配置优化包体积问题 // [Start, native_lib_package] "nativeLib": { "debugSymbol": { diff --git a/CompilingAndBuilding/library2/build-profile.json5 b/CompilingAndBuilding/library2/build-profile.json5 index b4c29d66c21a291d2e6b566e647d94f73b02e175..46f13189d5e64ba4a760734f460ef303561cdf67 100644 --- a/CompilingAndBuilding/library2/build-profile.json5 +++ b/CompilingAndBuilding/library2/build-profile.json5 @@ -1,7 +1,7 @@ //FAQ:编译报错“Duplicated files found in module entry. This may cause unexpected errors at runtime” { "apiType": "stageMode", - //[Start enable_override] + // [Start enable_override] "buildOption": { "nativeLib": { "filter": { @@ -9,7 +9,7 @@ } } }, - //[End enable_override] + // [End enable_override] "buildOptionSet": [ { "name": "release", diff --git a/CompilingAndBuilding/library2/hvigorfile.ts b/CompilingAndBuilding/library2/hvigorfile.ts index 42187071482d292588ad40babeda74f7b8d97a23..886b8bbbc57a050bd005b304fe9933f55d83d8ed 100644 --- a/CompilingAndBuilding/library2/hvigorfile.ts +++ b/CompilingAndBuilding/library2/hvigorfile.ts @@ -1,6 +1,9 @@ +// FAQ:构建报错"Cannot read properties of undefined(reading 'XXX')" +// [Start harTasks] import { harTasks } from '@ohos/hvigor-ohos-plugin'; export default { system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ } +// [End harTasks] \ No newline at end of file diff --git a/CompilingAndBuilding/library3/.gitignore b/CompilingAndBuilding/library3/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/CompilingAndBuilding/library3/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/CompilingAndBuilding/library3/BuildProfile.ets b/CompilingAndBuilding/library3/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/CompilingAndBuilding/library3/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/CompilingAndBuilding/library3/Index.ets b/CompilingAndBuilding/library3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..42bf4161c271e1b14d42a7ab98c982acc9bc3592 --- /dev/null +++ b/CompilingAndBuilding/library3/Index.ets @@ -0,0 +1 @@ +export { MainPage } from './src/main/ets/components/MainPage'; diff --git a/CompilingAndBuilding/library3/build-profile.json5 b/CompilingAndBuilding/library3/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..926b1f414b9e8c5ef240be5a7dc841e8c73bf346 --- /dev/null +++ b/CompilingAndBuilding/library3/build-profile.json5 @@ -0,0 +1,35 @@ +// FAQ:如何定制构建多目标产物 +// [Start multi_objective_product] +{ + "apiType": "stageMode", + "buildOption": { + "arkOptions": { + // "apPath": "./modules.ap" /* Profile used for profile-guided optimization (PGO), a compiler optimization technique to improve app runtime performance. */ + } + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": true, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default", + "runtimeOS": "HarmonyOS" + }, + { + "name": "ohosTest", + } + ] +} +// [Start multi_objective_product] \ No newline at end of file diff --git a/CompilingAndBuilding/library3/consumer-rules.txt b/CompilingAndBuilding/library3/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/CompilingAndBuilding/library3/hvigorfile.ts b/CompilingAndBuilding/library3/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..01e28d9a69a6412cb6628e03e9bdba587b35e0fe --- /dev/null +++ b/CompilingAndBuilding/library3/hvigorfile.ts @@ -0,0 +1,37 @@ +// FAQ:如何在构建任务中执行shell脚本 +// [Start shell] +import { harTasks } from '@ohos/hvigor-ohos-plugin'; +import { exec } from 'node:child_process'; +import util from 'node:util'; + +const scriptPath = 'xxxx.bat'; + +export function customPluginFunction1(str?: string) { + return { + pluginId: 'CustomPluginID1', + apply(pluginContext) { + pluginContext.registerTask({ + // 编写自定义任务 + name: 'customTask1', + run: (taskContext) => { + console.log('run into: '); + const execPromise = util.promisify(exec) + execPromise(scriptPath).then(res => { + console.log(res, 'res'); + }).catch(err => { + console.log(err, 'err'); + }) + }, + // 确认自定义任务插入位置 + dependencies: ['default@BuildJS'], + postDependencies: ['default@CompileArkTS'] + }) + } + } +} + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins: [customPluginFunction1()] /* Custom plugin to extend the functionality of Hvigor. */ +} +// [End shell] \ No newline at end of file diff --git a/CompilingAndBuilding/library3/hvigorfile_comfig.ts b/CompilingAndBuilding/library3/hvigorfile_comfig.ts new file mode 100644 index 0000000000000000000000000000000000000000..598b31d43978c77bcd0d7ac487080e8a759a30ce --- /dev/null +++ b/CompilingAndBuilding/library3/hvigorfile_comfig.ts @@ -0,0 +1,50 @@ + +//FAQ:如何快速关闭工程中所有字节码HAR配置 +// [Start hvigorfile] +// 工程级hvigorfile.ts文件 +import { hvigor, HvigorNode, HvigorPlugin } from '@ohos/hvigor'; +import { appTasks, OhosHarContext, OhosPluginId, Target } from '@ohos/hvigor-ohos-plugin'; +// 实现自定义插件 +export function customPlugin(): HvigorPlugin { + return { + pluginId: 'customPlugin', + async apply(currentNode: HvigorNode): Promise { + hvigor.afterNodeEvaluate(async () => { + // 注册模块级任务 + harTask(currentNode); + }); + } + }; +} +function harTask(currentNode: HvigorNode) { + currentNode.subNodes((node: HvigorNode) => { + const context = node.getContext(OhosPluginId.OHOS_HAR_PLUGIN) + context?.targets((target: Target) => { + const targetName = target.getTargetName(); + node.registerTask({ + // 任务名称 + name: `HarTask`, + // 任务执行逻辑主体函数 + run() { + if (context.getBuildProfileOpt) { + const buildProfile = context.getBuildProfileOpt(); + console.log(buildProfile) + // 设置字节码har配置为false + buildProfile["buildOption"] = { arkOptions: { byteCodeHar: false } }; + console.log(buildProfile) + context.setBuildProfileOpt(buildProfile); + } + }, + // 配置前置任务依赖 + dependencies: [`${targetName}@PackageHar`], + // 配置任务的后置任务依赖 + postDependencies: ['assembleHar'] + }); + }); + }); +} +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[customPlugin()] /* Custom plugin to extend the functionality of Hvigor. */ +} +// [End hvigorfile] \ No newline at end of file diff --git a/CompilingAndBuilding/library3/obfuscation-rules.txt b/CompilingAndBuilding/library3/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/CompilingAndBuilding/library3/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/CompilingAndBuilding/library3/oh-package.json5 b/CompilingAndBuilding/library3/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ee8879e46eba6fff4e156740ee00cfb943285110 --- /dev/null +++ b/CompilingAndBuilding/library3/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "library3", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/CompilingAndBuilding/library3/src/main/ets/components/MainPage.ets b/CompilingAndBuilding/library3/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..9de5eb33fe973c00e1ddc28c9f079ace6d473711 --- /dev/null +++ b/CompilingAndBuilding/library3/src/main/ets/components/MainPage.ets @@ -0,0 +1,19 @@ +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/CompilingAndBuilding/library3/src/main/ets/components/index.ets b/CompilingAndBuilding/library3/src/main/ets/components/index.ets new file mode 100644 index 0000000000000000000000000000000000000000..eb1543714ff3bdb329f0409bf5badbe64c9e8099 --- /dev/null +++ b/CompilingAndBuilding/library3/src/main/ets/components/index.ets @@ -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. +*/ + +/* +* FAQ:文件没有默认导出,但可以默认导入的场景说明 +*/ + +// [Start import_test] +// index.ets文件 +import test from './test' + + +test.addFunction.add(1,2) +// [End import_test] diff --git a/CompilingAndBuilding/library3/src/main/ets/components/test.d.ts b/CompilingAndBuilding/library3/src/main/ets/components/test.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..3217f13d494017e3d54606df0b39c92652c305e5 --- /dev/null +++ b/CompilingAndBuilding/library3/src/main/ets/components/test.d.ts @@ -0,0 +1,25 @@ +/* +* 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. +*/ + +/* +* FAQ:文件没有默认导出,但可以默认导入的场景说明 +*/ + +// [Start addFunction] +// test.d.ts文件 +export const addFunction: { + add: (a: number, b: number) => number +} +// [End addFunction] \ No newline at end of file diff --git a/CompilingAndBuilding/library3/src/main/ets/components/w.ets b/CompilingAndBuilding/library3/src/main/ets/components/w.ets new file mode 100644 index 0000000000000000000000000000000000000000..ad6f0bc932d00d1854def9e37730fd25b14b65ee --- /dev/null +++ b/CompilingAndBuilding/library3/src/main/ets/components/w.ets @@ -0,0 +1,10 @@ +// FAQ:构建报错"Cannot read properties of undefined(reading 'XXX')" +// [Start CorrectWriting] +// Correct writing +class w { + public a: string[][] = [] + test() { + console.log("1", this.a[0]) + } +} +// [End CorrectWriting] \ No newline at end of file diff --git a/CompilingAndBuilding/library3/src/main/module.json5 b/CompilingAndBuilding/library3/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f66ef4cebc2adda76177cbefe202f6edffddede2 --- /dev/null +++ b/CompilingAndBuilding/library3/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "library3", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/CompilingAndBuilding/library3/src/main/resources/base/element/float.json b/CompilingAndBuilding/library3/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/CompilingAndBuilding/library3/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/CompilingAndBuilding/library3/src/main/resources/base/element/string.json b/CompilingAndBuilding/library3/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f51a9c8461a55f6312ef950344e3145b7f82d607 --- /dev/null +++ b/CompilingAndBuilding/library3/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/CompilingAndBuilding/library3/src/ohosTest/ets/test/Ability.test.ets b/CompilingAndBuilding/library3/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/CompilingAndBuilding/library3/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +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/CompilingAndBuilding/library3/src/ohosTest/ets/test/List.test.ets b/CompilingAndBuilding/library3/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/CompilingAndBuilding/library3/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/CompilingAndBuilding/library3/src/ohosTest/module.json5 b/CompilingAndBuilding/library3/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ff702d714aaab7840a827d30133283e06f5a94b1 --- /dev/null +++ b/CompilingAndBuilding/library3/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "library3_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/CompilingAndBuilding/library3/src/test/List.test.ets b/CompilingAndBuilding/library3/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/CompilingAndBuilding/library3/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/CompilingAndBuilding/library3/src/test/LocalUnit.test.ets b/CompilingAndBuilding/library3/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/CompilingAndBuilding/library3/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // 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. + 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/CompilingAndBuilding/react/.gitignore b/CompilingAndBuilding/react/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/CompilingAndBuilding/react/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/CompilingAndBuilding/react/BuildProfile.ets b/CompilingAndBuilding/react/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a501e5ddee8ea6d28961648fc7dd314a5304bd4 --- /dev/null +++ b/CompilingAndBuilding/react/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'debug'; +export const DEBUG = true; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/CompilingAndBuilding/react/Index.ets b/CompilingAndBuilding/react/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..7fc19da52e158ef139aeaf35beb07f242cac84aa --- /dev/null +++ b/CompilingAndBuilding/react/Index.ets @@ -0,0 +1,2 @@ +import React from './src/main/ets/components/React'; +export default React; diff --git a/CompilingAndBuilding/react/build-profile.json5 b/CompilingAndBuilding/react/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e6773f9f5d76a66d6d19fddc9c6ddb3f5621d3b1 --- /dev/null +++ b/CompilingAndBuilding/react/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/CompilingAndBuilding/react/consumer-rules.txt b/CompilingAndBuilding/react/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/CompilingAndBuilding/react/hvigorfile.ts b/CompilingAndBuilding/react/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42187071482d292588ad40babeda74f7b8d97a23 --- /dev/null +++ b/CompilingAndBuilding/react/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/CompilingAndBuilding/react/obfuscation-rules.txt b/CompilingAndBuilding/react/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/CompilingAndBuilding/react/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/CompilingAndBuilding/react/oh-package.json5 b/CompilingAndBuilding/react/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c4d9a216c1935b8b13235c2addabde4976a1265e --- /dev/null +++ b/CompilingAndBuilding/react/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "react", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} \ No newline at end of file diff --git a/CompilingAndBuilding/react/src/main/ets/components/React.ets b/CompilingAndBuilding/react/src/main/ets/components/React.ets new file mode 100644 index 0000000000000000000000000000000000000000..e611bb601164808ce944d6a7da0e9ee82866380c --- /dev/null +++ b/CompilingAndBuilding/react/src/main/ets/components/React.ets @@ -0,0 +1,7 @@ + +export default class React{ + static useId(){ + return 'xxx'; + } +} + diff --git a/CompilingAndBuilding/react/src/main/module.json5 b/CompilingAndBuilding/react/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b48817b086c369fd66e24ec4a3ac4724eb84fdf2 --- /dev/null +++ b/CompilingAndBuilding/react/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "react", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} \ No newline at end of file diff --git a/CompilingAndBuilding/react/src/main/resources/base/element/float.json b/CompilingAndBuilding/react/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/CompilingAndBuilding/react/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/CompilingAndBuilding/react/src/main/resources/base/element/string.json b/CompilingAndBuilding/react/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f51a9c8461a55f6312ef950344e3145b7f82d607 --- /dev/null +++ b/CompilingAndBuilding/react/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/CompilingAndBuilding/react/src/ohosTest/ets/test/Ability.test.ets b/CompilingAndBuilding/react/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/CompilingAndBuilding/react/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +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/CompilingAndBuilding/react/src/ohosTest/ets/test/List.test.ets b/CompilingAndBuilding/react/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/CompilingAndBuilding/react/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/CompilingAndBuilding/react/src/ohosTest/module.json5 b/CompilingAndBuilding/react/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..f89afbf2d7d283d6e4efb82c0c89d517bb1d2cad --- /dev/null +++ b/CompilingAndBuilding/react/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "react_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/CompilingAndBuilding/react/src/test/List.test.ets b/CompilingAndBuilding/react/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/CompilingAndBuilding/react/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/CompilingAndBuilding/react/src/test/LocalUnit.test.ets b/CompilingAndBuilding/react/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/CompilingAndBuilding/react/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // 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. + 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/Ndk/Ndk2/ImportThirdPartyLibraries/oh-package-lock.json5 b/Ndk/Ndk2/ImportThirdPartyLibraries/oh-package-lock.json5 index de2073e5eacf26b8c2ee111258c81f93d216c285..77782370a3ed2852735c5e649e15edfc4487704a 100644 --- a/Ndk/Ndk2/ImportThirdPartyLibraries/oh-package-lock.json5 +++ b/Ndk/Ndk2/ImportThirdPartyLibraries/oh-package-lock.json5 @@ -11,7 +11,7 @@ "packages": { "libapplication.so@src/main/cpp/types/libapplication": { "name": "libapplication.so", - "version": "0.0.0", + "version": "1.0.0", "resolved": "src/main/cpp/types/libapplication", "registryType": "local" }, diff --git a/Ndk/Ndk2/UndefinedSymbol/.gitignore b/Ndk/Ndk2/UndefinedSymbol/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/build-profile.json5 b/Ndk/Ndk2/UndefinedSymbol/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/hvigorfile.ts b/Ndk/Ndk2/UndefinedSymbol/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/Ndk/Ndk2/UndefinedSymbol/obfuscation-rules.txt b/Ndk/Ndk2/UndefinedSymbol/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/oh-package.json5 b/Ndk/Ndk2/UndefinedSymbol/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..86ef29d93300c211965b866ee3af7f8eec58562a --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "undefinedsymbol", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/CMakeLists.txt b/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..e1943cd3c0487fdf7764fee74bc26ed39d499943 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/CMakeLists.txt @@ -0,0 +1,10 @@ +# FAQ:CPP编译报错"A 'undefined symbol' error has occurred +# [Start cmake_minimum_required] +cmake_minimum_required(VERSION 3.10) +project(MyProject) +set(CMAKE_CXX_STANDARD 17) +include_directories(${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR}/include) +# Add all source files +add_library(myProgram SAHRED main.cpp myLibrary.cpp) +# [End cmake_minimum_required] \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/CMakeLists1.txt b/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/CMakeLists1.txt new file mode 100644 index 0000000000000000000000000000000000000000..4ecb899cc1d7231fcdb1d0af951e9c07db80324d --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/CMakeLists1.txt @@ -0,0 +1,17 @@ +# FAQ: CPP编译报错"A 'undefined symbol' error has occurred +# [Start cmake_minimum_required] +cmake_minimum_required(VERSION 3.10) +project(MyProject) +set(CMAKE_CXX_STANDARD 17) +# Ensure the addition of the header file for the third-party library +include_directories(${PATH_TO_EXTERNAL_LIBRARY} + ${PATH_TO_EXTERNAL_LIBRARY}/include) +# Add source files +add_library(myProgram SAHRED main.cpp myLibrary.cpp) +# Link to third-party libraries +target_link_libraries(myProgram PUBLIC /path/to/external/library) +# [End cmake_minimum_required] + +# [Start CMAKE_VERBOSE_MAKEFILE] +set(CMAKE_VERBOSE_MAKEFILE ON) +# [End CMAKE_VERBOSE_MAKEFILE] \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/myLibrary.cpp b/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/myLibrary.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aade91065f4de75f4df2b2bb01a11330dc2b2f69 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/myLibrary.cpp @@ -0,0 +1,7 @@ +// FAQ: CPP编译报错"A 'undefined symbol' error has occurred +// [Start cmake_minimum_required] +#include "myLibrary.h" +void myFunction() { +// Function implementation +} +// [End cmake_minimum_required] \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/myLibrary.h b/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/myLibrary.h new file mode 100644 index 0000000000000000000000000000000000000000..ce9260577dcca3ef584d2645ead556984d285d1d --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/myLibrary.h @@ -0,0 +1,7 @@ +// FAQ:CPP编译报错"A 'undefined symbol' error has occurred +// [Start myFunction] +#ifndef MY_LIBRARY_H +#define MY_LIBRARY_H +void myFunction(); +#endif +// [End myFunction] \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/types/libnativegetarktsobject/Index.d.ts b/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/types/libnativegetarktsobject/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..686d2f7349a47b1ed98542d35c96985c990fa3b3 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/types/libnativegetarktsobject/Index.d.ts @@ -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. + */ +/** + * FAQ: Native侧如何获取ArkTS侧Object对象及其成员变量 + */ + +// [Start native_get_ark_ts_object_index] +// index.d.ts +export const callFunction: (a:object) => void; +// [End native_get_ark_ts_object_index] \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/types/libnativegetarktsobject/oh-package.json5 b/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/types/libnativegetarktsobject/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ea410725a8826704d061021d98cf02aa76cd8016 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/main/cpp/types/libnativegetarktsobject/oh-package.json5 @@ -0,0 +1,6 @@ +{ + "name": "libentry.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/ets/pages/Index.ets b/Ndk/Ndk2/UndefinedSymbol/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e2d24ad42693fc877d51bb7820f0a9da68fa135 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/main/ets/pages/Index.ets @@ -0,0 +1,23 @@ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/ets/undefinedsymbolability/UndefinedSymbolAbility.ets b/Ndk/Ndk2/UndefinedSymbol/src/main/ets/undefinedsymbolability/UndefinedSymbolAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..93e8dc0d301d2f97efa9764de2e8c66541c94810 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/main/ets/undefinedsymbolability/UndefinedSymbolAbility.ets @@ -0,0 +1,43 @@ +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class UndefinedSymbolAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/module.json5 b/Ndk/Ndk2/UndefinedSymbol/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a3e8840556bd56428c16768aea585384f964d89 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/main/module.json5 @@ -0,0 +1,28 @@ +{ + "module": { + "name": "UndefinedSymbol", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "UndefinedSymbolAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "UndefinedSymbolAbility", + "srcEntry": "./ets/undefinedsymbolability/UndefinedSymbolAbility.ets", + "description": "$string:UndefinedSymbolAbility_desc", + "icon": "$media:layered_image", + "label": "$string:UndefinedSymbolAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/element/color.json b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/element/float.json b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/element/string.json b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..1f7a4392f02c8dcbc1ef8692a79c29426193a5c6 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "UndefinedSymbolAbility_desc", + "value": "description" + }, + { + "name": "UndefinedSymbolAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/media/background.png b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/media/background.png differ diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/media/foreground.png b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/media/foreground.png differ diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/media/layered_image.json b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/media/startIcon.png b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/media/startIcon.png differ diff --git a/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/profile/main_pages.json b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/Ndk/Ndk2/UndefinedSymbol/src/mock/mock-config.json5 b/Ndk/Ndk2/UndefinedSymbol/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/src/ohosTest/ets/test/Ability.test.ets b/Ndk/Ndk2/UndefinedSymbol/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +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/Ndk/Ndk2/UndefinedSymbol/src/ohosTest/ets/test/List.test.ets b/Ndk/Ndk2/UndefinedSymbol/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/src/ohosTest/module.json5 b/Ndk/Ndk2/UndefinedSymbol/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ae4f1d2d15e14a39416d5165dee276b25cc54cf7 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "UndefinedSymbol_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/Ndk/Ndk2/UndefinedSymbol/src/test/List.test.ets b/Ndk/Ndk2/UndefinedSymbol/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/Ndk/Ndk2/UndefinedSymbol/src/test/LocalUnit.test.ets b/Ndk/Ndk2/UndefinedSymbol/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/Ndk/Ndk2/UndefinedSymbol/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // 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. + 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/Ndk/Ndk2/UnknownType/.gitignore b/Ndk/Ndk2/UnknownType/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/build-profile.json5 b/Ndk/Ndk2/UnknownType/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/hvigorfile.ts b/Ndk/Ndk2/UnknownType/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/Ndk/Ndk2/UnknownType/obfuscation-rules.txt b/Ndk/Ndk2/UnknownType/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/Ndk/Ndk2/UnknownType/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/oh-package.json5 b/Ndk/Ndk2/UnknownType/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..6399e0cf2d15c36a1e4757953788ed562a4678f1 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "unknowntype", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/Ndk/Ndk2/UnknownType/src/main/cpp/CMakeLists.txt b/Ndk/Ndk2/UnknownType/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..204952467c1e148f1adf8da117fa2adbc98e6e29 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/main/cpp/CMakeLists.txt @@ -0,0 +1,19 @@ +# CPP编译报错"A 'unknown type name' error has occurred" +# [Start cmake_minimum_required] +cmake_minimum_required(VERSION 3.10) +project(MyProject) +set(CMAKE_CXX_STANDARD 17) +# Add header file directory +include_directories(${CMAKE_SOURCE_DIR}/include) +# Add source file +add_library(myProgram SHARED src/main.cpp src/myLibrary.cpp) +# [End cmake_minimum_required] + +# [Start CMAKE_VERBOSE_MAKEFILE] +set(CMAKE_VERBOSE_MAKEFILE ON) +# [End CMAKE_VERBOSE_MAKEFILE] + +# [Start msgDirectory] +message(STATUS "Source directory: ${CMAKE_SOURCE_DIR}") +message(STATUS "Include directories: ${CMAKE_INCLUDE_PATH}") +# [Start msgDirectory] \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/src/main/cpp/mian.cpp b/Ndk/Ndk2/UnknownType/src/main/cpp/mian.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d9249bd1fc00ec476871a1b5ce164aecd0966690 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/main/cpp/mian.cpp @@ -0,0 +1,9 @@ +// FAQ: CPP编译报错"A 'unknown type name' error has occurred" +// [Start MyType] +#include "myLibrary.h" +int main() { + MyType obj; + // 使用自定义类型 + return 0; +} +// [End MyType] \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/src/main/cpp/myLibrary.h b/Ndk/Ndk2/UnknownType/src/main/cpp/myLibrary.h new file mode 100644 index 0000000000000000000000000000000000000000..74a8963fe54f6ee393c116bb992f653517df420a --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/main/cpp/myLibrary.h @@ -0,0 +1,11 @@ +// FAQ:# CPP编译报错"A 'unknown type name' error has occurred" +// [Start MyTypeClass] +#ifndef MY_LIBRARY_H +#define MY_LIBRARY_H +class MyType { +public: + MyType() {} + void doSomething(); +}; +#endif +// [End MyTypeClass] \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/src/main/cpp/types/libnativegetarktsobject/Index.d.ts b/Ndk/Ndk2/UnknownType/src/main/cpp/types/libnativegetarktsobject/Index.d.ts new file mode 100644 index 0000000000000000000000000000000000000000..686d2f7349a47b1ed98542d35c96985c990fa3b3 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/main/cpp/types/libnativegetarktsobject/Index.d.ts @@ -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. + */ +/** + * FAQ: Native侧如何获取ArkTS侧Object对象及其成员变量 + */ + +// [Start native_get_ark_ts_object_index] +// index.d.ts +export const callFunction: (a:object) => void; +// [End native_get_ark_ts_object_index] \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/src/main/cpp/types/libnativegetarktsobject/oh-package.json5 b/Ndk/Ndk2/UnknownType/src/main/cpp/types/libnativegetarktsobject/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ea410725a8826704d061021d98cf02aa76cd8016 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/main/cpp/types/libnativegetarktsobject/oh-package.json5 @@ -0,0 +1,6 @@ +{ + "name": "libentry.so", + "types": "./Index.d.ts", + "version": "1.0.0", + "description": "Please describe the basic information." +} \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/src/main/ets/pages/Index.ets b/Ndk/Ndk2/UnknownType/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e2d24ad42693fc877d51bb7820f0a9da68fa135 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/main/ets/pages/Index.ets @@ -0,0 +1,23 @@ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/src/main/ets/unknowntypeability/UnknownTypeAbility.ets b/Ndk/Ndk2/UnknownType/src/main/ets/unknowntypeability/UnknownTypeAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..183dc430ee183dce01576a480611a9ed89df41fd --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/main/ets/unknowntypeability/UnknownTypeAbility.ets @@ -0,0 +1,43 @@ +import { AbilityConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class UnknownTypeAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} diff --git a/Ndk/Ndk2/UnknownType/src/main/module.json5 b/Ndk/Ndk2/UnknownType/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..29d71ec863a340032a7b71d53b73d2798121f38f --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/main/module.json5 @@ -0,0 +1,28 @@ +{ + "module": { + "name": "UnknownType", + "type": "feature", + "description": "$string:module_desc", + "mainElement": "UnknownTypeAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "UnknownTypeAbility", + "srcEntry": "./ets/unknowntypeability/UnknownTypeAbility.ets", + "description": "$string:UnknownTypeAbility_desc", + "icon": "$media:layered_image", + "label": "$string:UnknownTypeAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true + } + ] + } +} \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/src/main/resources/base/element/color.json b/Ndk/Ndk2/UnknownType/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/src/main/resources/base/element/float.json b/Ndk/Ndk2/UnknownType/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/Ndk/Ndk2/UnknownType/src/main/resources/base/element/string.json b/Ndk/Ndk2/UnknownType/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..56635ea902449f0c79af4727bfb55377a1c7baf8 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "UnknownTypeAbility_desc", + "value": "description" + }, + { + "name": "UnknownTypeAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/src/main/resources/base/media/background.png b/Ndk/Ndk2/UnknownType/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/Ndk/Ndk2/UnknownType/src/main/resources/base/media/background.png differ diff --git a/Ndk/Ndk2/UnknownType/src/main/resources/base/media/foreground.png b/Ndk/Ndk2/UnknownType/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/Ndk/Ndk2/UnknownType/src/main/resources/base/media/foreground.png differ diff --git a/Ndk/Ndk2/UnknownType/src/main/resources/base/media/layered_image.json b/Ndk/Ndk2/UnknownType/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/src/main/resources/base/media/startIcon.png b/Ndk/Ndk2/UnknownType/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/Ndk/Ndk2/UnknownType/src/main/resources/base/media/startIcon.png differ diff --git a/Ndk/Ndk2/UnknownType/src/main/resources/base/profile/main_pages.json b/Ndk/Ndk2/UnknownType/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/Ndk/Ndk2/UnknownType/src/mock/mock-config.json5 b/Ndk/Ndk2/UnknownType/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/src/ohosTest/ets/test/Ability.test.ets b/Ndk/Ndk2/UnknownType/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +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/Ndk/Ndk2/UnknownType/src/ohosTest/ets/test/List.test.ets b/Ndk/Ndk2/UnknownType/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/src/ohosTest/module.json5 b/Ndk/Ndk2/UnknownType/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..99ad5dcc7c3087744dce72d1d458bf09656d7e68 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "UnknownType_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/Ndk/Ndk2/UnknownType/src/test/List.test.ets b/Ndk/Ndk2/UnknownType/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/Ndk/Ndk2/UnknownType/src/test/LocalUnit.test.ets b/Ndk/Ndk2/UnknownType/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/Ndk/Ndk2/UnknownType/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // 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. + 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/Ndk/Ndk2/build-profile.json5 b/Ndk/Ndk2/build-profile.json5 index e2f8a00046250911cd7482e5c57fef6c3ccb1ca6..e705198ee23438cf6c8c3fb3c18d96144b8db3aa 100644 --- a/Ndk/Ndk2/build-profile.json5 +++ b/Ndk/Ndk2/build-profile.json5 @@ -228,6 +228,30 @@ ] } ] + }, + { + "name": "UndefinedSymbol", + "srcPath": "./UndefinedSymbol", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "UnknownType", + "srcPath": "./UnknownType", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] } ] } \ No newline at end of file diff --git a/Ndk/Ndk2/log.txt b/Ndk/Ndk2/log.txt index 71f298339cb8d5d6af03382d01d393ef948ce283..22ddb41b8ebb5b22748c23f365eab6dbb54e041c 100644 --- a/Ndk/Ndk2/log.txt +++ b/Ndk/Ndk2/log.txt @@ -1,223 +1,112 @@ -14:15:21:754 log timer task size: 1 -14:15:35:470 log task queue not empty -14:15:35:470 log task size: 1 -14:15:35:470 log before pop task size: 1 -14:15:35:471 log after task size: 0 -14:15:35:981 log timer task size: 1 -14:56:10:017 log task queue not empty -14:56:10:017 log task size: 1 -14:56:10:017 log before pop task size: 1 -14:56:10:017 log after task size: 0 -14:56:10:519 log timer task size: 1 -14:56:11:681 log task queue not empty -14:56:11:681 log task size: 1 -14:56:11:681 log before pop task size: 1 -14:56:11:681 log after task size: 0 -14:56:11:873 log task queue not empty -14:56:11:874 log task size: 1 -14:56:11:874 log before pop task size: 1 -14:56:11:874 log after task size: 0 -14:56:12:187 log timer task size: 1 -14:56:12:379 log timer task size: 1 -14:56:29:617 log task queue not empty -14:56:29:618 log task size: 1 -14:56:29:618 log before pop task size: 1 -14:56:29:618 log after task size: 0 -14:56:30:127 log timer task size: 1 -15:09:43:921 log task queue not empty -15:09:43:921 log task size: 1 -15:09:43:921 log before pop task size: 1 -15:09:43:921 log after task size: 0 -15:09:44:428 log timer task size: 1 -15:09:45:073 log task queue not empty -15:09:45:073 log task size: 1 -15:09:45:073 log before pop task size: 1 -15:09:45:074 log after task size: 0 -15:09:45:576 log timer task size: 1 -15:15:41:442 log task queue not empty -15:15:41:442 log task size: 1 -15:15:41:442 log before pop task size: 1 -15:15:41:442 log after task size: 0 -15:15:41:956 log timer task size: 1 -15:15:42:674 log task queue not empty -15:15:42:674 log task size: 1 -15:15:42:674 log before pop task size: 1 -15:15:42:674 log after task size: 0 -15:15:43:179 log timer task size: 1 -15:28:08:034 log task queue not empty -15:28:08:035 log task size: 1 -15:28:08:035 log before pop task size: 1 -15:28:08:035 log after task size: 0 -15:28:08:537 log timer task size: 1 -15:28:08:562 log task queue not empty -15:28:08:562 log task size: 1 -15:28:08:562 log before pop task size: 1 -15:28:08:562 log after task size: 0 -15:28:09:075 log timer task size: 1 -15:46:52:387 log timer task size: 1 -15:56:19:837 log task queue not empty -15:56:19:837 log task size: 1 -15:56:19:837 log before pop task size: 1 -15:56:19:837 log after task size: 0 -15:56:20:281 log task queue not empty -15:56:20:281 log task size: 1 -15:56:20:281 log before pop task size: 1 -15:56:20:282 log after task size: 0 -15:56:20:350 log timer task size: 1 -15:56:20:792 log timer task size: 1 -16:34:25:953 log task queue not empty -16:34:25:954 log task size: 1 -16:34:25:954 log before pop task size: 1 -16:34:25:954 log after task size: 0 -16:34:25:954 log task queue not empty -16:34:25:954 log task size: 1 -16:34:25:954 log before pop task size: 1 -16:34:25:954 log after task size: 0 -16:34:26:457 log timer task size: 1 -16:34:26:457 log timer task size: 1 -16:34:30:962 log task queue not empty -16:34:30:963 log task size: 1 -16:34:30:963 log before pop task size: 1 -16:34:30:963 log after task size: 0 -16:34:30:965 log task queue not empty -16:34:30:965 log task size: 1 -16:34:30:965 log before pop task size: 1 -16:34:30:965 log after task size: 0 -16:34:30:967 log task queue not empty -16:34:30:967 log task size: 1 -16:34:30:967 log before pop task size: 1 -16:34:30:967 log after task size: 0 -16:34:30:969 log task queue not empty -16:34:30:969 log task size: 1 -16:34:30:969 log before pop task size: 1 -16:34:30:969 log after task size: 0 -16:34:30:976 log task queue not empty -16:34:30:976 log task size: 1 -16:34:30:976 log before pop task size: 1 -16:34:30:976 log after task size: 0 -16:34:31:474 log timer task size: 1 -16:34:31:474 log timer task size: 1 -16:34:31:489 log timer task size: 1 -16:34:33:505 log task queue not empty -16:34:33:505 log task size: 1 -16:34:33:506 log before pop task size: 1 -16:34:33:506 log after task size: 0 -16:34:34:020 log timer task size: 1 -16:34:35:331 log task queue not empty -16:34:35:331 log task size: 1 -16:34:35:331 log before pop task size: 1 -16:34:35:331 log after task size: 0 -16:34:35:810 log task queue not empty -16:34:35:810 log task size: 1 -16:34:35:810 log before pop task size: 1 -16:34:35:810 log after task size: 0 -16:34:35:847 log timer task size: 1 -16:34:36:320 log timer task size: 1 -16:34:37:506 log task queue not empty -16:34:37:507 log task size: 1 -16:34:37:507 log before pop task size: 1 -16:34:37:507 log after task size: 0 -16:34:38:015 log timer task size: 1 -16:34:42:961 log task queue not empty -16:34:42:961 log task size: 1 -16:34:42:961 log before pop task size: 1 -16:34:42:961 log after task size: 0 -16:34:43:462 log timer task size: 1 -16:34:44:176 log task queue not empty -16:34:44:176 log task size: 1 -16:34:44:176 log before pop task size: 1 -16:34:44:176 log after task size: 0 -16:34:44:386 log task queue not empty -16:34:44:386 log task size: 1 -16:34:44:387 log before pop task size: 1 -16:34:44:387 log after task size: 0 -16:34:44:681 log timer task size: 1 -16:34:44:901 log timer task size: 1 -16:34:44:999 log task queue not empty -16:34:44:999 log task size: 1 -16:34:44:999 log before pop task size: 1 -16:34:44:999 log after task size: 0 -16:34:45:500 log timer task size: 1 -16:34:45:610 log task queue not empty -16:34:45:610 log task size: 1 -16:34:45:610 log before pop task size: 1 -16:34:45:610 log after task size: 0 -16:34:46:112 log timer task size: 1 -16:34:50:938 log task queue not empty -16:34:50:938 log task size: 1 -16:34:50:938 log before pop task size: 1 -16:34:50:938 log after task size: 0 -16:34:51:444 log timer task size: 1 -16:34:56:086 log task queue not empty -16:34:56:086 log task size: 1 -16:34:56:086 log before pop task size: 1 -16:34:56:086 log after task size: 0 -16:34:56:087 log task queue not empty -16:34:56:087 log task size: 1 -16:34:56:087 log before pop task size: 1 -16:34:56:087 log after task size: 0 -16:34:56:590 log timer task size: 1 -16:35:01:095 log task queue not empty -16:35:01:095 log task size: 1 -16:35:01:095 log before pop task size: 1 -16:35:01:095 log after task size: 0 -16:35:01:098 log task queue not empty -16:35:01:098 log task size: 1 -16:35:01:098 log before pop task size: 1 -16:35:01:098 log after task size: 0 -16:35:01:609 log timer task size: 1 -16:49:26:575 log task queue not empty -16:49:26:575 log task size: 1 -16:49:26:575 log before pop task size: 1 -16:49:26:575 log after task size: 0 -16:49:27:089 log timer task size: 1 -16:49:28:144 log task queue not empty -16:49:28:144 log task size: 1 -16:49:28:144 log before pop task size: 1 -16:49:28:144 log after task size: 0 -16:49:28:645 log timer task size: 1 -16:49:30:559 log task queue not empty -16:49:30:559 log task size: 1 -16:49:30:559 log before pop task size: 1 -16:49:30:559 log after task size: 0 -16:49:30:560 log task queue not empty -16:49:30:560 log task size: 1 -16:49:30:560 log before pop task size: 1 -16:49:30:560 log after task size: 0 -16:49:31:066 log timer task size: 1 -16:49:35:568 log task queue not empty -16:49:35:568 log task size: 1 -16:49:35:568 log before pop task size: 1 -16:49:35:568 log after task size: 0 -16:49:35:572 log task queue not empty -16:49:35:572 log task size: 1 -16:49:35:572 log before pop task size: 1 -16:49:35:572 log after task size: 0 -16:49:36:078 log timer task size: 1 -09:56:21:903 log timer task size: 1 -15:27:10:692 log task queue not empty -15:27:10:693 log task size: 1 -15:27:10:693 log before pop task size: 1 -15:27:10:693 log after task size: 0 -15:27:10:965 log task queue not empty -15:27:10:965 log task size: 1 -15:27:10:965 log before pop task size: 1 -15:27:10:965 log after task size: 0 -15:27:11:042 log timer task size: 1 -15:27:11:200 log timer task size: 1 -15:27:11:466 log timer task size: 1 -15:27:17:752 log task queue not empty -15:27:17:753 log task size: 1 -15:27:17:753 log before pop task size: 1 -15:27:17:753 log after task size: 0 -15:27:18:257 log timer task size: 1 -15:27:21:520 log task queue not empty -15:27:21:520 log task size: 1 -15:27:21:520 log before pop task size: 1 -15:27:21:520 log after task size: 0 -15:27:22:034 log timer task size: 1 -15:27:26:740 log task queue not empty -15:27:26:740 log task size: 1 -15:27:26:740 log before pop task size: 1 -15:27:26:740 log after task size: 0 -15:27:27:252 log timer task size: 1 +20:20:14:018 log task queue not empty +20:20:14:019 log task size: 1 +20:20:14:019 log before pop task size: 1 +20:20:14:020 log after task size: 0 +20:20:14:538 log timer task size: 1 +20:20:28:448 log task queue not empty +20:20:28:449 log task size: 1 +20:20:28:449 log before pop task size: 1 +20:20:28:449 log after task size: 0 +20:20:28:953 log timer task size: 1 +20:21:00:845 log task queue not empty +20:21:00:845 log task size: 1 +20:21:00:845 log before pop task size: 1 +20:21:00:846 log after task size: 0 +20:21:01:348 log timer task size: 1 +20:21:07:087 log task queue not empty +20:21:07:087 log task size: 1 +20:21:07:088 log before pop task size: 1 +20:21:07:088 log after task size: 0 +20:21:07:594 log timer task size: 1 +20:21:08:156 log task queue not empty +20:21:08:156 log task size: 1 +20:21:08:157 log before pop task size: 1 +20:21:08:157 log after task size: 0 +20:21:08:500 log task queue not empty +20:21:08:501 log task size: 1 +20:21:08:502 log before pop task size: 1 +20:21:08:503 log after task size: 0 +20:21:08:507 log task queue not empty +20:21:08:507 log task size: 1 +20:21:08:508 log before pop task size: 1 +20:21:08:508 log after task size: 0 +20:21:08:660 log timer task size: 1 +20:21:08:715 log task queue not empty +20:21:08:715 log task size: 1 +20:21:08:716 log before pop task size: 1 +20:21:08:716 log after task size: 0 +20:21:08:719 log task queue not empty +20:21:08:720 log task size: 1 +20:21:08:720 log before pop task size: 1 +20:21:08:720 log after task size: 0 +20:21:09:006 log timer task size: 1 +20:21:09:009 log task queue not empty +20:21:09:010 log task size: 1 +20:21:09:010 log before pop task size: 1 +20:21:09:011 log after task size: 0 +20:21:09:015 log task queue not empty +20:21:09:016 log task size: 1 +20:21:09:016 log before pop task size: 1 +20:21:09:017 log after task size: 0 +20:21:09:022 log timer task size: 1 +20:21:09:148 log task queue not empty +20:21:09:148 log task size: 1 +20:21:09:149 log before pop task size: 1 +20:21:09:149 log after task size: 0 +20:21:09:153 log task queue not empty +20:21:09:153 log task size: 1 +20:21:09:154 log before pop task size: 1 +20:21:09:154 log after task size: 0 +20:21:09:228 log timer task size: 1 +20:21:09:228 log timer task size: 1 +20:21:09:526 log timer task size: 1 +20:21:09:665 log timer task size: 1 +20:21:10:101 log task queue not empty +20:21:10:101 log task size: 1 +20:21:10:101 log before pop task size: 1 +20:21:10:102 log after task size: 0 +20:21:10:105 log task queue not empty +20:21:10:105 log task size: 1 +20:21:10:105 log before pop task size: 1 +20:21:10:106 log after task size: 0 +20:21:10:109 log task queue not empty +20:21:10:109 log task size: 1 +20:21:10:110 log before pop task size: 1 +20:21:10:110 log after task size: 0 +20:21:10:113 log task queue not empty +20:21:10:113 log task size: 1 +20:21:10:113 log before pop task size: 1 +20:21:10:114 log after task size: 0 +20:21:10:117 log task queue not empty +20:21:10:118 log task size: 1 +20:21:10:118 log before pop task size: 1 +20:21:10:118 log after task size: 0 +20:21:10:121 log task queue not empty +20:21:10:121 log task size: 1 +20:21:10:122 log before pop task size: 1 +20:21:10:122 log after task size: 0 +20:21:10:604 log timer task size: 1 +20:21:10:619 log timer task size: 1 +20:21:10:620 log timer task size: 1 +20:21:10:620 log timer task size: 1 +20:21:10:635 log timer task size: 1 +20:21:14:234 log task queue not empty +20:21:14:235 log task size: 1 +20:21:14:235 log before pop task size: 1 +20:21:14:235 log after task size: 0 +20:21:14:750 log timer task size: 1 +20:22:35:482 log task queue not empty +20:22:35:482 log task size: 1 +20:22:35:483 log before pop task size: 1 +20:22:35:483 log after task size: 0 +20:22:35:992 log timer task size: 1 +20:27:45:838 log task queue not empty +20:27:45:839 log task size: 1 +20:27:45:840 log before pop task size: 1 +20:27:45:841 log after task size: 0 +20:27:46:576 log timer task size: 1 +20:27:48:396 log task queue not empty +20:27:48:397 log task size: 1 +20:27:48:397 log before pop task size: 1 +20:27:48:397 log after task size: 0 +20:27:49:764 log timer task size: 1 diff --git a/ParameterTest/.gitignore b/ParameterTest/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..d2ff20141ceed86d87c0ea5d99481973005bab2b --- /dev/null +++ b/ParameterTest/.gitignore @@ -0,0 +1,12 @@ +/node_modules +/oh_modules +/local.properties +/.idea +**/build +/.hvigor +.cxx +/.clangd +/.clang-format +/.clang-tidy +**/.test +/.appanalyzer \ No newline at end of file diff --git a/ParameterTest/.parameterFile/parameterFile.json5 b/ParameterTest/.parameterFile/parameterFile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..b36830be76a0e7d8183b8af62d5f9b32e8ba57f1 --- /dev/null +++ b/ParameterTest/.parameterFile/parameterFile.json5 @@ -0,0 +1,12 @@ +{ + "version": "1.0.0", + "dependencies": { + "libtest1": "file:../libtest1" + }, + "devDependencies": { + "libtest2": "file:../libtest2" + }, + "dynamicDependencies": { + "libtest3": "file:../libtest3" + } +} \ No newline at end of file diff --git a/ParameterTest/AppScope/app.json5 b/ParameterTest/AppScope/app.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8bcd3ab6bd274c7b521aa60d6ad30de91ec094d1 --- /dev/null +++ b/ParameterTest/AppScope/app.json5 @@ -0,0 +1,10 @@ +{ + "app": { + "bundleName": "com.example.parametertest", + "vendor": "example", + "versionCode": 1000000, + "versionName": "1.0.0", + "icon": "$media:layered_image", + "label": "$string:app_name" + } +} diff --git a/ParameterTest/AppScope/resources/base/element/string.json b/ParameterTest/AppScope/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..137594d7ac34f72baa1d9c49e2ef1399667837d6 --- /dev/null +++ b/ParameterTest/AppScope/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "app_name", + "value": "ParameterTest" + } + ] +} diff --git a/ParameterTest/AppScope/resources/base/media/background.png b/ParameterTest/AppScope/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ParameterTest/AppScope/resources/base/media/background.png differ diff --git a/ParameterTest/AppScope/resources/base/media/foreground.png b/ParameterTest/AppScope/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ParameterTest/AppScope/resources/base/media/foreground.png differ diff --git a/ParameterTest/AppScope/resources/base/media/layered_image.json b/ParameterTest/AppScope/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ParameterTest/AppScope/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/ParameterTest/build-profile.json5 b/ParameterTest/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c85febcac6b41b2e8f56ccaf59e51348d2c9a68a --- /dev/null +++ b/ParameterTest/build-profile.json5 @@ -0,0 +1,61 @@ +{ + "app": { + "signingConfigs": [], + "products": [ + { + "name": "default", + "signingConfig": "default", + "compatibleSdkVersion": "5.0.4(16)", + "runtimeOS": "HarmonyOS", + "buildOption": { + "strictMode": { + "caseSensitiveCheck": true, + "useNormalizedOHMUrl": true + } + } + } + ], + "buildModeSet": [ + { + "name": "debug", + }, + { + "name": "release" + } + ] + }, + "modules": [ + { + "name": "entry", + "srcPath": "./entry", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "libtest1", + "srcPath": "./libtest1" + }, + { + "name": "libtest3", + "srcPath": "./libtest3", + "targets": [ + { + "name": "default", + "applyToProducts": [ + "default" + ] + } + ] + }, + { + "name": "libtest2", + "srcPath": "./libtest2", + } + ] +} \ No newline at end of file diff --git a/ParameterTest/code-linter.json5 b/ParameterTest/code-linter.json5 new file mode 100644 index 0000000000000000000000000000000000000000..073990fa45394e1f8e85d85418ee60a8953f9b99 --- /dev/null +++ b/ParameterTest/code-linter.json5 @@ -0,0 +1,32 @@ +{ + "files": [ + "**/*.ets" + ], + "ignore": [ + "**/src/ohosTest/**/*", + "**/src/test/**/*", + "**/src/mock/**/*", + "**/node_modules/**/*", + "**/oh_modules/**/*", + "**/build/**/*", + "**/.preview/**/*" + ], + "ruleSet": [ + "plugin:@performance/recommended", + "plugin:@typescript-eslint/recommended" + ], + "rules": { + "@security/no-unsafe-aes": "error", + "@security/no-unsafe-hash": "error", + "@security/no-unsafe-mac": "warn", + "@security/no-unsafe-dh": "error", + "@security/no-unsafe-dsa": "error", + "@security/no-unsafe-ecdsa": "error", + "@security/no-unsafe-rsa-encrypt": "error", + "@security/no-unsafe-rsa-sign": "error", + "@security/no-unsafe-rsa-key": "error", + "@security/no-unsafe-dsa-key": "error", + "@security/no-unsafe-dh-key": "error", + "@security/no-unsafe-3des": "error" + } +} \ No newline at end of file diff --git a/ParameterTest/entry/.gitignore b/ParameterTest/entry/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ParameterTest/entry/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/ParameterTest/entry/build-profile.json5 b/ParameterTest/entry/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4d611879c7913fb0610c686e2399258ab3a6dad1 --- /dev/null +++ b/ParameterTest/entry/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + } + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest", + } + ] +} \ No newline at end of file diff --git a/ParameterTest/entry/hvigorfile.ts b/ParameterTest/entry/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..c6edcd90486dd5a853cf7d34c8647f08414ca7a3 --- /dev/null +++ b/ParameterTest/entry/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hapTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hapTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/ParameterTest/entry/obfuscation-rules.txt b/ParameterTest/entry/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ParameterTest/entry/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/ParameterTest/entry/oh-package.json5 b/ParameterTest/entry/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..248c3b7541a589682a250f86a6d3ecf7414d2d6a --- /dev/null +++ b/ParameterTest/entry/oh-package.json5 @@ -0,0 +1,10 @@ +{ + "name": "entry", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "", + "author": "", + "license": "", + "dependencies": {} +} + diff --git a/ParameterTest/entry/src/main/ets/entryability/EntryAbility.ets b/ParameterTest/entry/src/main/ets/entryability/EntryAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..508880af8c33aa838016d1cd4b2c68be2f447540 --- /dev/null +++ b/ParameterTest/entry/src/main/ets/entryability/EntryAbility.ets @@ -0,0 +1,44 @@ +import { AbilityConstant, ConfigurationConstant, UIAbility, Want } from '@kit.AbilityKit'; +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { window } from '@kit.ArkUI'; + +const DOMAIN = 0x0000; + +export default class EntryAbility extends UIAbility { + onCreate(want: Want, launchParam: AbilityConstant.LaunchParam): void { + this.context.getApplicationContext().setColorMode(ConfigurationConstant.ColorMode.COLOR_MODE_NOT_SET); + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onCreate'); + } + + onDestroy(): void { + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onDestroy'); + } + + onWindowStageCreate(windowStage: window.WindowStage): void { + // Main window is created, set main page for this ability + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageCreate'); + + windowStage.loadContent('pages/Index', (err) => { + if (err.code) { + hilog.error(DOMAIN, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err)); + return; + } + hilog.info(DOMAIN, 'testTag', 'Succeeded in loading the content.'); + }); + } + + onWindowStageDestroy(): void { + // Main window is destroyed, release UI related resources + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onWindowStageDestroy'); + } + + onForeground(): void { + // Ability has brought to foreground + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onForeground'); + } + + onBackground(): void { + // Ability has back to background + hilog.info(DOMAIN, 'testTag', '%{public}s', 'Ability onBackground'); + } +} \ No newline at end of file diff --git a/ParameterTest/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets b/ParameterTest/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e4de99282050bad799ac892eb85ac5449364a51 --- /dev/null +++ b/ParameterTest/entry/src/main/ets/entrybackupability/EntryBackupAbility.ets @@ -0,0 +1,16 @@ +import { hilog } from '@kit.PerformanceAnalysisKit'; +import { BackupExtensionAbility, BundleVersion } from '@kit.CoreFileKit'; + +const DOMAIN = 0x0000; + +export default class EntryBackupAbility extends BackupExtensionAbility { + async onBackup() { + hilog.info(DOMAIN, 'testTag', 'onBackup ok'); + await Promise.resolve(); + } + + async onRestore(bundleVersion: BundleVersion) { + hilog.info(DOMAIN, 'testTag', 'onRestore ok %{public}s', JSON.stringify(bundleVersion)); + await Promise.resolve(); + } +} \ No newline at end of file diff --git a/ParameterTest/entry/src/main/ets/pages/Index.ets b/ParameterTest/entry/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..8e2d24ad42693fc877d51bb7820f0a9da68fa135 --- /dev/null +++ b/ParameterTest/entry/src/main/ets/pages/Index.ets @@ -0,0 +1,23 @@ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + RelativeContainer() { + Text(this.message) + .id('HelloWorld') + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .alignRules({ + center: { anchor: '__container__', align: VerticalAlign.Center }, + middle: { anchor: '__container__', align: HorizontalAlign.Center } + }) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .height('100%') + .width('100%') + } +} \ No newline at end of file diff --git a/ParameterTest/entry/src/main/module.json5 b/ParameterTest/entry/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a1cea8b6a4560cee7bda7a2db52f310c035ab6c8 --- /dev/null +++ b/ParameterTest/entry/src/main/module.json5 @@ -0,0 +1,52 @@ +{ + "module": { + "name": "entry", + "type": "entry", + "description": "$string:module_desc", + "mainElement": "EntryAbility", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false, + "pages": "$profile:main_pages", + "abilities": [ + { + "name": "EntryAbility", + "srcEntry": "./ets/entryability/EntryAbility.ets", + "description": "$string:EntryAbility_desc", + "icon": "$media:layered_image", + "label": "$string:EntryAbility_label", + "startWindowIcon": "$media:startIcon", + "startWindowBackground": "$color:start_window_background", + "exported": true, + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ] + } + ], + "extensionAbilities": [ + { + "name": "EntryBackupAbility", + "srcEntry": "./ets/entrybackupability/EntryBackupAbility.ets", + "type": "backup", + "exported": false, + "metadata": [ + { + "name": "ohos.extension.backup", + "resource": "$profile:backup_config" + } + ], + } + ] + } +} \ No newline at end of file diff --git a/ParameterTest/entry/src/main/resources/base/element/color.json b/ParameterTest/entry/src/main/resources/base/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..3c712962da3c2751c2b9ddb53559afcbd2b54a02 --- /dev/null +++ b/ParameterTest/entry/src/main/resources/base/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#FFFFFF" + } + ] +} \ No newline at end of file diff --git a/ParameterTest/entry/src/main/resources/base/element/float.json b/ParameterTest/entry/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/ParameterTest/entry/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/ParameterTest/entry/src/main/resources/base/element/string.json b/ParameterTest/entry/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f94595515a99e0c828807e243494f57f09251930 --- /dev/null +++ b/ParameterTest/entry/src/main/resources/base/element/string.json @@ -0,0 +1,16 @@ +{ + "string": [ + { + "name": "module_desc", + "value": "module description" + }, + { + "name": "EntryAbility_desc", + "value": "description" + }, + { + "name": "EntryAbility_label", + "value": "label" + } + ] +} \ No newline at end of file diff --git a/ParameterTest/entry/src/main/resources/base/media/background.png b/ParameterTest/entry/src/main/resources/base/media/background.png new file mode 100644 index 0000000000000000000000000000000000000000..923f2b3f27e915d6871871deea0420eb45ce102f Binary files /dev/null and b/ParameterTest/entry/src/main/resources/base/media/background.png differ diff --git a/ParameterTest/entry/src/main/resources/base/media/foreground.png b/ParameterTest/entry/src/main/resources/base/media/foreground.png new file mode 100644 index 0000000000000000000000000000000000000000..97014d3e10e5ff511409c378cd4255713aecd85f Binary files /dev/null and b/ParameterTest/entry/src/main/resources/base/media/foreground.png differ diff --git a/ParameterTest/entry/src/main/resources/base/media/layered_image.json b/ParameterTest/entry/src/main/resources/base/media/layered_image.json new file mode 100644 index 0000000000000000000000000000000000000000..fb49920440fb4d246c82f9ada275e26123a2136a --- /dev/null +++ b/ParameterTest/entry/src/main/resources/base/media/layered_image.json @@ -0,0 +1,7 @@ +{ + "layered-image": + { + "background" : "$media:background", + "foreground" : "$media:foreground" + } +} \ No newline at end of file diff --git a/ParameterTest/entry/src/main/resources/base/media/startIcon.png b/ParameterTest/entry/src/main/resources/base/media/startIcon.png new file mode 100644 index 0000000000000000000000000000000000000000..205ad8b5a8a42e8762fbe4899b8e5e31ce822b8b Binary files /dev/null and b/ParameterTest/entry/src/main/resources/base/media/startIcon.png differ diff --git a/ParameterTest/entry/src/main/resources/base/profile/backup_config.json b/ParameterTest/entry/src/main/resources/base/profile/backup_config.json new file mode 100644 index 0000000000000000000000000000000000000000..78f40ae7c494d71e2482278f359ec790ca73471a --- /dev/null +++ b/ParameterTest/entry/src/main/resources/base/profile/backup_config.json @@ -0,0 +1,3 @@ +{ + "allowToBackupRestore": true +} \ No newline at end of file diff --git a/ParameterTest/entry/src/main/resources/base/profile/main_pages.json b/ParameterTest/entry/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/ParameterTest/entry/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/ParameterTest/entry/src/main/resources/dark/element/color.json b/ParameterTest/entry/src/main/resources/dark/element/color.json new file mode 100644 index 0000000000000000000000000000000000000000..79b11c2747aec33e710fd3a7b2b3c94dd9965499 --- /dev/null +++ b/ParameterTest/entry/src/main/resources/dark/element/color.json @@ -0,0 +1,8 @@ +{ + "color": [ + { + "name": "start_window_background", + "value": "#000000" + } + ] +} \ No newline at end of file diff --git a/ParameterTest/entry/src/mock/mock-config.json5 b/ParameterTest/entry/src/mock/mock-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7a73a41bfdf76d6f793007240d80983a52f15f97 --- /dev/null +++ b/ParameterTest/entry/src/mock/mock-config.json5 @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/ParameterTest/entry/src/ohosTest/ets/test/Ability.test.ets b/ParameterTest/entry/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/ParameterTest/entry/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +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/ParameterTest/entry/src/ohosTest/ets/test/List.test.ets b/ParameterTest/entry/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/ParameterTest/entry/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/ParameterTest/entry/src/ohosTest/module.json5 b/ParameterTest/entry/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..55725a929993a8a18b3808d41ef037759440488b --- /dev/null +++ b/ParameterTest/entry/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "entry_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/ParameterTest/entry/src/test/List.test.ets b/ParameterTest/entry/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/ParameterTest/entry/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/ParameterTest/entry/src/test/LocalUnit.test.ets b/ParameterTest/entry/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/ParameterTest/entry/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // 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. + 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/ParameterTest/hvigor/hvigor-config.json5 b/ParameterTest/hvigor/hvigor-config.json5 new file mode 100644 index 0000000000000000000000000000000000000000..a63d34ae5ce5833b3874807e2b8d472687c6c5bf --- /dev/null +++ b/ParameterTest/hvigor/hvigor-config.json5 @@ -0,0 +1,22 @@ +{ + "modelVersion": "5.0.4", + "dependencies": { + }, + "execution": { + // "analyze": "normal", /* Define the build analyze mode. Value: [ "normal" | "advanced" | false ]. Default: "normal" */ + // "daemon": true, /* Enable daemon compilation. Value: [ true | false ]. Default: true */ + // "incremental": true, /* Enable incremental compilation. Value: [ true | false ]. Default: true */ + // "parallel": true, /* Enable parallel compilation. Value: [ true | false ]. Default: true */ + // "typeCheck": false, /* Enable typeCheck. Value: [ true | false ]. Default: false */ + }, + "logging": { + // "level": "info" /* Define the log level. Value: [ "debug" | "info" | "warn" | "error" ]. Default: "info" */ + }, + "debugging": { + // "stacktrace": false /* Disable stacktrace compilation. Value: [ true | false ]. Default: false */ + }, + "nodeOptions": { + // "maxOldSpaceSize": 8192 /* Enable nodeOptions maxOldSpaceSize compilation. Unit M. Used for the daemon process. Default: 8192*/ + // "exposeGC": true /* Enable to trigger garbage collection explicitly. Default: true*/ + } +} diff --git a/ParameterTest/hvigorfile.ts b/ParameterTest/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..f3cb9f1a87a81687554a76283af8df27d8bda775 --- /dev/null +++ b/ParameterTest/hvigorfile.ts @@ -0,0 +1,6 @@ +import { appTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: appTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/ParameterTest/libtest1/.gitignore b/ParameterTest/libtest1/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ParameterTest/libtest1/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/ParameterTest/libtest1/BuildProfile.ets b/ParameterTest/libtest1/BuildProfile.ets new file mode 100644 index 0000000000000000000000000000000000000000..6033e79a01b85a7b72e746eb3c8eba704e312bd5 --- /dev/null +++ b/ParameterTest/libtest1/BuildProfile.ets @@ -0,0 +1,17 @@ +/** + * Use these variables when you tailor your ArkTS code. They must be of the const type. + */ +export const HAR_VERSION = '1.0.0'; +export const BUILD_MODE_NAME = 'release'; +export const DEBUG = false; +export const TARGET_NAME = 'default'; + +/** + * BuildProfile Class is used only for compatibility purposes. + */ +export default class BuildProfile { + static readonly HAR_VERSION = HAR_VERSION; + static readonly BUILD_MODE_NAME = BUILD_MODE_NAME; + static readonly DEBUG = DEBUG; + static readonly TARGET_NAME = TARGET_NAME; +} \ No newline at end of file diff --git a/ParameterTest/libtest1/Index.ets b/ParameterTest/libtest1/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..42bf4161c271e1b14d42a7ab98c982acc9bc3592 --- /dev/null +++ b/ParameterTest/libtest1/Index.ets @@ -0,0 +1 @@ +export { MainPage } from './src/main/ets/components/MainPage'; diff --git a/ParameterTest/libtest1/build-profile.json5 b/ParameterTest/libtest1/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e6773f9f5d76a66d6d19fddc9c6ddb3f5621d3b1 --- /dev/null +++ b/ParameterTest/libtest1/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/ParameterTest/libtest1/consumer-rules.txt b/ParameterTest/libtest1/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/ParameterTest/libtest1/hvigorfile.ts b/ParameterTest/libtest1/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42187071482d292588ad40babeda74f7b8d97a23 --- /dev/null +++ b/ParameterTest/libtest1/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/ParameterTest/libtest1/obfuscation-rules.txt b/ParameterTest/libtest1/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ParameterTest/libtest1/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/ParameterTest/libtest1/oh-package.json5 b/ParameterTest/libtest1/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..3a0d100ce8fb200464597561517d76dc0a1065cf --- /dev/null +++ b/ParameterTest/libtest1/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "libtest1", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} \ No newline at end of file diff --git a/ParameterTest/libtest1/src/main/ets/components/MainPage.ets b/ParameterTest/libtest1/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..9de5eb33fe973c00e1ddc28c9f079ace6d473711 --- /dev/null +++ b/ParameterTest/libtest1/src/main/ets/components/MainPage.ets @@ -0,0 +1,19 @@ +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/ParameterTest/libtest1/src/main/module.json5 b/ParameterTest/libtest1/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ebe580fb6912df42cfeaf28f0e19ab6d231e9cc5 --- /dev/null +++ b/ParameterTest/libtest1/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "libtest1", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} \ No newline at end of file diff --git a/ParameterTest/libtest1/src/main/resources/base/element/float.json b/ParameterTest/libtest1/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/ParameterTest/libtest1/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/ParameterTest/libtest1/src/main/resources/base/element/string.json b/ParameterTest/libtest1/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f51a9c8461a55f6312ef950344e3145b7f82d607 --- /dev/null +++ b/ParameterTest/libtest1/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/ParameterTest/libtest1/src/ohosTest/ets/test/Ability.test.ets b/ParameterTest/libtest1/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/ParameterTest/libtest1/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +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/ParameterTest/libtest1/src/ohosTest/ets/test/List.test.ets b/ParameterTest/libtest1/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/ParameterTest/libtest1/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/ParameterTest/libtest1/src/ohosTest/module.json5 b/ParameterTest/libtest1/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..16ed32cb2e041396844c1622bdc850e48c6bb388 --- /dev/null +++ b/ParameterTest/libtest1/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "libtest1_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/ParameterTest/libtest1/src/test/List.test.ets b/ParameterTest/libtest1/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/ParameterTest/libtest1/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/ParameterTest/libtest1/src/test/LocalUnit.test.ets b/ParameterTest/libtest1/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/ParameterTest/libtest1/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // 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. + 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/ParameterTest/libtest2/.gitignore b/ParameterTest/libtest2/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ParameterTest/libtest2/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/ParameterTest/libtest2/Index.ets b/ParameterTest/libtest2/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..42bf4161c271e1b14d42a7ab98c982acc9bc3592 --- /dev/null +++ b/ParameterTest/libtest2/Index.ets @@ -0,0 +1 @@ +export { MainPage } from './src/main/ets/components/MainPage'; diff --git a/ParameterTest/libtest2/build-profile.json5 b/ParameterTest/libtest2/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..e6773f9f5d76a66d6d19fddc9c6ddb3f5621d3b1 --- /dev/null +++ b/ParameterTest/libtest2/build-profile.json5 @@ -0,0 +1,31 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + }, + "consumerFiles": [ + "./consumer-rules.txt" + ] + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} diff --git a/ParameterTest/libtest2/consumer-rules.txt b/ParameterTest/libtest2/consumer-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/ParameterTest/libtest2/hvigorfile.ts b/ParameterTest/libtest2/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..42187071482d292588ad40babeda74f7b8d97a23 --- /dev/null +++ b/ParameterTest/libtest2/hvigorfile.ts @@ -0,0 +1,6 @@ +import { harTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: harTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/ParameterTest/libtest2/obfuscation-rules.txt b/ParameterTest/libtest2/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ParameterTest/libtest2/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/ParameterTest/libtest2/oh-package.json5 b/ParameterTest/libtest2/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..c814ac5bbba582e79b4a2dea35b0de7cb42309a3 --- /dev/null +++ b/ParameterTest/libtest2/oh-package.json5 @@ -0,0 +1,9 @@ +{ + "name": "libtest2", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "dependencies": {} +} diff --git a/ParameterTest/libtest2/src/main/ets/components/MainPage.ets b/ParameterTest/libtest2/src/main/ets/components/MainPage.ets new file mode 100644 index 0000000000000000000000000000000000000000..9de5eb33fe973c00e1ddc28c9f079ace6d473711 --- /dev/null +++ b/ParameterTest/libtest2/src/main/ets/components/MainPage.ets @@ -0,0 +1,19 @@ +@Component +export struct MainPage { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .width('100%') + } + .height('100%') + } +} diff --git a/ParameterTest/libtest2/src/main/module.json5 b/ParameterTest/libtest2/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..12dafd18885e2f3021176eb67bbf81e69635df18 --- /dev/null +++ b/ParameterTest/libtest2/src/main/module.json5 @@ -0,0 +1,11 @@ +{ + "module": { + "name": "libtest2", + "type": "har", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ] + } +} diff --git a/ParameterTest/libtest2/src/main/resources/base/element/float.json b/ParameterTest/libtest2/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/ParameterTest/libtest2/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/ParameterTest/libtest2/src/main/resources/base/element/string.json b/ParameterTest/libtest2/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..f51a9c8461a55f6312ef950344e3145b7f82d607 --- /dev/null +++ b/ParameterTest/libtest2/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "page_show", + "value": "page from package" + } + ] +} diff --git a/ParameterTest/libtest2/src/ohosTest/ets/test/Ability.test.ets b/ParameterTest/libtest2/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/ParameterTest/libtest2/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +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/ParameterTest/libtest2/src/ohosTest/ets/test/List.test.ets b/ParameterTest/libtest2/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/ParameterTest/libtest2/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/ParameterTest/libtest2/src/ohosTest/module.json5 b/ParameterTest/libtest2/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..4c72cb31a7dc46be5486458137b6573d11f51ecb --- /dev/null +++ b/ParameterTest/libtest2/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "libtest2_test", + "type": "feature", + "deviceTypes": [ + "default", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} diff --git a/ParameterTest/libtest2/src/test/List.test.ets b/ParameterTest/libtest2/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/ParameterTest/libtest2/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/ParameterTest/libtest2/src/test/LocalUnit.test.ets b/ParameterTest/libtest2/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/ParameterTest/libtest2/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // 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. + 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/ParameterTest/libtest3/.gitignore b/ParameterTest/libtest3/.gitignore new file mode 100644 index 0000000000000000000000000000000000000000..e2713a2779c5a3e0eb879efe6115455592caeea5 --- /dev/null +++ b/ParameterTest/libtest3/.gitignore @@ -0,0 +1,6 @@ +/node_modules +/oh_modules +/.preview +/build +/.cxx +/.test \ No newline at end of file diff --git a/ParameterTest/libtest3/Index.ets b/ParameterTest/libtest3/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..aae957d81d252f33754de5e81c49a2e50361bea4 --- /dev/null +++ b/ParameterTest/libtest3/Index.ets @@ -0,0 +1 @@ +export { add } from './src/main/ets/utils/Calc'; \ No newline at end of file diff --git a/ParameterTest/libtest3/build-profile.json5 b/ParameterTest/libtest3/build-profile.json5 new file mode 100644 index 0000000000000000000000000000000000000000..ce80db2a169f21a98e0d82d0fb4e67d5be90ac53 --- /dev/null +++ b/ParameterTest/libtest3/build-profile.json5 @@ -0,0 +1,28 @@ +{ + "apiType": "stageMode", + "buildOption": { + }, + "buildOptionSet": [ + { + "name": "release", + "arkOptions": { + "obfuscation": { + "ruleOptions": { + "enable": false, + "files": [ + "./obfuscation-rules.txt" + ] + } + } + }, + }, + ], + "targets": [ + { + "name": "default" + }, + { + "name": "ohosTest" + } + ] +} \ No newline at end of file diff --git a/ParameterTest/libtest3/hvigorfile.ts b/ParameterTest/libtest3/hvigorfile.ts new file mode 100644 index 0000000000000000000000000000000000000000..d993120bd71f5f5dfe04480be9dc5f73c00c2599 --- /dev/null +++ b/ParameterTest/libtest3/hvigorfile.ts @@ -0,0 +1,6 @@ +import { hspTasks } from '@ohos/hvigor-ohos-plugin'; + +export default { + system: hspTasks, /* Built-in plugin of Hvigor. It cannot be modified. */ + plugins:[] /* Custom plugin to extend the functionality of Hvigor. */ +} diff --git a/ParameterTest/libtest3/obfuscation-rules.txt b/ParameterTest/libtest3/obfuscation-rules.txt new file mode 100644 index 0000000000000000000000000000000000000000..272efb6ca3f240859091bbbfc7c5802d52793b0b --- /dev/null +++ b/ParameterTest/libtest3/obfuscation-rules.txt @@ -0,0 +1,23 @@ +# Define project specific obfuscation rules here. +# You can include the obfuscation configuration files in the current module's build-profile.json5. +# +# For more details, see +# https://developer.huawei.com/consumer/cn/doc/harmonyos-guides-V5/source-obfuscation-V5 + +# Obfuscation options: +# -disable-obfuscation: disable all obfuscations +# -enable-property-obfuscation: obfuscate the property names +# -enable-toplevel-obfuscation: obfuscate the names in the global scope +# -compact: remove unnecessary blank spaces and all line feeds +# -remove-log: remove all console.* statements +# -print-namecache: print the name cache that contains the mapping from the old names to new names +# -apply-namecache: reuse the given cache file + +# Keep options: +# -keep-property-name: specifies property names that you want to keep +# -keep-global-name: specifies names that you want to keep in the global scope + +-enable-property-obfuscation +-enable-toplevel-obfuscation +-enable-filename-obfuscation +-enable-export-obfuscation \ No newline at end of file diff --git a/ParameterTest/libtest3/oh-package.json5 b/ParameterTest/libtest3/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..09d0c49519c60546856851552880f3f8169f7137 --- /dev/null +++ b/ParameterTest/libtest3/oh-package.json5 @@ -0,0 +1,11 @@ +{ + "name": "libtest3", + "version": "1.0.0", + "description": "Please describe the basic information.", + "main": "Index.ets", + "author": "", + "license": "Apache-2.0", + "packageType": "InterfaceHar", + "dependencies": { + } +} \ No newline at end of file diff --git a/ParameterTest/libtest3/src/main/ets/pages/Index.ets b/ParameterTest/libtest3/src/main/ets/pages/Index.ets new file mode 100644 index 0000000000000000000000000000000000000000..aa2bbab626aae97d640ad63d4cfdad3465a43e3d --- /dev/null +++ b/ParameterTest/libtest3/src/main/ets/pages/Index.ets @@ -0,0 +1,20 @@ +@Entry +@Component +struct Index { + @State message: string = 'Hello World'; + + build() { + Row() { + Column() { + Text(this.message) + .fontSize($r('app.float.page_text_font_size')) + .fontWeight(FontWeight.Bold) + .onClick(() => { + this.message = 'Welcome'; + }) + } + .width('100%') + } + .height('100%') + } +} \ No newline at end of file diff --git a/ParameterTest/libtest3/src/main/ets/utils/Calc.ets b/ParameterTest/libtest3/src/main/ets/utils/Calc.ets new file mode 100644 index 0000000000000000000000000000000000000000..08ab263da026007816dc1f175f5ebb19a989ec20 --- /dev/null +++ b/ParameterTest/libtest3/src/main/ets/utils/Calc.ets @@ -0,0 +1,3 @@ +export function add(a: number, b: number) { + return a + b; +} \ No newline at end of file diff --git a/ParameterTest/libtest3/src/main/module.json5 b/ParameterTest/libtest3/src/main/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..7e1d9e5e209cb313085b936da770024d4c9ea6c6 --- /dev/null +++ b/ParameterTest/libtest3/src/main/module.json5 @@ -0,0 +1,14 @@ +{ + "module": { + "name": "libtest3", + "type": "shared", + "description": "$string:shared_desc", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "pages": "$profile:main_pages" + } +} \ No newline at end of file diff --git a/ParameterTest/libtest3/src/main/resources/base/element/float.json b/ParameterTest/libtest3/src/main/resources/base/element/float.json new file mode 100644 index 0000000000000000000000000000000000000000..33ea22304f9b1485b5f22d811023701b5d4e35b6 --- /dev/null +++ b/ParameterTest/libtest3/src/main/resources/base/element/float.json @@ -0,0 +1,8 @@ +{ + "float": [ + { + "name": "page_text_font_size", + "value": "50fp" + } + ] +} diff --git a/ParameterTest/libtest3/src/main/resources/base/element/string.json b/ParameterTest/libtest3/src/main/resources/base/element/string.json new file mode 100644 index 0000000000000000000000000000000000000000..98e1d8a84b3d8539ea33e79fe2ac593a05d23bb4 --- /dev/null +++ b/ParameterTest/libtest3/src/main/resources/base/element/string.json @@ -0,0 +1,8 @@ +{ + "string": [ + { + "name": "shared_desc", + "value": "description" + } + ] +} \ No newline at end of file diff --git a/ParameterTest/libtest3/src/main/resources/base/profile/main_pages.json b/ParameterTest/libtest3/src/main/resources/base/profile/main_pages.json new file mode 100644 index 0000000000000000000000000000000000000000..1898d94f58d6128ab712be2c68acc7c98e9ab9ce --- /dev/null +++ b/ParameterTest/libtest3/src/main/resources/base/profile/main_pages.json @@ -0,0 +1,5 @@ +{ + "src": [ + "pages/Index" + ] +} diff --git a/ParameterTest/libtest3/src/ohosTest/ets/test/Ability.test.ets b/ParameterTest/libtest3/src/ohosTest/ets/test/Ability.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..85c78f67579d6e31b5f5aeea463e216b9b141048 --- /dev/null +++ b/ParameterTest/libtest3/src/ohosTest/ets/test/Ability.test.ets @@ -0,0 +1,35 @@ +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/ParameterTest/libtest3/src/ohosTest/ets/test/List.test.ets b/ParameterTest/libtest3/src/ohosTest/ets/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..794c7dc4ed66bd98fa3865e07922906e2fcef545 --- /dev/null +++ b/ParameterTest/libtest3/src/ohosTest/ets/test/List.test.ets @@ -0,0 +1,5 @@ +import abilityTest from './Ability.test'; + +export default function testsuite() { + abilityTest(); +} \ No newline at end of file diff --git a/ParameterTest/libtest3/src/ohosTest/module.json5 b/ParameterTest/libtest3/src/ohosTest/module.json5 new file mode 100644 index 0000000000000000000000000000000000000000..82057110396cf516f0fdb979d6420f0dcfb79aed --- /dev/null +++ b/ParameterTest/libtest3/src/ohosTest/module.json5 @@ -0,0 +1,13 @@ +{ + "module": { + "name": "libtest3_test", + "type": "feature", + "deviceTypes": [ + "phone", + "tablet", + "2in1" + ], + "deliveryWithInstall": true, + "installationFree": false + } +} \ No newline at end of file diff --git a/ParameterTest/libtest3/src/test/List.test.ets b/ParameterTest/libtest3/src/test/List.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..bb5b5c3731e283dd507c847560ee59bde477bbc7 --- /dev/null +++ b/ParameterTest/libtest3/src/test/List.test.ets @@ -0,0 +1,5 @@ +import localUnitTest from './LocalUnit.test'; + +export default function testsuite() { + localUnitTest(); +} \ No newline at end of file diff --git a/ParameterTest/libtest3/src/test/LocalUnit.test.ets b/ParameterTest/libtest3/src/test/LocalUnit.test.ets new file mode 100644 index 0000000000000000000000000000000000000000..165fc1615ee8618b4cb6a622f144a9a707eee99f --- /dev/null +++ b/ParameterTest/libtest3/src/test/LocalUnit.test.ets @@ -0,0 +1,33 @@ +import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium'; + +export default function localUnitTest() { + describe('localUnitTest', () => { + // 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. + 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/ParameterTest/oh-package-lock.json5 b/ParameterTest/oh-package-lock.json5 new file mode 100644 index 0000000000000000000000000000000000000000..8a494cc4e53827e39035e30fbe0aed24728996d6 --- /dev/null +++ b/ParameterTest/oh-package-lock.json5 @@ -0,0 +1,33 @@ +{ + "meta": { + "stableOrder": true + }, + "lockfileVersion": 3, + "ATTENTION": "THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.", + "specifiers": { + "libtest1@libtest1": "libtest1@libtest1", + "libtest2@libtest2": "libtest2@libtest2", + "libtest3@libtest3": "libtest3@libtest3" + }, + "packages": { + "libtest1@libtest1": { + "name": "libtest1", + "version": "1.0.0", + "resolved": "libtest1", + "registryType": "local" + }, + "libtest2@libtest2": { + "name": "libtest2", + "version": "1.0.0", + "resolved": "libtest2", + "registryType": "local" + }, + "libtest3@libtest3": { + "name": "libtest3", + "version": "1.0.0", + "resolved": "libtest3", + "registryType": "local", + "packageType": "InterfaceHar" + } + } +} \ No newline at end of file diff --git a/ParameterTest/oh-package.json5 b/ParameterTest/oh-package.json5 new file mode 100644 index 0000000000000000000000000000000000000000..fa8fe5df602e4888cddbb520a440c01ffa6dbac7 --- /dev/null +++ b/ParameterTest/oh-package.json5 @@ -0,0 +1,21 @@ +// [Start parameterJson5] +{ + "name": "parameter-test", + "version": "@param:version", + "modelVersion": "5.0.4", + "description": "test desc.", + "main": "index.ets", + "author": "test author", + "license": "ISC", + "dependencies": { + "libtest1": "@param:dependencies.libtest1" + }, + "devDependencies": { + "libtest2": "@param:devDependencies.libtest2" + }, + "dynamicDependencies": { + "libtest3": "@param:dynamicDependencies.libtest3" + }, + "parameterFile": '.parameterFile/parameterFile.json5',// Enable parameterization and specify the path to the parameterized configuration file +} +// [// [End parameterJson5]] \ No newline at end of file