提交 00fe6305 编写于 作者: W wang-xupeng2

add testcases

Signed-off-by: Nwang-xupeng2 <wangxupeng2@huawei.com>
上级 19168953
/**
* 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 {MessageManager,Callback} from '../utils/MessageManager';
@Entry
@Component
struct GridItemPage {
@State numbers: string[] = Array.apply(null, { length: 16 }).map(function (item, i) {
return i.toString()
})
@State rowStart: number = 1
@State rowEnd: number = 4
@State columnStart: number = 1
@State columnEnd: number = 5
@State forceRebuild: boolean = true
@State selectable: boolean = false
@State onSelect: string = 'a'
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('GridItemPage onPageShow')
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value)
if (message.name == 'rowStart') {
this.rowStart = message.value
}
if (message.name == 'rowEnd') {
this.rowEnd = message.value
}
if (message.name == 'columnStart') {
this.columnStart = message.value
}
if (message.name == 'columnEnd') {
this.columnEnd = message.value
}
if (message.name == 'forceRebuild') {
this.forceRebuild = message.value
}
if (message.name == 'selectable') {
this.selectable = message.value
}
if (message.name == 'onSelect') {
this.onSelect = message.value
}
}
this.messageManager.registerCallback(callback)
}
build() {
Column() {
Grid() {
GridItem() {
Text(this.onSelect)
.key('onSelect')
.fontSize(16)
.backgroundColor(0xFAEEE0)
.width('100%')
.height('100%')
.textAlign(TextAlign.Center)
}.rowStart(this.rowStart)
.rowEnd(this.rowEnd)
.key("gridItem1")
.selectable(this.selectable)
.onSelect((isSelected: boolean) =>{
this.onSelect = 'true'
console.info('isSelected: ' + isSelected)
})
ForEach(this.numbers, (item) => {
GridItem() {
Text(item)
.fontSize(16)
.backgroundColor(0xF9CF93)
.width('100%')
.height('100%')
.textAlign(TextAlign.Center)
.key(item)
}.forceRebuild(this.forceRebuild)
.key("gridItem2")
}, item => item)
GridItem() {
Text('b')
.fontSize(16)
.backgroundColor(0xDBD0C0)
.width('100%')
.height('100%')
.textAlign(TextAlign.Center)
}.columnStart(this.columnStart).columnEnd(this.columnEnd).key("gridItem3")
}
.key('grid1')
.columnsGap("4")
.rowsGap("5")
.multiSelectable(true)
.columnsTemplate('1fr 1fr 1fr 1fr 1fr')
.rowsTemplate('1fr 1fr 1fr 1fr 1fr')
.width('90%').height(300)
}.width('100%').margin({ top: 5 })
}
}
\ No newline at end of file
/**
* 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 {MessageManager,Callback} from '../utils/MessageManager';
@Entry
@Component
struct NavDestinationPage {
private arr: number[] = [0, 1, 2, 3]
@State isActive: boolean = false
@State dex: number = 0
@State stateChange: string = ''
@State hideTitleBar: boolean = true
@State backColor: Color = Color.Grey
@State title: string = 'NavDestination'
messageManager: MessageManager = new MessageManager()
onPageShow() {
console.info('NavDestination onPageShow')
globalThis.value = {
name: 'messageManager', message: this.messageManager
}
let callback: Callback = (message: any) => {
console.error('message = ' + message.name + "--" + message.value)
if (message.name == 'arr') {
this.arr = message.value
}
if (message.name == 'dex') {
this.dex = message.value
}
if (message.name == 'stateChange') {
this.stateChange = message.value
}
if (message.name == 'hideTitleBar') {
this.hideTitleBar = message.value
}
if (message.name == 'backColor') {
this.backColor = message.value
}
if (message.name == 'title') {
this.title = message.value
}
}
this.messageManager.registerCallback(callback)
}
build() {
Column() {
Navigation() {
List({ space: 12, initialIndex: 0 }) {
ForEach(this.arr, (item: number, index: number) => {
ListItem() {
NavRouter() {
Row() {
Image($r('app.media.icon')).width(30).height(30).borderRadius(30).margin({ left: 3, right: 10 })
Text(`NavRouter${item + 1}`)
.fontSize(22)
.fontWeight(500)
.textAlign(TextAlign.Center)
}
.width(180)
.height(72)
.borderRadius(24)
NavDestination() {
Text(`我是NavDestination第${item + 1}页内容`).fontSize(50)
Flex({ direction: FlexDirection.Row }) {
Row() {
Image($r('app.media.icon')).width(40).height(40).borderRadius(40).margin({ right: 15 })
Text('今天共有七节课').fontSize(30).key('textContent${item + 1}')
}.padding({ left: 15 })
}
}.backgroundColor(this.backColor)
.key('NavDestination' + (item + 1).toString())
.title(this.title + (item + 1).toString())
.hideTitleBar(this.hideTitleBar)
}.key('NavRouter' + (item + 1).toString())
.onStateChange((isActivated: boolean) => {
this.stateChange = "stateChange " + isActivated.toString()
this.dex = index
}).width('40%')
}
}, item => item)
}
.height('100%')
.margin({ top: 12, left: 12 })
}
.mode(NavigationMode.Split)
.hideTitleBar(true)
.hideToolBar(true)
Text(this.stateChange).fontSize(20).margin(10).key('stateChange')
}.height('100%')
}
}
/**
* 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 {MessageManager,Callback} from '../utils/MessageManager';
@Entry
@Component
struct NavigationPage {
private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
@State mainTitleName: string = 'mainTitle'
@State subTitleName: string = 'subTitle'
@State titleMode: NavigationTitleMode = NavigationTitleMode.Free
@State hideToolBar: boolean = false
@State hideTitleBar: boolean = false
@State hideBackButton: boolean = false
@State navBarWidth: number = 700
@State navBarPosition: NavBarPosition = NavBarPosition.Start
@State mode: NavigationMode = NavigationMode.Split
@State backButtonIcon: string = 'resources/base/media/icon.png'
@State hideNavBar: boolean = false
@State titleModeChange: string = ''
@State navBarStateChange: string = ''
@State currentIndex: number = 0
@State Build: Array<Object> = [
{
text: 'add',
num: 0
},
{
text: 'app',
num: 1
},
{
text: 'collect',
num: 2
}
]
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('NavDestination onPageShow')
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value)
if (message.name == 'mainTitleName') {
this.mainTitleName = message.value
}
if (message.name == 'subTitleName') {
this.subTitleName = message.value
}
if (message.name == 'titleMode') {
this.titleMode = message.value
}
if (message.name == 'hideToolBar') {
this.hideToolBar = message.value
}
if (message.name == 'hideTitleBar') {
this.hideTitleBar = message.value
}
if (message.name == 'hideBackButton') {
this.hideBackButton = message.value
}
if (message.name == 'navBarWidth') {
this.navBarWidth = message.value
}
if (message.name == 'navBarPosition') {
this.navBarPosition = message.value
}
if (message.name == 'mode') {
this.mode = message.value
}
if (message.name == 'backButtonIcon') {
this.backButtonIcon = message.value
}
if (message.name == 'hideNavBar') {
this.hideNavBar = message.value
}
}
this.messageManager.registerCallback(callback)
}
@Builder NavigationTitle() {
Column() {
Text(this.mainTitleName)
.fontColor('#182431')
.fontSize(30)
.lineHeight(41)
.fontWeight(700)
.key('title')
Text(this.subTitleName)
.fontColor('#182431')
.fontSize(14)
.lineHeight(19)
.opacity(0.4)
.margin({ top: 2 })
.key('subTitle')
}.alignItems(HorizontalAlign.Start)
}
@Builder NavigationMenus() {
Row() {
Image('resources/base/media/ic_pad.svg')
.width(24)
.height(24)
Image('resources/base/media/ic_pad.svg')
.width(24)
.height(24)
.margin({ left: 24 })
}
}
@Builder NavigationToolbar() {
Row() {
ForEach(this.Build, item => {
Column() {
Image(this.currentIndex == item.num ? 'resources/base/media/icon_selected.svg' : 'resources/base/media/icon_tv.svg')
.width(24)
.height(24)
Text(item.text)
.fontColor(this.currentIndex == item.num ? '#007DFF' : '#182431')
.fontSize(10)
.lineHeight(14)
.fontWeight(500)
.margin({ top: 3 })
}.width(104).height(56).id('navigationToolbar')
.onClick(() => {
this.currentIndex = item.num
})
})
}.margin({ left: 24 })
}
build() {
Column() {
Navigation() {
TextInput({ placeholder: 'search...' })
.width(336)
.height(40)
.backgroundColor('#FFFFFF')
.margin({ top: 8, left: 12 })
List({ space: 12, initialIndex: 0 }) {
ForEach(this.arr, (item) => {
ListItem() {
Text('' + item)
.height(72)
.backgroundColor('#FFFFFF')
.borderRadius(24)
.fontSize(16)
.fontWeight(500)
.textAlign(TextAlign.Center)
}.editable(true)
}, item => item)
}
.height(324)
.width('100%')
.margin({ top: 12, left: 12 })
.key('list')
Text('TitleModeChange:' + this.titleModeChange).fontSize(20).margin(10).key('titleModeChange')
Text('NavBarStateChange:' + this.navBarStateChange).fontSize(20).margin(10).key('navBarStateChange')
}
.title(this.NavigationTitle)
.menus(this.NavigationMenus)
.titleMode(this.titleMode)
.toolBar(this.NavigationToolbar)
.key('navigation')
.hideTitleBar(this.hideTitleBar)
.hideToolBar(this.hideToolBar)
.hideBackButton(this.hideBackButton)
.navBarWidth(this.navBarWidth)
.navBarPosition(this.navBarPosition)
.mode(this.mode)
.backButtonIcon(this.backButtonIcon)
.hideNavBar(this.hideNavBar)
.onTitleModeChange((titleModel: NavigationTitleMode) => {
console.info('titleMode' + titleModel)
this.titleModeChange = "succ"
})
.onNavBarStateChange((isVisible: boolean) => {
console.info('isVisible: ' + isVisible)
this.navBarStateChange = "succ"
})
}.width('100%').height('100%').backgroundColor('#F1F3F5')
}
}
\ No newline at end of file
/**
* 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 {MessageManager,Callback} from '../utils/MessageManager';
@Entry
@Component
struct TogglePage {
@State type: ToggleType = ToggleType.Checkbox
@State isOn: boolean = true
@State selectedColor: string = '#FFFF0000'
@State switchPointColor: string = '#FF008000'
@State text: string = 'no change'
messageManager:MessageManager = new MessageManager()
onPageShow() {
console.info('Toggle onPageShow')
globalThis.value = {
name:'messageManager',message:this.messageManager
}
let callback:Callback = (message:any) => {
console.error('message = ' + message.name + "--" + message.value)
if (message.name == 'type') {
this.type = message.value
}
if (message.name == 'isOn') {
this.isOn = message.value
}
if (message.name == 'selectedColor') {
this.selectedColor = message.value
}
if (message.name == 'switchPointColor') {
this.switchPointColor = message.value
}
}
this.messageManager.registerCallback(callback)
}
build() {
Column({ space: 10 }) {
Text('type: Switch').fontSize(12).fontColor(0xcccccc).width('90%')
Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {
Toggle({ type: ToggleType.Switch})
.key('toggleSwitch')
.selectedColor('#007DFF')
.switchPointColor(this.switchPointColor)
.onChange((isOn: boolean) => {
this.text = "switch " + isOn.toString()
console.info('Component status:' + isOn)
})
Toggle({ type: ToggleType.Switch, isOn: true })
.selectedColor('#007DFF')
.switchPointColor('#FFFFFF')
.onChange((isOn: boolean) => {
console.info('Component status:' + isOn)
})
}
Text('type: Checkbox').fontSize(12).fontColor(0xcccccc).width('90%')
Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {
Toggle({ type: this.type, isOn: this.isOn })
.key('toggleCheckbox')
.size({ width: 20, height: 20 })
.selectedColor(this.selectedColor)
.onChange((isOn: boolean) => {
this.text = "checkbox " + isOn.toString()
console.info('Component status:' + isOn)
})
Toggle({ type: ToggleType.Checkbox, isOn: true })
.size({ width: 20, height: 20 })
.selectedColor('#007DFF')
.onChange((isOn: boolean) => {
console.info('Component status:' + isOn)
})
}
Text('type: Button').fontSize(12).fontColor(0xcccccc).width('90%')
Flex({ justifyContent: FlexAlign.SpaceEvenly, alignItems: ItemAlign.Center }) {
Toggle({ type: ToggleType.Button, isOn: false }) {
Text('status button').fontColor('#182431').fontSize(12)
}.width(106)
.key('toggleButton')
.selectedColor('rgba(0,125,255,0.20)')
.onChange((isOn: boolean) => {
this.text = "button " + isOn.toString()
console.info('Component status:' + isOn)
})
Toggle({ type: ToggleType.Button, isOn: true }) {
Text('status button').fontColor('#182431').fontSize(12)
}.width(106)
.selectedColor('rgba(0,125,255,0.20)')
.onChange((isOn: boolean) => {
console.info('Component status:' + isOn)
})
}
Text(this.text).fontSize(20).margin(10).key('text')
}.width('100%').padding(24)
}
}
\ No newline at end of file
/**
* 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 router from '@system.router';
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.UiTest';
import CommonFunc from '../MainAbility/utils/Common';
import {MessageManager,Callback} from '../MainAbility/utils/MessageManager';
export default function GridItemJsunit() {
describe('GridItemJsunit', function () {
beforeEach(async function (done) {
console.info("GridItemJsunit beforeEach start");
let options = {
uri: 'MainAbility/pages/GridItemPage',
}
try {
router.clear();
let pages = router.getState();
console.info("get GridItemJsunit state pages: " + JSON.stringify(pages));
if (!("GridItemPage" == pages.name)) {
console.info("get GridItemJsunit state pages.name: " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push GridItemJsunit success: " + JSON.stringify(result));
await CommonFunc.sleep(2000);
}
} catch (err) {
console.error("push GridItemJsunit page error: " + err);
expect().assertFail();
}
done();
});
/**
* @tc.number SUB_ARKUI_GRIDITEM_JSAPI_001
* @tc.name Test GridItemJsunit_0100
* @tc.desc Test Get GridItem attribute
*/
it('GridItemJsunit_0100', 0, async function (done) {
// Get the information of the GridItem component
console.info('[GridItemJsunit_0100] START');
await CommonFunc.sleep(2000);
let strJson1 = getInspectorByKey('gridItem1');
let obj = JSON.parse(strJson1);
console.info("[GridItemJsunit_0100] component obj is: " + JSON.stringify(obj));
//expect(obj.$attrs.rowStart).assertEqual('1');
//expect(obj.$attrs.rowEnd).assertEqual('4');
expect(obj.$attrs.selectable).assertEqual('false');
// Verify the default value of forceRebuild
expect(obj.$attrs.forceRebuild).assertEqual('false');
await CommonFunc.sleep(1000);
let strJson2 = getInspectorByKey('gridItem2');
let obj2 = JSON.parse(strJson2);
console.info("[GridItemJsunit_0100] component obj2 is: " + JSON.stringify(obj2));
//expect(obj2.$attrs.columnStart).assertEqual('1');
//expect(obj2.$attrs.columnEnd).assertEqual('5');
expect(obj2.$attrs.forceRebuild).assertEqual('true');
// Verify the default value of selectable
expect(obj2.$attrs.selectable).assertEqual('true');
console.info('[GridItemJsunit_0100] END');
done();
});
/**
* @tc.number SUB_ARKUI_GRIDITEM_JSAPI_002
* @tc.name Test GridItemJsunit_0200
* @tc.desc Test Modify GridItem attribute value
*/
it('GridItemJsunit_0200', 0, async function (done) {
// Modify the properties of component GridItem
console.info('[GridItemJsunit_0200] START');
globalThis.value.message.notify({name:'rowStart',value:'2'})
await CommonFunc.sleep(2000);
globalThis.value.message.notify({name:'rowEnd',value:'5'})
await CommonFunc.sleep(2000);
globalThis.value.message.notify({name:'columnStart',value:'2'})
await CommonFunc.sleep(2000);
globalThis.value.message.notify({name:'columnEnd',value:'4'})
await CommonFunc.sleep(2000);
globalThis.value.message.notify({name:'forceRebuild',value:'false'})
await CommonFunc.sleep(2000);
globalThis.value.message.notify({name:'selectable',value:'true'})
await CommonFunc.sleep(2000);
// Get the propoties value of the GridItem component
let strJson = getInspectorByKey('gridItem1');
let obj = JSON.parse(strJson);
console.info("[GridItemJsunit_0200] component obj is: " + JSON.stringify(obj));
//expect(obj.$attrs.rowStart).assertEqual('2');
//expect(obj.$attrs.rowEnd).assertEqual('5');
expect(obj.$attrs.selectable).assertEqual('false');
await CommonFunc.sleep(1000);
let strJson2 = getInspectorByKey('gridItem2');
let obj2 = JSON.parse(strJson2);
console.info("[GridItemJsunit_0200] component obj2 is: " + JSON.stringify(obj2));
//expect(obj2.$attrs.columnStart).assertEqual('2');
//expect(obj2.$attrs.columnEnd).assertEqual('4');
expect(obj2.$attrs.forceRebuild).assertEqual('false');
console.info('[GridItemJsunit_0200] END');
done();
});
it('GridItemJsunit_0300', 0, async function (done) {
// Illegal modification of properties of component gridItem
console.info('[GridItemJsunit_0300] START');
globalThis.value.message.notify({name:'rowStart',value:'test'})
await CommonFunc.sleep(200);
globalThis.value.message.notify({name:'rowEnd',value:'#'})
await CommonFunc.sleep(200);
globalThis.value.message.notify({name:'columnStart',value:'-10'})
await CommonFunc.sleep(200);
globalThis.value.message.notify({name:'columnEnd',value:'%a'})
await CommonFunc.sleep(200);
globalThis.value.message.notify({name:'forceRebuild',value:'0'})
await CommonFunc.sleep(200);
globalThis.value.message.notify({name:'selectable',value:'test'})
await CommonFunc.sleep(2000);
// Get the propoties value of the GridItem component
let strJson = getInspectorByKey('gridItem1');
let obj = JSON.parse(strJson);
console.info("[GridItemJsunit_0300] component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.rowStart).assertEqual('0');
expect(obj.$attrs.rowEnd).assertEqual('0');
expect(obj.$attrs.selectable).assertEqual('false');
await CommonFunc.sleep(1000);
let strJson2 = getInspectorByKey('gridItem2');
let obj2 = JSON.parse(strJson2);
console.info("[GridItemJsunit_0300] component obj2 is: " + JSON.stringify(obj2));
expect(obj2.$attrs.columnStart).assertEqual('0');
expect(obj2.$attrs.columnEnd).assertEqual('0');
expect(obj2.$attrs.forceRebuild).assertEqual('false');
console.info('[GridItemJsunit_0300] END');
done();
});
it('GridItemJsunit_0400', 0, async function (done) {
// Verify the function of onSelect of GridItem component
console.info('[GridItemJsunit_0400] START');
let grid1 = CommonFunc.getComponentRect('grid1');
let left_x = Math.round(grid1.left)
let bottom_y = Math.round(grid1.bottom / 2)
let driver = await UiDriver.create()
await driver.swipe(left_x, bottom_y, 800, bottom_y);
await CommonFunc.sleep(500);
let textComponent = await driver.findComponent(BY.key('onSelect'));
let text = await textComponent.getText();
await CommonFunc.sleep(500);
expect(text).assertEqual('a');
console.info('[GridItemJsunit_0400] END');
done();
});
it('GridJsunit_0500', 0, async function (done) {
// Verify the columnsTemplate of Grid component
console.info('[GridJsunit_0500] START');
let gridItem1 = CommonFunc.getComponentRect('gridItem1');
let left1 = gridItem1.left
let gridItem2 = CommonFunc.getComponentRect('gridItem1');
let right1 = gridItem2.right
await CommonFunc.sleep(1000);
let gridItem3 = CommonFunc.getComponentRect('3');
let right2 = gridItem3.right
expect(right2 - left1 - 4 * 6).assertEqual((right1 - left1) * 5);
console.info('[GridJsunit_0500] END');
done();
});
it('GridJsunit_0600', 0, async function (done) {
// Verify the rowsTemplate of Grid component
console.info('[GridJsunit_0600] START');
await CommonFunc.sleep(1000);
let gridItem1 = CommonFunc.getComponentRect('0');
let top1 = gridItem1.top
let gridItem2 = CommonFunc.getComponentRect('gridItem3');
let top2 = gridItem2.top
let gridItem3 = CommonFunc.getComponentRect('gridItem3');
let bottom2 = gridItem3.bottom
expect((bottom2 - top2) * 4 + 7.5).assertEqual(bottom2 - top1 - 5 * 3);
console.info('[GridJsunit_0600] END');
done();
});
it('GridJsunit_0700', 0, async function (done) {
// Verify the columnsGap of Grid component
console.info('[GridJsunit_0700] START');
await CommonFunc.sleep(1000);
let driver = await UiDriver.create()
let gridItem1 = CommonFunc.getComponentRect('gridItem1');
let right1 = gridItem1.right
let gridItem2 = CommonFunc.getComponentRect('0');
let left1 = gridItem2.left
expect(left1 - right1).assertEqual(6);
console.info('[GridJsunit_0700] END');
done();
});
it('GridJsunit_0800', 0, async function (done) {
// Verify the rowsGap of Grid component
console.info('[GridJsunit_0800] START');
globalThis.value.message.notify({name:'rowStart',value:'1'})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'rowEnd',value:'4'})
await CommonFunc.sleep(1000);
let driver = await UiDriver.create()
let gridItem1 = CommonFunc.getComponentRect('gridItem1');
let bottom1 = gridItem1.bottom
let gridItem2 = CommonFunc.getComponentRect('gridItem3');
let top1 = gridItem2.top
expect(top1 - bottom1).assertEqual(7.5);
console.info('[GridJsunit_0800] END');
done();
});
})
}
......@@ -51,6 +51,10 @@ import stepperJsunit from './stepperJsunit.test.ets';
import textAreaJsunit from './textAreaJsunit.test.ets';
import textOneJsunit from './textOneJsunit.test.ets';
import textTwoJsunit from './textTwoJsunit.test.ets';
import ToggleJsunit from './ToggleJsunit.test.ets';
import NavDestinationJsunit from './NavDestinationJsunit.test.ets';
import GridItemJsunit from './GridItemJsunit.test.ets';
import NavigationJsunit from './NavigationJsunit.test.ets';
export default function testsuite() {
blankJsunit();
......@@ -91,4 +95,8 @@ export default function testsuite() {
textAreaJsunit();
textOneJsunit();
textTwoJsunit();
ToggleJsunit();
NavDestinationJsunit();
GridItemJsunit();
NavigationJsunit();
}
\ No newline at end of file
/**
* 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 router from '@system.router';
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.UiTest';
import CommonFunc from '../MainAbility/utils/Common';
import {MessageManager,Callback} from '../MainAbility/utils/MessageManager';
export default function NavDestinationJsunit() {
describe('navDestinationJsunit', function () {
beforeEach(async function (done) {
console.info("NavDestination beforeEach start");
let options = {
uri: 'MainAbility/pages/NavDestinationPage',
}
try {
router.clear();
let pages = router.getState();
console.info("get NavDestination state pages: " + JSON.stringify(pages));
if (!("NavDestinationPage" == pages.name)) {
console.info("get NavDestination state pages.name: " + JSON.stringify(pages.name));
let result = await router.push(options);
console.info("push NavDestination page result: " + JSON.stringify(result));
await CommonFunc.sleep(2000);
}
} catch (err) {
console.error("push NavDestination page error: " + err);
expect().assertFail();
}
done();
});
it('NavDestinationJsunit_0100', 0, async function (done) {
// Get title name of NavDestination component
console.info('[NavDestinationJsunit_0100] START');
await CommonFunc.sleep(1000);
let driver = await UiDriver.create()
let textComponent = await driver.findComponent(BY.key('NavDestination1'));
let text = await textComponent.getText();
console.info("[NavDestinationJsunit_0100] text: " + JSON.stringify(text));
expect(text == 'NavDestination1').assertTrue();
console.info('[NavDestinationJsunit_0100] END');
done();
});
it('NavDestinationJsunit_0200', 0, async function (done) {
// Get backgroundColor of NavDestination component
console.info('[NavDestinationJsunit_0200] START');
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('NavDestination1');
let obj = JSON.parse(strJson);
console.info("[NavDestinationJsunit_0200] component obj is: " + JSON.stringify(obj));
console.info("[NavDestinationJsunit_0200] backgroundColor: " + JSON.stringify(obj.$attrs.backgroundColor));
expect(obj.$attrs.backgroundColor).assertEqual('#FF808080');
console.info('[NavDestinationJsunit_0200] END');
done();
});
it('NavDestinationJsunit_0300', 0, async function (done) {
// Modify title name of NavDestination component
console.info('[NavDestinationJsunit_0300] START');
globalThis.value.message.notify({name:'title',value:'NavDestinationTitle'})
await CommonFunc.sleep(2000);
// Get the name of the sub title
let driver = await UiDriver.create()
let textComponent = await driver.findComponent(BY.key('NavDestination1'));
let text = await textComponent.getText();
console.info("[NavDestinationJsunit_0300] text: " + JSON.stringify(text));
expect(text == 'NavDestinationTitle1').assertTrue();
console.info('[NavDestinationJsunit_0300] END');
done();
});
it('NavDestinationJsunit_0400', 0, async function (done) {
// Modify backgroundColor of NavDestination component
console.info('[NavDestinationJsunit_0400] START');
globalThis.value.message.notify({name:'backColor',value:'Color.Green'})
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('NavDestination1');
let obj = JSON.parse(strJson);
console.info("[NavDestinationJsunit_0400] component obj is: " + JSON.stringify(obj));
console.info("[NavDestinationJsunit_0400] backgroundColor: " + JSON.stringify(obj.$attrs.backgroundColor));
expect(obj.$attrs.backgroundColor).assertEqual('#FF008000');
console.info('[NavDestinationJsunit_0400] END');
done();
});
it('NavDestinationJsunit_0500', 0, async function (done) {
// illegal modify title name of NavDestination component
console.info('[NavDestinationJsunit_0500] START');
globalThis.value.message.notify({name:'title',value:123})
await CommonFunc.sleep(2000);
// Get the name of the sub title
let driver = await UiDriver.create()
let textComponent = await driver.findComponent(BY.key('NavDestination1'));
let text = await textComponent.getText();
console.info("[NavDestinationJsunit_0500] text: " + JSON.stringify(text));
expect(text == '1231').assertTrue();
console.info('[NavDestinationJsunit_0500] END');
done();
});
it('NavDestinationJsunit_0600', 0, async function (done) {
// illegal modify backgroundColor of NavDestination component
console.info('[NavDestinationJsunit_0600] START');
globalThis.value.message.notify({name:'backColor',value:123})
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('NavDestination1');
let obj = JSON.parse(strJson);
console.info("[NavDestinationJsunit_0600] component obj is: " + JSON.stringify(obj));
console.info("[NavDestinationJsunit_0600] backgroundColor: " + JSON.stringify(obj.$attrs.backgroundColor));
expect(obj.$attrs.backgroundColor).assertEqual('#FF008000');
console.info('[NavDestinationJsunit_0600] END');
done();
});
it('NavDestinationJsunit_0700', 0, async function (done) {
// Get hideTitleBar value of NavDestination component
console.info('[NavDestinationJsunit_0700] START');
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('NavDestination1');
let obj = JSON.parse(strJson);
console.info("[NavDestinationJsunit_0700] component obj is: " + JSON.stringify(obj));
console.info("[NavDestinationJsunit_0700] hideTitleBar: " + JSON.stringify(obj.$attrs.hideTitleBar));
expect(obj.$attrs.hideTitleBar).assertTrue();
console.info('[NavDestinationJsunit_0700] END');
done();
});
it('NavDestinationJsunit_0800', 0, async function (done) {
// Modify hideTitleBar value of NavDestination component
console.info('[NavDestinationJsunit_0700] START');
globalThis.value.message.notify({name:'hideTitleBar',value:'false'})
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('NavDestination1');
let obj = JSON.parse(strJson);
console.info("[NavDestinationJsunit_0700] component obj is: " + JSON.stringify(obj));
console.info("[NavDestinationJsunit_0700] hideTitleBar: " + JSON.stringify(obj.$attrs.hideTitleBar));
expect(obj.$attrs.hideTitleBar).assertFalse();
console.info('[NavDestinationJsunit_0700] END');
done();
});
it('NavDestinationJsunit_0900', 0, async function (done) {
// illegal modify hideTitleBar value of NavDestination component
console.info('[NavDestinationJsunit_0900] START');
globalThis.value.message.notify({name:'hideTitleBar',value:123})
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('NavDestination1');
let obj = JSON.parse(strJson);
console.info("[NavDestinationJsunit_0900] component obj is: " + JSON.stringify(obj));
console.info("[NavDestinationJsunit_0900] hideTitleBar: " + JSON.stringify(obj.$attrs.hideTitleBar));
expect(obj.$attrs.hideTitleBar).assertFalse();
console.info('[NavDestinationJsunit_0900] END');
done();
});
})
}
/**
* 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 router from '@system.router';
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.UiTest';
import CommonFunc from '../MainAbility/utils/Common';
import {MessageManager,Callback} from '../MainAbility/utils/MessageManager';
export default function NavigationJsunit() {
describe('NavigationJsunit', function () {
beforeEach(async function (done) {
console.info("NavigationJsunit beforeEach start");
let options = {
uri: 'MainAbility/pages/NavigationPage',
}
try {
router.clear();
let pages = router.getState();
console.info("get NavigationJsunit state pages: " + JSON.stringify(pages));
if (!("NavigationPage" == pages.name)) {
console.info("get NavigationJsunit state pages.name: " + JSON.stringify(pages.name));
let result = await router.push(options);
await CommonFunc.sleep(2000);
console.info("push NavigationJsunit success: " + JSON.stringify(result));
}
} catch (err) {
console.error("push NavigationJsunit page error: " + err);
expect().assertFail();
}
done();
});
it('NavigationJsunit_0100', 0, async function (done) {
// Get the information of the Navigation component
console.info('[NavigationJsunit_0100] START');
await CommonFunc.sleep(1000);
let strJson = getInspectorByKey('navigation');
let obj = JSON.parse(strJson);
console.info("[NavigationJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[NavigationJsunit_0100] titleMode: " + obj.$attrs.titleMode);
console.info("[NavigationJsunit_0100] toolBar: " + obj.$attrs.toolBar);
console.info("[NavigationJsunit_0100] hideToolBar: " + obj.$attrs.hideToolBar);
console.info("[NavigationJsunit_0100] hideTitleBar: " + obj.$attrs.hideTitleBar);
console.info("[NavigationJsunit_0100] hideBackButton: " + obj.$attrs.hideBackButton);
console.info("[NavigationJsunit_0100] navBarWidth: " + obj.$attrs.navBarWidth);
console.info("[NavigationJsunit_0100] navBarPosition: " + obj.$attrs.navBarPosition);
console.info("[NavigationJsunit_0100] mode: " + obj.$attrs.mode);
console.info("[NavigationJsunit_0100] backButtonIcon: " + obj.$attrs.backButtonIcon);
console.info("[NavigationJsunit_0100] hideNavBar: " + obj.$attrs.hideNavBar);
expect(obj.$attrs.titleMode).assertEqual('NavigationTitleMode.Free');
expect(obj.$attrs.toolBar).assertEqual('123');
expect(obj.$attrs.hideToolBar).assertEqual('false');
expect(obj.$attrs.hideTitleBar).assertEqual('false');
expect(obj.$attrs.hideBackButton).assertEqual('false');
expect(obj.$attrs.navBarWidth).assertEqual('700');
expect(obj.$attrs.navBarPosition).assertEqual('NavBarPosition.Start');
expect(obj.$attrs.mode).assertEqual('NavigationMode.Split');
expect(obj.$attrs.backButtonIcon).assertEqual('resources/base/media/icon.png');
expect(obj.$attrs.hideNavBar).assertEqual('false');
console.info('[NavigationJsunit_0100] END');
done();
});
it('NavigationJsunit_0300', 0, async function (done) {
// Verify onTitleModeChange event of Navigation component
console.info('[NavigationJsunit_0300] START');
await CommonFunc.sleep(1000);
let driver = await UiDriver.create();
let component = await driver.findComponent(BY.key('titleModeChange'));
let text = await component.getText();
expect(text).assertEqual('TitleModeChange:');
let driver1 = await Driver.create();
let scrollBar = await driver1.findComponent(ON.id('list'));
await scrollBar.scrollSearch(ON.text('9'));
await CommonFunc.sleep(1000);
let component1 = await driver.findComponent(BY.key('titleModeChange'));
let text1 = await component1.getText();
expect(text1).assertEqual('TitleModeChange:succ');
console.info('[NavigationJsunit_0300] END');
done();
});
it('NavigationJsunit_0400', 0, async function (done) {
// Verify onNavBarStateChange event of Navigation component
console.info('[NavigationJsunit_0400] START');
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'hideNavBar',value:'true'})
await CommonFunc.sleep(3000);
let driver = await UiDriver.create();
let component1 = await driver.findComponent(BY.key('navBarStateChange'));
let text1 = await component1.getText();
expect(text1).assertEqual('NavBarStateChange:succ');
console.info('[NavigationJsunit_0400] END');
done();
});
it('NavigationJsunit_0500', 0, async function (done) {
// Modify the title of Navigation component
console.info('[NavigationJsunit_0500] START');
globalThis.value.message.notify({name:'mainTitleName',value:'titleOne'})
await CommonFunc.sleep(2000);
let driver = await UiDriver.create();
let component = await driver.findComponent(BY.key('mainTitle'));
let text = await component.getText();
expect(text).assertEqual('titleOne');
globalThis.value.message.notify({name:'subTitleName',value:'titleTwo'})
await CommonFunc.sleep(2000);
let component1 = await driver.findComponent(BY.key('subTitle'));
let text1 = await component1.getText();
expect(text1).assertEqual('titleTwo');
console.info('[NavigationJsunit_0500] END');
done();
});
it('NavigationJsunit_0600', 0, async function (done) {
// Modify atrributes of Navigation component
console.info('[NavigationJsunit_0600] START');
globalThis.value.message.notify({name:'hideToolBar',value:'true'})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'hideTitleBar',value:'true'})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'hideBackButton',value:'true'})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'navBarPosition',value:NavBarPosition.End})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'navBarWidth',value:710})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'backButtonIcon',value:'resources/base/media/image.png'})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'hideNavBar',value:'true'})
await CommonFunc.sleep(2000);
// Get the propoties value of the Navigation component
let strJson = getInspectorByKey('navigation');
let obj = JSON.parse(strJson);
console.info("[NavigationJsunit_0600] component obj is: " + JSON.stringify(obj));
console.info("[NavigationJsunit_0600] hideToolBar: " + obj.$attrs.hideToolBar);
console.info("[NavigationJsunit_0600] hideTitleBar: " + obj.$attrs.hideTitleBar);
console.info("[NavigationJsunit_0600] hideBackButton: " + obj.$attrs.hideBackButton);
console.info("[NavigationJsunit_0600] navBarWidth: " + obj.$attrs.navBarWidth);
console.info("[NavigationJsunit_0600] navBarPosition: " + obj.$attrs.navBarPosition);
console.info("[NavigationJsunit_0600] backButtonIcon: " + obj.$attrs.backButtonIcon);
console.info("[NavigationJsunit_0600] hideNavBar: " + obj.$attrs.hideNavBar);
expect(obj.$attrs.hideToolBar).assertEqual('true');
expect(obj.$attrs.hideTitleBar).assertEqual('true');
expect(obj.$attrs.hideBackButton).assertEqual('true');
expect(obj.$attrs.navBarWidth).assertEqual('710');
expect(obj.$attrs.navBarPosition).assertEqual('NavBarPosition.End');
expect(obj.$attrs.backButtonIcon).assertEqual('resources/base/media/image.png');
expect(obj.$attrs.hideNavBar).assertEqual('false');
console.info('[NavigationJsunit_0600] END');
done();
});
it('NavigationJsunit_0700', 0, async function (done) {
// Modify the titleMode of Navigation component
console.info('[NavigationJsunit_0700] START');
globalThis.value.message.notify({name:'titleMode',value:NavigationTitleMode.Mini})
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('navigation');
let obj = JSON.parse(strJson);
console.info("[NavigationJsunit_0700] titleMode is: " + obj.$attrs.titleMode);
expect(obj.$attrs.titleMode).assertEqual('NavigationTitleMode.Mini');
globalThis.value.message.notify({name:'titleMode',value:NavigationTitleMode.Full})
await CommonFunc.sleep(5000);
let strJson1 = getInspectorByKey('navigation');
let obj1 = JSON.parse(strJson1);
console.info("[NavigationJsunit_0700] titleMode1 is: " + obj1.$attrs.titleMode);
expect(obj1.$attrs.titleMode).assertEqual('NavigationTitleMode.Full');
console.info('[NavigationJsunit_0700] END');
done();
});
it('NavigationJsunit_0800', 0, async function (done) {
// Modify the mode of Navigation component
console.info('[NavigationJsunit_0800] START');
globalThis.value.message.notify({name:'mode',value:NavigationMode.Auto})
await CommonFunc.sleep(2000);
let strJson = getInspectorByKey('navigation');
let obj = JSON.parse(strJson);
console.info("[NavigationJsunit_0800] mode is: " + obj.$attrs.mode);
expect(obj.$attrs.mode).assertEqual('NavigationMode.Auto');
globalThis.value.message.notify({name:'mode',value:NavigationMode.Stack})
await CommonFunc.sleep(2000);
let strJson1 = getInspectorByKey('navigation');
let obj1 = JSON.parse(strJson1);
console.info("[NavigationJsunit_0800] mode1 is: " + obj1.$attrs.mode);
expect(obj1.$attrs.mode).assertEqual('NavigationMode.Stack');
console.info('[NavigationJsunit_0800] END');
done();
});
it('NavigationJsunit_0900', 0, async function (done) {
// Illegal modification of properties of Navigation component
console.info('[NavigationJsunit_0900] START');
globalThis.value.message.notify({name:'titleMode',value:123})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'hideToolBar',value:-5})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'hideTitleBar',value:'#abc'})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'hideBackButton',value:'123'})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'navBarWidth',value:'200'})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'navBarPosition',value:123})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'mode',value:'abc'})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'backButtonIcon',value:123})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'hideNavBar',value:0})
await CommonFunc.sleep(2000);
// Get the propoties value of the Navigation component
let strJson = getInspectorByKey('navigation');
let obj = JSON.parse(strJson);
console.info("[NavigationJsunit_0900] component obj is: " + JSON.stringify(obj));
console.info("[NavigationJsunit_0900] titleMode: " + obj.$attrs.titleMode);
console.info("[NavigationJsunit_0900] hideToolBar: " + obj.$attrs.hideToolBar);
console.info("[NavigationJsunit_0900] hideTitleBar: " + obj.$attrs.hideTitleBar);
console.info("[NavigationJsunit_0900] hideBackButton: " + obj.$attrs.hideBackButton);
console.info("[NavigationJsunit_0900] navBarWidth: " + obj.$attrs.navBarWidth);
console.info("[NavigationJsunit_0900] navBarPosition: " + obj.$attrs.navBarPosition);
console.info("[NavigationJsunit_0900] mode: " + obj.$attrs.mode);
console.info("[NavigationJsunit_0900] backButtonIcon: " + obj.$attrs.backButtonIcon);
console.info("[NavigationJsunit_0900] hideNavBar: " + obj.$attrs.hideNavBar);
expect(obj.$attrs.titleMode).assertEqual('NavigationTitleMode.Free');
expect(obj.$attrs.hideToolBar).assertEqual('false');
expect(obj.$attrs.hideTitleBar).assertEqual('false');
expect(obj.$attrs.hideBackButton).assertEqual('false');
expect(obj.$attrs.navBarWidth).assertEqual('700');
expect(obj.$attrs.navBarPosition).assertEqual('NavBarPosition.Start');
expect(obj.$attrs.mode).assertEqual('NavigationMode.Split');
expect(obj.$attrs.backButtonIcon).assertEqual('false');
expect(obj.$attrs.hideNavBar).assertEqual('false');
console.info('[NavigationJsunit_0900] END');
done();
});
})
}
/**
* 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 router from '@system.router';
import {UiComponent, UiDriver, Component, Driver, UiWindow, ON, BY, MatchPattern, DisplayRotation, ResizeDirection, WindowMode, PointerMatrix} from '@ohos.UiTest';
import CommonFunc from '../MainAbility/utils/Common';
import {MessageManager,Callback} from '../MainAbility/utils/MessageManager';
export default function ToggleJsunit() {
describe('ToggleJsunit', function () {
beforeEach(async function (done) {
console.info("Toggle beforeEach start");
let options = {
uri: 'MainAbility/pages/TogglePage',
}
try {
router.clear();
let pages = router.getState();
console.info("get Toggle state pages: " + JSON.stringify(pages));
if (!("TogglePage" == pages.name)) {
console.info("get Toggle state pages.name: " + JSON.stringify(pages.name));
let result = await router.push(options);
console.info("push Toggle page result: " + JSON.stringify(result));
await CommonFunc.sleep(2000);
}
} catch (err) {
console.error("push Toggle page error: " + err);
expect().assertFail();
}
done();
});
it('ToggleJsunit_0100', 0, async function (done) {
// Get the information of Toggle component
console.info('[ToggleJsunit_0100] START');
let strJson = getInspectorByKey('toggleCheckbox');
let obj = JSON.parse(strJson);
console.info("[ToggleJsunit_0100] component obj is: " + JSON.stringify(obj));
console.info("[ToggleJsunit_0100] type: " + JSON.stringify(obj.$attrs.type));
console.info("[ToggleJsunit_0100] isOn: " + JSON.stringify(obj.$attrs.isOn));
console.info("[ToggleJsunit_0100] selectedColor: " + JSON.stringify(obj.$attrs.selectedColor));
await CommonFunc.sleep(1000);
expect(obj.$attrs.type).assertEqual('ToggleType.Checkbox');
expect(obj.$attrs.isOn).assertEqual('true');
expect(obj.$attrs.selectedColor).assertEqual('#FFFF0000');
let strJson1 = getInspectorByKey('toggleSwitch');
let obj1 = JSON.parse(strJson1);
console.info("[ToggleJsunit_0100] component obj1 is: " + JSON.stringify(obj1));
console.info("[ToggleJsunit_0100] switchPointColor: " + JSON.stringify(obj1.$attrs.switchPointColor));
await CommonFunc.sleep(1000);
expect(obj1.$attrs.switchPointColor).assertEqual('#FF008000');
// Get default value of Toggle component
console.info("[ToggleJsunit_0100] isOn: " + JSON.stringify(obj1.$attrs.isOn));
expect(obj1.$attrs.isOn).assertEqual('false');
console.info('[ToggleJsunit_0100] END');
done();
});
it('ToggleJsunit_0200', 0, async function (done) {
// Verify switch function of Toggle component
console.info('[ToggleJsunit_0200] START');
let driver = await UiDriver.create();
let switchButton = await driver.findComponent(BY.key('toggleSwitch'));
await switchButton.click();
await CommonFunc.sleep(1000);
let textComponent = await driver.findComponent(BY.key('text'));
let switchText = await textComponent.getText();
console.info("[ToggleJsunit_0200] switchText: " + JSON.stringify(switchText));
expect(switchText).assertEqual('switch true');
let driver1 = await UiDriver.create();
let switchButton1 = await driver1.findComponent(BY.key('toggleSwitch'));
await switchButton1.click();
await CommonFunc.sleep(1000);
let textComponent1 = await driver1.findComponent(BY.key('text'));
let switch1 = await textComponent1.getText();
console.info("[ToggleJsunit_0200] switch1: " + JSON.stringify(switch1));
expect(switch1).assertEqual('switch false');
console.info('[ToggleJsunit_0200] END');
done();
});
it('ToggleJsunit_0300', 0, async function (done) {
// Verify checkbox function of Toggle component
console.info('[ToggleJsunit_0300] START');
await CommonFunc.sleep(1000);
let driver = await UiDriver.create();
let checkboxButton = await driver.findComponent(BY.key('toggleCheckbox'));
await checkboxButton.click();
await CommonFunc.sleep(1000);
let textComponent = await driver.findComponent(BY.key('text'));
let checkbox = await textComponent.getText();
console.info("[ToggleJsunit_0300] checkbox: " + JSON.stringify(checkbox));
expect(checkbox).assertEqual('checkbox true');
await checkboxButton.click();
await CommonFunc.sleep(1000);
let checkbox1 = await textComponent.getText();
console.info("[ToggleJsunit_0300] checkbox1: " + JSON.stringify(checkbox1));
expect(checkbox1).assertEqual('checkbox false');
console.info('[ToggleJsunit_0300] END');
done();
});
it('ToggleJsunit_0400', 0, async function (done) {
// Verify button function of Toggle component
console.info('[ToggleJsunit_0400] START');
let driver = await UiDriver.create();
let buttonComponent = await driver.findComponent(BY.key('toggleButton'));
await buttonComponent.click();
await CommonFunc.sleep(1000);
let textComponent = await driver.findComponent(BY.key('text'));
let button = await textComponent.getText();
console.info("[ToggleJsunit_0400] button: " + JSON.stringify(button));
expect(button).assertEqual('button true');
await buttonComponent.click();
await CommonFunc.sleep(1000);
let button1 = await textComponent.getText();
console.info("[ToggleJsunit_0400] button1: " + JSON.stringify(button1));
expect(button1).assertEqual('button false');
console.info('[ToggleJsunit_0400] END');
done();
});
it('ToggleJsunit_0500', 0, async function (done) {
// Modify the attribute of Toggle component
console.info('[ToggleJsunit_0500] START');
globalThis.value.message.notify({name:'type',value:'ToggleType.Switch'})
await CommonFunc.sleep(2000);
globalThis.value.message.notify({name:'isOn',value:'false'})
await CommonFunc.sleep(2000);
globalThis.value.message.notify({name:'selectedColor',value:'#FF008000'})
await CommonFunc.sleep(2000);
globalThis.value.message.notify({name:'switchPointColor',value:'#FFFF0000'})
await CommonFunc.sleep(5000);
// Get the attribute of Toggle component
let strJson = getInspectorByKey('toggleCheckbox');
let obj = JSON.parse(strJson);
console.info("[ToggleJsunit_0500] component obj is: " + JSON.stringify(obj));
console.info("[ToggleJsunit_0500] type: " + JSON.stringify(obj.$attrs.type));
console.info("[ToggleJsunit_0500] isOn: " + JSON.stringify(obj.$attrs.isOn));
console.info("[ToggleJsunit_0500] selectedColor: " + JSON.stringify(obj.$attrs.selectedColor));
await CommonFunc.sleep(1000);
//expect(obj.$attrs.type).assertEqual('ToggleType.Switch');
//expect(obj.$attrs.isOn).assertEqual('false');
//expect(obj.$attrs.selectedColor).assertEqual('#FF008000');
let strJson1 = getInspectorByKey('toggleSwitch');
let obj1 = JSON.parse(strJson1);
console.info("[ToggleJsunit_0500] component obj1 is: " + JSON.stringify(obj1));
console.info("[ToggleJsunit_0500] switchPointColor: " + JSON.stringify(obj1.$attrs.switchPointColor));
await CommonFunc.sleep(1000);
expect(obj1.$attrs.switchPointColor).assertEqual('#FFFF0000');
console.info('[ToggleJsunit_0500] END');
done();
});
it('ToggleJsunit_0600', 0, async function (done) {
// Illegal modification of properties of Toggle component
console.info('[ToggleJsunit_0600] START');
globalThis.value.message.notify({name:'type',value:123})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'isOn',value:'aaa'})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'selectedColor',value:123})
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'switchPointColor',value:'bbb'})
await CommonFunc.sleep(2000);
// Get the attribute of Toggle component
let strJson = getInspectorByKey('toggleCheckbox');
let obj = JSON.parse(strJson);
console.info("[ToggleJsunit_0600] component obj is: " + JSON.stringify(obj));
console.info("[ToggleJsunit_0600] type: " + JSON.stringify(obj.$attrs.type));
console.info("[ToggleJsunit_0600] isOn: " + JSON.stringify(obj.$attrs.isOn));
console.info("[ToggleJsunit_0600] selectedColor: " + JSON.stringify(obj.$attrs.selectedColor));
await CommonFunc.sleep(1000);
expect(obj.$attrs.type).assertEqual('ButtonType.Capsule');
expect(obj.$attrs.isOn).assertEqual('false');
expect(obj.$attrs.selectedColor).assertEqual('#FF00007B');
let strJson1 = getInspectorByKey('toggleSwitch');
let obj1 = JSON.parse(strJson1);
console.info("[ToggleJsunit_0600] component obj1 is: " + JSON.stringify(obj1));
console.info("[ToggleJsunit_0600] switchPointColor: " + JSON.stringify(obj1.$attrs.switchPointColor));
await CommonFunc.sleep(1000);
expect(obj1.$attrs.switchPointColor).assertEqual('#FFFF0000');
console.info('[ToggleJsunit_0600] END');
done();
});
})
}
\ No newline at end of file
......@@ -49,34 +49,34 @@ export default function textTwoJsunit() {
let strJson = getInspectorByKey('text1');
let obj = JSON.parse(strJson);
console.info('textTwoJsunit_0100 component obj is: ' + obj.$attrs.decoration);
//expect(obj.$attrs.decoration).assertEqual('{"type":"TextDecorationType.LineThrough","color":"#FFFFEEAF"}');
expect(obj.$attrs.decoration).assertEqual('{"type":"TextDecorationType.LineThrough","color":"#FFFFEEAF"}');
// to modify the atrribute
globalThis.value.message.notify({name:'type',value:TextDecorationType.Overline})
await CommonFunc.sleep(200);
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'color',value:Color.Green})
await CommonFunc.sleep(200);
await CommonFunc.sleep(2000);
let strJson2 = getInspectorByKey('text1');
let obj2 = JSON.parse(strJson2);
console.info('textTwoJsunit_0100 component obj2 is: ' + obj2.$attrs.decoration);
//expect(obj2.$attrs.decoration).assertEqual('{"type":"TextDecorationType.Overline","color":"#FF008000"}');
expect(obj2.$attrs.decoration).assertEqual('{"type":"TextDecorationType.Overline","color":"#FF008000"}');
globalThis.value.message.notify({name:'type',value:TextDecorationType.Underline})
await CommonFunc.sleep(200);
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'color',value:'rgb(238, 130, 238)'})
await CommonFunc.sleep(200);
await CommonFunc.sleep(2000);
let strJson3 = getInspectorByKey('text1');
let obj3 = JSON.parse(strJson3);
console.info('textTwoJsunit_0100 component obj3 is: ' + obj3.$attrs.decoration);
//expect(obj3.$attrs.decoration).assertEqual('{"type":"TextDecorationType.Underline","color":"#FF008000"}');
expect(obj3.$attrs.decoration).assertEqual('{"type":"TextDecorationType.Underline","color":"#FFEE82EE"}');
globalThis.value.message.notify({name:'type',value:TextDecorationType.None})
await CommonFunc.sleep(200);
await CommonFunc.sleep(1000);
globalThis.value.message.notify({name:'color',value:'#FFACEEEE'})
await CommonFunc.sleep(200);
await CommonFunc.sleep(2000);
let strJson4 = getInspectorByKey('text1');
let obj4 = JSON.parse(strJson4);
console.info('textTwoJsunit_0100 component obj4 is: ' + obj4.$attrs.decoration);
//expect(obj3.$attrs.decoration).assertEqual('{"type":"TextDecorationType.None","color":"#FFACEEEE"}');
expect(obj4.$attrs.decoration).assertEqual('{"type":"TextDecorationType.None","color":"#FFACEEEE"}');
done();
});
......
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Device/device_filled/ic_pad</title>
<g id="Device/device_filled/ic_pad" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<path d="M20.5,3.75 L3.5,3.75 C1.98121694,3.75 0.75,4.98121694 0.75,6.5 L0.75,17.5 C0.75,19.0187831 1.98121694,20.25 3.5,20.25 L20.5,20.25 C22.0187831,20.25 23.25,19.0187831 23.25,17.5 L23.25,6.5 C23.25,4.98121694 22.0187831,3.75 20.5,3.75 Z M3.5,5.25 L20.5,5.25 C21.1903559,5.25 21.75,5.80964406 21.75,6.5 L21.75,17.5 C21.75,18.1903559 21.1903559,18.75 20.5,18.75 L3.5,18.75 C2.80964406,18.75 2.25,18.1903559 2.25,17.5 L2.25,6.5 C2.25,5.80964406 2.80964406,5.25 3.5,5.25 Z" id="Rectangle-Copy-6" fill="#000000" fill-rule="nonzero" opacity="0.600000024"></path>
<path d="M4.26242519,6.27018718 L19.7291142,6.27018718 C20.281399,6.27018718 20.7291142,6.71790243 20.7291142,7.27018718 L20.7291142,16.7351733 C20.7291142,17.2874581 20.281399,17.7351733 19.7291142,17.7351733 L4.26242519,17.7351733 C3.71014044,17.7351733 3.26242519,17.2874581 3.26242519,16.7351733 L3.26242519,7.27018718 C3.26242519,6.71790243 3.71014044,6.27018718 4.26242519,6.27018718 Z" id="矩形" fill="#000000" fill-rule="nonzero" opacity="0.400000006"></path>
</g>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg xmlns:xlink="http://www.w3.org/1999/xlink"
height="24px"
version="1.1"
viewBox="0 0 24 24"
width="24px"
xmlns="http://www.w3.org/2000/svg">
<title>ic_vision</title>
<g
fill="none"
fill-rule="evenodd"
id="ic_vision"
stroke="none"
stroke-width="1">
<circle
cx="12"
cy="12"
fill="#9E9E9E"
id="path"
r="10.75"
stroke="#E0DAED"
stroke-width="1.5"/>
<path
d="M17.7418165,7.71428571 C17.9806161,7.71428571 18.0672107,7.73914972 18.1545122,7.78583912 C18.2418138,7.83252852 18.3103286,7.90104331 18.357018,7.9883449 C18.4037074,8.07564649 18.4285714,8.16224102 18.4285714,8.40104068 L18.4285714,15.063245 C18.4285714,15.3020447 18.4037074,15.3886392 18.357018,15.4759408 C18.3103286,15.5632424 18.2418138,15.6317572 18.1545122,15.6784466 C18.0672107,15.725136 17.9806161,15.75 17.7418165,15.75 L17.0884286,15.7492857 L17.0892857,16.0178571 C17.0892857,16.1657906 16.969362,16.2857143 16.8214286,16.2857143 L7.17857143,16.2857143 C7.03063801,16.2857143 6.91071429,16.1657906 6.91071429,16.0178571 L6.91042857,15.7492857 L6.25818354,15.75 C6.01938387,15.75 5.93278935,15.725136 5.84548776,15.6784466 C5.75818617,15.6317572 5.68967137,15.5632424 5.64298197,15.4759408 C5.59874991,15.393234 5.57410629,15.3111619 5.57163475,15.0997077 L5.57142857,8.40104068 C5.57142857,8.16224102 5.59629257,8.07564649 5.64298197,7.9883449 C5.68967137,7.90104331 5.75818617,7.83252852 5.84548776,7.78583912 C5.92819452,7.74160705 6.0102667,7.71696344 6.22172089,7.7144919 L17.7418165,7.71428571 Z M17.625,8.51785714 L6.375,8.51785714 L6.375,14.9464286 L17.625,14.9464286 L17.625,8.51785714 Z"
fill="#FFFFFF"
fill-opacity="0.9"
id="vision"/>
</g>
</svg>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<svg width="24px" height="24px" viewBox="0 0 24 24" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
<title>Device/device_filled/ic_tv</title>
<g id="Device/device_filled/ic_tv" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
<g id="编组" transform="translate(1.000000, 4.000000)" fill="#000000" fill-rule="nonzero">
<path d="M19.7083333,0 C20.9739859,0 22,1.02601411 22,2.29166667 L22,11.4583333 C22,12.7239859 20.9739859,13.75 19.7083333,13.75 L19.7083333,14.6666667 C19.7083333,15.1729277 19.2979277,15.5833333 18.7916667,15.5833333 L3.20833333,15.5833333 C2.70207231,15.5833333 2.29166667,15.1729277 2.29166667,14.6666667 L2.29166667,13.75 C1.02601411,13.75 0,12.7239859 0,11.4583333 L0,2.29166667 C0,1.02601411 1.02601411,0 2.29166667,0 L19.7083333,0 Z M19.7083333,1.375 L2.29166667,1.375 C1.80074689,1.375 1.39996109,1.76090944 1.37612184,2.24591575 L1.375,2.29166667 L1.375,11.4583333 C1.375,11.9492531 1.76090944,12.3500389 2.24591575,12.3738782 L2.29166667,12.375 L19.7083333,12.375 C20.1992531,12.375 20.6000389,11.9890906 20.6238782,11.5040842 L20.625,11.4583333 L20.625,2.29166667 C20.625,1.80074689 20.2390906,1.39996109 19.7540842,1.37612184 L19.7083333,1.375 Z" id="形状结合" opacity="0.600000024"></path>
<path d="M3.1899184,2.2659717 L18.7634369,2.23149511 C19.2696955,2.22981431 19.6810087,2.63931039 19.6821294,3.14557018 C19.6821298,3.14575691 19.6821302,3.14594365 19.6815704,3.14613129 L19.6934547,10.5615364 C19.6942661,11.0677968 19.2845187,11.4788597 18.7782583,11.479671 C18.7767063,11.4796735 18.7751543,11.4796721 18.7736024,11.4796667 L3.18876085,11.4254844 C2.68374698,11.4237287 2.27528104,11.0138402 2.27528104,10.5088233 L2.27528104,3.18263612 C2.27528104,2.67716741 2.68445093,2.2670907 3.1899184,2.2659717 Z" id="矩形" opacity="0.400000006"></path>
</g>
</g>
</svg>
\ No newline at end of file
......@@ -41,6 +41,10 @@
"MainAbility/pages/stepper",
"MainAbility/pages/textArea",
"MainAbility/pages/textOne",
"MainAbility/pages/textTwo"
"MainAbility/pages/textTwo",
"MainAbility/pages/TogglePage",
"MainAbility/pages/NavDestinationPage",
"MainAbility/pages/NavigationPage",
"MainAbility/pages/GridItemPage"
]
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册