提交 ee562c51 编写于 作者: Z zhangrao

add component

Signed-off-by: Nzhangrao <zhangrao@huawei.com>
上级 1afabe1d
......@@ -94,14 +94,12 @@
"pages/general-properties/flex",
"pages/swiper",
"pages/gridPage",
"pages/general-properties/rotationGesture",
"pages/text",
"pages/badge",
"pages/canvas",
"pages/longPressGesture",
"pages/badge",
"pages/button",
"pages/general-properties/rotationGesture",
"pages/gridPage",
"pages/general-properties/touchAble",
"pages/swiper",
......@@ -109,9 +107,7 @@
"pages/general-properties/ResponseRegion",
"pages/general-properties/PanGesture",
"pages/QrCode",
"pages/general-properties/PanGesture",
"pages/tabs",
"pages/general-properties/PanGesture",
"pages/tapGesture",
"pages/progress",
"pages/animate"
......
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import events_emitter from '@ohos.emitter';
@Entry
@Component
struct RotationGestureExample {
@State angle: number = 0
@State eventType: string = ''
@State isTouched: boolean = false;
build() {
Flex({ direction: FlexDirection.Column, alignItems: ItemAlign.Center, justifyContent: FlexAlign.SpaceBetween }) {
Text('RotationGesture angle:' + this.angle)
}
.height(300).width(300).padding(20).border({ width:1 })
.margin(80).rotate({ x:1, y:2, z:3, angle: this.angle })
.key('gesture')
.onTouch((event: TouchEvent) => {
this.isTouched = true
if (event.type === TouchType.Down) {
this.eventType = 'Down'
}
if (event.type === TouchType.Up) {
this.eventType = 'Up'
}
if (event.type === TouchType.Move) {
this.eventType = 'Move'
}
console.info('RotationGesture TouchType:' + this.eventType)
try {
var backData = {
data: {
"ACTION": this.isTouched,
"EVENT_TYPE": this.eventType
}
}
var backEvent = {
eventId: 56,
priority: events_emitter.EventPriority.LOW
}
console.info("RotationGesture start to emit action state")
events_emitter.emit(backEvent, backData)
} catch (err) {
console.info("RotationGesture emit action state err: " + JSON.stringify(err.message))
}
})
.gesture(
RotationGesture()
.onActionStart((event: RotationGestureEvent) => {
console.log('Rotation start')
})
.onActionUpdate((event: RotationGestureEvent) => {
this.angle = event.angle
})
.onActionEnd(() => {
console.log('Rotation end')
})
)
}
}
......@@ -28,7 +28,7 @@ struct LongPressGestureExample {
.height(200).width(300).padding(60).border({ width:1 }).margin(30)
.gesture(
LongPressGesture({ repeat: true })
.onAction((event: LongPressGestureEvent) => {
.onAction(() => {
console.info("longPressGesture current action onAction")
this.eventString = 'onAction';
console.info('onAction current action state is: ' + this.eventString);
......
......@@ -15,6 +15,7 @@
import events_emitter from '@ohos.emitter'
@Entry
@Component
struct ProgressExample {
......@@ -54,12 +55,30 @@ struct ProgressExample {
priority: events_emitter.EventPriority.LOW
}
events_emitter.on(stateChangeEventThree, this.stateChangCallBack)
var stateChangeEventFour = {
eventId: 42,
priority: events_emitter.EventPriority.LOW
}
events_emitter.on(stateChangeEventFour, this.stateChangCallBack)
var stateChangeEventFive = {
eventId: 41,
priority: events_emitter.EventPriority.LOW
}
events_emitter.on(stateChangeEventFive, this.stateChangCallBack)
var stateChangeEventSix = {
eventId: 40,
priority: events_emitter.EventPriority.LOW
}
events_emitter.on(stateChangeEventSix, this.stateChangCallBack)
}
build() {
Column({ space: 15 }) {
Text('Linear Progress').fontSize(9).fontColor(0xCCCCCC).width('90%')
Progress({ value: 20, total: 150 ,style: ProgressStyle.Linear }).width(200).value(this.value).key('LPValue')
Progress({ value: 20, style: ProgressStyle.Linear }).width(200).value(this.value).key('LPValue')
Progress({ value: 20, total: 150, style: ProgressStyle.Linear }).color(Color.Red).width(200)
Text('Eclipse Progress').fontSize(40).fontColor(0x0F0F0F).width('90%')
......
// @ts-nocheck
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
......@@ -44,8 +45,7 @@ import borderJsunit from './general-properties/BorderJsunit.test.ets';
import flexJsunit from './general-properties/FlexJsunit.test.ets';
import gridJsunit from './GridJsunit.test.ets';
import canvasJsunit from './CanvasJsunit.test.ets';
import rotationGestureJsUnit from './general-properties/RotationGestureJsunit.test.ets';
import textJsunit from './textJsunit.test.ets';
import textJsunit from './TextJsunit.test.ets';
import badgeJsunit from './BadgeJsunit.test.ets';
import longPressGestureJsUnit from './LongPressGesture.test.ets';
import buttonJsunit from './ButtonJsunit.test.ets';
......@@ -89,7 +89,6 @@ export default function testsuite() {
borderJsunit();
flexJsunit();
gridJsunit();
rotationGestureJsUnit();
textJsunit();
badgeJsunit();
canvasJsunit();
......
......@@ -53,7 +53,7 @@ export default function progressJsunit() {
try {
let eventData = {
data: {
"value": 88
"value": 100
}
}
var innerEvent = {
......@@ -69,7 +69,7 @@ export default function progressJsunit() {
let strJson = getInspectorByKey('LPValue');
let obj = JSON.parse(strJson);
console.info("testProgress_100 component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.value).assertEqual("88.000000");
expect(obj.$attrs.value).assertEqual("100.000000");
console.info('testProgress_100 END');
done();
});
......@@ -94,7 +94,7 @@ export default function progressJsunit() {
try {
let eventData = {
data: {
"value": 74
"value": 100
}
}
var innerEvent = {
......@@ -110,7 +110,7 @@ export default function progressJsunit() {
let strJson = getInspectorByKey('EPValue');
let obj = JSON.parse(strJson);
console.info("testProgress_300 component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.value).assertEqual("74.000000");
expect(obj.$attrs.value).assertEqual("100.000000");
console.info('testProgress_300 END');
done();
});
......@@ -135,7 +135,7 @@ export default function progressJsunit() {
try {
let eventData = {
data: {
"value": 61
"value": 100
}
}
var innerEvent = {
......@@ -151,7 +151,7 @@ export default function progressJsunit() {
let strJson = getInspectorByKey('EPValue');
let obj = JSON.parse(strJson);
console.info("testProgress_500 component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.value).assertEqual("61.000000");
expect(obj.$attrs.value).assertEqual("100.000000");
console.info('testProgress_500 END');
done();
});
......@@ -166,5 +166,95 @@ export default function progressJsunit() {
console.info('testProgress_600 END');
done();
});
it('testProgress_700', 0, async function (done) {
console.info('testProgress_700 START');
let strJson1 = getInspectorByKey('LPValue');
let objLP = JSON.parse(strJson1);
console.info("testProgress_700 component objLP is: " + objLP.$attrs.value);
await Utils.sleep(1000);
try {
let eventData = {
data: {
"value": 0
}
}
var innerEvent = {
eventId: 42,
priority: events_emitter.EventPriority.LOW
}
console.info("testProgress_700 start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("testProgress_700 change component data error: " + err.message);
}
await Utils.sleep(2000);
let strJson = getInspectorByKey('LPValue');
let obj = JSON.parse(strJson);
console.info("testProgress_700 component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.value).assertEqual("0.000000");
console.info('testProgress_700 END');
done();
});
it('testProgress_800', 0, async function (done) {
console.info('testProgress_800 START');
let strJson1 = getInspectorByKey('EPValue');
let objEP = JSON.parse(strJson1);
console.info("testProgress_800 component objEP is: " + objEP.$attrs.value);
await Utils.sleep(1000);
try {
let eventData = {
data: {
"value": 0
}
}
var innerEvent = {
eventId: 41,
priority: events_emitter.EventPriority.LOW
}
console.info("testProgress_800 start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("testProgress_800 change component data error: " + err.message);
}
await Utils.sleep(2000);
let strJson = getInspectorByKey('EPValue');
let obj = JSON.parse(strJson);
console.info("testProgress_800 component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.value).assertEqual("0.000000");
console.info('testProgress_800 END');
done();
});
it('testProgress_900', 0, async function (done) {
console.info('testProgress_900 START');
let strJson1 = getInspectorByKey('CPValue');
let objCP = JSON.parse(strJson1);
console.info("testProgress_900 component objCP is: " + objCP.$attrs.value);
await Utils.sleep(1000);
try {
let eventData = {
data: {
"value": 0
}
}
var innerEvent = {
eventId: 40,
priority: events_emitter.EventPriority.LOW
}
console.info("testProgress_900 start to publish emit");
events_emitter.emit(innerEvent, eventData);
} catch (err) {
console.log("testProgress_900 change component data error: " + err.message);
}
await Utils.sleep(2000);
let strJson = getInspectorByKey('EPValue');
let obj = JSON.parse(strJson);
console.info("testProgress_900 component obj is: " + JSON.stringify(obj));
expect(obj.$attrs.value).assertEqual("0.000000");
console.info('testProgress_900 END');
done();
});
})
}
\ No newline at end of file
/**
* Copyright (c) 2021 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
// @ts-nocheck
import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from "deccjsunit/index.ets"
import router from '@system.router';
import Utils from '../Utils';
import events_emitter from '@ohos.events.emitter';
export default function rotationGestureJsUnit() {
describe('rotationGestureTest', function () {
var x_value;
var y_value;
beforeEach(async function (done) {
let options = {
uri: 'pages/general-properties/rotationGesture',
}
try {
router.clear();
let pages = router.getState();
console.info("get rotationGesture state success " + JSON.stringify(pages));
if (!("rotationGesture" == pages.name)) {
console.info("get rotationGesture state name " + JSON.stringify(pages.name));
let result = await router.push(options);
await Utils.sleep(1000);
console.info("push rotationGesture page result " + JSON.stringify(result));
}
} catch (err) {
console.error("push rotationGesture page error " + JSON.stringify(result));
}
done()
});
afterEach(async function () {
await Utils.sleep(1000);
console.info("rotationGesture after each called");
});
it('rotationGestureTest_0100', 0, async function (done) {
console.info('rotationGestureTest_0100 START');
let strJson = getInspectorByKey('gesture');
console.info("rotationGestureTest_0100 component strJson:" + strJson);
let obj = JSON.parse(strJson);
console.info("rotationGestureTest_0100 component obj is: " + JSON.stringify(obj));
expect(obj.$type).assertEqual('Flex');
console.info('rotationGestureTest_0100 END');
done();
});
it('rotationGestureTest_0200', 0, async function (done) {
console.info('rotationGestureTest_0200 START');
let rect = await Utils.getComponentRect('gesture')
console.info("rotationGestureTest_0200 rectInfo is " + JSON.stringify(rect));
x_value = rect.left + (rect.right - rect.left) / 20
y_value = rect.top + (rect.bottom - rect.top) / 20
console.info("rotationGestureTest_0200 onTouch location is: " + "[x]=== " + x_value + " [y]===" + y_value);
let point: TouchObject = {
id: 2,
x: x_value,
y: y_value,
type: TouchType.Down,
}
await Utils.sleep(1000)
var callback = (eventData) => {
console.info("rotationGestureTest_0200 get event state result is: " + JSON.stringify(eventData));
expect(eventData.data.ACTION).assertEqual(true)
expect(eventData.data.EVENT_TYPE).assertEqual('Down')
}
var innerEvent = {
eventId: 56,
priority: events_emitter.EventPriority.LOW
}
try {
events_emitter.on(innerEvent, callback)
} catch (err) {
console.info("rotationGestureTest_0200 on events_emitter err : " + JSON.stringify(err));
}
console.info('rotationGestureTest_0200 testSendTouchEvent ' + sendTouchEvent(point));
await Utils.sleep(1000)
console.info('rotationGestureTest_0200 END');
done();
});
})
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册