提交 2aa5191b 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

refactor: 优化示例及测试

上级 3304de23
......@@ -3,7 +3,6 @@ const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isIos = platformInfo.startsWith('ios')
const isWeb = platformInfo.startsWith('web')
const isMP = platformInfo.startsWith('mp')
const isHarmony = platformInfo.startsWith('harmony')
describe("payment", () => {
if (
......
......@@ -27,7 +27,6 @@ describe('touch-events-test', () => {
it('touch-event-case1', async () => {
let x = 40
let y = 150
......@@ -53,7 +52,8 @@ describe('touch-events-test', () => {
expect(ret).toBe(true)
})
it('touch-event-case3', async () => {
// TODO: harmony swiper preventDefault
it('test swiper preventDefault stopPropagation', async () => {
await page.waitFor(1500);
await page.callMethod('resetEvent')
let x = 25
......@@ -73,7 +73,6 @@ describe('touch-events-test', () => {
})
it('touch-event-case4', async () => {
const viewTouchEvent = await page.data('viewTouchEvent')
const swiperItemTouchEvent = await page.data('swiperItemTouchEvent')
const swiperTouchEvent = await page.data('swiperTouchEvent')
......
......@@ -22,15 +22,14 @@ describe('touch-events-test', () => {
it('test-slider-max-value', async () => {
let iconRect = await page.data('sliderRect')
let x = iconRect.x + 25
let y = iconRect.y + 15
const sliderX = await page.data('sliderX')
const sliderY = await page.data('sliderY')
const x = sliderX + 25
const y = sliderY + 15
// 滑动事件
await program.swipe({
startPoint: {x: x, y: y},
endPoint: {x: x+1000,y: y},
startPoint: {x, y},
endPoint: {x: x + 1000, y},
duration: 300
})
......@@ -40,15 +39,14 @@ describe('touch-events-test', () => {
})
it('test-slider-click', async () => {
let iconRect = await page.data('sliderRect')
let x = iconRect.x + 100
let y = iconRect.y + iconRect.height / 2.0
const sliderX = await page.data('sliderX')
const sliderY = await page.data('sliderY')
const sliderHeight = await page.data('sliderHeight')
const x = sliderX + 100
const y = sliderY + sliderHeight / 2.0
// 点击事件
await program.tap(
{x: x, y: y}
)
await program.tap({x, y})
await page.waitFor(600);
const ret = await page.data('sliderValue')
......
......@@ -11,16 +11,22 @@
export default {
data() {
return {
sliderRect: null as DOMRect | null,
sliderX: 0,
sliderY: 0,
sliderHeight: 0,
sliderValue: 0
}
},
onReady() {
// #ifdef APP-IOS
let sliderEle = uni.getElementById("slider")
this.sliderRect = sliderEle?.getBoundingClientRect()
// #ifdef APP-IOS || APP-HARMONY
const sliderEle = uni.getElementById("slider")
const sliderRect = sliderEle?.getBoundingClientRect()
this.sliderX = sliderRect.x
this.sliderY = sliderRect.y
this.sliderHeight = sliderRect.height
// 加上导航栏及状态栏高度
this.sliderRect.y += uni.getSystemInfoSync().safeArea.top + 44
const systemInfo = uni.getSystemInfoSync()
this.sliderY += systemInfo.safeAreaInsets.top + 44
// #endif
},
methods: {
......
......@@ -161,9 +161,13 @@
<slider :show-value="true" backgroundColor="rgba(32,32,32,0.5)" valueColor="#555" />
</view>
<navigator url="./slider-in-swiper">
<navigator class="uni-common-mb" url="./slider-in-swiper">
<button>slider in swiper</button>
</navigator>
<navigator class="uni-common-mb" url="./slider-maxValue">
<button>slider maxValue</button>
</navigator>
</view>
</scroll-view>
</template>
......@@ -179,4 +183,4 @@
.m-l-a {
margin-left: auto;
}
</style>
</style>
......@@ -166,7 +166,7 @@
let ele = uni.getElementById("swiper-view")
let eleRect = ele?.getBoundingClientRect()
if (eleRect != null) {
this.swipeX = eleRect.width - 10
this.swipeX = eleRect.width - 50
this.swipeY += eleRect.y + uni.getSystemInfoSync().safeArea.top + 44 + 35
}
// #endif
......
......@@ -17,24 +17,22 @@ describe('swiper-touch-test', () => {
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(1500);
await page.waitFor('view');
})
it('swiper-touch-test', async () => {
it('滑动切换 swiper', async () => {
let x = await page.data('swipeX')
let y = await page.data('swipeY')
await program.swipe({
startPoint: {x: x,y: y},
endPoint: {x: 10,y: y},
startPoint: {x, y},
endPoint: {x: 10, y},
duration: 200
})
await page.waitFor(1000)
let val = await page.data('currentValChange')
console.log(val)
expect(val).toEqual(1)
})
......
......@@ -5,7 +5,6 @@ describe('component-native-web-view', () => {
const isIOS = platformInfo.startsWith('ios')
const isMP = platformInfo.startsWith('mp')
const isWeb = platformInfo.startsWith('web')
const isHarmony = platformInfo.startsWith('harmony')
if (isWeb || process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
it('web', async () => {
......@@ -55,36 +54,34 @@ describe('component-native-web-view', () => {
});
expect(1).toBe(1)
});
if (!isHarmony) {
it('test touch event', async () => {
const windowInfo = await program.callUniMethod('getWindowInfo');
await program.tap({
x: 1,
y: windowInfo.statusBarHeight + 44 + 1
});
await page.waitFor(500);
if (!isIOS) {
expect(await page.data('isTouchEnable')).toBe(true);
}
it('test touch event', async () => {
const windowInfo = await program.callUniMethod('getWindowInfo');
await program.tap({
x: 1,
y: windowInfo.safeAreaInsets.top + 44 + 1
});
await page.waitFor(500);
if (!isIOS) {
expect(await page.data('isTouchEnable')).toBe(true);
}
await page.setData({
pointerEvents: 'none',
isTouchEnable: false
});
await page.waitFor(100);
await program.tap({
x: 10,
y: windowInfo.statusBarHeight + 44 + 10
});
await page.waitFor(500);
if (!isIOS) {
expect(await page.data('isTouchEnable')).toBe(false);
}
await page.setData({
pointerEvents: 'auto'
});
await page.setData({
pointerEvents: 'none',
isTouchEnable: false
});
}
await page.waitFor(100);
await program.tap({
x: 10,
y: windowInfo.safeAreaInsets.top + 44 + 10
});
await page.waitFor(500);
if (!isIOS) {
expect(await page.data('isTouchEnable')).toBe(false);
}
await page.setData({
pointerEvents: 'auto'
});
});
it('test event loading load', async () => {
await page.callMethod('reload');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册