提交 6c34dbce 编写于 作者: DCloud-yyl's avatar DCloud-yyl

Merge branch 'dev' into alpha

...@@ -3,6 +3,8 @@ ...@@ -3,6 +3,8 @@
<!-- 读取日历权限,用于演示权限申请监听API:uni.createRequestPermissionListener --> <!-- 读取日历权限,用于演示权限申请监听API:uni.createRequestPermissionListener -->
<uses-permission android:name="android.permission.READ_CALENDAR"/> <uses-permission android:name="android.permission.READ_CALENDAR"/>
<!-- 录音权限,用于演示获取录音权限API:uni.getAppAuthorizeSetting 返回的microphoneAuthorized属性值 -->
<uses-permission android:name="android.permission.RECORD_AUDIO"/>
<application> <application>
......
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('API-loading', () => {
let page;
const isAndroid = process.env.UNI_OS_NAME === "android";
beforeAll(async () => {
page = await program.reLaunch('/pages/API/action-sheet/action-sheet')
await page.waitFor(200);
});
it("onload-action-sheet-test", async () => {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("action-sheet-test-current-0", async () => {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
await page.setData({
showErrorToast:false,
current: 0,
itemContentLarge:false,
itemNumLargeSelect:false,
itemColorCustom:false,
})
const btnToastDurationButton = await page.$('#btn-action-sheet-show')
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("action-sheet-test-current-0-largeContent", async () => {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
await page.setData({
showErrorToast:false,
current: 0,
itemContentLarge:true,
itemNumLargeSelect:false,
itemColorCustom:false,
})
const btnToastDurationButton = await page.$('#btn-action-sheet-show')
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("action-sheet-test-current-0-largeContent-largeNum", async () => {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
await page.setData({
showErrorToast:false,
current: 0,
itemContentLarge:true,
itemNumLargeSelect:true,
itemColorCustom:false,
})
const btnToastDurationButton = await page.$('#btn-action-sheet-show')
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("action-sheet-test-current-0-largeContent-largeNum-customColor", async () => {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
await page.setData({
showErrorToast:false,
current: 0,
itemContentLarge:true,
itemNumLargeSelect:true,
itemColorCustom:true,
})
const btnToastDurationButton = await page.$('#btn-action-sheet-show')
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("action-sheet-test-current-1", async () => {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
await page.setData({
current: 1,
itemContentLarge:false,
itemNumLargeSelect:false,
itemColorCustom:false,
})
const btnToastDurationButton = await page.$('#btn-action-sheet-show')
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("action-sheet-test-current-1-largeContent", async () => {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
await page.setData({
showErrorToast:false,
current: 1,
itemContentLarge:true,
itemNumLargeSelect:false,
itemColorCustom:false,
})
const btnToastDurationButton = await page.$('#btn-action-sheet-show')
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("action-sheet-test-current-1-largeContent-largeNum", async () => {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
await page.setData({
showErrorToast:false,
current: 1,
itemContentLarge:true,
itemNumLargeSelect:true,
itemColorCustom:false,
})
const btnToastDurationButton = await page.$('#btn-action-sheet-show')
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("action-sheet-test-current-1-largeContent-largeNum-customColor", async () => {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
await page.setData({
showErrorToast:false,
current: 1,
itemContentLarge:true,
itemNumLargeSelect:true,
itemColorCustom:true,
})
const btnToastDurationButton = await page.$('#btn-action-sheet-show')
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("action-sheet-test-current-2", async () => {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
await page.setData({
current: 2,
itemContentLarge:false,
itemNumLargeSelect:false,
itemColorCustom:false,
})
const btnToastDurationButton = await page.$('#btn-action-sheet-show')
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("action-sheet-test-current-2-largeContent", async () => {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
await page.setData({
showErrorToast:false,
current: 2,
itemContentLarge:true,
itemNumLargeSelect:false,
itemColorCustom:false,
})
const btnToastDurationButton = await page.$('#btn-action-sheet-show')
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("action-sheet-test-current-2-largeContent-largeNum", async () => {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
await page.setData({
showErrorToast:false,
current: 2,
itemContentLarge:true,
itemNumLargeSelect:true,
itemColorCustom:false,
})
const btnToastDurationButton = await page.$('#btn-action-sheet-show')
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("action-sheet-test-current-2-largeContent-largeNum-customColor", async () => {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
await page.setData({
showErrorToast:false,
current: 2,
itemContentLarge:true,
itemNumLargeSelect:true,
itemColorCustom:true,
})
const btnToastDurationButton = await page.$('#btn-action-sheet-show')
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
});
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
</view> </view>
<view class="uni-padding-wrap"> <view class="uni-padding-wrap">
<view class="uni-btn-v"> <view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="actionSheetTap">弹出action sheet</button> <button class="uni-btn-v" type="default" @tap="actionSheetTap" id="btn-action-sheet-show">弹出action sheet</button>
</view> </view>
</view> </view>
</view> </view>
...@@ -41,7 +41,8 @@ ...@@ -41,7 +41,8 @@
title: 'action-sheet', title: 'action-sheet',
itemColorCustom: false, itemColorCustom: false,
itemContentLarge: false, itemContentLarge: false,
itemNumLargeSelect: false, itemNumLargeSelect: false,
showErrorToast:true,
items: [{ items: [{
value: '标题', value: '标题',
name: '有标题' name: '有标题'
...@@ -64,7 +65,11 @@ ...@@ -64,7 +65,11 @@
itemList:['item1', 'item2'], itemList:['item1', 'item2'],
}) })
}, },
methods: { methods: {
//自动化测试例专用
jest_getWindowInfo() : GetWindowInfoResult {
return uni.getWindowInfo();
},
radioChange(e : UniRadioGroupChangeEvent) { radioChange(e : UniRadioGroupChangeEvent) {
for (let i = 0; i < this.items.length; i++) { for (let i = 0; i < this.items.length; i++) {
if (this.items[i].value === e.detail.value) { if (this.items[i].value === e.detail.value) {
...@@ -127,11 +132,13 @@ ...@@ -127,11 +132,13 @@
}) })
}, },
fail: (e) => { fail: (e) => {
console.log(e); console.log(e);
uni.showToast({ if(this.showErrorToast){
title: e.errMsg, uni.showToast({
icon: "none" title: e.errMsg,
}) icon: "none"
})
}
} }
}) })
} }
......
...@@ -29,8 +29,7 @@ ...@@ -29,8 +29,7 @@
数量限制 数量限制
</view> </view>
<view class="uni-list-cell-right"> <view class="uni-list-cell-right">
<input class="click-t" :value="countIndex+1" type="number" :maxlength="1" @confirm="chooseImageCount" <input class="click-t" :value="countIndex+1" type="number" :maxlength="1" @confirm="chooseImageCount" confirm-type="done" />
confirm-type="done" />
</view> </view>
</view> </view>
<view class="uni-list-cell cell-pd"> <view class="uni-list-cell cell-pd">
...@@ -41,7 +40,7 @@ ...@@ -41,7 +40,7 @@
<switch :checked="isCrop" @change="switchCrop"></switch> <switch :checked="isCrop" @change="switchCrop"></switch>
</view> </view>
</view> </view>
<view ref="cropOptionNode" class="crop-option" :style="{'height':isCrop?'200px':'0px'}"> <view ref="cropOptionNode" class="crop-option" :style="{'height':isCrop?'200px':'0px','margin-bottom':isCrop?'11px':'0px'}">
<view class="uni-list-cell cell-pd"> <view class="uni-list-cell cell-pd">
<view class="uni-list-cell-left item_width"> <view class="uni-list-cell-left item_width">
图片质量(%) 图片质量(%)
...@@ -285,11 +284,11 @@ ...@@ -285,11 +284,11 @@
} }
.crop-option { .crop-option {
border-top-color: lightgray; margin-left: 11px;
border-width: 1px; margin-right: 11px;
border-style: solid; border-radius: 11px;
padding: 10px; background-color: #eee;
transition: height; transition-property: height, margin-bottom;
transition-duration: 300ms; transition-duration: 200ms;
} }
</style> </style>
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<view class="uni-label" style="width:180px;">是否授权使用摄像头</view> <view class="uni-label" style="width:180px;">是否授权使用摄像头</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="cameraAuthorized" /> <input type="text" :disabled="true" placeholder="未获取" :value="cameraAuthorized" />
</view> </view>
</view> </view>
<view class="uni-list-cell"> <view class="uni-list-cell">
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<view class="uni-label" style="width:180px;">是否授权使用定位</view> <view class="uni-label" style="width:180px;">是否授权使用定位</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="locationAuthorized" /> <input type="text" :disabled="true" placeholder="未获取" :value="locationAuthorized" />
</view> </view>
</view> </view>
<view class="uni-list-cell"> <view class="uni-list-cell">
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<view class="uni-label" style="width:180px;">定位准确度</view> <view class="uni-label" style="width:180px;">定位准确度</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="locationAccuracy" /> <input type="text" :disabled="true" placeholder="未获取" :value="locationAccuracy" />
</view> </view>
</view> </view>
<view class="uni-list-cell"> <view class="uni-list-cell">
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<view class="uni-label" style="width:180px;">是否授权使用麦克风</view> <view class="uni-label" style="width:180px;">是否授权使用麦克风</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="microphoneAuthorized" /> <input type="text" :disabled="true" placeholder="未获取" :value="microphoneAuthorized" />
</view> </view>
</view> </view>
<view class="uni-list-cell"> <view class="uni-list-cell">
...@@ -39,7 +39,7 @@ ...@@ -39,7 +39,7 @@
<view class="uni-label" style="width:180px;">是否授权通知</view> <view class="uni-label" style="width:180px;">是否授权通知</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="notificationAuthorized" /> <input type="text" :disabled="true" placeholder="未获取" :value="notificationAuthorized" />
</view> </view>
</view> </view>
</view> </view>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<view class="uni-label" style="width:180px;">{{item.label}}</view> <view class="uni-label" style="width:180px;">{{item.label}}</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<textarea style="width: 100%;" :auto-height="true" :disabled="true" placeholder="未获取" :value="item.value" /> <text style="width: 100%;" :value="item.value == '' ? '未获取' : item.value " />
</view> </view>
</view> </view>
</view> </view>
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
}}</view> }}</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<textarea style="width: 100%;" :auto-height="true" :disabled="true" placeholder="未获取" :value="item.value" /> <text style="width: 100%;" :value="item.value == '' ? '未获取' : item.value " />
</view> </view>
</view> </view>
</view> </view>
......
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
}}</view> }}</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<textarea style="width: 100%;" :auto-height="true" :disabled="true" placeholder="未获取" :value="item.value" /> <text style="width: 100%;" :value="item.value == '' ? '未获取' : item.value " />
</view> </view>
</view> </view>
</view> </view>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<view class="uni-label" style="width:180px;">蓝牙的系统开关</view> <view class="uni-label" style="width:180px;">蓝牙的系统开关</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="bluetoothEnabled" /> <input type="text" :disabled="true" placeholder="未获取" :value="bluetoothEnabled" />
</view> </view>
</view> </view>
<view class="uni-list-cell"> <view class="uni-list-cell">
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<view class="uni-label" style="width:180px;">地理位置的系统开关</view> <view class="uni-label" style="width:180px;">地理位置的系统开关</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="locationEnabled" /> <input type="text" :disabled="true" placeholder="未获取" :value="locationEnabled" />
</view> </view>
</view> </view>
<view class="uni-list-cell"> <view class="uni-list-cell">
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
<view class="uni-label" style="width:180px;">Wi-Fi 的系统开关</view> <view class="uni-label" style="width:180px;">Wi-Fi 的系统开关</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="wifiEnabled" /> <input type="text" :disabled="true" placeholder="未获取" :value="wifiEnabled" />
</view> </view>
</view> </view>
<view class="uni-list-cell"> <view class="uni-list-cell">
...@@ -31,7 +31,7 @@ ...@@ -31,7 +31,7 @@
<view class="uni-label" style="width:180px;">设备方向</view> <view class="uni-label" style="width:180px;">设备方向</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<input class="uni-input" type="text" :disabled="true" placeholder="未获取" :value="deviceOrientation" /> <input type="text" :disabled="true" placeholder="未获取" :value="deviceOrientation" />
</view> </view>
</view> </view>
</view> </view>
...@@ -62,7 +62,15 @@ ...@@ -62,7 +62,15 @@
this.bluetoothEnabled = (res.bluetoothEnabled ?? false) ? "开启" : "关闭"; this.bluetoothEnabled = (res.bluetoothEnabled ?? false) ? "开启" : "关闭";
this.locationEnabled = res.locationEnabled ? "开启" : "关闭"; this.locationEnabled = res.locationEnabled ? "开启" : "关闭";
this.wifiEnabled = (res.wifiEnabled ?? false) ? "开启" : "关闭"; this.wifiEnabled = (res.wifiEnabled ?? false) ? "开启" : "关闭";
this.deviceOrientation = res.deviceOrientation this.deviceOrientation = res.deviceOrientation
if(res.bluetoothError != null){
this.bluetoothEnabled = "无蓝牙权限"
}
if(res.wifiError != null){
this.wifiEnabled = "无WiFi权限"
}
} }
} }
} }
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
<view class="uni-label" style="width: 180px">{{ item.label }}</view> <view class="uni-label" style="width: 180px">{{ item.label }}</view>
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<textarea style="width: 100%;" :auto-height="true" :disabled="true" placeholder="未获取" :value="item.value" /> <text style="width: 100%;" :value="item.value == '' ? '未获取' : item.value " />
</view> </view>
</view> </view>
</view> </view>
......
...@@ -67,6 +67,10 @@ ...@@ -67,6 +67,10 @@
}, 2000); }, 2000);
}, },
methods: { methods: {
//自动化测试例专用
jest_getWindowInfo() : GetWindowInfoResult {
return uni.getWindowInfo();
},
radioChange(e : UniRadioGroupChangeEvent) { radioChange(e : UniRadioGroupChangeEvent) {
const selected = this.items.find((item) : boolean => { const selected = this.items.find((item) : boolean => {
......
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('API-loading', () => {
let page;
const isAndroid = process.env.UNI_OS_NAME === "android";
beforeAll(async () => {
page = await program.reLaunch('/pages/API/modal/modal')
await page.waitFor(200);
});
it("onload-modal-test", async () => {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-0", async () => {
await page.setData({
current: 0,
showCancelSelect: false,
cancelTextSelect: false,
confirmTextSelect: false,
editableSelect: false,
placeholderTextSelect: false,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-1", async () => {
await page.setData({
current: 1,
showCancelSelect: false,
cancelTextSelect: false,
confirmTextSelect: false,
editableSelect: false,
placeholderTextSelect: false,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-2", async () => {
await page.setData({
current: 2,
showCancelSelect: false,
cancelTextSelect: false,
confirmTextSelect: false,
editableSelect: false,
placeholderTextSelect: false,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-2-showCancel", async () => {
await page.setData({
current: 2,
showCancelSelect: true,
cancelTextSelect: false,
confirmTextSelect: false,
editableSelect: false,
placeholderTextSelect: false,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-2-showCancel-cancelText", async () => {
await page.setData({
current: 2,
showCancelSelect: true,
cancelTextSelect: true,
confirmTextSelect: false,
editableSelect: false,
placeholderTextSelect: false,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-2-showCancel-cancelText-confirmText", async () => {
await page.setData({
current: 2,
showCancelSelect: true,
cancelTextSelect: true,
confirmTextSelect: true,
editableSelect: false,
placeholderTextSelect: false,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-2-showCancel-cancelText-confirmText-editable-placeholder", async () => {
await page.setData({
current: 2,
showCancelSelect: true,
cancelTextSelect: true,
confirmTextSelect: true,
editableSelect: true,
placeholderTextSelect: true,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-2-showCancel-confirmText-editable-placeholder", async () => {
await page.setData({
current: 2,
showCancelSelect: true,
cancelTextSelect: false,
confirmTextSelect: true,
editableSelect: true,
placeholderTextSelect: true,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-2-showCancel-editable-placeholder", async () => {
await page.setData({
current: 2,
showCancelSelect: true,
cancelTextSelect: false,
confirmTextSelect: false,
editableSelect: true,
placeholderTextSelect: true,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-2-showCancel-placeholder", async () => {
await page.setData({
current: 2,
showCancelSelect: true,
cancelTextSelect: false,
confirmTextSelect: false,
editableSelect: false,
placeholderTextSelect: true,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-2-showCancel", async () => {
await page.setData({
current: 2,
showCancelSelect: true,
cancelTextSelect: false,
confirmTextSelect: false,
editableSelect: false,
placeholderTextSelect: false,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-2-showCancel-cancelText-editable-placeholder", async () => {
await page.setData({
current: 2,
showCancelSelect: true,
cancelTextSelect: true,
confirmTextSelect: false,
editableSelect: true,
placeholderTextSelect: true,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-2-showCancel-cancelText-placeholder", async () => {
await page.setData({
current: 2,
showCancelSelect: true,
cancelTextSelect: true,
confirmTextSelect: false,
editableSelect: false,
placeholderTextSelect: true,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-2-showCancel-cancelText", async () => {
await page.setData({
current: 2,
showCancelSelect: true,
cancelTextSelect: true,
confirmTextSelect: false,
editableSelect: false,
placeholderTextSelect: false,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-2-showCancel-cancelText-confirmText-placeholder", async () => {
await page.setData({
current: 2,
showCancelSelect: true,
cancelTextSelect: true,
confirmTextSelect: true,
editableSelect: false,
placeholderTextSelect: true,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-2-showCancel-cancelText-confirmText", async () => {
await page.setData({
current: 2,
showCancelSelect: true,
cancelTextSelect: true,
confirmTextSelect: true,
editableSelect: false,
placeholderTextSelect: false,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("modal-test-current-2-showCancel-cancelText-confirmText-editable", async () => {
await page.setData({
current: 2,
showCancelSelect: true,
cancelTextSelect: true,
confirmTextSelect: true,
editableSelect: true,
placeholderTextSelect: false,
})
const btnModalButton = await page.$('#btn-modal-show')
await btnModalButton.tap()
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
height: windowHeight,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
});
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
</view> </view>
<view class="uni-padding-wrap uni-common-mt"> <view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v"> <view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="modalTap"> <button class="uni-btn-v" type="default" @tap="modalTap" id="btn-modal-show">
modal测试 modal测试
</button> </button>
</view> </view>
...@@ -87,6 +87,10 @@ ...@@ -87,6 +87,10 @@
}) })
}, },
methods: { methods: {
//自动化测试例专用
jest_getWindowInfo() : GetWindowInfoResult {
return uni.getWindowInfo();
},
showCancelChange: function (e : UniSwitchChangeEvent) { showCancelChange: function (e : UniSwitchChangeEvent) {
this.showCancelSelect = e.detail.value this.showCancelSelect = e.detail.value
}, },
......
...@@ -10,6 +10,16 @@ describe('nodes-info', () => { ...@@ -10,6 +10,16 @@ describe('nodes-info', () => {
page = await program.reLaunch(PAGE_PATH) page = await program.reLaunch(PAGE_PATH)
await page.waitFor(500) await page.waitFor(500)
}) })
it('get-root-node-info', async () => {
// 测试 class 选择器
await getRootNode('.page')
// 测试 id 选择器
await getRootNode('#page')
// 测试 标签 选择器
// await getRootNode('page')
})
it('get-node-info', async () => { it('get-node-info', async () => {
const btnGetNodeInfo = await page.$('.btn-get-node-info') const btnGetNodeInfo = await page.$('.btn-get-node-info')
...@@ -53,4 +63,19 @@ describe('nodes-info', () => { ...@@ -53,4 +63,19 @@ describe('nodes-info', () => {
}) */ }) */
// #endif // #endif
}) })
async function getRootNode(selector) {
const page = await program.currentPage()
await page.setData({
rootNodeInfo: null,
})
await page.waitFor(100)
await page.callMethod('getRootNodeInfo', selector)
await page.waitFor(100)
const data = await page.data()
expect(data.rootNodeInfo != null).toBe(true)
}
<template> <template>
<view class="page"> <view class="page" id="page">
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<button class="btn btn-get-node-info" @click="getNodeInfo">getNodeInfo</button> <button class="btn btn-get-node-info" @click="getNodeInfo">getNodeInfo</button>
<button class="btn btn-get-all-node-info" @click="getAllNodeInfo">getAllNodeInfo</button> <button class="btn btn-get-all-node-info" @click="getAllNodeInfo">getAllNodeInfo</button>
...@@ -53,6 +53,8 @@ ...@@ -53,6 +53,8 @@
return { return {
title: 'createSelectorQuery', title: 'createSelectorQuery',
nodeInfoList: [] as NodeInfoType[], nodeInfoList: [] as NodeInfoType[],
// 仅用于自动化测试
rootNodeInfo: null as NodeInfoType | null,
//供自动化测试使用 //供自动化测试使用
// resizeRectValid: false // resizeRectValid: false
} }
...@@ -68,6 +70,23 @@ ...@@ -68,6 +70,23 @@
} */ } */
}, },
methods: { methods: {
// 仅用于自动化测试
getRootNodeInfo(selector: string) {
uni.createSelectorQuery().select(selector).boundingClientRect().exec((ret) => {
if (ret.length == 1) {
const nodeInfo = ret[0] as NodeInfo;
const nodeType = {
left: nodeInfo.left,
top: nodeInfo.top,
right: nodeInfo.right,
bottom: nodeInfo.bottom,
width: nodeInfo.width,
height: nodeInfo.height,
} as NodeInfoType;
this.rootNodeInfo = nodeType
}
})
},
getNodeInfo() { getNodeInfo() {
uni.createSelectorQuery().select('.rect1').boundingClientRect().exec((ret) => { uni.createSelectorQuery().select('.rect1').boundingClientRect().exec((ret) => {
this.nodeInfoList.length = 0 this.nodeInfoList.length = 0
......
...@@ -241,6 +241,42 @@ describe('ExtApi-StorageInfoTest', () => { ...@@ -241,6 +241,42 @@ describe('ExtApi-StorageInfoTest', () => {
expect(parseObj['name']).toEqual('james') expect(parseObj['name']).toEqual('james')
await page.setData({
key: "autotest_key_mock",
data:"1234567890"
})
await page.waitFor(600)
btnSetStorageButtonInfo = await page.$('.btn-setstorageSync')
await btnSetStorageButtonInfo.tap()
await page.waitFor(600)
btnGetStorageButtonInfo = await page.$('.btn-getstorageSync')
await btnGetStorageButtonInfo.tap()
await page.waitFor(600)
let strRet = await getData('apiGetData')
// 顺序不能保证,验证长度和各个属性来区分
expect(typeof strRet).toEqual("string")
expect(strRet).toEqual("1234567890")
await page.setData({
key: "autotest_key_mock",
data:"1234567.890"
})
await page.waitFor(600)
btnSetStorageButtonInfo = await page.$('.btn-setstorageSync')
await btnSetStorageButtonInfo.tap()
await page.waitFor(600)
btnGetStorageButtonInfo = await page.$('.btn-getstorageSync')
await btnGetStorageButtonInfo.tap()
await page.waitFor(600)
let strRet2 = await getData('apiGetData')
// 顺序不能保证,验证长度和各个属性来区分
expect(typeof strRet2).toEqual("string")
expect(strRet2).toEqual("1234567.890")
}); });
}); });
...@@ -49,11 +49,21 @@ ...@@ -49,11 +49,21 @@
<button type="default" style="width:50%" @tap="floatMock"> <button type="default" style="width:50%" @tap="floatMock">
填充浮点型 填充浮点型
</button> </button>
</view> </view>
<view class="uni-flex uni-row"> <view class="uni-flex uni-row">
<button type="default" style="width:100%" @tap="jsonLikeMock"> <button type="default" style="width:50%" @tap="jsonLikeMock">
填充符合json格式的字符串 填充json字符串
</button>
<button type="default" style="width:50%" @tap="longLikeMock">
填充整数字符串
</button>
</view>
<view class="uni-flex uni-row">
<button type="default" style="width:50%" @tap="floatLikeMock">
填充浮点字符串
</button>
<button type="default" style="width:50%" @tap="negativeLikeMock">
填充负数字符串
</button> </button>
</view> </view>
</view> </view>
...@@ -124,6 +134,19 @@ ...@@ -124,6 +134,19 @@
age: 12, age: 12,
from: "american" from: "american"
}); });
},
longLikeMock() {
this.key = 'key_' + Math.random()
this.data = "1234567890"
},
floatLikeMock() {
this.key = 'key_' + Math.random()
this.data = "321456.1234567890"
},
negativeLikeMock() {
this.key = 'key_' + Math.random()
this.data = "-321456"
}, },
strMock() { strMock() {
this.key = 'key_' + Math.random() this.key = 'key_' + Math.random()
......
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('API-toast', () => {
let page;
const isAndroid = process.env.UNI_OS_NAME === "android";
beforeAll(async () => {
page = await program.reLaunch('/pages/API/toast/toast')
await page.waitFor(600);
});
it("onload-toast-test", async () => {
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("btn-toast-default-1", async () => {
const btnToastDefaultButton = await page.$('#btn-toast-default')
await btnToastDefaultButton.tap()
await page.waitFor(200)
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("btn-toast-duration-1", async () => {
const btnToastDurationButton = await page.$('#btn-toast-duration')
await btnToastDurationButton.tap()
await page.waitFor(2000)
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("btn-toast-errorIcon-1", async () => {
const btnToastErrorIconButton = await page.$('#btn-toast-errorIcon')
await btnToastErrorIconButton.tap()
await page.waitFor(200)
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
it("btn-toast-loading-1", async () => {
const btnToastLoadingButton = await page.$('#btn-toast-loading')
await btnToastLoadingButton.tap()
await page.waitFor(200)
const btnToastHideButton = await page.$('#btn-toast-hide')
await btnToastHideButton.tap()
await page.waitFor(200)
if (isAndroid) {
const image = await program.screenshot({
adb: true,
area: {
x: 0,
y: 200,
},
});
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
}
})
// it("btn-toast-postion-bottom-1", async () => {
// const btnToastButton = await page.$('#btn-toast-postion-bottom')
// await btnToastButton.tap()
// await page.waitFor(200)
// if (isAndroid) {
// const windowHeight = uni.getWindowInfo().windowHeight;
// const windowWidth = uni.getWindowInfo().windowWidth;
// const image = await program.screenshot({
// adb: true,
// area: {
// x: 0,
// y: 200,
// height: windowHeight,
// width:windowWidth
// },
// });
// expect(image).toMatchImageSnapshot();
// }else{
// const image = await program.screenshot({
// adb: true,
// fullPage: true
// });
// expect(image).toMatchImageSnapshot()
// }
// })
});
...@@ -3,17 +3,17 @@ ...@@ -3,17 +3,17 @@
<page-head :title="title"></page-head> <page-head :title="title"></page-head>
<view class="uni-padding-wrap"> <view class="uni-padding-wrap">
<view class="uni-btn-v"> <view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="toast1Tap">点击弹出默认toast</button> <button class="uni-btn-v" type="default" @tap="toast1Tap" id="btn-toast-default" >点击弹出默认toast</button>
<button class="uni-btn-v" type="default" @tap="toastTapIconError">点击弹出设置icon的toast</button> <button class="uni-btn-v" type="default" @tap="toastTapIconError" id="btn-toast-errorIcon">点击弹出设置icon的toast</button>
<button class="uni-btn-v" type="default" @tap="toast2Tap">点击弹出设置duration的toast</button> <button class="uni-btn-v" type="default" @tap="toast2Tap" id="btn-toast-duration">点击弹出设置duration的toast</button>
<button class="uni-btn-v" type="default" @tap="toast3Tap">点击弹出显示loading的toast</button> <button class="uni-btn-v" type="default" @tap="toast3Tap" id="btn-toast-loading">点击弹出显示loading的toast</button>
<!-- #ifndef MP-ALIPAY --> <!-- #ifndef MP-ALIPAY -->
<button class="uni-btn-v" type="default" @tap="toast4Tap">点击弹出显示自定义图片的toast</button> <button class="uni-btn-v" type="default" @tap="toast4Tap">点击弹出显示自定义图片的toast</button>
<!-- #endif --> <!-- #endif -->
<!-- #ifdef APP-PLUS --> <!-- #ifdef APP-PLUS -->
<button class="uni-btn-v" type="default" @tap="toast5Tap">点击显示无图标的居底toast</button> <button class="uni-btn-v" type="default" @tap="toast5Tap" id="btn-toast-postion-bottom">点击显示无图标的居底toast</button>
<!-- #endif --> <!-- #endif -->
<button class="uni-btn-v" type="default" @tap="hideToast">点击隐藏toast</button> <button class="uni-btn-v" type="default" @tap="hideToast" id="btn-toast-hide">点击隐藏toast</button>
</view> </view>
<text>{{exeRet}}</text> <text>{{exeRet}}</text>
</view> </view>
...@@ -41,7 +41,7 @@ ...@@ -41,7 +41,7 @@
uni.showToast({ uni.showToast({
title: "默认", title: "默认",
success: (res) => { success: (res) => {
this.exeRet = "success:" + JSON.stringify(res) + new Date() this.exeRet = "success:" + JSON.stringify(res)
}, },
fail: (res) => { fail: (res) => {
this.exeRet = "fail:" + JSON.stringify(res) this.exeRet = "fail:" + JSON.stringify(res)
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
title: "默认", title: "默认",
icon: 'error', icon: 'error',
success: (res) => { success: (res) => {
this.exeRet = "success:" + JSON.stringify(res) + new Date() this.exeRet = "success:" + JSON.stringify(res)
}, },
fail: (res) => { fail: (res) => {
this.exeRet = "fail:" + JSON.stringify(res) this.exeRet = "fail:" + JSON.stringify(res)
...@@ -65,7 +65,7 @@ ...@@ -65,7 +65,7 @@
title: "duration 3000", title: "duration 3000",
duration: 3000, duration: 3000,
success: (res) => { success: (res) => {
this.exeRet = "success:" + JSON.stringify(res) + new Date() this.exeRet = "success:" + JSON.stringify(res)
}, },
fail: (res) => { fail: (res) => {
this.exeRet = "fail:" + JSON.stringify(res) this.exeRet = "fail:" + JSON.stringify(res)
...@@ -78,7 +78,7 @@ ...@@ -78,7 +78,7 @@
icon: "loading", icon: "loading",
duration: 5000, duration: 5000,
success: (res) => { success: (res) => {
this.exeRet = "success:" + JSON.stringify(res) + new Date() this.exeRet = "success:" + JSON.stringify(res)
}, },
fail: (res) => { fail: (res) => {
this.exeRet = "fail:" + JSON.stringify(res) this.exeRet = "fail:" + JSON.stringify(res)
...@@ -90,7 +90,7 @@ ...@@ -90,7 +90,7 @@
title: "logo", title: "logo",
image: "/static/uni.png", image: "/static/uni.png",
success: (res) => { success: (res) => {
this.exeRet = "success:" + JSON.stringify(res) + new Date() this.exeRet = "success:" + JSON.stringify(res)
}, },
fail: (res) => { fail: (res) => {
this.exeRet = "fail:" + JSON.stringify(res) this.exeRet = "fail:" + JSON.stringify(res)
...@@ -103,7 +103,7 @@ ...@@ -103,7 +103,7 @@
title: "显示一段轻提示", title: "显示一段轻提示",
position: 'bottom', position: 'bottom',
success: (res) => { success: (res) => {
this.exeRet = "success:" + JSON.stringify(res) + new Date() this.exeRet = "success:" + JSON.stringify(res)
}, },
fail: (res) => { fail: (res) => {
this.exeRet = "fail:" + JSON.stringify(res) this.exeRet = "fail:" + JSON.stringify(res)
......
...@@ -127,7 +127,7 @@ ...@@ -127,7 +127,7 @@
<text class="uni-title-text">设置输入框聚焦时光标的位置(点击生效)</text> <text class="uni-title-text">设置输入框聚焦时光标的位置(点击生效)</text>
</view> </view>
<view class="input-wrapper"> <view class="input-wrapper">
<input ref="input" class="uni-input" value="0123456789" :cursor="cursor" /> <input ref="input" class="uni-input" value="0123456789" :cursor="cursor" @blur="onCursorBlurChange"/>
</view> </view>
</view> </view>
...@@ -137,7 +137,7 @@ ...@@ -137,7 +137,7 @@
</view> </view>
<view class="input-wrapper"> <view class="input-wrapper">
<input ref="input2" class="uni-input" value="0123456789" :selection-start="selectionStart" <input ref="input2" class="uni-input" value="0123456789" :selection-start="selectionStart"
:selection-end="selectionEnd" /> :selection-end="selectionEnd" @blur="onSelectionBlurChange"/>
</view> </view>
</view> </view>
...@@ -269,22 +269,28 @@ ...@@ -269,22 +269,28 @@
} }
}, },
methods: { methods: {
inputFocusKeyBoardChange(e : InputKeyboardHeightChangeEvent) { inputFocusKeyBoardChange(e : UniInputKeyboardHeightChangeEvent) {
this.inputFocusKeyBoardChangeValue = e.detail.height > 50 this.inputFocusKeyBoardChangeValue = e.detail.height > 50
}, },
onMaxLengthInput(event : InputEvent) { onMaxLengthInput(event : UniInputEvent) {
this.onMaxLengthInputValue = event.detail.value this.onMaxLengthInputValue = event.detail.value
}, },
setCursor: function (cursor : number) { setCursor: function (cursor : number) {
(this.$refs['input'] as UniInputElement).focus(); (this.$refs['input'] as UniInputElement).focus();
this.cursor = cursor; this.cursor = cursor;
},
onCursorBlurChange(){
this.cursor = 0
}, },
setSelection: function (selectionStart : number, selectionEnd : number) { setSelection: function (selectionStart : number, selectionEnd : number) {
(this.$refs['input2'] as UniInputElement).focus(); (this.$refs['input2'] as UniInputElement).focus();
this.selectionStart = selectionStart; this.selectionStart = selectionStart;
this.selectionEnd = selectionEnd; this.selectionEnd = selectionEnd;
},
onSelectionBlurChange(){
this.selectionEnd = 0;
}, },
clearInput: function (event : InputEvent) { clearInput: function (event : UniInputEvent) {
this.inputClearValue = event.detail.value this.inputClearValue = event.detail.value
if (event.detail.value.length > 0) { if (event.detail.value.length > 0) {
this.showClearIcon = true this.showClearIcon = true
...@@ -299,23 +305,23 @@ ...@@ -299,23 +305,23 @@
changePassword: function () { changePassword: function () {
this.showPassword = !this.showPassword this.showPassword = !this.showPassword
}, },
onInput: function (event : InputEvent) { onInput: function (event : UniInputEvent) {
console.log("键盘输入", JSON.stringify(event.detail)); console.log("键盘输入", JSON.stringify(event.detail));
this.inputEventDetail = JSON.stringify(event.detail) this.inputEventDetail = JSON.stringify(event.detail)
}, },
onFocus: function (event : InputFocusEvent) { onFocus: function (event : UniInputFocusEvent) {
console.log("输入框聚焦", JSON.stringify(event.detail)); console.log("输入框聚焦", JSON.stringify(event.detail));
this.focusAndBlurEventDetail = JSON.stringify(event.detail); this.focusAndBlurEventDetail = JSON.stringify(event.detail);
}, },
onBlur: function (event : InputBlurEvent) { onBlur: function (event : UniInputBlurEvent) {
console.log("输入框失去焦点", JSON.stringify(event.detail)); console.log("输入框失去焦点", JSON.stringify(event.detail));
this.focusAndBlurEventDetail = JSON.stringify(event.detail); this.focusAndBlurEventDetail = JSON.stringify(event.detail);
}, },
onConfirm: function (event : InputConfirmEvent) { onConfirm: function (event : UniInputConfirmEvent) {
console.log("点击完成按钮", JSON.stringify(event.detail)); console.log("点击完成按钮", JSON.stringify(event.detail));
this.confirmEventDetail = JSON.stringify(event.detail); this.confirmEventDetail = JSON.stringify(event.detail);
}, },
onKeyborardHeightChange: function (event : InputKeyboardHeightChangeEvent) { onKeyborardHeightChange: function (event : UniInputKeyboardHeightChangeEvent) {
console.log("键盘高度发生变化", JSON.stringify(event.detail)); console.log("键盘高度发生变化", JSON.stringify(event.detail));
this.keyboardHeightChangeEventDetail = JSON.stringify(event.detail); this.keyboardHeightChangeEventDetail = JSON.stringify(event.detail);
}, },
......
...@@ -10,7 +10,7 @@ export default { ...@@ -10,7 +10,7 @@ export default {
confirm_hold_boolean: false, confirm_hold_boolean: false,
focus_boolean: true, focus_boolean: true,
auto_focus_boolean: false, auto_focus_boolean: false,
default_value:"", default_value:"1\n2\n3\n4\n5\n6",
maxlength:-1, maxlength:-1,
inputmode_enum: [{"value":1,"name":"text"},{"value":2,"name":"decimal"},{"value":3,"name":"numeric"},{"value":4,"name":"tel"},{"value":5,"name":"search"},{"value":6,"name":"email"},{"value":7,"name":"url"},{"value":0,"name":"none"}] as ItemType[], inputmode_enum: [{"value":1,"name":"text"},{"value":2,"name":"decimal"},{"value":3,"name":"numeric"},{"value":4,"name":"tel"},{"value":5,"name":"search"},{"value":6,"name":"email"},{"value":7,"name":"url"},{"value":0,"name":"none"}] as ItemType[],
cursor_color: "#3393E2", cursor_color: "#3393E2",
......
...@@ -80,10 +80,11 @@ ...@@ -80,10 +80,11 @@
}, },
methods: { methods: {
onTabClick(index : number) { onTabClick(index : number) {
this.setSelectedIndex(index); if (this.selectedIndex == index && index == 0) {
if (index == 0) { this.displayArrow = false;
(this.$refs["tab1"]! as ComponentPublicInstance).$callMethod('scrollTop', 0) (this.$refs["tab1"]! as ComponentPublicInstance).$callMethod('scrollTop', 0)
} }
this.setSelectedIndex(index);
}, },
onTabPageEvent(top : number) { onTabPageEvent(top : number) {
this.displayArrow = top > this.tabViewHeight this.displayArrow = top > this.tabViewHeight
......
...@@ -17,12 +17,12 @@ ...@@ -17,12 +17,12 @@
'/static/template/drop-card/1.jpg', '/static/template/drop-card/1.jpg',
'/static/template/drop-card/2.jpg', '/static/template/drop-card/2.jpg',
'/static/template/drop-card/3.jpg' '/static/template/drop-card/3.jpg'
] as string[] ] as string.ImageURIString[]
} }
} }
} }
</script> </script>
<style> <style>
.root { .root {
flex: 1; flex: 1;
position: relative; position: relative;
......
...@@ -21,7 +21,7 @@ const pages = [ ...@@ -21,7 +21,7 @@ const pages = [
"pages/component/swiper/swiper", "pages/component/swiper/swiper",
"pages/component/image/image", "pages/component/image/image",
"pages/component/image/image-format", "pages/component/image/image-format",
"pages/component/image/image-mode", ...(process.env.android_cpu_type !== 'x86_64' ? ["pages/component/image/image-mode"] : []), // x86_64 模拟器 image-model 截图崩溃
"pages/component/video/video-format", "pages/component/video/video-format",
"pages/component/navigator/navigator", "pages/component/navigator/navigator",
"pages/component/navigator/navigate", "pages/component/navigator/navigate",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册