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

!5406 ets api覆盖代码提交

Merge pull request !5406 from Nicklaus/master
...@@ -75,7 +75,16 @@ ...@@ -75,7 +75,16 @@
"pages/alphabetIndexer", "pages/alphabetIndexer",
"pages/checkBoxGroup", "pages/checkBoxGroup",
"pages/circle", "pages/circle",
"pages/ellipse" "pages/ellipse",
"pages/grid",
"pages/gridItem",
"pages/inspector",
"pages/lazyForEach",
"pages/path",
"pages/polygon",
"pages/polyLine",
"pages/rect",
"pages/scroll"
], ],
"name": ".MainAbility", "name": ".MainAbility",
"window": { "window": {
......
/**
* 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 GridMaxCount {
@State Number: String[] = ['5', '6', '7', '8', '9']
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear GridMaxCount start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear GridMaxCount end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("grid-MaxCount")
.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("maxCountText")
Column({ space: 5 }) {
Grid() {
ForEach(this.Number, (day: string) => {
ForEach(this.Number, (day: string) => {
GridItem() {
Text(day)
.fontSize(16)
.backgroundColor(0xF9CF93)
.width('100%')
.height('100%')
.textAlign(TextAlign.Center)
}
}, day => day)
}, day => day)
}
.columnsTemplate('1fr 1fr 1fr 1fr 1fr')
.rowsTemplate('1fr 1fr 1fr 1fr 1fr')
.columnsGap(10)
.rowsGap(10)
.width('90%')
.backgroundColor(0xFAEEE0)
.height(300)
.maxCount(5)
.key("maxCountTest")
}
}.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';
import events_emitter from '@ohos.events.emitter';
@Entry
@Component
export default
struct GridItemOnSelect {
@State Number: String[] = ['5', '6', '7', '8', '9']
@State isSelect: boolean = false;
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear GridItemOnSelect start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear GridItemOnSelect end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("gridItem-OnSelect")
.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("onSelectText")
Column({ space: 5 }) {
Grid() {
ForEach(this.Number, (day: string) => {
ForEach(this.Number, (day: string) => {
GridItem() {
Text(day)
.fontSize(16)
.backgroundColor(0xF9CF93)
.width('100%')
.height('100%')
.textAlign(TextAlign.Center)
.key("onSelected")
}.onSelect((isSelect)=>{
console.info("Select:" + isSelect)
//this.showToast("onSelect() " + index)
this.isSelect = true;
try {
var backData = {
data: {
"STATUS": this.isSelect
}
}
let backEvent = {
eventId: 10200,
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))
}
})
}, day => day)
}, day => day)
}
.columnsTemplate('1fr 1fr 1fr 1fr 1fr')
.rowsTemplate('1fr 1fr 1fr 1fr 1fr')
.columnsGap(10)
.rowsGap(10)
.width('90%')
.backgroundColor(0xFAEEE0)
.height(300)
}
}.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';
import events_emitter from '@ohos.events.emitter';
@Entry
@Component
export default
struct Inspector {
@State message: string = 'test'
@State setColor:string = '#F9CF93'
@State catchStatus:string = "success"
onPageShow() {
console.info('[inspector] page show called');
var stateChangeEvent = {
eventId: 103,
priority: events_emitter.EventPriority.LOW
}
events_emitter.on(stateChangeEvent, this.stateChangCallBack);
}
private stateChangCallBack = (eventData) => {
console.info("[inspector] page stateChangCallBack");
if (eventData != null) {
console.info("[inspector] page state change called:" + JSON.stringify(eventData));
if (eventData.data.setColor != null) {
this.setColor = eventData.data.setColor;
}
}
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("inspector")
.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 })
Row() {
Column() {
Text(this.message)
.key("inspectorApiOne")
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(()=> {
let getInspectorNodesObj = JSON.stringify(getInspectorNodes())
try {
var backData = {
data: {
"getInspectorNodes": getInspectorNodesObj,
"result":"success"
}
}
let backEvent = {
eventId: 101,
priority: events_emitter.EventPriority.LOW
}
console.info("inspector_101 onClick start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("inspector_101 onClick emit action state err: " + JSON.stringify(err.message))
}
})
Text("inspectorApiTwo")
.key("inspectorApiTwo")
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(()=> {
let getInspectorNodeByIdObj = JSON.stringify(getInspectorNodeById(1))
try {
var backData1 = {
data: {
"result": "success",
"getInspectorNodeById":getInspectorNodeByIdObj
}
}
let backEvent1 = {
eventId: 102,
priority: events_emitter.EventPriority.LOW
}
console.info("inspector_102 onClick start to emit action state")
events_emitter.emit(backEvent1, backData1)
} catch (err) {
console.info("inspector_102 onClick emit action state err: " + JSON.stringify(err.message))
}
})
Text("inspectorApiThree")
.key("inspectorApiThree")
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(()=> {
setAppBgColor('#F9CF93');
})
Text("inspectorApiFour")
.key("inspectorApiFour")
.fontSize(50)
.fontWeight(FontWeight.Bold)
.onClick(()=> {
try{
Profiler.registerVsyncCallback((info: string) => {
console.info("VsyncCallback" + info)
});
Profiler.unregisterVsyncCallback();
this.catchStatus = "callBackSuccess"
}catch(err){
console.info("inspector_103 onClick err: " + JSON.stringify(err.message))
this.catchStatus = "callBackFail"
}
try {
var backData2 = {
data: {
"catchStatus": this.catchStatus,
}
}
let backEvent2 = {
eventId: 103,
priority: events_emitter.EventPriority.LOW
}
console.info("inspector_103 onClick start to emit action state")
events_emitter.emit(backEvent2, backData2)
} catch (err) {
console.info("inspector_103 onClick emit action state err: " + JSON.stringify(err.message))
}
})
}
.width('100%')
}
.height('100%')
}.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 events_emitter from '@ohos.events.emitter';
import Log from '../common/Log.ets';
class BasicDataSource implements IDataSource {
private listeners: DataChangeListener[] = []
public totalCount(): number {
return 0
}
public getData(index: number): any {
return undefined
}
registerDataChangeListener(listener: DataChangeListener): void {
if (this.listeners.indexOf(listener) < 0) {
console.info('add listener')
this.listeners.push(listener)
}
}
unregisterDataChangeListener(listener: DataChangeListener): void {
const pos = this.listeners.indexOf(listener);
if (pos >= 0) {
console.info('remove listener')
this.listeners.splice(pos, 1)
}
}
notifyDataReload(): void {
this.listeners.forEach(listener => {
listener.onDataReloaded()
})
}
notifyDataAdd(index: number): void {
this.listeners.forEach(listener => {
listener.onDataAdd(index)
})
}
notifyDataChange(index: number): void {
this.listeners.forEach(listener => {
listener.onDataChange(index)
})
}
notifyDataDelete(index: number): void {
this.listeners.forEach(listener => {
listener.onDataDelete(index)
})
}
notifyDataMove(from: number, to: number): void {
this.listeners.forEach(listener => {
listener.onDataMove(from, to)
})
}
}
class MyDataSource extends BasicDataSource {
private dataArray: string[] = ['/path/image0', '/path/image1', '/path/image2', '/path/image3']
public totalCount(): number {
return this.dataArray.length
}
public getData(index: number): any {
return this.dataArray[index]
}
public addData(index: number, data: string): void {
this.dataArray.splice(index, 0, data)
var datatest=this.dataArray.length
console.info('lenghth = '+ datatest)
for(var i = 0; i<datatest; i++){
console.info('after adding: '+ this.dataArray[i])
}
this.notifyDataAdd(index)
this.notifyDataChange(index)
}
public pushData(data: string): void {
this.dataArray.push(data)
this.notifyDataAdd(this.dataArray.length - 1)
var datatest=this.dataArray.length
console.info('lenghth = '+ datatest)
for(var i = 0; i<datatest; i++){
console.info('after adding: '+ this.dataArray[i])
}
}
public moveData(index1:number,index2:number):void{
if(index1 < index2){
var temp = this.dataArray[index1]
for(var i = index1; i < index2 ;i++){
this.dataArray[i] = this.dataArray[i+1]
}
this.dataArray[index2] = temp
for(var j = 0 ; j < this.dataArray.length ; j++){
console.info('after moving :' + this.dataArray[j])
}
}
else if (index1 > index2){
var temp = this.dataArray[index1]
for(var i = index1 ; i > index2; i--){
this.dataArray[i] = this.dataArray[i-1]
}
this.dataArray[index2] = temp
for(var j = 0 ; j < this.dataArray.length ; j++){
console.info('after moving :' + this.dataArray[j])
}
}
this.notifyDataMove(index1,index2)
}
public popData(): void {
this.dataArray.pop()
this.notifyDataDelete(this.dataArray.length)
var datatest=this.dataArray.length
console.info('lenghth = '+ datatest)
for(var i = 0; i<datatest; i++){
console.info('after deleting: '+ this.dataArray[i])
}
}
public changeData(index: number): void {
this.dataArray[index] = 'apple'
var datatest=this.dataArray.length
console.info('lenghth = '+ datatest)
for(var i = 0; i<datatest; i++){
console.info('after changing: '+ this.dataArray[i])
}
this.notifyDataChange(index)
}
}
const TAG = 'ets_apiLack_add';
@Entry
@Component
export default
struct LazyForEachOnDataAdd {
private data: MyDataSource = new MyDataSource()
private scroller: Scroller = new Scroller()
@State result_101:boolean = true
@State result_102:boolean = true
@State result_103:boolean = true
@State result_104:boolean = true
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear LazyForEachOnDataAdd start`)
}
aboutToDisappear() {
Log.showInfo(TAG, `aboutToDisAppear LazyForEachOnDataAdd end`)
}
build() {
Column() {
Stack({ alignContent: Alignment.End }) {
Scroll(this.scroller) {
Flex({
direction: FlexDirection.Column,
alignItems: ItemAlign.Start,
justifyContent: FlexAlign.SpaceBetween
}) {
Text("lazyForEach-OnDataAdd")
.width(300)
.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("onDataAddText")
List({ space: 3 }) {
LazyForEach(this.data, (item: string) => {
ListItem() {
Row() {
Image(item).width("30%").height(50)
Text(item).fontSize(20).margin({ left: 10 })
}.margin({ left: 10, right: 10 })
}
.key("listItemOne")
.onClick(() => {
try{
this.data.pushData('/path/image' + this.data.totalCount())
console.info("this.data.totalCount() is :" + this.data.totalCount())
}catch(err){
this.result_101 = false
console.info("LazyForEachOnDataAdd_101 onClick emit action err: " + JSON.stringify(err.message))
}
try {
var backData1 = {
data: {
"result1": this.result_101,
}
}
let backEvent1 = {
eventId: 101,
priority: events_emitter.EventPriority.LOW
}
console.info("LazyForEachOnDataAdd_101 onClick start to emit action")
events_emitter.emit(backEvent1, backData1)
} catch (err) {
console.info("LazyForEachOnDataAdd_101 onClick emit action err: " + JSON.stringify(err.message))
}
})
}, item => item)
}
Text("lazyForEach-OnDataMove")
.width(300)
.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("onDataMoveText")
List({ space: 3 }) {
LazyForEach(this.data, (item: string) => {
ListItem() {
Row() {
Image(item).width("30%").height(50)
Text(item).fontSize(20).margin({ left: 10 })
}.margin({ left: 10, right: 10 })
}
.key("listItemTwo")
.onClick(() => {
try{
this.data.moveData(3, 1)
}catch(err){
this.result_102 = false
console.info("LazyForEachOnDataAdd_102 onClick emit action err: " + JSON.stringify(err.message))
}
try {
var backData2 = {
data: {
"result2": this.result_102,
}
}
let backEvent2 = {
eventId: 102,
priority: events_emitter.EventPriority.LOW
}
console.info("LazyForEachOnDataAdd_102 onClick start to emit action")
events_emitter.emit(backEvent2, backData2)
} catch (err) {
console.info("LazyForEachOnDataAdd_102 onClick emit action err: " + JSON.stringify(err.message))
}
})
}, item => item)
}
Text("lazyForEach-OnDataDelete")
.width(300)
.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("onDataDeleteText")
List({ space: 3 }) {
LazyForEach(this.data, (item: string) => {
ListItem() {
Row() {
Image(item).width("30%").height(50)
Text(item).fontSize(20).margin({ left: 10 })
}.margin({ left: 10, right: 10 })
}
.key("listItemThree")
.onClick(() => {
try{
this.data.popData()
}catch(err){
this.result_103 = false
console.info("LazyForEachOnDataAdd_103 onClick emit action err: " + JSON.stringify(err.message))
}
try {
var backData3 = {
data: {
"result3": this.result_103,
}
}
let backEvent3 = {
eventId: 103,
priority: events_emitter.EventPriority.LOW
}
console.info("LazyForEachOnDataAdd_103 onClick start to emit action")
events_emitter.emit(backEvent3, backData3)
} catch (err) {
console.info("LazyForEachOnDataAdd_103 onClick emit action err: " + JSON.stringify(err.message))
}
})
}, item => item)
}
Text("lazyForEach-OnDataChange")
.width(300)
.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("onDataChangeText")
List({ space: 3 }) {
LazyForEach(this.data, (item: string) => {
ListItem() {
Row() {
Image(item).width("30%").height(50)
Text(item).fontSize(20).margin({ left: 10 })
}.margin({ left: 10, right: 10 })
}
.key("listItemFour")
.onClick(() => {
try{
this.data.changeData(2)
}catch(err){
this.result_104 = false
console.info("LazyForEachOnDataAdd_104 onClick emit action err: " + JSON.stringify(err.message))
}
try {
var backData4 = {
data: {
"result4": this.result_104,
}
}
let backEvent4 = {
eventId: 104,
priority: events_emitter.EventPriority.LOW
}
console.info("LazyForEachOnDataAdd_104 onClick start to emit action")
events_emitter.emit(backEvent4, backData4)
} catch (err) {
console.info("LazyForEachOnDataAdd_104 onClick emit action err: " + JSON.stringify(err.message))
}
})
}, item => item)
}
}.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 PathNew {
private path: any = new Path({
width: 100,
height: 100,
commands: 'M150 0 L300 300 L0 300 Z'
})
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear PathNew start`)
}
aboutToDisappear() {
Log.showInfo(TAG, `aboutToDisAppear PathNew end`)
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text("path-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")
Path().width(100).height(100).commands('M150 0 L300 300 L0 300 Z')
.key("Path")
}.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 PolyLineNe {
private polyline: PolylineAttribute = new Polyline({
width: 100,
height: 100
})
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear PolyLineNe start`)
}
aboutToDisappear() {
Log.showInfo(TAG, `aboutToDisAppear PolyLineNe end`)
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text("polyLine-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")
Polyline().width(100).height(100).points([[0, 0], [0, 100], [100, 100]])
.key("Polyline")
}.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 PolygonNe {
private polygon: PolygonAttribute = new Polygon({
width: 100,
height: 100
})
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear PolygonNe start`)
}
aboutToDisappear() {
Log.showInfo(TAG, `aboutToDisAppear PolygonNe end`)
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text("polygon-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")
Polygon({ width: 100, height: 100 }).points([[0, 0], [50, 100], [100, 0]])
.key("Polygon")
}.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 RectNe {
private rect: RectAttribute = new Rect({
width: '90%',
height: 50,
radiusHeight: 20,
radiusWidth: 20
})
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear RectNe start`)
}
aboutToDisappear() {
Log.showInfo(TAG, `aboutToDisAppear RectNe end`)
}
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.Center }) {
Text("rect-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")
Rect({ width: '90%', height: 50 }).radiusHeight(20).radiusWidth(20)
.key("Rect")
}.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 ScrollOnScrollBegin {
scroller: Scroller = new Scroller()
private arr: number[] = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear ScrollOnScrollBegin start`)
}
aboutToDisappear(){
Log.showInfo(TAG, `aboutToDisAppear ScrollOnScrollBegin end`)
}
build(){
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center,justifyContent:FlexAlign.Center }){
Text("scroll-OnScrollBegin")
.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("onScrollBeginText")
Scroll(this.scroller) {
Column() {
ForEach(this.arr, (item) => {
Text(item.toString())
.width('90%')
.height(150)
.backgroundColor(0xFFFFFF)
.borderRadius(15)
.fontSize(16)
.textAlign(TextAlign.Center)
.margin({ top: 10 })
}, item => item)
}.width('100%')
}
.scrollable(ScrollDirection.Vertical)
.onScrollBegin((dx: number, dy: number) => {
console.info('dx=' + dx + ",dy=" + dy)
return { dxRemain: dx, dyRemain: dy }
})
.scrollBar(BarState.On)
.scrollBarColor(Color.Gray)
.scrollBarWidth(30)
.onScroll((xOffset: number, yOffset: number) => {
console.info(xOffset + ' ' + yOffset)
})
.onScrollEdge((side: Edge) => {
console.info('To the edge')
})
.onScrollEnd(() => {
console.info('Scroll Stop')
})
.key("Scroll")
.width("100%")
.height("100%")
}.width("100%").height("100%")
}
}
...@@ -17,10 +17,28 @@ import alphabetIndexerOnSelectJsunit from './alphabetIndexer.test.ets'; ...@@ -17,10 +17,28 @@ import alphabetIndexerOnSelectJsunit from './alphabetIndexer.test.ets';
import checkBoxGroupSelectAllJsunit from './checkBoxGroup.test.ets'; import checkBoxGroupSelectAllJsunit from './checkBoxGroup.test.ets';
import circleNewJsunit from './circle.test.ets'; import circleNewJsunit from './circle.test.ets';
import ellipseNeJsunit from './ellipse.test.ets'; import ellipseNeJsunit from './ellipse.test.ets';
import gridMaxCountJsunit from './grid.test.ets';
import gridItemOnSelectJsunit from './gridItem.test.ets';
import inspectorJsunit from './inspector.test.ets'
import lazyForEachOnDataAddJsunit from './lazyForEach.test.ets';
import pathNewTest from './path.test.ets';
import polygonNewJsunit from './polygon.test.ets';
import polyLineNeJsunit from './polyLine.test.ets';
import rectNeJsunit from './rect.test.ets';
import scrollOnScrollBeginJsunit from './scroll.test.ets';
export default function testsuite() { export default function testsuite() {
alphabetIndexerOnSelectJsunit() alphabetIndexerOnSelectJsunit()
checkBoxGroupSelectAllJsunit() checkBoxGroupSelectAllJsunit()
circleNewJsunit() circleNewJsunit()
ellipseNeJsunit() ellipseNeJsunit()
gridMaxCountJsunit()
gridItemOnSelectJsunit()
inspectorJsunit()
lazyForEachOnDataAddJsunit()
pathNewTest()
polygonNewJsunit()
polyLineNeJsunit()
rectNeJsunit()
scrollOnScrollBeginJsunit()
} }
\ 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.
*/
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 gridMaxCountJsunit() {
describe('gridMaxCountTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/grid',
}
try {
router.clear();
let pages = router.getState();
console.info("get grid state success " + JSON.stringify(pages));
if (!("grid" == pages.name)) {
console.info("get grid state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push grid page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push grid page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("gridMaxCount after each called");
});
it('testcheckgridMaxCount0001', 0, async function (done) {
console.info('testcheckgridMaxCount testcheckgridMaxCount0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('maxCountTest');
console.info("[testcheckgridMaxCount0001] component selectedMaxcount strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Grid');
expect(obj.$attrs.maxCount).assertEqual("5");
console.info("[testcheckgridMaxCount0001] selectedMaxCount value :" + obj.$attrs.maxCount);
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'
import events_emitter from '@ohos.events.emitter';
export default function gridItemOnSelectJsunit() {
describe('gridItemOnSelectTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/gridItem',
}
try {
router.clear();
let pages = router.getState();
console.info("get gridItem state success " + JSON.stringify(pages));
if (!("gridItem" == pages.name)) {
console.info("get gridItem state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push gridItem page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push gridItem page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("gridItemOnSelect after each called");
});
it('testgridItemOnSelect0001', 0, async function (done) {
console.info('testgridItemOnSelect testgridItemOnSelect0001 START');
await Utils.sleep(2000);
let callback = (indexEvent) => {
console.info("onSelect_0001 get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.STATUS).assertEqual(true);
done();
}
let indexEvent = {
eventId: 10200,
priority: events_emitter.EventPriority.LOW
}
sendEventByKey('onSelected', 10, "")
try {
events_emitter.on(indexEvent, callback);
} catch (err) {
console.info("onSelect_0001 on events_emitter err : " + JSON.stringify(err));
}
console.info('testgridItemOnSelect0001 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 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 inspectorJsunit() {
describe('inspectorTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/inspector',
}
try {
router.clear();
let pages = router.getState();
console.info("get inspector state success " + JSON.stringify(pages));
if (!("inspector" == pages.name)) {
console.info("get inspector state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push inspector page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push inspector page error: " + err);
}
done()
});
afterEach(async function () {
console.info("inspectorTest after each called");
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0001
* @tc.name testlazyForEachOnDataAdd0001
* @tc.desic acelazyForEachOnDataAddEtsTest0001
*/
it('testInspectorTestAdd0001', 0, async function (done) {
console.info('Inspector testInspectorTestAdd0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('inspectorApiOne');
console.info("[testInspectorTestAdd0001] component width strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.fontSize).assertEqual("50.00fp");
console.info("[testInspectorTestAdd0001] fontSize value :" + obj.$attrs.fontSize);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0002
* @tc.name testInspectorTestAdd0002
* @tc.desic aceTestInspectorTestAdd0002
*/
it('testInspectorTestAdd0002', 0, async function (done) {
console.info('Inspector testInspectorTestAdd0002 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('inspectorApiOne');
console.info("[testInspectorTestAdd0002] component width strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Text');
expect(obj.$attrs.fontWeight).assertEqual("FontWeight.Bold");
console.info("[testInspectorTestAdd0002] fontWeight value :" + obj.$attrs.fontWeight);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0003
* @tc.name testInspectorTestAdd0003
* @tc.desic aceTestInspectorTestAdd0003
*/
it('testInspectorTestAdd0003', 0, async function (done) {
console.info("testInspectorTestAdd0003 start test");
var innerEvent1 = {
eventId: 101,
priority: events_emitter.EventPriority.LOW
}
var callback1 = (eventData) => {
console.info("eventData.data.getInspectorNodes result is: " + eventData.data.getInspectorNodes);
try{
console.info("callback1 success" );
console.info("inspector_101 eventData.data.result result is: " + eventData.data.result);
expect(eventData.data.result).assertEqual("success");
console.info("inspector_101 end: ");
if(eventData.data.getInspectorNodes != null){
console.info("eventData.data.result result is: " + eventData.data.result);
expect(eventData.data.result).assertEqual("success");
}
}catch(err){
console.info("inspector_101 on events_emitter err : " + JSON.stringify(err));
}
done();
}
try {
events_emitter.on(innerEvent1, callback1);
console.info("inspector_101 click result is: " + JSON.stringify(sendEventByKey('inspectorApiOne', 10, "")));
} catch (err) {
console.info("inspector_101 on events_emitter err : " + JSON.stringify(err));
}
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0004
* @tc.name testInspectorTestAdd0004
* @tc.desic aceTestInspectorTestAdd0004
*/
it('testInspectorTestAdd0004', 0, async function (done) {
var innerEvent2 = {
eventId: 102,
priority: events_emitter.EventPriority.LOW
}
var callback2 = (eventData) => {
console.info("eventData.data.getInspectorNodeById result is: " + eventData.data.getInspectorNodeById);
try{
console.info("callback2 success" );
console.info("inspector_102 eventData.data.result result is: " + eventData.data.result);
expect(eventData.data.result).assertEqual("success");
console.info("inspector_102 end");
}catch(err){
console.info("inspector_102 on events_emitter err : " + JSON.stringify(err));
}
done();
}
try{
console.info("inspector_102 click result is: " + JSON.stringify(sendEventByKey('inspectorApiTwo', 10, "")));
events_emitter.on(innerEvent2, callback2);
}catch(err){
console.info("inspector_102 on events_emitter err : " + JSON.stringify(err));
}
});
it('testInspectorTestAdd0005', 0, async function (done) {
console.info('testInspectorTestAdd0005 START');
try {
var eventData = {
data: {
"setColor": 'red'
}
}
var innerEvent = {
eventId: 103,
priority: events_emitter.EventPriority.LOW
}
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("[testInspectorTestAdd0005] change component data error: " + err.message);
}
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0004
* @tc.name testInspectorTestAdd0004
* @tc.desic aceTestInspectorTestAdd0004
*/
it('testInspectorTestAdd0006', 0, async function (done) {
var innerEvent3 = {
eventId: 103,
priority: events_emitter.EventPriority.LOW
}
var callback3 = (eventData) => {
try{
console.info("callback2 success" );
console.info("inspector_103 eventData.data.result result is: " + eventData.data.catchStatus);
expect(eventData.data.catchStatus).assertEqual("callBackSuccess");
console.info("inspector_103 end");
}catch(err){
console.info("inspector_103 on events_emitter err : " + JSON.stringify(err));
}
done();
}
try{
console.info("inspector_103 click result is: " + JSON.stringify(sendEventByKey('inspectorApiFour', 10, "")));
events_emitter.on(innerEvent3, callback3);
}catch(err){
console.info("inspector_103 on events_emitter err : " + JSON.stringify(err));
}
});
})
}
/**
* 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 lazyForEachOnDataAddJsunit() {
describe('lazyForEachOnDataAddTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/lazyForEach',
}
try {
router.clear();
let pages = router.getState();
console.info("get lazyForEach state success " + JSON.stringify(pages));
if (!("lazyForEach" == pages.name)) {
console.info("get lazyForEach state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push lazyForEach page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push lazyForEach page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("lazyForEachOnDataAdd after each called");
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0001
* @tc.name testlazyForEachOnDataAdd0001
* @tc.desic acelazyForEachOnDataAddEtsTest0001
*/
it('testlazyForEachOnDataAdd0001', 0, async function (done) {
console.info('lazyForEachOnDataAdd testlazyForEachOnDataAdd0001 START');
var innerEvent1 = {
eventId: 101,
priority: events_emitter.EventPriority.LOW
}
var callback1 = (eventData) => {
console.info("eventData.data.result1 result is: " + eventData.data.result1);
try{
console.info("callback1 success" );
console.info("Lazy_101 eventData.data.result1 result is: " + eventData.data.result1);
expect(eventData.data.result1).assertEqual(true);
console.info('lazyForEachOnDataAdd testlazyForEachOnDataAdd0001 END');
}catch(err){
console.info("Lazy_101 on events_emitter err : " + JSON.stringify(err));
}
done();
}
try{
console.info("Lazy_101 click result is:" + JSON.stringify(sendEventByKey('listItemOne', 10, "")));
events_emitter.on(innerEvent1, callback1);
}catch(err){
console.info("Lazy_101 on events_emitter err : " + JSON.stringify(err));
}
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0002
* @tc.name testlazyForEachOnDataAdd0002
* @tc.desic acelazyForEachOnDataAddEtsTest0002
*/
it('testlazyForEachOnDataAdd0002', 0, async function (done) {
console.info('lazyForEachOnDataAdd testlazyForEachOnDataAdd0002 START');
var innerEvent2 = {
eventId: 102,
priority: events_emitter.EventPriority.LOW
}
var callback2 = (eventData) => {
console.info("eventData.data.result2 result is: " + eventData.data.result2);
try{
console.info("callback2 success" );
console.info("Lazy_102 eventData.data.result2 result is: " + eventData.data.result2);
expect(eventData.data.result2).assertEqual(true);
console.info('lazyForEachOnDataAdd testlazyForEachOnDataAdd0002 END');
}catch(err){
console.info("Lazy_102 on events_emitter err : " + JSON.stringify(err));
}
done();
}
try{
console.info("Lazy_102 click result is:" + JSON.stringify(sendEventByKey('listItemTwo', 10, "")));
events_emitter.on(innerEvent2, callback2);
}catch(err){
console.info("Lazy_102 on events_emitter err : " + JSON.stringify(err));
}
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0003
* @tc.name testlazyForEachOnDataAdd0003
* @tc.desic acelazyForEachOnDataAddEtsTest0003
*/
it('testlazyForEachOnDataAdd0003', 0, async function (done) {
console.info('lazyForEachOnDataAdd testlazyForEachOnDataAdd0003 START');
var innerEvent3 = {
eventId: 103,
priority: events_emitter.EventPriority.LOW
}
var callback3 = (eventData) => {
console.info("eventData.data.result3 result is: " + eventData.data.result3);
try{
console.info("callback3 success" );
console.info("Lazy_103 eventData.data.result3 result is: " + eventData.data.result3);
expect(eventData.data.result3).assertEqual(true);
console.info('lazyForEachOnDataAdd testlazyForEachOnDataAdd0003 END');
}catch(err){
console.info("Lazy_103 on events_emitter err : " + JSON.stringify(err));
}
done();
}
try{
console.info("Lazy_103 click result is:" + JSON.stringify(sendEventByKey('listItemThree', 10, "")));
events_emitter.on(innerEvent3, callback3);
}catch(err){
console.info("Lazy_103 on events_emitter err : " + JSON.stringify(err));
}
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0004
* @tc.name testlazyForEachOnDataAdd0004
* @tc.desic acelazyForEachOnDataAddEtsTest0004
*/
it('testlazyForEachOnDataAdd0004', 0, async function (done) {
console.info('lazyForEachOnDataAdd testlazyForEachOnDataAdd0004 START');
var innerEvent4 = {
eventId: 104,
priority: events_emitter.EventPriority.LOW
}
var callback4 = (eventData) => {
console.info("eventData.data.result4 result is: " + eventData.data.result4);
try{
console.info("callback4 success" );
console.info("Lazy_104 eventData.data.result4 result is: " + eventData.data.result4);
expect(eventData.data.result4).assertEqual(true);
console.info('lazyForEachOnDataAdd testlazyForEachOnDataAdd0004 END');
}catch(err){
console.info("Lazy_104 on events_emitter err : " + JSON.stringify(err));
}
done();
}
try{
console.info("Lazy_104 click result is:" + JSON.stringify(sendEventByKey('listItemFour', 10, "")));
events_emitter.on(innerEvent4, callback4);
}catch(err){
console.info("Lazy_104 on events_emitter err : " + JSON.stringify(err));
}
});
})
}
/**
* 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 pathNewTest() {
describe('pathNewTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/path',
}
try {
router.clear();
let pages = router.getState();
console.info("get path state success " + JSON.stringify(pages));
if (!("path" == pages.name)) {
console.info("get path state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push path page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push path page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("pathNe after each called");
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0001
* @tc.name testpathNe0001
* @tc.desic acepathNeEtsTest0001
*/
it('testpathNe0001', 0, async function (done) {
console.info('pathNe testpathNe0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Path');
console.info("[testpathNe0001] component width strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.width).assertEqual("150.00px");
console.info("[testpathNe0001] width value :" + obj.$attrs.width);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0002
* @tc.name testpathNe0002
* @tc.desic acepathNeEtsTest0002
*/
it('testpathNe0002', 0, async function (done) {
console.info('pathNe testpathNe0002 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Path');
console.info("[testpathNe0002] component height strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.height).assertEqual("150.00px");
console.info("[testpathNe0002] height value :" + obj.$attrs.height);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0003
* @tc.name testpathNe0003
* @tc.desic acepathNeEtsTest0003
*/
it('testpathNe0003', 0, async function (done) {
console.info('pathNe testpathNe0003 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Path');
console.info("[testpathNe0003] component fontSize strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.commands).assertEqual("M150 0 L300 300 L0 300 Z");
console.info("[testpathNe0003] commands value :" + obj.$attrs.commands);
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 polyLineNeJsunit() {
describe('polyLineNeTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/polyLine',
}
try {
router.clear();
let pages = router.getState();
console.info("get polyLine state success " + JSON.stringify(pages));
if (!("polyLine" == pages.name)) {
console.info("get polyLine state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push polyLine page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push polyLine page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("polyLineNe after each called");
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0001
* @tc.name testpolyLineNe0001
* @tc.desic acepolyLineNeEtsTest0001
*/
it('testpolyLineNe0001', 0, async function (done) {
console.info('polyLineNe testpolyLineNe0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Polyline');
console.info("[testpolyLineNe0001] component width strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.width).assertEqual("150.00px");
console.info("[testpolyLineNe0001] width value :" + obj.$attrs.width);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0002
* @tc.name testpolyLineNe0002
* @tc.desic acepolyLineNeEtsTest0002
*/
it('testpolyLineNe0002', 0, async function (done) {
console.info('polyLineNe testpolyLineNe0002 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Polyline');
console.info("[testpolyLineNe0002] component height strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.height).assertEqual("150.00px");
console.info("[testpolyLineNe0002] height value :" + obj.$attrs.height);
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 polygonNewJsunit() {
describe('polygonNewJsunit', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/polygon',
}
try {
router.clear();
let pages = router.getState();
console.info("get polygon state success " + JSON.stringify(pages));
if (!("polygon" == pages.name)) {
console.info("get polygon state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push polygon page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push polygon page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("polygonNe after each called");
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0001
* @tc.name testpolygonNe0001
* @tc.desic acepolygonNeEtsTest0001
*/
it('testpolygonNe0001', 0, async function (done) {
console.info('polygonNe testpolygonNe0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Polygon');
console.info("[testpolygonNe0001] component width strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.width).assertEqual("150.00px");
console.info("[testpolygonNe0001] width value :" + obj.$attrs.width);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0002
* @tc.name testpolygonNe0002
* @tc.desic acepolygonNeEtsTest0002
*/
it('testpolygonNe0002', 0, async function (done) {
console.info('polygonNe testpolygonNe0002 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Polygon');
console.info("[testpolygonNe0002] component height strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.height).assertEqual("150.00px");
console.info("[testpolygonNe0002] height value :" + obj.$attrs.height);
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 rectNeJsunit() {
describe('rectNeTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/rect',
}
try {
router.clear();
let pages = router.getState();
console.info("get rect state success " + JSON.stringify(pages));
if (!("rect" == pages.name)) {
console.info("get rect state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push rect page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push rect page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("rectNe after each called");
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0001
* @tc.name testrectNe0001
* @tc.desic acerectNeEtsTest0001
*/
it('testrectNe0001', 0, async function (done) {
console.info('rectNe testrectNe0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Rect');
console.info("[testrectNe0001] component width strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.width).assertEqual("90.00%");
console.info("[testrectNe0001] width value :" + obj.$attrs.width);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0002
* @tc.name testrectNe0002
* @tc.desic acerectNeEtsTest0002
*/
it('testrectNe0002', 0, async function (done) {
console.info('rectNe testrectNe0002 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Rect');
console.info("[testrectNe0002] component height strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Shape');
expect(obj.$attrs.height).assertEqual("75.00px");
console.info("[testrectNe0002] height value :" + obj.$attrs.height);
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'
import events_emitter from '@ohos.events.emitter';
export default function scrollOnScrollBeginJsunit() {
describe('scrollOnScrollBeginTest', function () {
beforeAll(async function (done) {
console.info("flex beforeEach start");
let options = {
uri: 'pages/scroll',
}
try {
router.clear();
let pages = router.getState();
console.info("get scroll state success " + JSON.stringify(pages));
if (!("scroll" == pages.name)) {
console.info("get scroll state success " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(2000);
console.info("push scroll page success " + JSON.stringify(result));
}
} catch (err) {
console.error("push scroll page error: " + err);
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("scrollOnScrollBegin after each called");
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0001
* @tc.name testscrollOnScrollBegin0001
* @tc.desic acescrollOnScrollBeginEtsTest0001
*/
it('testscrollOnScrollBegin0001', 0, async function (done) {
console.info('scrollOnScrollBegin testscrollOnScrollBegin0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Scroll');
console.info("[testscrollOnScrollBegin0001] component width strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Scroll');
expect(obj.$attrs.width).assertEqual("100.00%");
console.info("[testscrollOnScrollBegin0001] width value :" + obj.$attrs.width);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0002
* @tc.name testscrollOnScrollBegin0002
* @tc.desic acescrollOnScrollBeginEtsTest0002
*/
it('testscrollOnScrollBegin0002', 0, async function (done) {
console.info('scrollOnScrollBegin testscrollOnScrollBegin0002 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Scroll');
console.info("[testscrollOnScrollBegin0002] component height strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Scroll');
expect(obj.$attrs.height).assertEqual("100.00%");
console.info("[testscrollOnScrollBegin0002] height value :" + obj.$attrs.height);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0003
* @tc.name testscrollOnScrollBegin0003
* @tc.desic acescrollOnScrollBeginEtsTest0003
*/
it('testscrollOnScrollBegin0003', 0, async function (done) {
console.info('scrollOnScrollBegin testscrollOnScrollBegin0003 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Scroll');
console.info("[testscrollOnScrollBegin0003] component fontSize strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Scroll');
expect(obj.$attrs.scrollBar).assertEqual("BarState.On");
console.info("[testscrollOnScrollBegin0003] scrollBar value :" + obj.$attrs.scrollBar);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0004
* @tc.name testscrollOnScrollBegin0004
* @tc.desic acescrollOnScrollBeginEtsTest0004
*/
it('testscrollOnScrollBegin0004', 0, async function (done) {
console.info('scrollOnScrollBegin testscrollOnScrollBegin0004 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Scroll');
console.info("[testscrollOnScrollBegin0004] component opacity strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Scroll');
expect(obj.$attrs.scrollBarColor).assertEqual("#FF808080");
console.info("[testscrollOnScrollBegin0004] scrollBarColor value :" + obj.$attrs.scrollBarColor);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0005
* @tc.name testscrollOnScrollBegin0005
* @tc.desic acescrollOnScrollBeginEtsTest0005
*/
it('testscrollOnScrollBegin0005', 0, async function (done) {
console.info('scrollOnScrollBegin testscrollOnScrollBegin0005 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('Scroll');
console.info("[testscrollOnScrollBegin0005] component align strJson:" + strJson);
let obj = JSON.parse(strJson);
expect(obj.$type).assertEqual('Scroll');
expect(obj.$attrs.scrollBarWidth).assertEqual("30.00px");
console.info("[testscrollOnScrollBegin0005] scrollBarWidth value :" + obj.$attrs.scrollBarWidth);
done();
});
/*
* @tc.number SUB_ACE_BASIC_ETS_API_0012
* @tc.name testscrollOnScrollBegin0005
* @tc.desic acescrollOnScrollBeginEtsTest0006
*/
it('testscrollOnScrollBegin0006', 0, async function (done) {
console.info('scrollOnScrollBegin testscrollOnScrollBegin0006 START');
await Utils.sleep(2000);
let callback = (indexEvent) => {
console.info("scrollOnScrollBegin get state result is: " + JSON.stringify(indexEvent));
expect(indexEvent.data.STATUS).assertEqual(true);
}
let indexEvent = {
eventId: 10086,
priority: events_emitter.EventPriority.LOW
}
sendEventByKey('Scroll', 10, "")
try {
events_emitter.on(indexEvent, callback);
} catch (err) {
console.info("scrollOnScrollBegin on events_emitter err : " + JSON.stringify(err));
}
console.info('testscrollOnScrollBegin0006 END');
done();
});
})
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册