提交 cca958e5 编写于 作者: B bayanxing

api 覆盖

Signed-off-by: Nbayanxing <bayanxing@kaihong.com>
上级 22e3eddb
...@@ -81,7 +81,10 @@ ...@@ -81,7 +81,10 @@
"pages/inspector", "pages/inspector",
"pages/lazyForEach", "pages/lazyForEach",
"pages/path", "pages/path",
"pages/polygon" "pages/polygon",
"pages/polyLine",
"pages/rect",
"pages/scroll"
], ],
"name": ".MainAbility", "name": ".MainAbility",
"window": { "window": {
......
...@@ -12,12 +12,9 @@ ...@@ -12,12 +12,9 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
import events_emitter from '@ohos.events.emitter';
import Log from '../common/Log.ets'; import Log from '../common/Log.ets';
var indexOne:number = 1;
var indexTwo:number = 2;
class BasicDataSource implements IDataSource { class BasicDataSource implements IDataSource {
private listeners: DataChangeListener[] = [] private listeners: DataChangeListener[] = []
...@@ -101,9 +98,6 @@ class MyDataSource extends BasicDataSource { ...@@ -101,9 +98,6 @@ class MyDataSource extends BasicDataSource {
} }
public moveData(index1:number,index2:number):void{ public moveData(index1:number,index2:number):void{
indexOne = index1
indexTwo = index2
if(index1 < index2){ if(index1 < index2){
var temp = this.dataArray[index1] var temp = this.dataArray[index1]
for(var i = index1; i < index2 ;i++){ for(var i = index1; i < index2 ;i++){
...@@ -158,7 +152,10 @@ export default ...@@ -158,7 +152,10 @@ export default
struct LazyForEachOnDataAdd { struct LazyForEachOnDataAdd {
private data: MyDataSource = new MyDataSource() private data: MyDataSource = new MyDataSource()
private scroller: Scroller = new Scroller() private scroller: Scroller = new Scroller()
@State index1:number = 1 @State result_101:boolean = true
@State result_102:boolean = true
@State result_103:boolean = true
@State result_104:boolean = true
aboutToAppear() { aboutToAppear() {
Log.showInfo(TAG, `aboutToAppear LazyForEachOnDataAdd start`) Log.showInfo(TAG, `aboutToAppear LazyForEachOnDataAdd start`)
...@@ -203,8 +200,29 @@ struct LazyForEachOnDataAdd { ...@@ -203,8 +200,29 @@ struct LazyForEachOnDataAdd {
} }
.key("listItemOne") .key("listItemOne")
.onClick(() => { .onClick(() => {
this.data.pushData('/path/image' + this.data.totalCount()) try{
console.info("this.data.totalCount() is :" + this.data.totalCount() ) 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) }, item => item)
} }
...@@ -233,7 +251,28 @@ struct LazyForEachOnDataAdd { ...@@ -233,7 +251,28 @@ struct LazyForEachOnDataAdd {
} }
.key("listItemTwo") .key("listItemTwo")
.onClick(() => { .onClick(() => {
this.data.moveData(3, 1) 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) }, item => item)
} }
...@@ -262,7 +301,29 @@ struct LazyForEachOnDataAdd { ...@@ -262,7 +301,29 @@ struct LazyForEachOnDataAdd {
} }
.key("listItemThree") .key("listItemThree")
.onClick(() => { .onClick(() => {
this.data.popData() 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) }, item => item)
} }
...@@ -291,7 +352,28 @@ struct LazyForEachOnDataAdd { ...@@ -291,7 +352,28 @@ struct LazyForEachOnDataAdd {
} }
.key("listItemFour") .key("listItemFour")
.onClick(() => { .onClick(() => {
this.data.changeData(2) 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) }, item => item)
} }
......
/**
* 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 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%")
}
}
...@@ -23,16 +23,22 @@ import inspectorJsunit from './inspector.test.ets' ...@@ -23,16 +23,22 @@ import inspectorJsunit from './inspector.test.ets'
import lazyForEachOnDataAddJsunit from './lazyForEach.test.ets'; import lazyForEachOnDataAddJsunit from './lazyForEach.test.ets';
import pathNewTest from './path.test.ets'; import pathNewTest from './path.test.ets';
import polygonNewJsunit from './polygon.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() // gridMaxCountJsunit()
gridItemOnSelectJsunit() // gridItemOnSelectJsunit()
inspectorJsunit() // inspectorJsunit()
lazyForEachOnDataAddJsunit() lazyForEachOnDataAddJsunit()
pathNewTest() // pathNewTest()
polygonNewJsunit() // polygonNewJsunit()
// polyLineNeJsunit()
// rectNeJsunit()
// scrollOnScrollBeginJsunit()
} }
\ No newline at end of file
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
* limitations under the License. * limitations under the License.
*/ */
import events_emitter from '@ohos.events.emitter';
import router from '@system.router'; import router from '@system.router';
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index" import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "hypium/index"
import Utils from './Utils.ets' import Utils from './Utils.ets'
...@@ -52,14 +53,125 @@ export default function lazyForEachOnDataAddJsunit() { ...@@ -52,14 +53,125 @@ export default function lazyForEachOnDataAddJsunit() {
*/ */
it('testlazyForEachOnDataAdd0001', 0, async function (done) { it('testlazyForEachOnDataAdd0001', 0, async function (done) {
console.info('lazyForEachOnDataAdd testlazyForEachOnDataAdd0001 START'); console.info('lazyForEachOnDataAdd testlazyForEachOnDataAdd0001 START');
await Utils.sleep(2000);
let strJson = getInspectorByKey('onDataAddText'); var innerEvent1 = {
console.info("[testlazyForEachOnDataAdd0001] component width strJson:" + strJson); eventId: 101,
let obj = JSON.parse(strJson); priority: events_emitter.EventPriority.LOW
expect(obj.$type).assertEqual('Text'); }
expect(obj.$attrs.width).assertEqual("300.00vp"); var callback1 = (eventData) => {
console.info("[testlazyForEachOnDataAdd0001] width value :" + obj.$attrs.width); console.info("eventData.data.result1 result is: " + eventData.data.result1);
done(); 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 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 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.
先完成此消息的编辑!
想要评论请 注册