提交 5b3b259c 编写于 作者: DCloud_iOS_WZT's avatar DCloud_iOS_WZT

Merge branch 'dev' of https://gitcode.net/dcloud/hello-uni-app-x into dev

......@@ -3,12 +3,16 @@ import App from './App.uvue'
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
app.config.errorHandler = (err, vm, info) => {
console.log(err, vm, info)
}
app.mixin({
onReady() {
// #ifdef APP-ANDROID
setTimeout(() => {
console.log((this as BasePage).$nativePage!.getDomJson())
}, 100)
// #endif
}
})
return {
......
......@@ -269,7 +269,6 @@
"navigationBarTitleText": "web-view-local"
}
},
// #ifndef APP-IOS
{
"path": "pages/component/unicloud-db-contacts/list",
"style": {
......@@ -301,7 +300,6 @@
"navigationBarTitleText": "mixinDatacom"
}
},
// #endif
{
"path": "pages/component/general-attribute/general-attribute",
"style": {
......@@ -576,6 +574,13 @@
"navigationBarTitleText": "get-system-setting"
}
},
{
"path": "pages/API/element-takesnapshot/element-takesnapshot",
"style": {
"navigationBarTitleText": "takeSnapshot",
"enablePullDownRefresh": false
}
},
// #endif
// #ifndef WEB
{
......@@ -655,13 +660,6 @@
"enablePullDownRefresh": false
}
},
{
"path": "pages/API/element-takesnapshot/element-takesnapshot",
"style": {
"navigationBarTitleText": "takeSnapshot",
"enablePullDownRefresh": false
}
},
{
"path": "pages/API/element-draw/element-draw",
"style": {
......
......@@ -117,6 +117,12 @@
})
},
fail: (e) => {
if(this.showErrorToast){
uni.showToast({
title: e.errMsg,
icon: "none"
})
}
console.log(e);
}
})
......
......@@ -23,7 +23,7 @@ describe('ExtApi-DownloadFile', () => {
});
let shouldTestCookie = false
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
let version = process.env.uniTestPlatformInfo
version = parseInt(version.split(" ")[1])
shouldTestCookie = version > 9
......
<template>
<!-- #ifdef APP -->
<scroll-view class="page-scroll-view">
<!-- #endif -->
<view class="page">
<page-head :title="title"></page-head>
<view class="service-item" v-for="(item, index) in serviceList" :key="index">
<text class="service-name">{{item.name}}:</text>
<view class="provider-list">
<text class="provider-item" v-for="(item2, index2) in item.provider" :key="index2">{{item2}}</text>
</view>
</view>
<button class="btn-get-provider" type="primary" @click="getProvider">getProvider</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
type ProviderItem = {
service : string,
name : string,
provider : string[]
}
export default {
data() {
return {
title: 'provider',
serviceList: [
{ service: "oauth", name: "登陆", provider: [] },
{ service: "share", name: "分享", provider: [] },
{ service: "payment", name: "支付", provider: [] },
{ service: "push", name: "推送", provider: [] },
{ service: "location", name: "定位", provider: [] }
] as ProviderItem[]
}
},
methods: {
getProvider() {
this.serviceList.forEach((item : ProviderItem) => {
uni.getProvider({
service: item.service,
success: (e) => {
this.updateProvider(e.service, e.provider);
}
})
})
},
updateProvider(service : string, provider : string[]) {
const item : ProviderItem | null = this.serviceList.find((item : ProviderItem) : boolean => {
return item.service == service
});
if (item != null) {
item.provider = provider
}
}
}
}
</script>
<style>
.page {
padding: 15px;
}
.service-item {
margin-top: 10px;
}
.service-name {
font-weight: bold;
}
.provider-list {
margin-left: 32px;
}
.provider-item {
line-height: 1.5;
}
.btn-get-provider {
margin-top: 30px;
}
</style>
......@@ -22,7 +22,7 @@ describe("onLoad", () => {
expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
});
it("navigateBack", async () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "navigateBack");
......
......@@ -86,7 +86,7 @@ describe('ExtApi-Request', () => {
});
let shouldTestCookie = false
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
let version = process.env.uniTestPlatformInfo
version = parseInt(version.split(" ")[1])
shouldTestCookie = version > 9
......@@ -108,4 +108,10 @@ describe('ExtApi-Request', () => {
res = await page.data('jest_result');
expect(res).toBe(true)
});
it('Check Get With Data', async () => {
res = await page.callMethod('jest_get_with_data')
await page.waitFor(2000);
res = await page.data('jest_result');
expect(res).toBe(true)
})
});
......@@ -301,6 +301,25 @@
},
});
},
jest_get_with_data() {
uni.request({
url: "https://unidemo.dcloud.net.cn/api/banner/36kr",
method: "GET",
data:{
column: 'id,post_id,title,author_name,cover,published_at' //需要的字段名
},
timeout: 6000,
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success: () => {
this.jest_result = true;
},
fail: () => {
this.jest_result = false;
},
});
},
}
}
</script>
......@@ -10,7 +10,7 @@
<!-- #ifndef MP-ALIPAY -->
<button class="uni-btn-v" type="default" @tap="toast4Tap">点击弹出显示自定义图片的toast</button>
<!-- #endif -->
<!-- #ifdef APP-PLUS -->
<!-- #ifdef APP -->
<button class="uni-btn-v" type="default" @tap="toast5Tap" id="btn-toast-postion-bottom">点击显示无图标的居底toast</button>
<!-- #endif -->
<button class="uni-btn-v" type="default" @tap="hideToast" id="btn-toast-hide">点击隐藏toast</button>
......@@ -101,7 +101,7 @@
},
})
},
// #ifdef APP-PLUS
// #ifdef APP
toast5Tap: function () {
uni.showToast({
title: "显示一段轻提示",
......
......@@ -37,7 +37,7 @@ describe('ExtApi-UploadFile', () => {
});
let shouldTestCookie = false
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
let version = process.env.uniTestPlatformInfo
version = parseInt(version.split(" ")[1])
shouldTestCookie = version > 9
......
......@@ -8,7 +8,7 @@ describe('component-native-overflow', () => {
//检测overflow设置hidden,visible
it('check_view_overflow', async () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
let version = process.env.uniTestPlatformInfo
version = parseInt(version.split(" ")[1])
//安卓7模拟器不截图 导致闪退
......
......@@ -86,4 +86,11 @@ describe('Button.uvue', () => {
const value = await page.callMethod('checkUniButtonElement')
expect(value).toBe(true)
})
it("setbuttonEmpty", async () => {
const textBtn = await page.$('.btn')
await page.setData({
text: '',
})
expect(await textBtn.text()).toEqual('')
})
})
......@@ -37,9 +37,9 @@
})
},
//用于自动化测试
checkUniButtonElement(): boolean {
checkUniButtonElement() : boolean {
const button = uni.getElementById("testButton")
if(button != null && button instanceof UniButtonElement) {
if (button != null && button instanceof UniButtonElement) {
return true
}
return false
......@@ -97,4 +97,9 @@
background-color: #179b16;
border-color: #179b16;
}
.button-hover {
color: rgba(0, 0, 0, 0.6);
background-color: #dedede;
}
</style>
......@@ -36,7 +36,9 @@
</script>
<template>
<scroll-view direction="vertical" style="flex:1">
<view class="main">
<!--type-->
<view class="container">
<button style="margin: 10px;" :disabled="disabled_boolean" :size="size_enum[size_enum_current].name"
......@@ -136,9 +138,15 @@
</view>
<view class="content">
<button style="margin: 10px;" type="primary" size="default" :disabled="disabled_boolean">uni-app x</button>
<button style="margin: 10px;" type="primary" @tap="change_disabled_boolean(!disabled_boolean)">修改disabled为{{disabled_boolean}}</button>
<button style="margin: 10px;" type="primary"
@tap="change_disabled_boolean(!disabled_boolean)">修改disabled为{{!disabled_boolean}}</button>
</view>
<view class="content">
<button style="margin: 10px;" type="primary" size="default" :disabled="disabled_boolean" hover-class="none">hover-class none</button>
</view>
</view>
</scroll-view>
</template>
<style>
......@@ -173,6 +181,15 @@
.container {
width: 100%;
height: 60px;
/* background-color: orange; */
}
.is-hover {
color: rgba(255, 255, 255, 0.6);
background-color: #179b16;
border-color: #179b16;
}
.button-hover {
color: rgba(0, 0, 0, 0.6);
background-color: #dedede;
}
</style>
......@@ -10,7 +10,7 @@ describe('event trigger sequence', () => {
})
it('touch', async () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
await el.touchstart({
touches: [{
identifier: 1,
......@@ -56,7 +56,7 @@ describe('event trigger sequence', () => {
})
it('longPress', async () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
await el.longpress()
const data = await page.data()
expect(data.onLongPressTime).toBeGreaterThan(0)
......
......@@ -30,7 +30,7 @@ describe('component-native-image', () => {
expect(await page.data('loadError')).toBe(true)
})
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
it('check-cookie', async () => {
await page.setData({
autoTest: true,
......
......@@ -147,19 +147,19 @@ describe('component-native-input', () => {
expect(await (await page.$('#uni-input-cursor-color')).attribute("cursor-color")).toBe("red")
})
it("maxlength default", async () => {
const input = await page.$('#uni-input-disable');
it("maxlength", async () => {
const input = await page.$('#uni-input-maxlength');
let str = "";
for(let i = 0;i < 200;i++){
str += `${i}`
}
await page.setData({
disableValue: str
inputMaxLengthValue: str
})
let length = (await input.attribute("value")).length
expect(length).toBe(140)
expect(length).toBe(10)
await page.setData({
disableValue: ""
inputMaxLengthValue: ""
})
})
......
......@@ -59,7 +59,7 @@
<text class="uni-title-text">设置禁用输入框</text>
</view>
<view class="input-wrapper">
<input id="uni-input-disable" class="uni-input" :disabled="true" :value="disableValue"/>
<input id="uni-input-disable" class="uni-input" :disabled="true"/>
</view>
</view>
......@@ -266,7 +266,6 @@
inputPasswordValue: "",
inputFocusKeyBoardChangeValue: true,
holdKeyboard: false,
disableValue: ""
}
},
methods: {
......
<template>
<scroll-view style="flex:1;" :refresher-enabled="true" :refresher-triggered="refresherTriggered"
refresher-default-style="none" @refresherpulling="onRefresherpulling" @refresherrefresh="onRefresherrefresh">
refresher-default-style="none" @refresherpulling="onRefresherpulling" @refresherrefresh="onRefresherrefresh" @refresherrestore="onRefreshrestore">
<view style="height: 25px;"></view>
<view v-for="i in 20" class="content-item">
<text class="text">item-{{i}}</text>
......@@ -38,9 +38,6 @@
methods: {
onRefresherpulling(e : RefresherEvent) {
this.pullingDistance = e.detail.dy;
if (this.pullingDistance.toDouble() == 0.0) {
this.resetting = false;
}
},
onRefresherrefresh() {
this.refresherTriggered = true
......@@ -49,6 +46,10 @@
this.resetting = true;
}, 1500)
},
onRefreshrestore() {
this.pullingDistance = 0
this.resetting = false;
}
}
}
</script>
......
......@@ -64,10 +64,10 @@
data() {
return {
items: [] as Item[],
refresherEnabled: false,
refresherEnabled: true,
refresherTriggered: false,
refresherThreshold: 45,
refresherDefaultStyle: "white",
refresherDefaultStyle: "black",
refresherBackground: "transparent",
}
},
......
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('component-native-scroll-view-refresher', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
let page;
beforeAll(async () => {
page = await program.reLaunch('/pages/component/scroll-view/scroll-view-refresher');
......
......@@ -19,7 +19,7 @@ describe('component-native-sticky-section', () => {
await page.setData({
scrolling: 'true'
})
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
//跳转到id为C的StickyHeader位置
await page.callMethod('gotoStickyHeader', 'C')
}
......
......@@ -13,23 +13,55 @@ describe('text-props', () => {
})
it('empty text', async () => {
await page.setData({
autoTest: true
})
const element = await page.$('#empty-text')
if (element != null) {
const { width, height } = await element.size()
expect(width).toBe(0)
expect(height).toBe(0)
}
await page.callMethod("setEmptyText")
await page.waitFor(100)
const element2 = await page.$('#empty-text2')
if (element2 != null) {
const { width, height } = await element2.size()
expect(width).toBe(0)
expect(height).toBe(0)
}
await page.setData({
autoTest: false
})
})
if (process.env.uniTestPlatformInfo.indexOf('web') > -1) {
return
it('nested text', async () => {
await page.setData({
autoTest: true
})
await page.callMethod("setNestedText")
await page.waitFor(100)
const element = await page.$('#nested-text')
if (element != null) {
expect(await element.text()).toBe("修改三级节点文本")
}
await page.setData({
autoTest: false
})
})
it('text nested', async () => {
page.callMethod("setTextNested")
const element = await page.$('#text-nested')
it('height text', async () => {
await page.setData({
autoTest: true
})
await page.callMethod("setHeightText")
await page.waitFor(100)
const element = await page.$('#height-text')
if (element != null) {
expect(await element.text()).toBe("二级节点文字红色且背景色黄色")
expect(await element.text()).toBe("修改设置高度文本")
}
await page.setData({
autoTest: false
})
})
})
......@@ -78,7 +78,7 @@
<view class="text-box">
<text
>一级节点黑色
<text id="text-nested" ref="text-nested" style="color: red;background-color: yellow;"
<text style="color: red;background-color: yellow;"
>二级节点红色且背景色黄色
<text>三级节点不继承二级的颜色</text>
</text>
......@@ -96,10 +96,22 @@
<text class="text-padding" style="width: 200px;height: 100px;">hello uni-app x</text>
</view>
<view v-if="autoTest">
<view class="uni-row">
<text id="empty-text"></text>
</view>
<view class="uni-row">
<text id="empty-text2">{{emptyText}}</text>
</view>
<text
>一级节点文本
<text
>二级节点文本
<text id="nested-text">{{nestedText}}</text>
</text>
</text>
<text id="height-text" style="height: 50px;">{{heightText}}</text>
</view>
</view>
</scroll-view>
</template>
......@@ -112,12 +124,23 @@ export default {
multiLineText:
'HBuilderX,轻巧、极速,极客编辑器;uni-app x,终极跨平台方案;uts,大一统语言;HBuilderX,轻巧、极速,极客编辑器;uni-app x,终极跨平台方案;uts,大一统语言',
singleLineText: 'uni-app x,终极跨平台方案',
// 自动化测试
autoTest: false,
nestedText: '三级节点文本',
emptyText: '空文本',
heightText: '设置高度文本'
}
},
methods: {
// 自动化测试
setTextNested() {
(this.$refs["text-nested"] as UniTextElement).value = "二级节点文字红色且背景色黄色";
setNestedText() {
this.nestedText = "修改三级节点文本";
},
setEmptyText() {
this.emptyText = "";
},
setHeightText() {
this.heightText = "修改设置高度文本";
}
}
}
......
......@@ -12,7 +12,7 @@ describe('component-native-web-view', () => {
});
it('screenshot', async () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
await page.waitFor(async () => {
return await page.data('loadFinish') === true;
});
......
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('component-native-web-view', () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
let page;
beforeAll(async () => {
page = await program.reLaunch('/pages/component/web-view/web-view');
......
......@@ -121,7 +121,7 @@ const pages = [
// '/pages/API/element-draw/element-draw',
]
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android')&& !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
// 规避 web 端不支持页面
pages.push(
"/pages/component/list-view/list-view",
......
......@@ -3,6 +3,7 @@
:refresher-enabled="true" :refresher-triggered="refresherTriggered" refresher-default-style="none"
@refresherpulling="onRefresherpulling"
@refresherrefresh="onRefresherrefresh"
@refresherrestore="onRefreshrestore"
:refresher-threshold="refresherThreshold"
>
<view v-for="i in 20" class="content-item">
......@@ -43,9 +44,6 @@
onRefresherpulling(e:RefresherEvent){
// console.log('onRefresherpulling',e.detail.dy)
this.pullingDistance = e.detail.dy
if (this.pullingDistance.toDouble() == 0.0) {
this.resetting = false;
}
},
onRefresherrefresh(){
this.refresherTriggered = true
......@@ -53,12 +51,10 @@
this.refresherTriggered = false
},1500)
},
// onRefresherrestore(e:RefresherEvent){
// console.log('onRefresherrestore',e)
// },
// onRefresherabort(e:RefresherEvent){
// console.log('onRefresherabort',e)
// },
onRefreshrestore() {
this.pullingDistance = 0
this.resetting = false;
}
}
}
</script>
......
......@@ -237,7 +237,7 @@ const PAGE_PATH =
describe("shot-compare", () => {
let shouldCompareScreenShot = false
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
let version = process.env.uniTestPlatformInfo
version = parseInt(version.split(" ")[1])
shouldCompareScreenShot = version > 9
......
......@@ -236,7 +236,7 @@ const PAGE_PATH =
describe("shot-compare", () => {
let shouldCompareScreenShot = false
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
let version = process.env.uniTestPlatformInfo
version = parseInt(version.split(" ")[1])
shouldCompareScreenShot = version > 9
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册