diff --git a/network/WebSocket/entry/src/main/ets/common/BindServiceIp.ets b/network/WebSocket/entry/src/main/ets/common/BindServiceIp.ets index 574bb1848412a8d9357ec23294056d7b78998382..7858913fb1e261dd3092b5c18ee62c9eb507b1a3 100644 --- a/network/WebSocket/entry/src/main/ets/common/BindServiceIp.ets +++ b/network/WebSocket/entry/src/main/ets/common/BindServiceIp.ets @@ -16,7 +16,8 @@ @Component export default struct BindServiceIp { @Link ipAddress: string - private onBind: () => void + private onBind: () => void = () => { + } build() { Column() { diff --git a/network/WebSocket/entry/src/main/ets/common/ChatsPage.ets b/network/WebSocket/entry/src/main/ets/common/ChatsPage.ets index 8d1e9a68853fec7af8c2a9074df2b0743b28b62e..765e95d5b5941c8b02afdc72e007f4ad771d1c35 100644 --- a/network/WebSocket/entry/src/main/ets/common/ChatsPage.ets +++ b/network/WebSocket/entry/src/main/ets/common/ChatsPage.ets @@ -50,9 +50,9 @@ export default struct ChatsPage { build() { Column() { List() { - LazyForEach(this.chats, (item) => { + LazyForEach(this.chats, (item: ChatData) => { ListItem() { - if (item.isServer) { + if (item.isServer as boolean) { this.ChatsMessage($r('app.string.server'), item.message, Direction.Ltr) } else { this.ChatsMessage($r('app.string.me'), item.message, Direction.Rtl) @@ -60,7 +60,7 @@ export default struct ChatsPage { } .padding(10) .width('100%') - }, (item, index) => item.message + index) + }, (item: ChatData, index?: number) => item.message + index) }.width('100%').height('100%') } .width('100%') diff --git a/network/WebSocket/entry/src/main/ets/common/SendMessage.ets b/network/WebSocket/entry/src/main/ets/common/SendMessage.ets index cbc7b84503ebf9d488817d4be9e38de6a788f444..0898369564640f5e76da468f13dbdeacbb7a6454 100644 --- a/network/WebSocket/entry/src/main/ets/common/SendMessage.ets +++ b/network/WebSocket/entry/src/main/ets/common/SendMessage.ets @@ -16,7 +16,8 @@ @Component export default struct SendMessage { @Link message: string - private sendMessage: () => void + private sendMessage: () => void = () => { + } build() { Row() { diff --git a/network/WebSocket/entry/src/main/ets/common/TopBar.ets b/network/WebSocket/entry/src/main/ets/common/TopBar.ets index fc6a743075cd1828ac2d823e430f97308f77ad43..c6c0bf406eb091b58cc2953bbf869ff48836c7c6 100644 --- a/network/WebSocket/entry/src/main/ets/common/TopBar.ets +++ b/network/WebSocket/entry/src/main/ets/common/TopBar.ets @@ -16,7 +16,8 @@ @Component export default struct TopBar { @Link isConnect: boolean - private connect: () => void + private connect: () => void = () => { + } build() { Row() { diff --git a/network/WebSocket/entry/src/main/ets/model/DataSource.ets b/network/WebSocket/entry/src/main/ets/model/DataSource.ets index 06cc60a22521629e65853078d5576611935eab0f..2fbaae797236572d077a36982fb92e4858d43ba4 100644 --- a/network/WebSocket/entry/src/main/ets/model/DataSource.ets +++ b/network/WebSocket/entry/src/main/ets/model/DataSource.ets @@ -12,6 +12,7 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import ChatData from './ChatData' class BasicDataSource implements IDataSource { private listeners: DataChangeListener[] = [] @@ -20,7 +21,7 @@ class BasicDataSource implements IDataSource { return 0 } - public getData(index: number): any { + public getData(index: number): undefined | string | ChatData { return undefined } @@ -40,38 +41,38 @@ class BasicDataSource implements IDataSource { } notifyDataReload(): void { - this.listeners.forEach(listener => { + this.listeners.forEach((listener: DataChangeListener) => { listener.onDataReloaded() }) } notifyDataAdd(index: number): void { - this.listeners.forEach(listener => { + this.listeners.forEach((listener: DataChangeListener) => { listener.onDataAdd(index) }) } notifyDataChange(index: number): void { - this.listeners.forEach(listener => { + this.listeners.forEach((listener: DataChangeListener) => { listener.onDataChange(index) }) } notifyDataDelete(index: number): void { - this.listeners.forEach(listener => { + this.listeners.forEach((listener: DataChangeListener) => { listener.onDataDelete(index) }) } notifyDataMove(from: number, to: number): void { - this.listeners.forEach(listener => { + this.listeners.forEach((listener: DataChangeListener) => { listener.onDataMove(from, to) }) } } export class WebSocketSource extends BasicDataSource { - public chatsData: Array + public chatsData: Array constructor(chatsData: Array) { super() @@ -82,16 +83,16 @@ export class WebSocketSource extends BasicDataSource { return this.chatsData.length } - public getData(index: number): any { + public getData(index: number): string | ChatData { return this.chatsData[index] } - public addData(index: number, data: any): void { + public addData(index: number, data: string | ChatData): void { this.chatsData.splice(index, 0, data) this.notifyDataAdd(index) } - public pushData(data: any): void { + public pushData(data: string | ChatData): void { this.chatsData.push(data) this.notifyDataAdd(this.chatsData.length - 1) } diff --git a/network/WebSocket/entry/src/main/ets/pages/Chats.ets b/network/WebSocket/entry/src/main/ets/pages/Chats.ets index fb5c751a20bfb372f211bb4b829caecccc719827..e1ef0b8fb7f615e0aeacb1f2b36994c60090f452 100644 --- a/network/WebSocket/entry/src/main/ets/pages/Chats.ets +++ b/network/WebSocket/entry/src/main/ets/pages/Chats.ets @@ -21,7 +21,8 @@ import ChatData from '../model/ChatData' import ChatsPage from '../common/ChatsPage' import SendMessage from '../common/SendMessage' import BindServiceIP from '../common/BindServiceIp' -import {WebSocketSource} from "../model/DataSource" +import { WebSocketSource } from "../model/DataSource" +import { BusinessError } from '@ohos.base' const TAG: string = '[Chats]' let socket: webSocket.WebSocket = webSocket.createWebSocket() @@ -30,7 +31,8 @@ let socket: webSocket.WebSocket = webSocket.createWebSocket() struct BindCustomDialog { @State ipAddress: string = '' private controller?: CustomDialogController - onBind: (ipAddress: string) => void + onBind: (ipAddress: string) => void = (ipAddress: string) => { + } build() { Column() { @@ -52,7 +54,7 @@ struct Chats { @State isConnect: boolean = false @State ipAddress: string = '' controller: CustomDialogController = new CustomDialogController({ - builder: BindCustomDialog({ onBind: this.onBind.bind(this) }), + builder: BindCustomDialog({ onBind: (ipAddress: string): void => this.onBind(ipAddress) }), autoCancel: false }) @@ -68,16 +70,16 @@ struct Chats { onConnect() { let promise = socket.connect(this.ipAddress) Logger.info(TAG, `ipAddress:${JSON.stringify(this.ipAddress)}`) - promise.then((value) => { + promise.then(() => { Logger.info(TAG, `connect success`) - }).catch((err) => { + }).catch((err: BusinessError) => { Logger.info(TAG, `connect fail, error:${JSON.stringify(err)}`) }) - socket.on('open', (err, value) => { + socket.on('open', () => { // 当收到on('open')事件时,可以通过send()方法与服务器进行通信 promptAction.showToast({ message: '连接成功,可以聊天了!', duration: 1500 }) }) - socket.on('message', (err, value) => { + socket.on('message', (err: BusinessError, value: Object) => { Logger.info(TAG, `on message, value = ${value}`) let receiveMessage = new ChatData(JSON.stringify(value), true) this.chats.pushData(receiveMessage) @@ -86,7 +88,8 @@ struct Chats { disConnect() { socket.off('open', (err, value) => { - Logger.info(TAG, `on open, status:${value['status']}, message:${value['message']}`) + let val: Record = value as Record; + Logger.info(TAG, `on open, status:${val['status']}, message:${val['message']}`); }) socket.off('message') promptAction.showToast({ message: '连接已断开!', duration: 1500 }) @@ -97,16 +100,16 @@ struct Chats { let sendMessage = new ChatData(this.message, false) this.chats.pushData(sendMessage) let sendResult = socket.send(this.message) - sendResult.then((value) => { + sendResult.then(() => { Logger.info(TAG, `[send]send success:${this.message}`) - }).catch((err) => { + }).catch((err: BusinessError) => { Logger.info(TAG, `[send]send fail, err:${JSON.stringify(err)}`) }) this.message = '' } build() { - Column() { + Column() { Text($r('app.string.EntryAbility_label')) .height(50) .fontSize(25) diff --git a/network/WebSocket/entry/src/ohosTest/ets/Application/TestAbilityStage.ts b/network/WebSocket/entry/src/ohosTest/ets/Application/TestAbilityStage.ts deleted file mode 100644 index 9ff1cd139f737bb5899c079d8a89e5891a189956..0000000000000000000000000000000000000000 --- a/network/WebSocket/entry/src/ohosTest/ets/Application/TestAbilityStage.ts +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import AbilityStage from "@ohos.application.AbilityStage" - -export default class TestAbilityStage extends AbilityStage { - onCreate() { - console.log("[Demo] TestAbilityStage onCreate") - } -} \ No newline at end of file diff --git a/network/WebSocket/entry/src/ohosTest/ets/TestAbility/TestAbility.ets b/network/WebSocket/entry/src/ohosTest/ets/TestAbility/TestAbility.ets deleted file mode 100644 index 0e24b250d199ac30ed74f7040224d7bd78d0aeb6..0000000000000000000000000000000000000000 --- a/network/WebSocket/entry/src/ohosTest/ets/TestAbility/TestAbility.ets +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; -import Ability from '@ohos.application.Ability' -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import { Hypium } from '@ohos/hypium' -import testsuite from '../test/List.test' -import Window from '@ohos.window' - -export default class TestAbility extends Ability { - onCreate(want, launchParam) { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onCreate'); - hilog.info(0x0000, 'testTag', '%{public}s', 'want param:' + JSON.stringify(want) ?? ''); - hilog.info(0x0000, 'testTag', '%{public}s', 'launchParam:'+ JSON.stringify(launchParam) ?? ''); - var abilityDelegator: any - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - var abilityDelegatorArguments: any - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'start run testcase!!!'); - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - } - - onDestroy() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onDestroy'); - } - - onWindowStageCreate(windowStage: Window.WindowStage) { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageCreate'); - windowStage.loadContent('testability/pages/Index', (err, data) => { - if (err.code) { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR); - hilog.error(0x0000, 'testTag', 'Failed to load the content. Cause: %{public}s', JSON.stringify(err) ?? ''); - return; - } - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', 'Succeeded in loading the content. Data: %{public}s', - JSON.stringify(data) ?? ''); - }); - } - - onWindowStageDestroy() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onWindowStageDestroy'); - } - - onForeground() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onForeground'); - } - - onBackground() { - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - hilog.info(0x0000, 'testTag', '%{public}s', 'TestAbility onBackground'); - } -} \ No newline at end of file diff --git a/network/WebSocket/entry/src/ohosTest/ets/TestAbility/TestAbility.ts b/network/WebSocket/entry/src/ohosTest/ets/TestAbility/TestAbility.ts deleted file mode 100644 index cf1c7d81db9ab0618a94439c88fea91d9984dd82..0000000000000000000000000000000000000000 --- a/network/WebSocket/entry/src/ohosTest/ets/TestAbility/TestAbility.ts +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import Ability from '@ohos.application.Ability' -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import { Hypium } from '@ohos/hypium' -import testsuite from '../test/List.test' - -export default class TestAbility extends Ability { - onCreate(want, launchParam) { - console.log('TestAbility onCreate') - } - - onDestroy() { - console.log('TestAbility onDestroy') - } - - onWindowStageCreate(windowStage) { - console.log('TestAbility onWindowStageCreate') - windowStage.loadContent("TestAbility/pages/index", (err, data) => { - if (err.code) { - console.error('Failed to load the content. Cause:' + JSON.stringify(err)) - return; - } - console.info('Succeeded in loading the content. Data: ' + JSON.stringify(data)) - }) - var abilityDelegator: any - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - var abilityDelegatorArguments: any - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - console.info('start run testcase!!!') - Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite) - } - - onWindowStageDestroy() { - console.log('TestAbility onWindowStageDestroy') - } - - onForeground() { - console.log('TestAbility onForeground') - } - - onBackground() { - console.log('TestAbility onBackground') - } -}; \ No newline at end of file diff --git a/network/WebSocket/entry/src/ohosTest/ets/TestAbility/pages/index.ets b/network/WebSocket/entry/src/ohosTest/ets/TestAbility/pages/index.ets deleted file mode 100644 index b7259f92de3dc962cc5cb622178d8b632c9d7a4d..0000000000000000000000000000000000000000 --- a/network/WebSocket/entry/src/ohosTest/ets/TestAbility/pages/index.ets +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import router from '@ohos.router'; - -@Entry -@Component -struct Index { - aboutToAppear() { - console.info('TestAbility index aboutToAppear') - } - - @State message: string = 'Hello World' - - build() { - Row() { - Column() { - Text(this.message) - .fontSize(50) - .fontWeight(FontWeight.Bold) - Button() { - Text('next page') - .fontSize(20) - .fontWeight(FontWeight.Bold) - } - .type(ButtonType.Capsule) - .margin({ - top: 20 - }) - .backgroundColor('#0D9FFB') - .width('35%') - .height('5%') - .onClick(() => { - }) - } - .width('100%') - } - .height('100%') - } -} \ No newline at end of file diff --git a/network/WebSocket/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts b/network/WebSocket/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts deleted file mode 100644 index 83ad209eadafca33ed5f401eeb9ff13cb17e9181..0000000000000000000000000000000000000000 --- a/network/WebSocket/entry/src/ohosTest/ets/TestRunner/OpenHarmonyTestRunner.ts +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import TestRunner from '@ohos.application.testRunner' -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' - -var abilityDelegator = undefined -var abilityDelegatorArguments = undefined - -function translateParamsToString(parameters) { - const keySet = new Set([ - '-s class', '-s notClass', '-s suite', '-s it', - '-s level', '-s testType', '-s size', '-s timeout', - '-s dryRun' - ]) - let targetParams = ''; - for (const key in parameters) { - if (keySet.has(key)) { - targetParams = `${targetParams} ${key} ${parameters[key]}` - } - } - return targetParams.trim() -} - -async function onAbilityCreateCallback() { - console.log("onAbilityCreateCallback"); -} - -async function addAbilityMonitorCallback(err: any) { - console.info("addAbilityMonitorCallback : " + JSON.stringify(err)) -} - -export default class OpenHarmonyTestRunner implements TestRunner { - constructor() { - } - - onPrepare() { - console.info("OpenHarmonyTestRunner OnPrepare ") - } - - async onRun() { - console.log('OpenHarmonyTestRunner onRun run') - abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments() - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - var testAbilityName = abilityDelegatorArguments.bundleName + '.TestAbility' - let lMonitor = { - abilityName: testAbilityName, - onAbilityCreate: onAbilityCreateCallback, - }; - abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback) - var cmd = 'aa start -d 0 -a TestAbility' + ' -b ' + abilityDelegatorArguments.bundleName - cmd += ' ' + translateParamsToString(abilityDelegatorArguments.parameters) - var debug = abilityDelegatorArguments.parameters["-D"] - if (debug == 'true') { - cmd += ' -D' - } - console.info('cmd : ' + cmd) - abilityDelegator.executeShellCommand(cmd, - (err: any, d: any) => { - console.info('executeShellCommand : err : ' + JSON.stringify(err)); - console.info('executeShellCommand : data : ' + d.stdResult); - console.info('executeShellCommand : data : ' + d.exitCode); - }) - console.info('OpenHarmonyTestRunner onRun end') - } -}; \ No newline at end of file diff --git a/network/WebSocket/entry/src/ohosTest/ets/test/Ability.test.ets b/network/WebSocket/entry/src/ohosTest/ets/test/Ability.test.ets deleted file mode 100644 index 431a54b960f733a8573546caf04e738791de78f5..0000000000000000000000000000000000000000 --- a/network/WebSocket/entry/src/ohosTest/ets/test/Ability.test.ets +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import hilog from '@ohos.hilog'; -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' - -export default function abilityTest() { - describe('ActsAbilityTest', function () { - // Defines a test suite. Two parameters are supported: test suite name and test suite function. - beforeAll(function () { - // 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(function () { - // 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(function () { - // 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(function () { - // 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, function () { - // Defines a test case. This API supports three parameters: test case name, filter parameter, and test case function. - hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO); - 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/network/WebSocket/entry/src/ohosTest/ets/test/App.test.ets b/network/WebSocket/entry/src/ohosTest/ets/test/App.test.ets deleted file mode 100644 index 7511da02280fe0d32cbb514e99449accb364d907..0000000000000000000000000000000000000000 --- a/network/WebSocket/entry/src/ohosTest/ets/test/App.test.ets +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import { describe, beforeAll, beforeEach, afterEach, afterAll, it, expect } from '@ohos/hypium' -import { UiDriver, BY, UiComponent, MatchPattern } from '@ohos.uitest' -import AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry' -import hilog from '@ohos.hilog' - -const BUNDLE = 'WebSocket' -const TAG = '[Sample_WebSocket]' -const DOMAIN = 0xF811 - -export default function appTest() { - describe('appTest', function () { - /** - * 拉起一个Ability - */ - it(BUNDLE + '_startAbility', 0, async function (done) { - hilog.info(DOMAIN, TAG, BUNDLE + '_startAbility start') - hilog.info(DOMAIN, TAG, BUNDLE + '_startAbility start') - let want = { - bundleName: 'ohos.samples.websocket', - abilityName: 'MainAbility' - } - var abilityDelegator: any - abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator() - await abilityDelegator.startAbility(want, (err, data) => { - hilog.info(DOMAIN, TAG, BUNDLE + '_startAbility get err ' + JSON.stringify(err)) - expect(0).assertEqual(err.code) - done() - hilog.info(DOMAIN, TAG, BUNDLE + '_startAbility end') - }) - }) - /** - * 输入Ip - */ - it(BUNDLE + '_IndexPage_BindIp', 0, async () => { - hilog.info(DOMAIN, TAG, BUNDLE + "_IndexPage_BindIp start") - let driver = await UiDriver.create() - await driver.delayMs(1000) - await driver.assertComponentExist(BY.key('ipInput')) - let ipInput = await driver.findComponent(BY.key('ipInput')) - await ipInput.inputText('192.168.101.41') - hilog.info(DOMAIN, TAG, BUNDLE + "_IndexPage_BindIp end") - }) - }) -} \ No newline at end of file diff --git a/network/WebSocket/entry/src/ohosTest/ets/test/List.test.ets b/network/WebSocket/entry/src/ohosTest/ets/test/List.test.ets deleted file mode 100644 index f97ef3a5e6dc9ac56e26684ceab17b2a577177e4..0000000000000000000000000000000000000000 --- a/network/WebSocket/entry/src/ohosTest/ets/test/List.test.ets +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -import appTest from './App.test' - -export default function testsuite() { - appTest() -} \ No newline at end of file diff --git a/network/WebSocket/entry/src/ohosTest/module.json5 b/network/WebSocket/entry/src/ohosTest/module.json5 deleted file mode 100644 index fd36ba53c20316b267de39f8dfd0e2063ba5eda1..0000000000000000000000000000000000000000 --- a/network/WebSocket/entry/src/ohosTest/module.json5 +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2022 Huawei Device Co., Ltd. - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -{ - "module": { - "name": "entry_test", - "type": "feature", - "description": "$string:module_test_desc", - "mainElement": "TestAbility", - "deviceTypes": [ - "phone" - ], - "deliveryWithInstall": true, - "installationFree": false, - "pages": "$profile:test_pages", - "abilities": [ - { - "name": "TestAbility", - "srcEntrance": "./ets/testability/TestAbility.ets", - "description": "$string:TestAbility_desc", - "icon": "$media:icon", - "label": "$string:TestAbility_label", - "visible": true, - "startWindowIcon": "$media:icon", - "startWindowBackground": "$color:start_window_background", - "skills": [ - { - "actions": [ - "action.system.home" - ], - "entities": [ - "entity.system.home" - ] - } - ] - } - ] - } -} diff --git a/network/WebSocket/entry/src/ohosTest/resources/base/element/color.json b/network/WebSocket/entry/src/ohosTest/resources/base/element/color.json deleted file mode 100644 index 1bbc9aa9617e97c45440e1d3d66afc1154837012..0000000000000000000000000000000000000000 --- a/network/WebSocket/entry/src/ohosTest/resources/base/element/color.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "color": [ - { - "name": "white", - "value": "#FFFFFF" - } - ] -} \ No newline at end of file diff --git a/network/WebSocket/entry/src/ohosTest/resources/base/element/string.json b/network/WebSocket/entry/src/ohosTest/resources/base/element/string.json deleted file mode 100644 index 65d8fa5a7cf54aa3943dcd0214f58d1771bc1f6c..0000000000000000000000000000000000000000 --- a/network/WebSocket/entry/src/ohosTest/resources/base/element/string.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "string": [ - { - "name": "module_test_desc", - "value": "test ability description" - }, - { - "name": "TestAbility_desc", - "value": "the test ability" - }, - { - "name": "TestAbility_label", - "value": "test label" - } - ] -} \ No newline at end of file diff --git a/network/WebSocket/entry/src/ohosTest/resources/base/media/icon.png b/network/WebSocket/entry/src/ohosTest/resources/base/media/icon.png deleted file mode 100644 index ce307a8827bd75456441ceb57d530e4c8d45d36c..0000000000000000000000000000000000000000 Binary files a/network/WebSocket/entry/src/ohosTest/resources/base/media/icon.png and /dev/null differ diff --git a/network/WebSocket/entry/src/ohosTest/resources/base/profile/test_pages.json b/network/WebSocket/entry/src/ohosTest/resources/base/profile/test_pages.json deleted file mode 100644 index fcef82b4dfc18e28106ff9ecd1c8b48ec74d18a4..0000000000000000000000000000000000000000 --- a/network/WebSocket/entry/src/ohosTest/resources/base/profile/test_pages.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "src": [ - "TestAbility/pages/index" - ] -}