未验证 提交 c2427f43 编写于 作者: O openharmony_ci 提交者: Gitee

!5321 js部分用例根据检视意见整改及ets api覆盖

Merge pull request !5321 from Nicklaus/master
...@@ -15,6 +15,7 @@ group("arkui") { ...@@ -15,6 +15,7 @@ group("arkui") {
testonly = true testonly = true
deps = [ deps = [
"ace_ets_component:ActsAceEtsComponentTest", "ace_ets_component:ActsAceEtsComponentTest",
"ace_ets_component_apilack:ActsAceEtsApiLackTest",
"ace_ets_component_five:ActsAceEtsComponentFiveTest", "ace_ets_component_five:ActsAceEtsComponentFiveTest",
"ace_ets_component_four:ActsAceEtsComponentFourTest", "ace_ets_component_four:ActsAceEtsComponentFourTest",
"ace_ets_component_three:ActsAceEtsComponentThreeTest", "ace_ets_component_three:ActsAceEtsComponentThreeTest",
......
# Copyright (c) 2021 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("//test/xts/tools/build/suite.gni")
ohos_js_hap_suite("ActsAceEtsApiLackTest") {
hap_profile = "./entry/src/main/config.json"
deps = [
":ace_ets_assets",
":ace_ets_resources",
":ace_ets_test_assets",
]
ets2abc = true
certificate_profile = "./signature/openharmony_sx.p7b"
hap_name = "ActsAceEtsApiLackTest"
subsystem_name = "arkui"
part_name = "ace_engine"
}
ohos_js_assets("ace_ets_assets") {
source_dir = "./entry/src/main/ets/MainAbility"
}
ohos_js_assets("ace_ets_test_assets") {
source_dir = "./entry/src/main/ets/TestAbility"
}
ohos_resources("ace_ets_resources") {
sources = [ "./entry/src/main/resources" ]
hap_profile = "./entry/src/main/config.json"
}
{
"description": "Configuration for aceEtsApiLack Tests",
"driver": {
"type": "OHJSUnitTest",
"test-timeout": "600000",
"bundle-name": "com.open.harmony.aceEtsApiLack",
"package-name": "com.open.harmony.aceEtsApiLack",
"shell-timeout": "600000"
},
"kits": [
{
"test-file-name": [
"ActsAceEtsApiLackTest.hap"
],
"type": "AppInstallKit",
"cleanup-apps": true
}
]
}
{
"app": {
"bundleName": "com.open.harmony.aceEtsApiLack",
"vendor": "open",
"version": {
"code": 1000000,
"name": "1.0.0"
},
"apiVersion": {
"compatible": 7,
"releaseType": "Release",
"target": 8
}
},
"deviceConfig": {},
"module": {
"package": "com.open.harmony.aceEtsApiLack",
"name": ".MyApplication",
"mainAbility": "com.open.harmony.aceEtsApiLack.MainAbility",
"deviceType": [
"phone"
],
"distro": {
"deliveryWithInstall": true,
"moduleName": "entry",
"moduleType": "entry",
"installationFree": false
},
"abilities": [
{
"skills": [
{
"entities": [
"entity.system.home"
],
"actions": [
"action.system.home"
]
}
],
"orientation": "unspecified",
"visible": true,
"srcPath": "MainAbility",
"name": ".MainAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:description_mainability",
"formsEnabled": false,
"label": "$string:entry_MainAbility",
"type": "page",
"launchType": "standard"
},
{
"orientation": "unspecified",
"visible": true,
"srcPath": "TestAbility",
"name": ".TestAbility",
"srcLanguage": "ets",
"icon": "$media:icon",
"description": "$string:TestAbility_desc",
"formsEnabled": false,
"label": "$string:TestAbility_label",
"type": "page",
"launchType": "standard"
}
],
"js": [
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index",
"pages/alphabetIndexer",
"pages/checkBoxGroup",
"pages/circle",
"pages/ellipse"
],
"name": ".MainAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
},
{
"mode": {
"syntax": "ets",
"type": "pageAbility"
},
"pages": [
"pages/index"
],
"name": ".TestAbility",
"window": {
"designWidth": 720,
"autoDesignWidth": false
}
}
]
}
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('Application onCreate')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ No newline at end of file
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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.
*/
const TAG = 'ets_apiLack_add';
/**
* Basic log class
*/
export default class Log {
/**
* print info level log
*
* @param {string} tag - Page or class tag
* @param {string} log - Log needs to be printed
*/
static showInfo(tag, log) {
console.info(`${TAG} tag: ${tag} --> ${log}`);
}
/**
* print debug level log
*
* @param {string} tag - Page or class tag
* @param {string} log - Log needs to be printed
*/
static showDebug(tag, log) {
console.debug(`${TAG} tag: ${tag} --> ${log}`);
}
/**
* print error level log
*
* @param {string} tag - Page or class tag
* @param {string} log - Log needs to be printed
*/
static showError(tag, log) {
console.error(`${TAG} tag: ${tag} --> ${log}`);
}
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 Log from '../common/Log.ets';
import prompt from '@ohos.prompt'
import events_emitter from '@ohos.events.emitter';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct AlphabetIndexerOnSelect {
private value: string[] = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N']
private content: string = "AlphabetIndexer Page"
@State onSelectStatus: boolean = false;
@State onRequestPopupDataStatus: boolean = false;
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear AlphabetIndexerOnSelect start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear AlphabetIndexerOnSelect end`)
}
showToast(message) {
prompt.showToast({
message: message,
duration: 2000
});
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text(`${this.content}`)
.fontSize(20)
.align(Alignment.Center)
.fontWeight(FontWeight.Bold)
AlphabetIndexer({ arrayValue: this.value, selected: 0 })
.color('#FFFF0000')
.selectedColor(0xffffff)
.key('alphabetIndexer')
.popupColor('#FF48D1CC')
.selectedBackgroundColor('#FF0000E6')
.popupBackground('#FF00DDDD')
.usingPopup(true)
.selectedFont({ size: 16, weight: FontWeight.Regular })
.popupFont({ size: 30, weight: FontWeight.Bolder, style: FontStyle.Normal })
.itemSize(28)
.width(100)
.height(300)
.alignStyle(IndexerAlign.Left)
.onSelect((index: number) => {
console.info(this.value[index] + 'on onSelect')
this.showToast("onSelect() " + index)
this.onSelectStatus = true;
try {
var backData = {
data: {
"STATUS": this.onSelectStatus
}
}
let backEvent = {
eventId: 10201,
priority: events_emitter.EventPriority.LOW
}
console.info("onSelect start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("onSelect emit action state err: " + JSON.stringify(err.message))
}
})
.onPopupSelect((index: number) => {
console.info(this.value[index] + 'on onPopupSelect')
this.showToast("onPopupSelect() " + index)
})
.onRequestPopupData((index: number) => {
console.info(this.value[index] + 'on onRequestPopupData')
this.showToast("onRequestPopupData() " + index)
this.onRequestPopupDataStatus = true
try {
var backData = {
data: {
"STATUS": this.onRequestPopupDataStatus
}
}
let backEvent = {
eventId: 10202,
priority: events_emitter.EventPriority.LOW
}
console.info("onRequestPopupData start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("onRequestPopupData emit action state err: " + JSON.stringify(err.message))
}
return ['1', '2', '3', '4', '5']
})
}.width("100%").height("100%")
}
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 prompt from '@ohos.prompt'
import events_emitter from '@ohos.events.emitter';
import Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct CheckBoxGroupSelectAll {
@State isSelect: boolean = true;
onPageShow() {
console.info('[CheckBoxGroup] page show called');
var stateChangeEvent = {
eventId: 908,
priority: events_emitter.EventPriority.LOW
}
events_emitter.on(stateChangeEvent, this.stateChangCallBack);
}
private stateChangCallBack = (eventData) => {
console.info("[CheckBoxGroup] page stateChangCallBack");
if (eventData != null) {
console.info("[CheckBoxGroup] page state change called:" + JSON.stringify(eventData));
if (eventData.data.isSelect != null) {
this.isSelect = eventData.data.isSelect;
}
}
}
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear CheckBoxGroupSelectAll start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear CheckBoxGroupSelectAll end`)
}
showToast(message) {
prompt.showToast({
message: message,
duration: 2000
});
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("checkBoxGroup-SelectAll")
.width(100)
.height(70)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("selectAllText")
Scroll() {
Column() {
CheckboxGroup({group : 'checkboxGroup'})
.selectedColor(0xed6f21)
.key('CheckboxGroup')
.selectAll(this.isSelect)
.onChange((itemName:CheckboxGroupResult) => {
console.info("TextPicker::dialogResult is" + JSON.stringify(itemName))
this.showToast(itemName.status.valueOf() == 0 ? "selectAll true" : "selectAll false");
})
Checkbox({ name: 'checkbox1', group: 'checkboxGroup' })
.selectedColor(0x39a2db)
.key("CheckboxOne")
.onChange((value: boolean) => {
console.info('Checkbox1 change is' + value)
})
Checkbox({ name: 'checkbox2', group: 'checkboxGroup' })
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox2 change is' + value)
})
Checkbox({ name: 'checkbox3', group: 'checkboxGroup' })
.selectedColor(0x39a2db)
.onChange((value: boolean) => {
console.info('Checkbox3 change is' + value)
})
}
}
}.width("100%").height("100%")
}
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct CircleNe {
@State w: string = "100px";
@State h: string = "100px";
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear CircleNew start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear CircleNew end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("circle-New")
.width(100)
.height(70)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("neText")
Circle()
.width(`${this.w}`)
.height(`${this.h}`)
.key('circle')
}.width("100%").height("100%")
}
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 Log from '../common/Log.ets';
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct EllipseNe {
@State w: string = "300.00px";
@State h: string = "300.00px";
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear EllipseNe start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear EllipseNe end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("ellipse-Ne")
.width(100)
.height(70)
.fontSize(20)
.opacity(1)
.align(Alignment.TopStart)
.fontColor(0xCCCCCC)
.lineHeight(25)
.border({ width: 1 })
.padding(10)
.textAlign(TextAlign.Center)
.textOverflow({ overflow: TextOverflow.None })
.key("neText")
Ellipse().width(`${this.w}`).height(`${this.h}`).key('ellipse')
}.width('100%').height('100%')
}
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 Log from '../common/Log.ets';
@Entry
@Component
struct MyComponent {
aboutToAppear() {
}
build() {
Flex({
direction: FlexDirection.Column,
alignItems: ItemAlign.Center,
justifyContent: FlexAlign.Center
}) {
Text('ace ApiLack ets test')
.fontSize(50)
.fontWeight(FontWeight.Bold)
}
.width('100%')
.height('100%')
}
}
\ No newline at end of file
// @ts-nocheck
/**
* Copyright (c) 2021 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 AbilityDelegatorRegistry from '@ohos.application.abilityDelegatorRegistry'
import { Hypium } from 'hypium/index'
import testsuite from '../test/List.test'
export default {
onCreate() {
console.info('Application onCreate')
var abilityDelegator: any
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
var abilityDelegatorArguments: any
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
console.info('start run testcase!!!')
Hypium.hypiumTest(abilityDelegator, abilityDelegatorArguments, testsuite)
},
onDestroy() {
console.info('Application onDestroy')
},
}
\ No newline at end of file
// @ts-nocheck
/**
* Copyright (c) 2021 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 '@system.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
// @ts-nocheck
/**
* Copyright (c) 2021 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 itName',
'-s level', '-s testType', '-s size', '-s timeout',
'-s package'
])
let targetParams = '';
for (const key in parameters) {
if (keySet.has(key)) {
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')
}
onRun() {
console.log('OpenHarmonyTestRunner onRun run')
abilityDelegatorArguments = AbilityDelegatorRegistry.getArguments()
abilityDelegator = AbilityDelegatorRegistry.getAbilityDelegator()
let lMonitor = {
abilityName: testAbilityName,
onAbilityCreate: onAbilityCreateCallback,
};
var testAbilityName = abilityDelegatorArguments.parameters['-p'] + '.MainAbility'
abilityDelegator.addAbilityMonitor(lMonitor, addAbilityMonitorCallback)
var cmd = 'aa start -d 0 -a ' + testAbilityName + ' -b ' + abilityDelegatorArguments.bundleName
cmd += ' '+translateParamsToString(abilityDelegatorArguments.parameters)
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 call abilityDelegator.getAppContext')
var context = abilityDelegator.getAppContext()
console.info('getAppContext : ' + JSON.stringify(context))
console.info('OpenHarmonyTestRunner onRun end')
}
};
\ No newline at end of file
/**
* Copyright (c) 2021 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 alphabetIndexerOnSelectJsunit from './alphabetIndexer.test.ets';
import checkBoxGroupSelectAllJsunit from './checkBoxGroup.test.ets';
import circleNewJsunit from './circle.test.ets';
import ellipseNeJsunit from './ellipse.test.ets';
export default function testsuite() {
alphabetIndexerOnSelectJsunit()
checkBoxGroupSelectAllJsunit()
circleNewJsunit()
ellipseNeJsunit()
}
\ No newline at end of file
// @ts-nocheck
/**
* Copyright (c) 2021 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.
*/
export default class Utils {
static rect_left;
static rect_top;
static rect_right;
static rect_bottom;
static rect_value;
static sleep(time) {
return new Promise((resolve, reject) => {
setTimeout(() => {
resolve()
}, time)
}).then(() => {
console.info(`sleep ${time} over...`)
})
}
static getComponentRect(key) {
let strJson = getInspectorByKey(key);
let obj = JSON.parse(strJson);
console.info("[getInspectorByKey] current component obj is: " + JSON.stringify(obj));
let rectInfo = JSON.parse('[' + obj.$rect + ']')
console.info("[getInspectorByKey] rectInfo is: " + rectInfo);
this.rect_left = JSON.parse('[' + rectInfo[0] + ']')[0]
this.rect_top = JSON.parse('[' + rectInfo[0] + ']')[1]
this.rect_right = JSON.parse('[' + rectInfo[1] + ']')[0]
this.rect_bottom = JSON.parse('[' + rectInfo[1] + ']')[1]
return this.rect_value = {
"left": this.rect_left, "top": this.rect_top, "right": this.rect_right, "bottom": this.rect_bottom
}
}
static async swipe(downX, downY, upX, upY, steps) {
console.info('start to swipe')
this.drags(downX, downY, upX, upY, steps, false)
}
static async drag(downX, downY, upX, upY, steps) {
console.info('start to drag')
this.drags(downX, downY, upX, upY, steps, true)
}
static async drags(downX, downY, upX, upY, steps, drag) {
var xStep;
var yStep;
var swipeSteps;
var ret;
xStep = 0;
yStep = 0;
ret = false;
swipeSteps = steps;
if (swipeSteps == 0) {
swipeSteps = 1;
}
xStep = (upX - downX) / swipeSteps;
yStep = (upY - downY) / swipeSteps;
console.info('move step is: ' + 'xStep: ' + xStep + ' yStep: ' + yStep)
var downPonit: TouchObject = {
id: 1,
x: downX,
y: downY,
type: TouchType.Down,
}
console.info('down touch started: ' + JSON.stringify(downPonit))
sendTouchEvent(downPonit);
console.info('start to move')
if (drag) {
await this.sleep(500)
}
for (var i = 1;i <= swipeSteps; i++) {
var movePoint: TouchObject = {
id: 1,
x: downX + (xStep * i),
y: downY + (yStep * i),
type: TouchType.Move
}
console.info('move touch started: ' + JSON.stringify(movePoint))
ret = sendTouchEvent(movePoint)
if (ret == false) {
break;
}
await this.sleep(5)
}
console.info('start to up')
if (drag) {
await this.sleep(100)
}
var upPoint: TouchObject = {
id: 1,
x: upX,
y: upY,
type: TouchType.Up,
}
console.info('up touch started: ' + JSON.stringify(upPoint))
sendTouchEvent(upPoint)
await this.sleep(500)
}
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 '@system.router';
import events_emitter from '@ohos.events.emitter';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"
import Utils from './Utils.ets'
export default function alphabetIndexerOnSelectJsunit() {
describe('alphabetIndexerOnSelectTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/alphabetIndexer',
}
try {
router.clear();
let pages = router.getState();
console.info("get alphabetIndexer state success " + JSON.stringify(pages));
if (!("alphabetIndexer" == pages.name)) {
console.info("get alphabetIndexer state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push alphabetIndexer page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push alphabetIndexer page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("alphabetIndexerOnSelect after each called");
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0001
* @tc.name testalphabetIndexer0001
* @tc.desic acealphabetIndexerEtsTest0001
*/
it('testalphabetIndexerWidth0001', 0, async function (done) {
console.info('alphabetIndexerWidth testalphabetIndexerWidth0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('alphabetIndexer');
console.info("[testalphabetIndexerWidth0001] component width strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('AlphabetIndexer');
expect(obj.$attrs.width).assertEqual("100.00vp");
console.info("[testalphabetIndexerWidth0001] width value :" + obj.$attrs.width);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0002
* @tc.name testalphabetIndexer0002
* @tc.desic acealphabetIndexerEtsTest0002
*/
it('testalphabetIndexerHeight0002', 0, async function (done) {
console.info('alphabetIndexerHeight testalphabetIndexerHeight0002 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('alphabetIndexer');
console.info("[testalphabetIndexerHeight0002] component height strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('AlphabetIndexer');
expect(obj.$attrs.height).assertEqual("300.00vp");
console.info("[testalphabetIndexerHeight0002] height value :" + obj.$attrs.height);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0003
* @tc.name testalphabetIndexer0003
* @tc.desic acealphabetIndexerEtsTest0003
*/
it('testalphabetIndexerColor0003', 0, async function (done) {
console.info('alphabetIndexerColor testalphabetIndexerColor0003 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('alphabetIndexer');
console.info("[testalphabetIndexerColor0003] component fontSize strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('AlphabetIndexer');
expect(obj.$attrs.color).assertEqual(undefined);
console.info("[testalphabetIndexerColor0003] color value :" + obj.$attrs.color);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0004
* @tc.name testalphabetIndexer0004
* @tc.desic acealphabetIndexerEtsTest0004
*/
it('testalphabetIndexerSelectedColor0004', 0, async function (done) {
console.info('alphabetIndexerSelectedColor testalphabetIndexerSelectedColor0004 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('alphabetIndexer');
console.info("[testalphabetIndexerOnSelect0004] component opacity strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('AlphabetIndexer');
expect(obj.$attrs.selectedColor).assertEqual("#FFFFFFFF");
console.info("[testalphabetIndexerSelectedColor0004] selectedColor value :" + obj.$attrs.selectedColor);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0005
* @tc.name testalphabetIndexer0005
* @tc.desic acealphabetIndexerEtsTest0005
*/
it('testalphabetIndexerPopupColor0005', 0, async function (done) {
console.info('alphabetIndexerPopupColor testalphabetIndexerPopupColor0005 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('alphabetIndexer');
console.info("[testalphabetIndexerPopupColor0005] component align strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('AlphabetIndexer');
expect(obj.$attrs.popupColor).assertEqual("#FF48D1CC");
console.info("[testalphabetIndexerPopupColor0005] popupColor value :" + obj.$attrs.popupColor);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0006
* @tc.name testalphabetIndexer0006
* @tc.desic acealphabetIndexerEtsTest0006
*/
it('testalphabetIndexerSelectedBackgroundColor0006', 0, async function (done) {
console.info('alphabetIndexerSelectedBackgroundColor testalphabetIndexerSelectedBackgroundColor0006 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('alphabetIndexer');
console.info("[testalphabetIndexerSelectedBackgroundColor0006] component fontColor strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('AlphabetIndexer');
expect(obj.$attrs.selectedBackgroundColor).assertEqual("#FF0000E6");
console.info("[testalphabetIndexerSelectedBackgroundColor0006] selectedBackgroundColor value :" + obj.$attrs.selectedBackgroundColor);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0007
* @tc.name testalphabetIndexer0007
* @tc.desic acealphabetIndexerEtsTest0007
*/
it('testalphabetIndexerPopupBackground0007', 0, async function (done) {
console.info('alphabetIndexerPopupBackground testalphabetIndexerPopupBackground0007 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('alphabetIndexer');
console.info("[testalphabetIndexerPopupBackground0007] component lineHeight strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('AlphabetIndexer');
expect(obj.$attrs.popupBackground).assertEqual("#E500DDDD");
console.info("[testalphabetIndexerPopupBackground0007] popupBackground value :" + obj.$attrs.popupBackground);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0009
* @tc.name testalphabetIndexer0009
* @tc.desic acealphabetIndexerEtsTest0009
*/
it('testalphabetIndexerUsingPopup0009', 0, async function (done) {
console.info('alphabetIndexerUsingPopup testalphabetIndexerUsingPopup009 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('alphabetIndexer');
console.info("[testalphabetIndexerUsingPopup0009] component padding strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('AlphabetIndexer');
expect(obj.$attrs.usingPopup).assertEqual(true);
console.info("[testalphabetIndexerUsingPopup0009] usingPopup value :" + obj.$attrs.usingPopup);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0010
* @tc.name testalphabetIndexer0010
* @tc.desic acealphabetIndexerEtsTest0010
*/
it('testalphabetIndexerItemSize0010', 0, async function (done) {
console.info('alphabetIndexerItemSize testalphabetIndexerItemSize0010 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('alphabetIndexer');
console.info("[testalphabetIndexerItemSize0010] component textAlign strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('AlphabetIndexer');
expect(obj.$attrs.itemSize).assertEqual("28.000000");
console.info("[testalphabetIndexerItemSize0010] itemSize value :" + obj.$attrs.itemSize);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0010
* @tc.name testalphabetIndexer0011
* @tc.desic acealphabetIndexerEtsTest0011
*/
it('testalphabetIndexerAlignStyle0011', 0, async function (done) {
console.info('alphabetIndexerAlignStyle testalphabetIndexerAlignStyle0011 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('alphabetIndexer');
console.info("[testalphabetIndexerAlignStyle0011] component strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('AlphabetIndexer');
expect(obj.$attrs.alignStyle).assertEqual("AlignStyle.Left");
console.info("[testalphabetIndexerItemSize0010] alignStyle value :" + obj.$attrs.alignStyle);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0012
* @tc.name testalphabetIndexerOnSelect0012
* @tc.desic acealphabetIndexerOnSelectEtsTest0012
*/
it('testalphabetIndexerOnSelect0012', 0, async function (done) {
console.info('alphabetIndexerOnSelect testalphabetIndexerOnSelect0011 START');
await Utils.sleep(2000);
try{
let callback = (indexEvent) => {
console.info("onSelect_0012 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.STATUS).assertEqual(true);
}
let indexEvent = {
eventId: 10201,
priority: events_emitter.EventPriority.LOW
}
sendEventByKey('alphabetIndexer', 10, "")
events_emitter.on(indexEvent, callback);
}catch(err){
console.info("onSelect_0012 on events_emitter err : " + JSON.stringify(err));
}
await Utils.sleep(2000);
try {
var innerEventOne = {
eventId: 10202,
priority: events_emitter.EventPriority.LOW
}
var callback1 = (eventData) => {
console.info("onRequestPopupData_0012 get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.STATUS).assertEqual(true);
}
sendEventByKey('alphabetIndexer', 10, "")
console.info("onSelect_0012 click result is: " + JSON.stringify(sendEventByKey('alphabetIndexer', 10, "")));
events_emitter.on(innerEventOne, callback1);
} catch (err) {
console.info("onRequestPopupData_0012 on events_emitter err : " + JSON.stringify(err));
}
console.info('testalphabetIndexerOnSelect0012 END');
done();
});
})
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 events_emitter from '@ohos.events.emitter';
import router from '@system.router';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"
import Utils from './Utils.ets'
export default function checkBoxGroupSelectAllJsunit() {
describe('checkBoxGroupSelectAllTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/checkBoxGroup',
}
try {
router.clear();
let pages = router.getState();
console.info("get checkBoxGroup state success " + JSON.stringify(pages));
if (!("checkBoxGroup" == pages.name)) {
console.info("get checkBoxGroup state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push checkBoxGroup page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push checkBoxGroup page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("checkBoxGroupSelectAll after each called");
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0001
* @tc.name testcheckBoxGroupSelectAll0001
* @tc.desic acecheckBoxGroupSelectAllEtsTest0001
*/
it('testcheckBoxGroupSelectAll0001', 0, async function (done) {
console.info('checkBoxGroupSelectAll testcheckBoxGroupSelectAll0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('CheckboxGroup');
console.info("[testcheckBoxGroupSelectAll0001] component selectedColor strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('CheckboxGroup');
expect(obj.$attrs.selectedColor).assertEqual("#FFED6F21");
console.info("[testcheckBoxGroupSelectAll0001] selectedColor value :" + obj.$attrs.selectedColor);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0002
* @tc.name testcheckBoxGroupSelectAll0002
* @tc.desic acecheckBoxGroupSelectAllEtsTest0002
*/
it('testcheckBoxGroupSelectAll0002', 0, async function (done) {
console.info('checkBoxGroupSelectAll testcheckBoxGroupSelectAll0002 START');
try {
var eventData = {
data: {
"isSelect": false
}
}
var innerEvent = {
eventId: 908,
priority: events_emitter.EventPriority.LOW
}
console.info("[testcheckBoxGroupSelectAll0002] start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[testcheckBoxGroupSelectAll0002] change component data error: " + err.message);
}
await Utils.sleep(2000);
let strJson = getInspectorByKey('CheckboxOne');
let obj = JSON.parse(strJson);
console.info("[testcheckBoxGroupSelectAll0002] obj is: " + JSON.stringify(obj));
expect(obj.$attrs.selectedColor).assertEqual("#FF39A2DB");
console.info("[testcheckBoxGroupSelectAll0002] selectedColor value :" + obj.$attrs.selectedColor);
console.info('testcheckBoxGroupSelectAll0002 END');
done();
});
})
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 '@system.router';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"
import Utils from './Utils.ets'
export default function circleNewJsunit() {
describe('circleNewTest', function () {
beforeAll(async function (done) {
console.info("circle beforeEach start");
let options = {
uri: 'pages/circle',
}
try {
router.clear();
let pages = router.getState();
console.info("get circle state success " + JSON.stringify(pages));
if (!("circle" == pages.name)) {
console.info("get circle state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push circle page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push circle page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("circleNew after each called");
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_001
* @tc.name testcircleNew001
* @tc.desic acecircleNewEtsTest001
*/
it('testcircleNew001', 0, async function (done) {
console.info('circleNew testcircleNew0011 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('circle');
console.info("[testcircleNew001] component textAlign strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.width).assertEqual("100.00px");
console.info("[testcircleNew001] width value :" + obj.$attrs.width);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_002
* @tc.name testcircleNew002
* @tc.desic acecircleNewEtsTest002
*/
it('testcircleNew002', 0, async function (done) {
console.info('circleNew testcircleNew002 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('circle');
console.info("[testcircleNew002] component textAlign strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.height).assertEqual("100.00px");
console.info("[testcircleNew002] width value :" + obj.$attrs.width);
done();
});
})
}
/**
* Copyright (c) 2022 Shenzhen Kaihong Digital Industry Development 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 '@system.router';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"
import Utils from './Utils.ets'
export default function ellipseNeJsunit() {
describe('ellipseNeTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/ellipse',
}
try {
router.clear();
let pages = router.getState();
console.info("get ellipse state success " + JSON.stringify(pages));
if (!("ellipse" == pages.name)) {
console.info("get ellipse state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push ellipse page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push ellipse page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("ellipseNe after each called");
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0001
* @tc.name testellipseNe0001
* @tc.desic aceellipseNeEtsTest0001
*/
it('testellipseNe0001', 0, async function (done) {
console.info('ellipseNe testellipseNe0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('ellipse');
console.info("[testellipseNe0001] component width strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.width).assertEqual("300.00px");
console.info("[testellipseNe0001] width value :" + obj.$attrs.width);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0002
* @tc.name testellipseNe0002
* @tc.desic aceellipseNeEtsTest0002
*/
it('testellipseNe0002', 0, async function (done) {
console.info('ellipseNe testellipseNe0002 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('ellipse');
console.info("[testellipseNe0002] component height strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.height).assertEqual("300.00px");
console.info("[testellipseNe0002] height value :" + obj.$attrs.height);
done();
});
})
}
{
"color": [
{
"name": "color_hello",
"value": "#ffff0000"
},
{
"name": "color_world",
"value": "#ff0000ff"
}
]
}
\ No newline at end of file
{
"float":[
{
"name":"font_hello",
"value":"28.0fp"
},
{
"name":"font_world",
"value":"20.0fp"
}
]
}
\ No newline at end of file
{
"string": [
{
"name": "entry_MainAbility",
"value": "entry_MainAbility"
},
{
"name": "description_mainability",
"value": "ETS_Empty Ability"
},
{
"name": "TestAbility_desc",
"value": "description"
},
{
"name": "TestAbility_label",
"value": "label"
},
{
"name":"string_hello",
"value":"Hello"
},
{
"name":"string_world",
"value":"World"
},
{
"name":"message_arrive",
"value":"We will arrive at %s."
}
]
}
\ No newline at end of file
...@@ -55,6 +55,58 @@ describe('basicabilityapi', function () { ...@@ -55,6 +55,58 @@ describe('basicabilityapi', function () {
}); });
} }
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0100
* @tc.name testClearInterval
* @tc.desc Cancel the repetitive timing tasks previously set by setInterval.
*/
it('testClearInterval', 0, async function(done) {
console.info('testClearInterval START');
let res = 0;
let testTimes = 5
let intervalID = -1;
let promise1 = new Promise((resolve, reject) => {
intervalID = setInterval(function () {
if(res === testTimes ){
resolve(null);
clearInterval(intervalID);
}else{
res++;
console.info('testClearInterval res = ' + res);
}
}, 100);
})
Promise.all([promise1]).then(() => {
console.info('testClearInterval finally');
expect(testTimes).assertEqual(res);
console.info('testClearInterval END');
done();
});
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0200
* @tc.name testConsole
* @tc.desc Print a text message.
*/
it('testConsole', 0, function () {
console.info('testConsole START');
try{
const versionCode = 1.1;
console.info('[console.info] versionCode: ' + versionCode);
console.debug('[console.debug] versionCode: ' + versionCode);
console.log('[console.log] versionCode: ' + versionCode);
console.warn('[console.warn] versionCode: ' + versionCode);
console.error('[console.error] versionCode: ' + versionCode);
expect(test).assertEqual('success');
console.info('testConsole END');
}
catch(e){
console.info('testConsole ERROR' + e);
}
});
/** /**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0300 * @tc.number SUB_ACE_BASICABILITY_JS_API_0300
* @tc.name testRouterPush * @tc.name testRouterPush
...@@ -294,6 +346,65 @@ describe('basicabilityapi', function () { ...@@ -294,6 +346,65 @@ describe('basicabilityapi', function () {
}, 500); }, 500);
}); });
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_0900
* @tc.name testPromptShowToast
* @tc.desc Show text pop-up window.
*/
it('testPromptShowToast', 0, function () {
try{
console.info('testPromptShowToast START');
const delay = 5000;
prompt.showToast({
message: 'message',
duration: delay,
});
expect(test).assertEqual('success');
console.info('[prompt.showToast] success');
console.info('testPromptShowToast END');
}
catch(e){
console.log('testPromptShowToast ERROR' + e);
}
});
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1000
* @tc.name testPromptDialog
* @tc.desc Display the dialog box in the page.
*/
it('testPromptDialog', 0, function () {
console.info('testPromptDialog START')
try{
prompt.showDialog({
title: 'dialog showDialog test',
message: 'message of dialog',
buttons: [
{
text: 'OK',
color: '#0000ff',
index: 0
}
],
success: function (ret) {
console.info("[prompt.showDialog] ret.index " + ret.index);
expect(testResult).toBeTrue();
},
cancel: function () {
console.log('[prompt.showDialog] dialog cancel callback');
expect(testResultFail).toBeTrue();
},
complete: function () {
console.log('[prompt.showDialog] complete');
}
});
console.info('testPromptDialog END');
}
catch(e) {
console.info('testPromptDialog error ' + e);
}
});
/** /**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1100 * @tc.number SUB_ACE_BASICABILITY_JS_API_1100
* @tc.name testConfigurationGetLocale * @tc.name testConfigurationGetLocale
...@@ -335,6 +446,29 @@ describe('basicabilityapi', function () { ...@@ -335,6 +446,29 @@ describe('basicabilityapi', function () {
}, delay, 'test', 'message'); }, delay, 'test', 'message');
}); });
/**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1300
* @tc.name testClearTimeout
* @tc.desc The timer previously established by calling setTimeout() is cancelled.
*/
it('testClearTimeout', 0, async function (done) {
console.info('testClearTimeout START');
let res = 0;
let timeoutID = setTimeout(function () {
res++;
}, 700);
await setTimeout(function () {
console.info('testClearTimeout delay 0.5s')
clearTimeout(timeoutID);
console.info("[clearTimeout] success");
}, 500);
await setTimeout(function () {
expect(0).assertEqual(res);
console.info('testClearTimeout END');
done();
}, 1000);
});
/** /**
* @tc.number SUB_ACE_BASICABILITY_JS_API_1400 * @tc.number SUB_ACE_BASICABILITY_JS_API_1400
* @tc.name testSetInterval * @tc.name testSetInterval
......
...@@ -152,7 +152,6 @@ describe('aceJsApiAndAttr', function () { ...@@ -152,7 +152,6 @@ describe('aceJsApiAndAttr', function () {
done(); done();
}); });
/** /**
* @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0500 * @tc.number SUB_ACE_BASIC_COMPONENT_JS_API_0500
* @tc.name testDivComponent * @tc.name testDivComponent
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册