diff --git a/ApiUsingStandards/README.md b/ApiUsingStandards/README.md index d3beb85e82c68fbe4d046ee4860b67cb8ef392ee..13657f235f8028cc482b1d4a70c83d1d288b75d8 100644 --- a/ApiUsingStandards/README.md +++ b/ApiUsingStandards/README.md @@ -6,13 +6,20 @@ ### 使用说明 -进入首面,加载示例逻辑。 +不涉及。 ### 工程目录 ``` -├──entry/src/main/ets +├──entry/src/main/ets +│ ├──cpp +│ │ ├──CMakeList.txt // CMake文件 +│ │ ├──napi_init.cpp // napi初始化 +│ │ └──callbackTest.cpp // callback测试类 +│ ├──cpp/types/libentry +│ │ ├──oh-package.json5 // lib打包信息 +│ │ └──Index.d.ts // lib接口索引 │ ├──entryability │ │ └──EntryAbility.ets // 入口类 │ ├──entrybackupability @@ -31,7 +38,7 @@ ### 具体实现 -1. 主要介绍易错API的使用规范,提供代码示例。 +1. 主要配套文档介绍易错API的使用规范。 ### 相关权限 diff --git a/ApiUsingStandards/entry/src/main/ets/pages/AVImageGenerator.ets b/ApiUsingStandards/entry/src/main/ets/pages/AVImageGenerator.ets index 074d10ad447a9359ca6c310456cf6673b0cbea70..968c0fce2c6f4015a8acf4b74074c5aa43347b11 100644 --- a/ApiUsingStandards/entry/src/main/ets/pages/AVImageGenerator.ets +++ b/ApiUsingStandards/entry/src/main/ets/pages/AVImageGenerator.ets @@ -17,7 +17,6 @@ import { media } from '@kit.MediaKit' import { image } from '@kit.ImageKit' import { fileIo as fs, ReadOptions } from '@kit.CoreFileKit'; import { display } from '@kit.ArkUI'; -import { common } from '@kit.AbilityKit'; class AVImageGeneratorClass { pixelMap: image.PixelMap[] = []; @@ -32,53 +31,49 @@ class AVImageGeneratorClass { videoHeight: number = 0; // [Start av_image_generator_class] - async fetchFrame() { - await this.fetchMeta() + async fetchFrame(): Promise { + await this.fetchMeta(); if (canIUse("SystemCapability.Multimedia.Media.AVImageGenerator")) { - this.pixelMap = new Array - let avImageGenerator: media.AVImageGenerator = await media.createAVImageGenerator() + this.pixelMap = new Array; + let avImageGenerator: media.AVImageGenerator = await media.createAVImageGenerator(); // raw fd - avImageGenerator.fdSrc = fs.openSync(this.rootPath + this.testFilename) + avImageGenerator.fdSrc = fs.openSync(this.rootPath + this.testFilename); for (let i = 0; i < 6; i++) { - console.info(`time real ${this.diffTime[i]}`) + console.info(`time real ${this.diffTime[i]}`); let pixelMap = await avImageGenerator.fetchFrameByTime(this.diffTime[i], this.seekOption, - { width: this.pixelMapWidth, height: this.pixelMapHeight }) - this.pixelMap.push(pixelMap) + { width: this.pixelMapWidth, height: this.pixelMapHeight }); + this.pixelMap.push(pixelMap); if (i == 0) { - this.pixelLcd = pixelMap - let rate = pixelMap.getImageInfoSync().size.height / pixelMap.getImageInfoSync().size.width + this.pixelLcd = pixelMap; + let rate = pixelMap.getImageInfoSync().size.height / pixelMap.getImageInfoSync().size.width; this.lcdHeight = - display.getDefaultDisplaySync().width / 2 / display.getDefaultDisplaySync().densityPixels * rate + display.getDefaultDisplaySync().width / 2 / display.getDefaultDisplaySync().densityPixels * rate; } - let imageInfo: image.ImageInfo = pixelMap.getImageInfoSync() - console.info(`colorFormat ${imageInfo.pixelFormat} width ${imageInfo.size.width} height ${imageInfo.size.height} isHdr ${imageInfo.isHdr}`) + let imageInfo: image.ImageInfo = pixelMap.getImageInfoSync(); + console.info(`colorFormat ${imageInfo.pixelFormat} width ${imageInfo.size.width} height ${imageInfo.size.height} isHdr ${imageInfo.isHdr}`); } } } - async fetchMeta() { + async fetchMeta(): Promise { if (canIUse("SystemCapability.Multimedia.Media.AVMetadataExtractor")) { - console.info(`typeof ${typeof media.createAVMetadataExtractor()}`) - let avMetadataExtractor: media.AVMetadataExtractor = await media.createAVMetadataExtractor() - - + console.info(`typeof ${typeof media.createAVMetadataExtractor()}`); + let avMetadataExtractor: media.AVMetadataExtractor = await media.createAVMetadataExtractor(); let fd: number = fs.openSync(this.rootPath + this.testFilename).fd; let fileSize: number = fs.statSync(this.rootPath + this.testFilename).size; - - let dataSrc: media.AVDataSrcDescriptor = { fileSize: fileSize, callback: (buffer, len, pos) => { if (buffer == undefined || len == undefined || pos == undefined) { - console.error(`dataSrc callback param invalid`) - return -1 + console.error(`dataSrc callback param invalid`); + return -1; } let options: ReadOptions = { offset: pos, length: len } - let num = fs.readSync(fd, buffer, options) - console.info('readAt end, num: ' + num) + let num = fs.readSync(fd, buffer, options); + console.info('readAt end, num: ' + num); if (num > 0 && fileSize >= pos) { return num; } @@ -86,43 +81,36 @@ class AVImageGeneratorClass { } } - - avMetadataExtractor.dataSrc = dataSrc - - - let metadata: media.AVMetadata - - + avMetadataExtractor.dataSrc = dataSrc; + let metadata: media.AVMetadata; try { - metadata = await avMetadataExtractor.fetchMetadata() + metadata = await avMetadataExtractor.fetchMetadata(); } catch (error) { - console.info('error code ' + error.code) - return + console.info('error code ' + error.code); + return; } - - - console.info(`metadata ${JSON.stringify(metadata)}`) + console.info(`metadata ${JSON.stringify(metadata)}`); if (metadata.duration) { - console.info(`fetchMetadata success duration ${metadata.duration}`) - let duration = parseInt(metadata.duration) * 1000 - let pick = duration / 5 - this.diffTime[0] = 0 - this.diffTime[5] = duration - let time = pick + console.info(`fetchMetadata success duration ${metadata.duration}`); + let duration = parseInt(metadata.duration) * 1000; + let pick = duration / 5; + this.diffTime[0] = 0; + this.diffTime[5] = duration; + let time = pick; for (let i = 1; i < 5; i++) { - this.diffTime[i] = time - time += pick + this.diffTime[i] = time; + time += pick; } } if (metadata.videoHeight && metadata.videoWidth) { - let rate = Number(metadata.videoHeight) / Number(metadata.videoWidth) + let rate = Number(metadata.videoHeight) / Number(metadata.videoWidth); if (metadata.videoOrientation && Number(metadata.videoOrientation) % 180) { rate = 1 / rate; } this.videoHeight = - display.getDefaultDisplaySync().width / 6 / display.getDefaultDisplaySync().densityPixels * rate + display.getDefaultDisplaySync().width / 6 / display.getDefaultDisplaySync().densityPixels * rate; } - await avMetadataExtractor.release() + await avMetadataExtractor.release(); } } // [End av_image_generator_class] diff --git a/ApiUsingStandards/entry/src/main/ets/pages/camera.ets b/ApiUsingStandards/entry/src/main/ets/pages/camera.ets index 76ba415f66d398d62fe0b75e561ae47d6b4b7a9a..ed8e35a7c7e778a5d7323aaf7956003b30377b96 100644 --- a/ApiUsingStandards/entry/src/main/ets/pages/camera.ets +++ b/ApiUsingStandards/entry/src/main/ets/pages/camera.ets @@ -22,11 +22,12 @@ import { camera } from '@kit.CameraKit'; class cameraClass { cameraManager: camera.CameraManager | undefined = undefined; - getCameraManager(context: Context) { + getCameraManager(context: Context): void { this.cameraManager = camera.getCameraManager(context); } - async addInput(cameraManager: camera.CameraManager, camera: camera.CameraDevice, session: camera.Session) { + async addInput(cameraManager: camera.CameraManager, camera: camera.CameraDevice, + session: camera.Session): Promise { let cameraInput: camera.CameraInput | undefined = undefined; // [Start add_input] cameraInput = cameraManager.createCameraInput(camera); @@ -37,7 +38,7 @@ class cameraClass { } async addOutput(cameraManager: camera.CameraManager, camera: camera.CameraDevice, session: camera.Session, - cameraOutputCapability: camera.CameraOutputCapability) { + cameraOutputCapability: camera.CameraOutputCapability): Promise { let previewOutput: camera.CameraOutput | undefined = undefined; let cameraInput: camera.CameraInput | undefined = undefined; let profile: camera.Profile = cameraOutputCapability.previewProfiles[0]; @@ -53,7 +54,7 @@ class cameraClass { } async addOutput1(cameraManager: camera.CameraManager, camera: camera.CameraDevice, session: camera.Session, - cameraOutputCapability: camera.CameraOutputCapability) { + cameraOutputCapability: camera.CameraOutputCapability): Promise { let previewOutput: camera.CameraOutput | undefined = undefined; let cameraInput: camera.CameraInput | undefined = undefined; let profile: camera.Profile = cameraOutputCapability.previewProfiles[0]; @@ -68,13 +69,13 @@ class cameraClass { session.commitConfig(); // [End add_output1] } - } -let cameraInput:camera.CameraInput; -let cameraSession:camera.Session; +let cameraInput: camera.CameraInput; +let cameraSession: camera.Session; + // [Start close_release] -async function onBackground() { +async function onBackground(): Promise { await cameraInput.close(); await cameraSession.release(); } diff --git a/ApiUsingStandards/entry/src/main/ets/pages/playStateCallback.ets b/ApiUsingStandards/entry/src/main/ets/pages/playStateCallback.ets index f61ca38536c0d51f00abc27b160d725704c4d9b9..4de3c1bf34c9b2c2e1340b2cdc27723c27feb2b5 100644 --- a/ApiUsingStandards/entry/src/main/ets/pages/playStateCallback.ets +++ b/ApiUsingStandards/entry/src/main/ets/pages/playStateCallback.ets @@ -19,7 +19,7 @@ import { BusinessError } from '@kit.BasicServicesKit'; import { avSession } from '@kit.AVSessionKit'; -const TAG = 'TEST'; +const TAG: string = 'TEST'; class avSessionClass { castController!: avSession.AVCastController; @@ -29,7 +29,7 @@ class avSessionClass { playStateCallback: (state: avSession.AVPlaybackState) => void = () => { } - create(context: Context, tag: string) { + create(context: Context, tag: string): void { avSession.createAVSession(context, tag, "audio").then(async (currentAVSession: avSession.AVSession) => { this.session = currentAVSession; let sessionController = await currentAVSession.getAVCastController(); @@ -46,7 +46,7 @@ class avSessionClass { }); } - prepare() { + prepare(): void { let playItem: avSession.AVQueueItem = { itemId: 0, description: { @@ -75,7 +75,7 @@ class avSessionClass { // [End prepare] } - onPrepare() { + onPrepare(): void { // [Start on_prepare] this.session?.on('pause', async () => { console.info(TAG, `on pause , do pause task`); diff --git a/ApiUsingStandards/entry/src/ohosTest/ets/test/Ability.test.ets b/ApiUsingStandards/entry/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100644 index 85c78f67579d6e31b5f5aeea463e216b9b141048..0000000000000000000000000000000000000000 --- a/ApiUsingStandards/entry/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,35 +0,0 @@ -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/ApiUsingStandards/entry/src/ohosTest/ets/test/List.test.ets b/ApiUsingStandards/entry/src/ohosTest/ets/test/List.test.ets deleted file mode 100644 index 794c7dc4ed66bd98fa3865e07922906e2fcef545..0000000000000000000000000000000000000000 --- a/ApiUsingStandards/entry/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/ApiUsingStandards/entry/src/ohosTest/module.json5 b/ApiUsingStandards/entry/src/ohosTest/module.json5 deleted file mode 100644 index 55725a929993a8a18b3808d41ef037759440488b..0000000000000000000000000000000000000000 --- a/ApiUsingStandards/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/ApiUsingStandards/entry/src/test/List.test.ets b/ApiUsingStandards/entry/src/test/List.test.ets deleted file mode 100644 index bb5b5c3731e283dd507c847560ee59bde477bbc7..0000000000000000000000000000000000000000 --- a/ApiUsingStandards/entry/src/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import localUnitTest from './LocalUnit.test'; - -export default function testsuite() { - localUnitTest(); -} \ No newline at end of file diff --git a/ApiUsingStandards/entry/src/test/LocalUnit.test.ets b/ApiUsingStandards/entry/src/test/LocalUnit.test.ets deleted file mode 100644 index 165fc1615ee8618b4cb6a622f144a9a707eee99f..0000000000000000000000000000000000000000 --- a/ApiUsingStandards/entry/src/test/LocalUnit.test.ets +++ /dev/null @@ -1,33 +0,0 @@ -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/JSCrash/README.md b/JSCrash/README.md index e60141283905625d990873407c0d88635d07be1d..e50d680e98a443bfd73a8de5bacf66b5db486023 100644 --- a/JSCrash/README.md +++ b/JSCrash/README.md @@ -7,7 +7,7 @@ ### 效果预览 -不涉及 +不涉及。 ### 工程目录 ``` diff --git a/JSCrash/entry/src/main/ets/pages/JSCrashCaseAnalyse1.ets b/JSCrash/entry/src/main/ets/pages/JSCrashCaseAnalyse1.ets index efb1ae76721ac90681ac6a6ab90ffbfb26ac464b..54843f35d16ac66424a2bf2c3d8187cd36576438 100644 --- a/JSCrash/entry/src/main/ets/pages/JSCrashCaseAnalyse1.ets +++ b/JSCrash/entry/src/main/ets/pages/JSCrashCaseAnalyse1.ets @@ -25,7 +25,8 @@ struct Index { // [Start updateGestureValue1] // Update the attributes related to manual effects - public updateGestureValue(screenWidth: number, recentScale: number, sceneContainerSessionList: SCBSceneContainerSession[]) { + public updateGestureValue(screenWidth: number, recentScale: number, + sceneContainerSessionList: SCBSceneContainerSession[]): void { // Calculation of the distance moved by the hand this.translationUpY = (this.multiCardsNum >= 1) ? sceneContainerSessionList[this.multiCardsNum - 1].needRenderTranslate.translateY : 0; // Report an incorrect line number this.translationDownY = (this.multiCardsNum >= 2) ? sceneContainerSessionList[this.multiCardsNum - 2].needRenderTranslate.translateY : 0; diff --git a/JSCrash/entry/src/main/ets/pages/JSCrashCaseAnalyse2.ets b/JSCrash/entry/src/main/ets/pages/JSCrashCaseAnalyse2.ets index 268bb2ff4c8af9019c6daff56ec48f74188166d0..a38af1724142de766e2ebfc5cb2ab1a9a7216076 100644 --- a/JSCrash/entry/src/main/ets/pages/JSCrashCaseAnalyse2.ets +++ b/JSCrash/entry/src/main/ets/pages/JSCrashCaseAnalyse2.ets @@ -25,7 +25,8 @@ struct Index { // [Start updateGestureValue2] // Update the attributes related to manual effects - public updateGestureValue(screenWidth: number, recentScale: number, sceneContainerSessionList: SCBSceneContainerSession[]) { + public updateGestureValue(screenWidth: number, recentScale: number, + sceneContainerSessionList: SCBSceneContainerSession[]): void { // Calculation of the distance moved by the hand this.translationUpY = (this.multiCardsNum >= 1) ? sceneContainerSessionList[this.multiCardsNum - 1]?.needRenderTranslate.translateY : 0; diff --git a/JSCrash/entry/src/main/ets/pages/utils.ets b/JSCrash/entry/src/main/ets/pages/utils.ets index 624c38b007bf4a3b92688590bb1195e592430e13..98e8e5760051c7cb929d01b940f5df81947e3079 100644 --- a/JSCrash/entry/src/main/ets/pages/utils.ets +++ b/JSCrash/entry/src/main/ets/pages/utils.ets @@ -1,9 +1,9 @@ import hilog from '@ohos.hilog'; -const TAG = 'ZCM_Default'; +const TAG: string = 'ZCM_Default'; -const DOMAIN = 0x0011; -const SYMBOL = " --> "; +const DOMAIN: number = 0x0011; +const SYMBOL: string = " --> "; export class Log { /** @@ -14,7 +14,7 @@ export class Log { * @param args Indicates the log parameters. * @since 7 */ - static showInfo(tag: string) { + static showInfo(tag: string): void { if (Log.isLoggable(tag, hilog.LogLevel.INFO)) { hilog.info(DOMAIN, TAG, tag + SYMBOL); } @@ -28,7 +28,7 @@ export class Log { * @param args Indicates the log parameters. * @since 7 */ - static showDebug(tag: string, format: string, ...args: string[]) { + static showDebug(tag: string, format: string, ...args: string[]): void { if (Log.isLoggable(tag, hilog.LogLevel.DEBUG)) { hilog.debug(DOMAIN, TAG, tag + SYMBOL + format, args); } @@ -42,7 +42,7 @@ export class Log { * @param args Indicates the log parameters. * @since 7 */ - static showWarn(tag: string, format: string, ...args: string[]) { + static showWarn(tag: string, format: string, ...args: string[]): void { if (Log.isLoggable(tag, hilog.LogLevel.WARN)) { hilog.warn(DOMAIN, TAG, tag + SYMBOL + format, args); } @@ -56,7 +56,7 @@ export class Log { * @param args Indicates the log parameters. * @since 7 */ - static showError(tag: string) { + static showError(tag: string): void { if (Log.isLoggable(tag, hilog.LogLevel.ERROR)) { hilog.error(DOMAIN, TAG, tag + SYMBOL); } @@ -70,7 +70,7 @@ export class Log { * @param args Indicates the log parameters. * @since 7 */ - static showFatal(tag: string, format: string, ...args: string[]) { + static showFatal(tag: string, format: string, ...args: string[]): void { if (Log.isLoggable(tag, hilog.LogLevel.FATAL)) { hilog.fatal(DOMAIN, TAG, tag + SYMBOL + format, args); } @@ -83,7 +83,7 @@ export class Log { * @param level log level * @since 7 */ - private static isLoggable(tag:string, level: hilog.LogLevel): boolean { + private static isLoggable(tag: string, level: hilog.LogLevel): boolean { return hilog.isLoggable(DOMAIN, tag, level); } } \ No newline at end of file diff --git a/JSCrash/entry/src/mock/mock-config.json5 b/JSCrash/entry/src/mock/mock-config.json5 deleted file mode 100644 index 7a73a41bfdf76d6f793007240d80983a52f15f97..0000000000000000000000000000000000000000 --- a/JSCrash/entry/src/mock/mock-config.json5 +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/JSCrash/entry/src/ohosTest/ets/test/Ability.test.ets b/JSCrash/entry/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100644 index 85c78f67579d6e31b5f5aeea463e216b9b141048..0000000000000000000000000000000000000000 --- a/JSCrash/entry/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,35 +0,0 @@ -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/JSCrash/entry/src/ohosTest/ets/test/List.test.ets b/JSCrash/entry/src/ohosTest/ets/test/List.test.ets deleted file mode 100644 index 794c7dc4ed66bd98fa3865e07922906e2fcef545..0000000000000000000000000000000000000000 --- a/JSCrash/entry/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/JSCrash/entry/src/ohosTest/module.json5 b/JSCrash/entry/src/ohosTest/module.json5 deleted file mode 100644 index 55725a929993a8a18b3808d41ef037759440488b..0000000000000000000000000000000000000000 --- a/JSCrash/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/JSCrash/entry/src/test/List.test.ets b/JSCrash/entry/src/test/List.test.ets deleted file mode 100644 index bb5b5c3731e283dd507c847560ee59bde477bbc7..0000000000000000000000000000000000000000 --- a/JSCrash/entry/src/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import localUnitTest from './LocalUnit.test'; - -export default function testsuite() { - localUnitTest(); -} \ No newline at end of file diff --git a/JSCrash/entry/src/test/LocalUnit.test.ets b/JSCrash/entry/src/test/LocalUnit.test.ets deleted file mode 100644 index 165fc1615ee8618b4cb6a622f144a9a707eee99f..0000000000000000000000000000000000000000 --- a/JSCrash/entry/src/test/LocalUnit.test.ets +++ /dev/null @@ -1,33 +0,0 @@ -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/ThreadIssueDetection/README.md b/ThreadIssueDetection/README.md index 761f0b004024adbe1101ed2a4e0067f2f5634b2f..0d4fa17c1ada3d314e79409b2b94ede0a4b476d4 100644 --- a/ThreadIssueDetection/README.md +++ b/ThreadIssueDetection/README.md @@ -6,13 +6,15 @@ ### 使用说明 -进入首面,加载示例逻辑。 +不涉及。 ### 工程目录 ``` -├──entry/src/main/ets +├──entry/src/main/ets +│ ├──cpp +│ │ └──UseTSANToDetectThreadingIssues.cpp // 检测示例代码 │ ├──entryability │ │ └──EntryAbility.ets // 入口类 │ ├──entrybackupability @@ -25,7 +27,7 @@ ### 具体实现 -1. 主要介绍如何使用TSan检测线程,提供代码示例。 +1. 主要介绍如何使用TSan检测线程,文章配套代码示例。 ### 相关权限 diff --git a/ThreadIssueDetection/entry/src/mock/mock-config.json5 b/ThreadIssueDetection/entry/src/mock/mock-config.json5 deleted file mode 100644 index 7a73a41bfdf76d6f793007240d80983a52f15f97..0000000000000000000000000000000000000000 --- a/ThreadIssueDetection/entry/src/mock/mock-config.json5 +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/ThreadIssueDetection/entry/src/ohosTest/ets/test/Ability.test.ets b/ThreadIssueDetection/entry/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100644 index 85c78f67579d6e31b5f5aeea463e216b9b141048..0000000000000000000000000000000000000000 --- a/ThreadIssueDetection/entry/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,35 +0,0 @@ -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/ThreadIssueDetection/entry/src/ohosTest/ets/test/List.test.ets b/ThreadIssueDetection/entry/src/ohosTest/ets/test/List.test.ets deleted file mode 100644 index 794c7dc4ed66bd98fa3865e07922906e2fcef545..0000000000000000000000000000000000000000 --- a/ThreadIssueDetection/entry/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/ThreadIssueDetection/entry/src/ohosTest/module.json5 b/ThreadIssueDetection/entry/src/ohosTest/module.json5 deleted file mode 100644 index 55725a929993a8a18b3808d41ef037759440488b..0000000000000000000000000000000000000000 --- a/ThreadIssueDetection/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/ThreadIssueDetection/entry/src/test/List.test.ets b/ThreadIssueDetection/entry/src/test/List.test.ets deleted file mode 100644 index bb5b5c3731e283dd507c847560ee59bde477bbc7..0000000000000000000000000000000000000000 --- a/ThreadIssueDetection/entry/src/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import localUnitTest from './LocalUnit.test'; - -export default function testsuite() { - localUnitTest(); -} \ No newline at end of file diff --git a/ThreadIssueDetection/entry/src/test/LocalUnit.test.ets b/ThreadIssueDetection/entry/src/test/LocalUnit.test.ets deleted file mode 100644 index 165fc1615ee8618b4cb6a622f144a9a707eee99f..0000000000000000000000000000000000000000 --- a/ThreadIssueDetection/entry/src/test/LocalUnit.test.ets +++ /dev/null @@ -1,33 +0,0 @@ -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/customPlugin/README.md b/customPlugin/README.md index 5944414b45304f1a723910fb54c3f4eb5877f735..037caa11703155c4407aed3f99414be8e1f42dbb 100644 --- a/customPlugin/README.md +++ b/customPlugin/README.md @@ -6,7 +6,7 @@ ### 使用说明 -编译工程,得到hvigor插件逻辑的编译产物。 +不涉及。 ### 工程结构 @@ -18,10 +18,11 @@ │ │ └──EntryBackupAbility.ets // 备份恢复类 │ └──pages │ └──Index.ets // 示例页面 +├──entry/src/main/resource // 应用资源目录 ├──library/src/main/ets │ └──components -│ └──MainPage.ets // library模块中MainPage -└──entry/src/main/resource // 应用静态资源目录 +│ └──MainPage.ets // library模块中MainPage +└──library/src/main/resource // lib资源目录 ``` ### 相关权限 diff --git a/customPlugin/entry/src/main/ets/pages/Index.ets b/customPlugin/entry/src/main/ets/pages/Index.ets index 626d387186e19622d1a7ef2c3bb7aaa9b35ff323..0f481f696485b8c840d49ad9e7d7dff7f6b71241 100644 --- a/customPlugin/entry/src/main/ets/pages/Index.ets +++ b/customPlugin/entry/src/main/ets/pages/Index.ets @@ -13,7 +13,6 @@ * limitations under the License. */ -import handover from '@hms.networkboost.handover'; @Entry @Component struct Index { diff --git a/customPlugin/entry/src/mock/mock-config.json5 b/customPlugin/entry/src/mock/mock-config.json5 deleted file mode 100644 index 7a73a41bfdf76d6f793007240d80983a52f15f97..0000000000000000000000000000000000000000 --- a/customPlugin/entry/src/mock/mock-config.json5 +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/customPlugin/entry/src/ohosTest/ets/test/Ability.test.ets b/customPlugin/entry/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100644 index 85c78f67579d6e31b5f5aeea463e216b9b141048..0000000000000000000000000000000000000000 --- a/customPlugin/entry/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,35 +0,0 @@ -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/customPlugin/entry/src/ohosTest/ets/test/List.test.ets b/customPlugin/entry/src/ohosTest/ets/test/List.test.ets deleted file mode 100644 index 794c7dc4ed66bd98fa3865e07922906e2fcef545..0000000000000000000000000000000000000000 --- a/customPlugin/entry/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/customPlugin/entry/src/ohosTest/module.json5 b/customPlugin/entry/src/ohosTest/module.json5 deleted file mode 100644 index 55725a929993a8a18b3808d41ef037759440488b..0000000000000000000000000000000000000000 --- a/customPlugin/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module": { - "name": "entry_test", - "type": "feature", - "deviceTypes": [ - "phone", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/customPlugin/entry/src/test/List.test.ets b/customPlugin/entry/src/test/List.test.ets deleted file mode 100644 index bb5b5c3731e283dd507c847560ee59bde477bbc7..0000000000000000000000000000000000000000 --- a/customPlugin/entry/src/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import localUnitTest from './LocalUnit.test'; - -export default function testsuite() { - localUnitTest(); -} \ No newline at end of file diff --git a/customPlugin/entry/src/test/LocalUnit.test.ets b/customPlugin/entry/src/test/LocalUnit.test.ets deleted file mode 100644 index 165fc1615ee8618b4cb6a622f144a9a707eee99f..0000000000000000000000000000000000000000 --- a/customPlugin/entry/src/test/LocalUnit.test.ets +++ /dev/null @@ -1,33 +0,0 @@ -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/customPlugin/library/BuildProfile.ets b/customPlugin/library/BuildProfile.ets deleted file mode 100644 index 3a501e5ddee8ea6d28961648fc7dd314a5304bd4..0000000000000000000000000000000000000000 --- a/customPlugin/library/BuildProfile.ets +++ /dev/null @@ -1,17 +0,0 @@ -/** - * 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/customPlugin/library/build-profile.json5 b/customPlugin/library/build-profile.json5 index e6773f9f5d76a66d6d19fddc9c6ddb3f5621d3b1..cda3307123ec7c43181580a86ef7e82a18319a34 100644 --- a/customPlugin/library/build-profile.json5 +++ b/customPlugin/library/build-profile.json5 @@ -23,9 +23,6 @@ "targets": [ { "name": "default" - }, - { - "name": "ohosTest" } ] } diff --git a/customPlugin/library/src/main/module.json5 b/customPlugin/library/src/main/module.json5 index dd30f8e0de7154e00da5009b23df656940652a64..39f9cdc6a027938963e6f8cdc77dde030fee223c 100644 --- a/customPlugin/library/src/main/module.json5 +++ b/customPlugin/library/src/main/module.json5 @@ -3,9 +3,7 @@ "name": "library", "type": "har", "deviceTypes": [ - "default", - "tablet", - "2in1" + "phone" ] } } diff --git a/customPlugin/library/src/ohosTest/ets/test/Ability.test.ets b/customPlugin/library/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100644 index 85c78f67579d6e31b5f5aeea463e216b9b141048..0000000000000000000000000000000000000000 --- a/customPlugin/library/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,35 +0,0 @@ -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/customPlugin/library/src/ohosTest/ets/test/List.test.ets b/customPlugin/library/src/ohosTest/ets/test/List.test.ets deleted file mode 100644 index 794c7dc4ed66bd98fa3865e07922906e2fcef545..0000000000000000000000000000000000000000 --- a/customPlugin/library/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import abilityTest from './Ability.test'; - -export default function testsuite() { - abilityTest(); -} \ No newline at end of file diff --git a/customPlugin/library/src/ohosTest/module.json5 b/customPlugin/library/src/ohosTest/module.json5 deleted file mode 100644 index 2d357bce9c10ce2146bf57f966d4e29f770ab067..0000000000000000000000000000000000000000 --- a/customPlugin/library/src/ohosTest/module.json5 +++ /dev/null @@ -1,13 +0,0 @@ -{ - "module": { - "name": "library_test", - "type": "feature", - "deviceTypes": [ - "default", - "tablet", - "2in1" - ], - "deliveryWithInstall": true, - "installationFree": false - } -} diff --git a/customPlugin/library/src/test/List.test.ets b/customPlugin/library/src/test/List.test.ets deleted file mode 100644 index bb5b5c3731e283dd507c847560ee59bde477bbc7..0000000000000000000000000000000000000000 --- a/customPlugin/library/src/test/List.test.ets +++ /dev/null @@ -1,5 +0,0 @@ -import localUnitTest from './LocalUnit.test'; - -export default function testsuite() { - localUnitTest(); -} \ No newline at end of file diff --git a/customPlugin/library/src/test/LocalUnit.test.ets b/customPlugin/library/src/test/LocalUnit.test.ets deleted file mode 100644 index 165fc1615ee8618b4cb6a622f144a9a707eee99f..0000000000000000000000000000000000000000 --- a/customPlugin/library/src/test/LocalUnit.test.ets +++ /dev/null @@ -1,33 +0,0 @@ -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