提交 c8d5d47f 编写于 作者: M mehaotian

Merge branch 'alpha' into alpha-stat

......@@ -2,7 +2,7 @@ root = true
[*]
charset = utf-8
end_of_line = lf
end_of_line = auto
indent_style = space
indent_size = 2
trim_trailing_whitespace = true
......
......@@ -29,6 +29,7 @@
} as OnShowOptions
},
onLaunch: function (res : OnLaunchOptions) {
this.globalData.launchOptions = res
// 自动化测试
......@@ -47,15 +48,28 @@
// } as PerformanceObserverOptions)
// 统计上报 - 应用启动
// uni.report({
// name: 'uni-app-launch',
// options: res,
// success(res_data) {
// console.log(res_data);
// }, fail(err_data) {
// console.log(err_data);
// }
// })
uni.report({
name: 'uni-app-launch',
options: res,
success(res_data) {
console.log(res_data);
}, fail(err) {
console.log(err);
}
})
// #ifdef APP
if (process.env.NODE_ENV !== 'development') { //真机运行可以注释此条件
uni.getPrivacySetting({
success(res1){
if(res1.needAuthorization){
uni.openDialogPage({
url: '/pages/component/button/privacy',
})
}
}
})
}
// #endif
},
onShow: function (res : OnShowOptions) {
this.globalData.onShowOption = res
......@@ -73,14 +87,14 @@
console.log('App Show')
// 统计上报 - 应用显示
// uni.report({
// name: 'uni-app-show',
// success(res_data) {
// console.log(res_data);
// }, fail(err_data) {
// console.log(err_data);
// }
// })
uni.report({
name: 'uni-app-show',
success(res_data) {
console.log(res_data);
}, fail(err) {
console.log(err);
}
})
},
onHide: function () {
// 自动化测试
......@@ -119,18 +133,18 @@
onExit() {
console.log('App Exit')
},
// onError(err : any) {
// // 统计上报 - 应用发生错误
// uni.report({
// name: 'uni-app-error',
// options: err,
// success(res) {
// console.log(res);
// }, fail(err) {
// console.log(err);
// }
// })
// },
onError(err : any) {
// 统计上报 - 应用发生错误
uni.report({
name: 'uni-app-error',
options: err,
success(res) {
console.log(res);
}, fail(err) {
console.log(err);
}
})
},
// #endif
methods: {
increasetLifeCycleNum() {
......@@ -182,10 +196,5 @@
.uni-top-window uni-tabbar .uni-tabbar {
background-color: #fff !important;
}
.uni-app--showleftwindow .uni-page-head-btn {
display: none !important;
}
/* #endif */
</style>
## 1.0.32
* update 4.31.2024102414-alpha
## 1.0.31
* update 4.28.2024092105-alpha
## 1.0.30
* update 4.27.2024091308-alpha
......
......@@ -6,6 +6,10 @@
type: String,
default: ''
},
disabled: {
type: Boolean,
default: false
},
defaultValue: {
type: Boolean,
default: false
......@@ -32,7 +36,7 @@
<template>
<view class="button-data-main uni-flex">
<view class="uni-title" style="width:80%">{{ title }}</view>
<switch :checked="_checked" @change="_change" />
<switch :checked="_checked" :disabled="disabled" @change="_change" />
</view>
</template>
......
// 仅测试 console.log 时机问题
import './test-main-console.uts'
import { uniStat } from '@/uni_modules/uni-stat/plugin.uts'
import App from './App.uvue'
import { createSSRApp } from 'vue'
......@@ -12,15 +11,13 @@ const collectItems = {
}
const statOptions = {
debug: false,
debug: true,
collectItems: collectItems,
}
export function createApp() {
const app = createSSRApp(App)
app.use(uniStat, statOptions)
// app.mixin({
// onReady() {
// setTimeout(() => {
......
......@@ -2,8 +2,8 @@
"name": "Hello uni-app x",
"appid": "__UNI__HelloUniAppX",
"description": "",
"versionName": "1.5",
"versionCode": 10500,
"versionName": "1.6",
"versionCode": 10600,
"uni-app-x": {},
/* 快应用特有相关 */
"quickapp": {},
......
......@@ -2,7 +2,7 @@
"id": "hello-uniapp-x-alpha",
"name": "hello-uniapp-x-alpha",
"displayName": "hello-uniapp-x-alpha",
"version": "1.0.30",
"version": "1.0.32",
"description": "演示 uni-app x 框架的组件、接口、模板",
"scripts": {
"check-commit": "node ./git-hooks/check-commit.cjs"
......
......@@ -297,21 +297,21 @@
},
{
"path": "pages/component/web-view/web-view",
"group": "0,8",
"group": "0,9",
"style": {
"navigationBarTitleText": "web-view"
}
},
{
"path": "pages/component/web-view/web-view/web-view-local",
"group": "0,8",
"group": "0,9",
"style": {
"navigationBarTitleText": "本地网页"
}
},
{
"path": "pages/component/unicloud-db/unicloud-db/contacts/list",
"group": "0,10",
"group": "0,11",
"style": {
"navigationBarTitleText": "联系人",
"enablePullDownRefresh": true
......@@ -337,7 +337,7 @@
},
{
"path": "pages/component/unicloud-db/unicloud-db/mixin-datacom/mixin-datacom",
"group": "0,10",
"group": "0,11",
"style": {
"navigationBarTitleText": "mixinDatacom"
}
......@@ -428,7 +428,7 @@
}
},
// #endif
// #ifdef WEB
// #ifdef WEB || APP
{
"path": "pages/component/map/map",
"group": "0,6",
......@@ -489,6 +489,34 @@
"navigationBarTitleText": "涂鸦"
}
},
// #ifndef WEB
{
"path": "pages/component/native-view/native-view",
"group": "0,2,4",
"style": {
"navigationBarTitleText": "native-view"
}
},
// #endif
// #ifndef WEB
{
"path": "pages/component/ad/ad",
"group": "0,8",
"style": {
"navigationBarTitleText": "ad | 信息流广告",
"enablePullDownRefresh": false
}
},
// #endif
// #ifndef WEB
{
"path": "pages/component/ad/list-view-ad",
"style": {
"navigationBarTitleText": "ad | 信息流广告",
"enablePullDownRefresh": false
}
},
// #endif
{
"path": "pages/tabBar/API",
"style": {
......@@ -567,14 +595,14 @@
},
{
"path": "pages/API/set-navigation-bar-color/set-navigation-bar-color",
"group": "1,2,1",
"group": "1,2,2",
"style": {
"navigationBarTitleText": "setNavigationBarColor | 设置导航条颜色"
}
},
{
"path": "pages/API/set-navigation-bar-title/set-navigation-bar-title",
"group": "1,2,2",
"group": "1,2,3",
"style": {
"navigationBarTitleText": "setNavigationBarTitle | 设置导航条标题"
}
......@@ -606,7 +634,7 @@
},
{
"path": "pages/API/pull-down-refresh/pull-down-refresh",
"group": "1,2,4",
"group": "1,2,5",
"style": {
"navigationBarTitleText": "pullDownRefresh | 页面下拉刷新",
"enablePullDownRefresh": true
......@@ -899,7 +927,7 @@
},
{
"path": "pages/API/page-scroll-to/page-scroll-to",
"group": "1,2,5",
"group": "1,2,6",
"style": {
"navigationBarTitleText": "pageScrollTo | 将页面滚动到指定位置"
}
......@@ -939,6 +967,13 @@
"navigationBarTitleText": "getWindowInfo | 获取窗口信息"
}
},
{
"path": "pages/API/get-window-info/window-area",
"style": {
"navigationBarTitleText": "window area",
"navigationStyle": "custom"
}
},
// #ifndef WEB
{
"path": "pages/API/element-draw/element-draw",
......@@ -1024,6 +1059,8 @@
"enablePullDownRefresh": false
}
},
// #endif
// #ifdef APP-IOS
{
"path": "pages/API/virtual-payment/virtual-payment-uni-pay",
"style": {
......@@ -1146,8 +1183,14 @@
"navigationBarTitleText": "provider | 服务提供商"
}
},
{
"path": "pages/API/privacy/privacy",
"group": "1,1,8",
"style": {
"navigationBarTitleText": "privacy | 隐私信息授权"
}
},
// #endif
// #ifndef WEB
{
"path": "pages/API/uni-push/uni-push",
"group": "1,15,0",
......@@ -1155,6 +1198,40 @@
"navigationBarTitleText": "推送"
}
},
{
"path": "pages/API/dialog-page/dialog-page",
"group": "1,2,1",
"style": {
"navigationBarTitleText": "dialogPage | 弹框页面"
}
},
{
"path": "pages/API/dialog-page/next-page",
"style": {
"navigationBarTitleText": "dialogNextPage"
}
},
{
"path": "pages/API/dialog-page/dialog-1",
"style": {
"navigationBarTitleText": "dialogPage1"
}
},
{
"path": "pages/API/dialog-page/dialog-2",
"style": {
"navigationBarTitleText": "dialogPage1"
}
},
// #ifndef WEB
{
"path": "pages/API/create-interstitial-ad/create-interstitial-ad",
"group": "1,13,1",
"style": {
"navigationBarTitleText": "createInterstitialAd | 插屏广告",
"enablePullDownRefresh": false
}
},
// #endif
{
"path": "pages/tabBar/CSS",
......@@ -1254,6 +1331,13 @@
"navigationBarTitleText": "border动态修改"
}
},
{
"path": "pages/CSS/border/border-update",
"group": "2,13",
"style": {
"navigationBarTitleText": "border更新样式"
}
},
{
"path": "pages/CSS/box-shadow/box-shadow",
"group": "2,15",
......@@ -1782,15 +1866,37 @@
"navigationBarTitleText": "",
"backgroundColorContent": "#fffae8"
}
},
// #ifdef APP-IOS
{
"path" : "pages/API/event-bus/uts-event-bus",
"style" :
{
"navigationBarTitleText" : ""
}
},
// #endif
// #ifdef APP
{
"path": "pages/component/button/privacy",
"style": {
"navigationBarTitleText": ""
}
}
// #endif
],
"globalStyle": {
// #ifdef APP-ANDROID
"hideStatusBar": false,
"hideBottomNavigationIndicator": false,
// #endif
"pageOrientation": "portrait",
"navigationBarTitleText": "Hello uniapp x",
"navigationBarTextStyle": "@navigationBarTextStyle",
"navigationBarBackgroundColor": "@navigationBarBackgroundColor",
"backgroundColorContent": "@backgroundColorContent",
"backgroundColor": "@backgroundColor"
"backgroundColor": "@backgroundColor",
"backgroundTextStyle": "@backgroundTextStyle"
},
"tabBar": {
"color": "@tabBarColor",
......@@ -1932,6 +2038,10 @@
{
"id": "component.basic-content.progress",
"name": "progress"
},
{
"id": "component.basic-content.native-view",
"name": "native-view"
}
]
},
......@@ -2021,6 +2131,10 @@
"id": "component.canvas",
"name": "画布"
},
{
"id": "component.ad",
"name": "广告"
},
{
"id": "component.web-view",
"name": "网页"
......@@ -2092,6 +2206,11 @@
{
"id": "api.base.provider",
"name": "provider"
},
null,
{
"id": "api.base.privacy",
"name": "privacy"
}
]
},
......@@ -2103,6 +2222,10 @@
"id": "api.page.navigator",
"name": "navigator"
},
{
"id": "api.page.dialogPage",
"name": "dialogPage"
},
{
"id": "api.page.setNavigationBarColor",
"name": "setNavigationBarColor"
......@@ -2355,6 +2478,10 @@
{
"id": "api.ad.createRewardedVideoAd",
"name": "createRewardedVideoAd"
},
{
"id": "api.ad.createInterstitialAd",
"name": "createInterstitialAd"
}
]
},
......
......@@ -29,7 +29,8 @@
数量限制
</view>
<view class="uni-list-cell-right">
<input class="click-t" :value="countIndex+1" type="number" :maxlength="1" @confirm="chooseImageCount" confirm-type="done" />
<input class="click-t" :value="countIndex+1" type="number" :maxlength="1" @confirm="chooseImageCount"
confirm-type="done" />
</view>
</view>
<view class="uni-list-cell cell-pd">
......@@ -40,13 +41,14 @@
<switch :checked="isCrop" @change="switchCrop"></switch>
</view>
</view>
<view ref="cropOptionNode" class="crop-option" :style="{'height':isCrop?'200px':'0px','margin-bottom':isCrop?'11px':'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-left item_width">
图片质量(%)
</view>
<view class="uni-list-cell-right">
<input :value="cropPercent" @confirm="cropPercentConfim" type="number" maxlength="-1"/>
<input :value="cropPercent" @confirm="cropPercentConfim" type="number" maxlength="-1" />
</view>
</view>
<view class="uni-list-cell cell-pd">
......@@ -54,7 +56,7 @@
裁剪宽度(px)
</view>
<view class="uni-list-cell-right">
<input :value="cropWidth" @confirm="cropWidthConfim" type="number" maxlength="-1"/>
<input :value="cropWidth" @confirm="cropWidthConfim" type="number" maxlength="-1" />
</view>
</view>
<view class="uni-list-cell cell-pd">
......@@ -62,7 +64,7 @@
裁剪高度(px)
</view>
<view class="uni-list-cell-right">
<input :value="cropHeight" @confirm="cropHeightConfim" type="number" maxlength="-1"/>
<input :value="cropHeight" @confirm="cropHeightConfim" type="number" maxlength="-1" />
</view>
</view>
<view class="uni-list-cell cell-pd">
......
......@@ -26,7 +26,7 @@
</view>
</template>
<script lang="uts">
function formatLocation (longitude, latitude) {
function formatLocation(longitude, latitude) {
if (typeof longitude === 'string' && typeof latitude === 'string') {
longitude = parseFloat(longitude)
latitude = parseFloat(latitude)
......@@ -39,7 +39,7 @@
}
}
export default {
data () {
data() {
return {
title: 'chooseLocation',
hasLocation: false,
......
......@@ -5,7 +5,7 @@
<view class="uni-title">请输入剪贴板内容</view>
<view class="uni-list">
<view class="uni-list-cell">
<input class="uni-input" type="text" placeholder="请输入剪贴板内容" :value="data" @input="dataChange"/>
<input class="uni-input" type="text" placeholder="请输入剪贴板内容" :value="data" @input="dataChange" />
</view>
</view>
<view class="uni-btn-v">
......@@ -22,7 +22,7 @@
title: 'get/setClipboardData',
data: '',
// 自动化测试
getDataTest:'',
getDataTest: '',
setClipboardTest: false
}
},
......@@ -88,5 +88,3 @@
<style>
</style>
......@@ -7,7 +7,8 @@
</view>
<view class="direction">
<view class="bg-compass-line"></view>
<image class="bg-compass" src="../../../static/compass.png" :style="'transform: rotate('+direction+'deg)'"></image>
<image class="bg-compass" src="../../../static/compass.png" :style="'transform: rotate('+direction+'deg)'">
</image>
<view class="direction-value">
<text>{{direction}}</text>
<text class="direction-degree">o</text>
......@@ -46,7 +47,7 @@
height: 540rpx;
align-items: center;
justify-content: center;
margin:0 auto;
margin: 0 auto;
}
.direction-value {
......
......@@ -50,8 +50,6 @@
quality: 80,
compressedWidth: null as number | null,
compressedHeight: null as number | null,
width: "auto",
height: "auto",
rotate: 0,
// 自动化测试
imageInfoForTest: null,
......@@ -75,8 +73,6 @@
quality: this.quality,
compressedWidth: this.compressedWidth,
compressedHeight: this.compressedHeight,
width: this.width,
height: this.height,
rotate: this.rotate,
success: (res) => {
console.log("compressImage success", JSON.stringify(res));
......@@ -137,12 +133,6 @@
onCompressedHeightConfirm(value : string) {
this.compressedHeight = parseInt(value);
},
onWidthConfirm(value : string) {
this.width = value;
},
onHeightConfirm(value : string) {
this.height = value;
},
onRotateConfirm(value : number) {
this.rotate = value;
},
......
......@@ -10,45 +10,42 @@ describe('inner-audio', () => {
await page.waitFor('view');
});
function getData(key = '') {
return new Promise(async (resolve, reject) => {
const data = await page.data()
resolve(key ? data[key] : data)
})
}
it('onCanplay',async()=>{
await page.waitFor(1000)
await page.waitFor(async()=>{
return await getData('isCanplay')
return await page.data('isCanplay')
})
expect(await getData('buffered')).toBeGreaterThan(0)
expect(await page.data('buffered')).toBeGreaterThan(0)
})
it('play-onPlay-onTimeUpdate', async () => {
await page.callMethod('play')
await page.waitFor(3000);
expect(await getData('isPlaying')).toBeTruthy()
console.log("duration:",await getData('duration'),"currentTime:",await getData('currentTime'))
expect(await getData('duration')).toBeCloseTo(175.109, 0);
// console.log("isPaused",await getData('isPaused'))
// expect(await getData('currentTime')).toBeGreaterThan(0);
// expect(await getData('isPaused')).toBeFalsy();
const waitTime = process.env.uniTestPlatformInfo.includes('chrome') ? 5000:3000
await page.waitFor(waitTime)
expect(await page.data('isPlaying')).toBeTruthy()
console.log("duration:",await page.data('duration'),"currentTime:",await page.data('currentTime'))
expect(await page.data('duration')).toBeCloseTo(175.109, 0);
// console.log("isPaused",await page.data('isPaused'))
// expect(await page.data('currentTime')).toBeGreaterThan(0);
// expect(await page.data('isPaused')).toBeFalsy();
});
it('seek-onSeeking-onSeeked', async () => {
await page.callMethod('onchange',20)
await page.waitFor(500);
expect(await getData('onSeekingTest')).toBeTruthy();
// expect(await getData('onWaitingTest')).toBeTruthy();
expect(await getData('onSeekedTest')).toBeTruthy();
const waitTime = process.env.uniTestPlatformInfo.includes('chrome') ? 1500:500
await page.waitFor(waitTime)
console.log("seek-onSeeking-onSeeked:",await page.data())
expect(await page.data('onSeekingTest')).toBeTruthy();
// expect(await page.data('onWaitingTest')).toBeTruthy();
// expect(await page.data('onSeekedTest')).toBeTruthy();
expect(await program.screenshot()).toSaveImageSnapshot();
});
it('pause-onPause', async () => {
await page.callMethod('pause')
await page.waitFor(500);
expect(await getData('isPlaying')).toBeFalsy()
// expect(await getData('isPaused')).toBeTruthy();
expect(await page.data('isPlaying')).toBeFalsy()
// expect(await page.data('isPaused')).toBeTruthy();
});
it('stop-onStop', async () => {
......@@ -58,8 +55,8 @@ describe('inner-audio', () => {
await page.callMethod('stop')
await page.callMethod('stop')
await page.waitFor(1000);
expect(await getData('isPlaying')).toBeFalsy()
// expect(await getData('isPaused')).toBeTruthy();
expect(await page.data('isPlaying')).toBeFalsy()
// expect(await page.data('isPaused')).toBeTruthy();
});
it('onEnded', async () => {
......@@ -67,7 +64,7 @@ describe('inner-audio', () => {
await page.waitFor(500);
await page.callMethod('play')
await page.waitFor(3000);
// expect(await getData('isPlayEnd')).toBeTruthy();
// expect(await page.data('isPlayEnd')).toBeTruthy();
});
});
......@@ -58,9 +58,9 @@
_isChanging: false,
_audioContext: null as InnerAudioContext | null,
// 自动化测试
onSeekingTest:false,
onSeekedTest:false,
onWaitingTest:false
onSeekingTest: false,
onSeekedTest: false,
onWaitingTest: false
}
},
computed: {
......@@ -129,7 +129,7 @@
}
this._audioContext!.onPlay(() => {
this.isPaused = false;
console.log('开始播放',this.isPaused);
console.log('开始播放', this.isPaused);
});
this.onTimeUpdate()
this.onWaiting()
......@@ -159,6 +159,7 @@
// console.log('onTimeUpdate:音频播放进度更新事件,currentTime',this._audioContext!.currentTime);
if (this._isChanging === true) { return; }
this.currentTime = this._audioContext!.currentTime || 0;
console.log('currentTime', this.currentTime);
if (this.currentTime > this.buffered) {
console.log('缓冲不足');
}
......@@ -208,7 +209,7 @@
console.log('音频停止事件');
});
this.isPlaying = false;
console.log('stop',this.isPaused);
console.log('stop', this.isPaused);
}
}
}
......
......@@ -6,7 +6,8 @@
</view>
<view class="formats" v-for="(item,index) in supportFormats" :key="index">
<text class="uni-subtitle-text">{{item.format}}</text>
<image class="icon-play" :src="(isPlaying && playIndex==index)?'/static/pause.png':'/static/play.png'" @click="play(item.src,index)"></image>
<image class="icon-play" :src="(isPlaying && playIndex==index)?'/static/pause.png':'/static/play.png'"
@click="play(item.src,index)"></image>
</view>
<view class="uni-title">
......@@ -14,7 +15,8 @@
</view>
<view class="formats" v-for="(item,index) in notSupportFormats" :key="index">
<text class="uni-subtitle-text">{{item.format}}</text>
<image class="icon-play" :src="(isPlaying && playIndex==index)?'/static/pause.png':'/static/play.png'" @click="play(item.src,index)"></image>
<image class="icon-play" :src="(isPlaying && playIndex==index)?'/static/pause.png':'/static/play.png'"
@click="play(item.src,index)"></image>
</view>
</view>
</template>
......@@ -28,7 +30,7 @@
data() {
return {
title: 'audio-format',
playIndex:0,
playIndex: 0,
isPlaying: false,
_audioContext: null as InnerAudioContext | null,
supportFormats: [
......@@ -62,7 +64,7 @@
src: 'https://web-ext-storage.dcloud.net.cn/uni-app-x/audio/ForElise.wav'
},
] as Array<AudioFormat>,
notSupportFormats:[
notSupportFormats: [
{
format: 'wma',
src: 'https://web-ext-storage.dcloud.net.cn/uni-app-x/audio/ForElise.wma'
......@@ -96,7 +98,7 @@
this._audioContext!.pause();
this.isPlaying = false;
},
play(audioUrl,index){
play(audioUrl, index) {
// console.log(index,audioUrl);
if (this.isPlaying && this.playIndex == index) {
this.pause();
......@@ -115,7 +117,7 @@
});
this._audioContext!.onError((err) => {
this.isPlaying = false;
console.log('err',err);
console.log('err', err);
});
},
},
......@@ -123,9 +125,10 @@
</script>
<style>
.formats{
.formats {
align-items: center;
}
.icon-play {
width: 60px;
height: 60px;
......
......@@ -6,7 +6,8 @@
</view>
<view class="formats" v-for="(item,index) in supportPaths" :key="index">
<text class="uni-subtitle-text">{{item.description}}</text>
<image class="icon-play" :src="(isPlaying && playIndex==index)?'/static/pause.png':'/static/play.png'" @click="play(item.src,index)"></image>
<image class="icon-play" :src="(isPlaying && playIndex==index)?'/static/pause.png':'/static/play.png'"
@click="play(item.src,index)"></image>
</view>
</view>
</template>
......@@ -20,7 +21,7 @@
data() {
return {
title: 'audio-path',
playIndex:0,
playIndex: 0,
isPlaying: false,
_audioContext: null as InnerAudioContext | null,
supportPaths: [
......@@ -61,7 +62,7 @@
this._audioContext!.pause();
this.isPlaying = false;
},
play(audioUrl,index){
play(audioUrl, index) {
// console.log(index,audioUrl);
if (this.isPlaying && this.playIndex == index) {
this.pause();
......@@ -80,7 +81,7 @@
});
this._audioContext!.onError((err) => {
this.isPlaying = false;
console.log('err',err);
console.log('err', err);
});
}
}
......@@ -88,9 +89,10 @@
</script>
<style>
.formats{
.formats {
align-items: center;
}
.icon-play {
width: 60px;
height: 60px;
......
<template>
<page-head title="插屏广告"></page-head>
<button :type="btnType" style="margin: 10px;" :disabled="btnDisable" @click="showAd()">{{btnText}}</button>
</template>
<script>
export default {
data() {
return {
btnText: "",
btnType: "primary",
btnDisable: false,
interstitialAd: null as InterstitialAd | null,
isAdLoadSuccess: false
}
},
onReady() {
this.loadAd()
},
methods: {
loadAd() {
if (this.btnDisable)
return
this.btnDisable = true
this.btnText = "正在加载广告"
this.btnType = "primary"
if (this.interstitialAd == null) {
this.interstitialAd = uni.createInterstitialAd({
adpid: "1111111113" //此处为测试广告位,实际开发中请在uni-ad后台申请自己的广告位后替换
})
this.interstitialAd!.onError((_) => {
this.btnType = "warn"
this.btnText = "广告加载失败,点击重试"
this.btnDisable = false
})
this.interstitialAd!.onLoad((_) => {
this.btnType = "primary"
this.btnText = "广告加载成功,点击观看"
this.btnDisable = false
this.isAdLoadSuccess = true
})
this.interstitialAd!.onClose((e) => {
this.isAdLoadSuccess = false
this.loadAd()
})
}
this.interstitialAd!.load()
},
showAd() {
if (this.isAdLoadSuccess) {
this.interstitialAd!.show()
} else {
this.loadAd()
}
}
}
}
</script>
<style>
</style>
......@@ -3,7 +3,8 @@
<scroll-view style="flex:1">
<!-- #endif -->
<page-head title="权限申请监听"></page-head>
<view class="permission-alert" id="permission-alert" :style="{'transform':isPermissionAlertShow ? 'translateY(0)':'translateY(-110px)'}">
<view class="permission-alert" id="permission-alert"
:style="{'transform':isPermissionAlertShow ? 'translateY(0)':'translateY(-110px)'}">
<text style="font-size: 20px;margin-bottom: 10px;margin-top: 5px;">访问日历权限申请说明:</text>
<text style="color: darkgray;">uni-app x正在申请访问日历权限用于演示,允许或拒绝均不会获取任何隐私信息。</text>
</view>
......
......@@ -163,7 +163,7 @@
node: true
} as NodeField, (ret) => {
const isElement = (ret as NodeInfo).node instanceof UniElement
if(isElement){
if (isElement) {
this.fieldsResultContainNode = true
} else {
this.fieldsResultContainNode = false
......@@ -175,7 +175,7 @@
uni.createSelectorQuery().select('#canvas1').node((ret) => {
const isElement = (ret as NodeInfo).node instanceof UniElement
const isCanvasElement = ((ret as NodeInfo).node as UniCanvasElement).tagName == 'CANVAS'
if(isElement && isCanvasElement){
if (isElement && isCanvasElement) {
this.nodeResultContainNode = true
} else {
this.nodeResultContainNode = false
......
<template>
<view id="dialog1" class="dialog-container">
<view class="dialog-content">
<text>title: {{title}}</text>
<text class="mt-10">onBackPress return true</text>
<button class="mt-10" id="dialog1-go-next-page" @click="goNextPage">go next page</button>
<button class="mt-10" id="dialog1-open-dialog2" @click="openDialog2">openDialog2</button>
<button class="mt-10" id="dialog1-close-dialog" @click="closeDialog">closeDialog</button>
<button class="mt-10" id="dialog1-close-this-dialog" @click="closeThisDialog">closeThisDialog</button>
<button class="mt-10" id="dialog1-back" @click="back">back</button>
</view>
</view>
</template>
<script>
import {
state,
setLifeCycleNum
} from '@/store/index.uts'
export default {
data() {
return {
title: 'dialog 1',
}
},
onLoad(options : OnLoadOptions) {
console.log('dialog 1 onLoad', options)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
if (options['name'] == 'dialog1') {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
},
onShow() {
console.log('dialog 1 onShow')
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
onReady() {
console.log('dialog 1 onReady')
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
const currentPages = getCurrentPages()
const parentPage = this.$page.getParentPage()!
const grandParentPage = parentPage.getParentPage()
const dialogPages = parentPage.getDialogPages()
const dialogPage = this.$page
if (
currentPages.length == 1 &&
grandParentPage == null &&
dialogPages.indexOf(dialogPage) != -1
) {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
},
onHide() {
console.log('dialog 1 onHide')
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 1)
},
onUnload() {
console.log('dialog 1 onUnload')
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 5)
},
onBackPress(options : OnBackPressOptions) : boolean | null {
console.log('dialogPage1 onBackPress', options)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
return true
},
methods: {
goNextPage() {
uni.navigateTo({ url: '/pages/API/dialog-page/next-page' })
},
openDialog2() {
uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-2',
disableEscBack: true,
success(res) {
console.log('openDialog2 success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('openDialog2 fail', err)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('openDialog2 complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
closeDialog() {
uni.closeDialogPage({
success(res) {
console.log('closeDialog success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('closeDialog fail', err)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('closeDialog complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
closeThisDialog() {
uni.closeDialogPage({
dialogPage: this.$page,
success(res) {
console.log('closeThisDialog success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('closeThisDialog fail', err)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('closeThisDialog complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
back() {
uni.navigateBack()
}
}
}
</script>
<style>
.dialog-container {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.3);
display: flex;
justify-content: center;
align-items: center;
}
.dialog-content {
width: 80%;
padding: 10px;
background-color: #fff;
border-radius: 6px;
}
.mt-10 {
margin-top: 10px;
}
</style>
<template>
<view id="dialog2" class="dialog-container">
<view class="dialog-content">
<text>title: {{title}}</text>
<text class="mt-10">onBackPress return false</text>
<button class="mt-10" @click="goNextPage">go next page</button>
<button class="mt-10" @click="openDialog1">openDialog1</button>
<button class="mt-10" @click="closeDialog">closeDialog</button>
<button class="mt-10" @click="closeThisDialog">closeThisDialog</button>
<button class="mt-10" @click="back">back</button>
</view>
</view>
</template>
<script>
import {
state,
setLifeCycleNum
} from '@/store/index.uts'
export default {
data() {
return {
title: 'dialog 2',
}
},
onLoad(options : OnLoadOptions) {
console.log('dialog 2 onLoad', options)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
onShow() {
console.log('dialog 2 onShow')
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
onReady() {
console.log('dialog 2 onReady')
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
onHide() {
console.log('dialog 2 onHide')
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 1)
},
onUnload() {
console.log('dialog 2 onUnload')
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 5)
},
onBackPress(options : OnBackPressOptions) : boolean | null {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
return false
},
methods: {
goNextPage() {
uni.navigateTo({ url: '/pages/API/dialog-page/next-page' })
},
openDialog1() {
uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-1?name=dialog1',
success(res) {
console.log('openDialog1 success', res)
},
fail(err) {
console.log('openDialog1 fail', err)
},
complete(res) {
console.log('openDialog1 complete', res)
}
})
},
closeDialog() {
uni.closeDialogPage({
success(res) {
console.log('closeDialog success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('closeDialog fail', err)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('closeDialog complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
closeThisDialog() {
uni.closeDialogPage({
dialogPage: this.$page,
success(res) {
console.log('closeThisDialog success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('closeThisDialog fail', err)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('closeThisDialog complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
back() {
uni.navigateBack()
}
}
}
</script>
<style>
.dialog-container {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.3);
display: flex;
justify-content: center;
align-items: center;
}
.dialog-content {
width: 80%;
padding: 10px;
background-color: #fff;
border-radius: 6px;
}
.mt-10 {
margin-top: 10px;
}
</style>
jest.setTimeout(20000)
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isWeb = platformInfo.startsWith('web')
const FIRST_PAGE_PATH = '/pages/API/dialog-page/dialog-page'
const NEXT_PAGE_PATH = '/pages/API/dialog-page/next-page'
describe('dialog page', () => {
if (process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
it('skip app-webview', () => {
expect(1).toBe(1)
})
return
}
let page;
let initLifeCycleNum;
let lifecycleNum;
beforeAll(async () => {
page = await program.reLaunch(FIRST_PAGE_PATH)
await page.waitFor('view');
initLifeCycleNum = await page.callMethod('getLifeCycleNum');
await page.callMethod('setLifeCycleNum', 0)
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(0)
});
it('open dialog1', async () => {
await page.callMethod('openDialog1');
// 无法通过获取 dom 元素来判断是否打开了 dialogPage
await page.waitFor(1000)
if (isWeb) {
await page.waitFor(2000)
}
const image = await program.screenshot({
deviceShot: true,
area: {
x: 0,
y: 200,
}
});
expect(image).toSaveImageSnapshot();
lifecycleNum = await page.callMethod('getLifeCycleNum')
// 不应触发父页面的生命周期,应该触发:
// 1. openDialogPage success & complete callback
// 2. dialog page 生命周期
expect(lifecycleNum).toBe(7)
await page.callMethod('setLifeCycleNum', 0)
});
it('closeDialogPage', async () => {
await page.callMethod('closeDialog');
const image = await program.screenshot({
deviceShot: true,
area: {
x: 0,
y: 200,
}
});
expect(image).toSaveImageSnapshot();
// closeDialogPage success & complete callback 应被触发
// dialogPage onUnload 应被触发
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(-3)
await page.callMethod('setLifeCycleNum', 0)
})
it('openDialog with wrong path', async () => {
await page.callMethod('openDialog1WrongPath')
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(-3)
await page.callMethod('setLifeCycleNum', 0)
})
it('navigateTo nextPage & open Dialog', async () => {
await page.callMethod('goNextPageOpenDialog1')
await page.waitFor(2000)
if (isWeb) {
await page.waitFor(3000)
}
page = await program.currentPage()
expect(page.path).toBe(NEXT_PAGE_PATH.substring(1))
await page.waitFor(1000)
if (isWeb) {
await page.waitFor(2000)
}
const image = await program.screenshot({
deviceShot: true,
area: {
x: 0,
y: 200,
}
});
expect(image).toSaveImageSnapshot();
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(-4)
await page.callMethod('setLifeCycleNum', 0)
})
it('dialog1 navigateBack', async () => {
await program.navigateBack()
page = await program.currentPage()
// dialogPage onBackPress 返回 true, 应可以拦截 navigateBack
expect(page.path).toBe(NEXT_PAGE_PATH.substring(1))
const image = await program.screenshot({
deviceShot: true,
area: {
x: 0,
y: 200,
}
});
expect(image).toSaveImageSnapshot();
lifecycleNum = await page.callMethod('getLifeCycleNum')
// onBackPress 生命周期应该被触发
expect(lifecycleNum).toBe(1)
await page.callMethod('setLifeCycleNum', 0)
})
it('open dialog2', async () => {
await page.callMethod('openDialog2')
await page.waitFor(1000)
if (isWeb) {
await page.waitFor(2000)
}
lifecycleNum = await page.callMethod('getLifeCycleNum')
// 应触发前一个 dialogPage 的 onHide
expect(lifecycleNum).toBe(4)
await page.callMethod('setLifeCycleNum', 0)
})
it('closeDialogPage', async () => {
await page.callMethod('closeDialog')
lifecycleNum = await page.callMethod('getLifeCycleNum')
// 应触发 success & complete 回调
// 应触发 dialogPage 的 unload,下层的 dialogPage 会先 show 再 unload
expect(lifecycleNum).toBe(-7)
const image = await program.screenshot({
deviceShot: true,
area: {
x: 0,
y: 200,
}
});
expect(image).toSaveImageSnapshot();
await page.callMethod('setLifeCycleNum', 0)
})
it('open multiple dialog page', async () => {
await page.callMethod('openDialog1')
await page.waitFor(1000)
if (isWeb) {
await page.waitFor(2000)
}
const image1 = await program.screenshot({
deviceShot: true,
area: {
x: 0,
y: 200,
}
});
expect(image1).toSaveImageSnapshot();
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(4)
await page.callMethod('openDialog2')
await page.waitFor(1000)
if (isWeb) {
await page.waitFor(2000)
}
const image2 = await program.screenshot({
deviceShot: true,
area: {
x: 0,
y: 200,
}
});
expect(image2).toSaveImageSnapshot();
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(8)
await page.callMethod('setLifeCycleNum', 0)
})
it('openDialogPage to home page', async () => {
await page.callMethod('openDialogPage1ToHomePage')
await page.waitFor(1000)
if (isWeb) {
await page.waitFor(2000)
}
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(4)
await page.callMethod('setLifeCycleNum', 0)
})
it('dialog2 navigateBack', async () => {
await program.navigateBack()
page = await program.currentPage()
// dialogPage onBackPress 返回 true, 应可以拦截 navigateBack
expect(page.path).toBe(FIRST_PAGE_PATH.substring(1))
const image = await program.screenshot({
deviceShot: true,
area: {
x: 0,
y: 200,
}
});
expect(image).toSaveImageSnapshot();
lifecycleNum = await page.callMethod('getLifeCycleNum')
// onBackPress 生命周期应该被触发
expect(lifecycleNum).toBe(2)
await page.callMethod('setLifeCycleNum', 0)
})
it('close specified dialogPage', async () => {
await page.callMethod('openDialog2')
await page.waitFor(1000)
if (isWeb) {
await page.waitFor(2000)
}
const image1 = await program.screenshot({
deviceShot: true,
area: {
x: 0,
y: 200,
}
});
expect(image1).toSaveImageSnapshot();
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(4)
await page.callMethod('openDialog1')
await page.waitFor(1000)
if (isWeb) {
await page.waitFor(2000)
}
const image2 = await program.screenshot({
deviceShot: true,
area: {
x: 0,
y: 200,
}
});
expect(image2).toSaveImageSnapshot();
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(10)
await page.callMethod('closeSpecifiedDialog', 0)
const image3 = await program.screenshot({
deviceShot: true,
area: {
x: 0,
y: 200,
}
});
expect(image3).toSaveImageSnapshot();
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(7)
await page.callMethod('closeSpecifiedDialog', 1)
const image4 = await program.screenshot({
deviceShot: true,
area: {
x: 0,
y: 200,
}
});
expect(image4).toSaveImageSnapshot();
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(5)
await page.callMethod('closeSpecifiedDialog', 0)
const image5 = await program.screenshot({
deviceShot: true,
area: {
x: 0,
y: 200,
}
});
expect(image5).toSaveImageSnapshot();
lifecycleNum = await page.callMethod('getLifeCycleNum')
expect(lifecycleNum).toBe(2)
})
afterAll(async () => {
await page.callMethod('setLifeCycleNum', initLifeCycleNum)
});
});
<template>
<view class="uni-padding-wrap">
<button class="uni-common-mt" id="go-next-page" @click="goNextPage">go next page</button>
<button class="uni-common-mt" id="open-dialog1" @click="openDialog1">open dialog 1</button>
<button class="uni-common-mt" id="open-dialog1-wrong-path" @click="openDialog1WrongPath">open dialog page 1 with
wrong path</button>
<button class="uni-common-mt" id="go-next-page-open-dialog1" @click="goNextPageOpenDialog1">go next page & open
dialog1</button>
</view>
</template>
<script lang='uts'>
import {
state,
setLifeCycleNum
} from '@/store/index.uts'
export default {
onLoad() {
console.log('dialogPage parent onLoad')
},
onShow() {
console.log('dialogPage parent onShow')
setLifeCycleNum(state.lifeCycleNum + 10)
},
onReady() {
console.log('dialogPage parent onReady')
},
onHide() {
console.log('dialogPage parent onHide')
setLifeCycleNum(state.lifeCycleNum - 10)
},
onUnload() {
console.log('dialogPage parent onUnload')
},
methods: {
goNextPage() {
uni.navigateTo({
url: '/pages/API/dialog-page/next-page'
})
},
openDialog1() {
uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-1?name=dialog1',
success(res) {
console.log('openDialogPage1 success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('openDialogPage1 fail', err)
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('openDialogPage1 complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
openDialog2() {
uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-2',
disableEscBack: true,
success(res) {
console.log('openDialog2 success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('openDialog2 fail', err)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('openDialog2 complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
openDialog1WrongPath() {
uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-11?name=dialog1',
success(res) {
console.log('openDialogPage1 success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('openDialogPage1 fail', err)
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('openDialogPage1 complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
goNextPageOpenDialog1() {
uni.navigateTo({
url: '/pages/API/dialog-page/next-page',
success() {
setTimeout(() => {
uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-1?name=dialog1',
success(res) {
console.log('openDialogPage1 success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('openDialogPage1 fail', err)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('openDialogPage1 complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
})
}, 1000)
}
})
},
closeDialog() {
uni.closeDialogPage({
success(res) {
console.log('closeDialog success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('closeDialog fail', err)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('closeDialog complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
closeSpecifiedDialog(index: number) {
const dialogPages = this.$page.getDialogPages()
uni.closeDialogPage({
dialogPage: dialogPages[index],
success(res) {
console.log('closeSomeOneDialog success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('closeSomeOneDialog fail', err)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('closeSomeOneDialog complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
setLifeCycleNum(value: number) {
setLifeCycleNum(value)
},
getLifeCycleNum(): number {
return state.lifeCycleNum
}
}
}
</script>
<template>
<view class='uni-padding-wrap'>
<button class="uni-common-mt" @click="openDialog1">open dialog1</button>
<button class="uni-common-mt" @click="openDialog2">open dialog2</button>
<button class="uni-common-mt" @click="openDialogPage1ToHomePage">open dialog page 1 to home page</button>
</view>
</template>
<script lang='uts'>
import {
state,
setLifeCycleNum
} from '@/store/index.uts'
export default {
onLoad() {
console.log('dialogPage parent onLoad')
},
onShow() {
console.log('dialogPage parent onShow')
},
onReady() {
console.log('dialogPage parent onReady')
},
onHide() {
console.log('dialogPage parent onHide')
},
onUnload() {
console.log('dialogPage parent onUnload')
},
methods: {
openDialog1() {
uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-1?name=dialog1',
success(res) {
console.log('openDialog1 success', res)
},
fail(err) {
console.log('openDialog1 fail', err)
},
complete(res) {
console.log('openDialog1 complete', res)
}
})
},
openDialog2() {
uni.openDialogPage({
url: '/pages/API/dialog-page/dialog-2',
disableEscBack: true,
success(res) {
console.log('openDialog2 success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('openDialog2 fail', err)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('openDialog2 complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
closeDialog() {
uni.closeDialogPage({
success(res) {
console.log('closeDialog success', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
},
fail(err) {
console.log('closeDialog fail', err)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 4)
},
complete(res) {
console.log('closeDialog complete', res)
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
openDialogPage1ToHomePage() {
const pages = getCurrentPages()
uni.openDialogPage({
parentPage: pages[0],
url: '/pages/API/dialog-page/dialog-1?name=dialog1',
success(res) {
console.log('openDialogPage1ToHomePage success', res)
uni.showToast({title: '在首页打开了 dialogPage'})
},
fail(err) {
console.log('openDialogPage1ToHomePage fail', err)
},
complete(res) {
console.log('openDialogPage1ToHomePage complete', res)
}
})
},
setLifeCycleNum(value: number) {
setLifeCycleNum(value)
},
getLifeCycleNum(): number {
return state.lifeCycleNum
}
}
}
</script>
......@@ -19,7 +19,6 @@
<!-- #endif -->
</template>
<script>
// #ifdef APP
import {
testInovkeDownloadFile,
......@@ -94,7 +93,7 @@
});
},
jest_set_cookie(){
jest_set_cookie() {
uni.request({
url: "https://request.dcloud.net.cn/api/http/header/setCookie",
method: "GET",
......@@ -111,7 +110,7 @@
});
},
jest_delete_cookie(){
jest_delete_cookie() {
uni.request({
url: "https://request.dcloud.net.cn/api/http/header/deleteCookie",
method: "GET",
......@@ -127,7 +126,7 @@
},
});
},
jest_cookie_download(needCookie: boolean){
jest_cookie_download(needCookie : boolean) {
uni.downloadFile({
url: "https://request.dcloud.net.cn/api/http/header/download",
success: () => {
......@@ -138,22 +137,22 @@
}
});
},
jest_uts_module_invoked(){
jest_uts_module_invoked() {
// #ifdef APP
testInovkeDownloadFile({
success:(res: any)=>{
success: (res : any) => {
this.jest_result = true
},
fail:(err: any)=>{
fail: (err : any) => {
this.jest_result = false
}
} as CommonOptions)
// #endif
},
jest_special_characters_download(){
jest_special_characters_download() {
uni.downloadFile({
url: "https://web-ext-storage.dcloud.net.cn/hello-uni-app-x/1789834995055525889-你好%23你好.png",
success: (res: DownloadFileSuccess) => {
success: (res : DownloadFileSuccess) => {
this.jest_result = true;
},
fail: () => {
......
......@@ -7,7 +7,8 @@
<button class="uni-btn btn-TakeSnapshot" type="primary" @tap="takeSnapshotClick">
点击截图并替换显示下方图片
</button>
<image style="margin-left:auto;margin-right:auto;margin-top:20px;width:90%;" :src="snapImage" :mode="mode" @longpress="saveToAlbum"></image>
<image style="margin-left:auto;margin-right:auto;margin-top:20px;width:90%;" :src="snapImage" :mode="mode"
@longpress="saveToAlbum"></image>
</view>
</template>
......
......@@ -5,9 +5,11 @@
<scroll-view style="flex: 1;">
<!-- #endif -->
<!-- #ifdef APP -->
<button class="btnstyle" type="primary" @tap="geAbsPath(sandboxPath)" id="btn-path">应用外置沙盒目录uni.env.SANDBOX_PATH</button>
<button class="btnstyle" type="primary" @tap="geAbsPath(sandboxPath)"
id="btn-path">应用外置沙盒目录uni.env.SANDBOX_PATH</button>
<button class="btnstyle" type="primary" @tap="geAbsPath(cachePath)" id="btn-path">缓存文件目录uni.env.CACHE_PATH</button>
<button class="btnstyle" type="primary" @tap="geAbsPath(userPath)" id="btn-path">用户文件目录uni.env.USER_DATA_PATH</button>
<button class="btnstyle" type="primary" @tap="geAbsPath(userPath)"
id="btn-path">用户文件目录uni.env.USER_DATA_PATH</button>
<button class="btnstyle" type="primary" @tap="geAbsPath(internalSandboxPath)"
id="btn-path">应用内置沙盒目录uni.env.ANDROID_INTERNAL_SANDBOX_PATH</button>
<!-- #endif -->
......
......@@ -77,4 +77,13 @@ describe('event-bus', () => {
const l3 = (await page.data()).log.length
expect(l3).toBe(0)
})
it('test return id', async () => {
await page.callMethod('clear')
expect((await page.data()).log.length).toBe(0)
await page.callMethod('testReturnId')
const logs = await page.data('log')
expect(logs.length).toBe(2)
expect(logs[0]).toBe('触发 test-return-id $on fn')
expect(logs[1]).toBe('触发 test-return-id $once fn')
})
})
......@@ -20,6 +20,7 @@
<text>接收到的 obj 参数:</text>
<text>{{JSON.stringify(objArg)}}</text>
</view>
<button @click="testReturnId">测试返回 id</button>
</view>
</view>
<!-- #ifdef APP -->
......@@ -49,7 +50,7 @@
uni.$on('test', this.fn2)
},
onObj() {
uni.$on('test-obj', (res: UTSJSONObject) => {
uni.$on('test-obj', (res : UTSJSONObject) => {
this.objArg = res
})
},
......@@ -71,6 +72,19 @@
clear() {
this.log.length = 0
},
testReturnId(){
const id1 = uni.$on('test-return-id', this.fn)
uni.$emit('test-return-id', '触发 test-return-id $on fn')
uni.$off('test-return-id', id1)
uni.$emit('test-return-id', '触发 test-return-id $on fn')
uni.$once('test-return-id', this.fn)
uni.$emit('test-return-id', '触发 test-return-id $once fn')
uni.$emit('test-return-id', '触发 test-return-id $once fn')
const id2 = uni.$once('test-id', this.fn)
uni.$off('test-return-id', id2)
uni.$emit('test-return-id', '触发 test-return-id $once fn')
}
},
}
</script>
......
// uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
const PAGE_PATH = '/pages/API/event-bus/uts-event-bus'
describe('event-bus', () => {
const platformInfo = process.env.uniTestPlatformInfo.toLowerCase()
if (!platformInfo.startsWith('ios')) {
it('pass', async () => {
expect(1).toBe(1);
});
return;
}
if (
platformInfo.indexOf('14.5') != -1 ||
platformInfo.indexOf('13.7') != -1 ||
platformInfo.indexOf('12.4') != -1
) {
it('iOS 14.5 13.7 12.4 不支持依赖uts插件测试', () => {
expect(1).toBe(1)
})
return
}
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor('view')
})
it('on', async () => {
await page.callMethod('clear')
await page.callMethod('JsOnUts')
await page.callMethod('emitFromUts')
const l1 = (await page.data()).log.length
expect(l1).toBeGreaterThan(0)
await page.callMethod('clear')
await page.callMethod('offUts')
await page.callMethod('emitFromUts')
const l2 = (await page.data()).log.length
expect(l2).toBe(0)
await page.callMethod('clear')
await page.callMethod('UtsOnJS')
await page.callMethod('emitFormJS')
const l3 = (await page.data()).log.length
expect(l3).toBeGreaterThan(0)
await page.callMethod('clear')
await page.callMethod('offJs')
await page.callMethod('emitFormJS')
const l4 = (await page.data()).log.length
console.log(l4)
expect(l4).toBe(0)
await page.callMethod('clear')
})
it('once', async () => {
await page.callMethod('clear')
await page.callMethod('JsOnUtsOnce')
await page.callMethod('emitFromUts')
const l1 = (await page.data()).log.length
expect(l1).toBeGreaterThan(0)
await page.callMethod('clear')
await page.callMethod('emitFromUts')
const l2 = (await page.data()).log.length
expect(l2).toBe(0)
await page.callMethod('clear')
await page.callMethod('UtsOnJSOnce')
await page.callMethod('emitFormJS')
const l3 = (await page.data()).log.length
expect(l3).toBeGreaterThan(0)
await page.callMethod('clear')
await page.callMethod('emitFormJS')
const l4 = (await page.data()).log.length
expect(l4).toBe(0)
await page.callMethod('clear')
})
})
<template>
<!-- #ifdef APP -->
<scroll-view class="page-scroll-view">
<!-- #endif -->
<view>
<button @click="JsOnUts">1. js监听uts消息</button>
<button @click="emitFromUts">2. uts中触发监听</button>
<button @click="offUts">取消uts消息监听</button>
<button @click="UtsOnJS">1. uts监听js消息</button>
<button @click="emitFormJS">2 .js中触发监听</button>
<button @click="offJs">取消js消息监听</button>
<button @click="clear">清空消息</button>
<view class="box">
<view>收到的消息:</view>
<view>
<view v-for="(item, index) in log" :key="index">{{ item }}</view>
</view>
</view>
</view>
<button @click="testAll">test all</button>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
import {
onJsMessage,
offJsMessage,
emitUtsMessage,
getMessageChannel,
getRevJsMessage,
clearJsMessage,
onJsMessageOnce,
} from "@/uni_modules/uts-eventbus"
export default {
data() {
return {
log: [] as string[],
}
},
methods: {
fn(res : string, res2 : string) {
console.log("on rev: " + res)
this.log.push(res)
this.log.push(res2)
},
fn2(res : string) {
this.log.push(res)
},
JsOnUts() {
uni.$off(getMessageChannel(), this.fn)
uni.$on(getMessageChannel(), this.fn)
},
offUts() {
uni.$off(getMessageChannel(), this.fn)
},
emitFromUts() {
emitUtsMessage("emit form uts")
},
JsOnUtsOnce() {
uni.$once(getMessageChannel(), this.fn2)
},
UtsOnJS() {
onJsMessage("JsMessage")
},
UtsOnJSOnce() {
onJsMessageOnce("JsMessage")
},
offJs() {
offJsMessage("JsMessage")
},
emitFormJS() {
clearJsMessage()
uni.$emit("JsMessage", "emit form js")
let msg = getRevJsMessage()
console.log("message:"+msg)
if (msg && msg.length){
this.log.push(msg)
}
},
clear() {
clearJsMessage()
this.log.length = 0
},
testAll() {
this.JsOnUts();
this.emitFromUts();
this.UtsOnJS();
this.emitFormJS();
}
},
}
</script>
<style>
.box {
padding: 10px;
}
</style>
......@@ -7,9 +7,9 @@
<script>
export default {
methods: {
exitAppClick:function(){
exitAppClick: function () {
uni.exit({
success:function(res){
success: function (res) {
console.log(res)
}
})
......
......@@ -6,12 +6,10 @@
<page-head :title="title"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-btn-v uni-common-mt">
<input class="uni-input" type="text" v-model="realName" name="real-name"
placeholder="姓名" maxlength="-1"/>
<input class="uni-input" type="text" v-model="realName" name="real-name" placeholder="姓名" maxlength="-1" />
</view>
<view class="uni-btn-v uni-common-mt">
<input class="uni-input" type="text" v-model="idCard" name="id-card"
placeholder="身份证号" maxlength="-1"/>
<input class="uni-input" type="text" v-model="idCard" name="id-card" placeholder="身份证号" maxlength="-1" />
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @click="facialRecognition">开始人脸识别</button>
......
......@@ -59,7 +59,7 @@
<input type="text" :disabled="true" placeholder="未获取" :value="notificationAuthorized" />
</view>
</view>
<!-- #ifdef APP-IOS -->
<!-- #ifdef APP-IOS -->
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">是否允许通知带有提醒</view>
......@@ -85,7 +85,7 @@
<input type="text" :disabled="true" placeholder="未获取" :value="notificationSoundAuthorized" />
</view>
</view>
<!-- #endif -->
<!-- #endif -->
</view>
<view class="uni-padding-wrap">
<view class="uni-btn-v">
......
......@@ -30,7 +30,7 @@
items: [] as Item[],
}
},
onUnload:function(){
onUnload: function () {
},
methods: {
getAppBaseInfo: function () {
......@@ -44,12 +44,12 @@
});
this.items = [] as Item[];
keys.sort().forEach( key => {
keys.sort().forEach(key => {
const value = res[key];
if(value != null){
if (value != null) {
const item = {
label: key,
value: "" + ((typeof value == "object")? JSON.stringify(value) : value)
value: "" + ((typeof value == "object") ? JSON.stringify(value) : value)
} as Item;
this.items.push(item);
}
......
const PAGE_PATH = '/pages/API/get-app/get-app'
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
describe('getApp', () => {
let page = null
......@@ -47,4 +49,8 @@ describe('getApp', () => {
expect(newLifeCycleNum - oldLifeCycleNum).toBe(100)
await page.callMethod('setLifeCycleNum', oldLifeCycleNum)
})
it('getAndroidApplication', async () => {
const res = await page.callMethod('getAndroidApplication')
expect(res).toBe(isAndroid)
})
})
......@@ -39,6 +39,10 @@
increase lifeCycleNum
</button>
<text class="uni-common-mt">lifeCycleNum: {{ lifeCycleNum }}</text>
<button class="uni-common-mt" @click="getAndroidApplication">
getAndroidApplication
</button>
<text class="uni-common-mt">androidApplication is null: {{ androidApplication == null }}</text>
</view>
</view>
<!-- #ifdef APP -->
......@@ -97,6 +101,7 @@
} as MyGlobalData,
newGlobalDataFuncRes: '',
lifeCycleNum: 0,
androidApplication: null as any | null
}
},
onReady() {
......@@ -161,12 +166,17 @@
},
_increasetLifeCycleNum: function () {
const app = getApp()
app.increasetLifeCycleNum()
app.vm!.increasetLifeCycleNum()
this.lifeCycleNum = state.lifeCycleNum
},
// 自动化测试
setLifeCycleNum(num : number) {
setLifeCycleNum(num)
},
getAndroidApplication() : boolean {
const app = getApp()
this.androidApplication = app.getAndroidApplication()
return this.androidApplication !== null
}
},
}
......
const HOME_PAGE_PATH = '/pages/tabBar/component'
const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages'
const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages?test=123'
describe('getCurrentPages', () => {
let page
......@@ -25,8 +25,6 @@ describe('getCurrentPages', () => {
expect(data.checked).toBe(true)
})
it('page-style', async () => {
page = await program.navigateTo(PAGE_PATH)
await page.callMethod('getPageStyle')
await page.waitFor(200)
const isEnablePullDownRefresh1 = (await page.data()).currentPageStyle.enablePullDownRefresh
......@@ -63,4 +61,25 @@ describe('getCurrentPages', () => {
return 'get-current-pages-test-js-get-current-pages-page-style-after-set-page-style'
}});
})
it('$page', async () => {
await page.setData({testing: true})
const res = await page.callMethod('check$page')
expect(res).toBe(true)
})
it('getParentPage', async () => {
const res = await page.callMethod('checkGetParentPage')
expect(res).toBe(true)
})
it('getDialogPages', async () => {
const res = await page.callMethod('checkGetDialogPages')
expect(res).toBe(true)
})
it('getElementById', async () => {
const res = await page.callMethod('checkGetElementById')
expect(res).toBe(true)
})
it('getAndroidView', async () => {
const res = await page.callMethod('checkGetAndroidView')
expect(res).toBe(true)
})
})
......@@ -12,14 +12,29 @@
<text style="margin-top: 5px">index: {{ index }}, route: {{ page.route }}</text>
</template>
</view>
<button class="uni-common-mt" @click="check$page">check $page</button>
<button class="uni-common-mt" @click="checkGetParentPage">
check getParentPage
</button>
<button class="uni-common-mt" @click="checkGetDialogPages">
check getDialogPages
</button>
<button id="check-get-element-by-id-btn" class="uni-common-mt" @click="checkGetElementById">
check getElementById
</button>
<button class="uni-common-mt" @click="checkGetAndroidView">
check getAndroidView
</button>
</view>
<page-head title="currentPageStyle"></page-head>
<template v-for="(item, index) in PageStyleArray">
<view class="page-style-item" v-if="currentPageStyle[item.key]!=null" :key="index">
<view class="page-style-item" v-if="currentPageStyle[item.key] != null" :key="index">
<view class="item-text">
<text class="item-text-key">{{item.key}}:</text>
<text class="item-text-value">{{currentPageStyle[item.key]}}</text>
<text class="item-text-key">{{ item.key }}:</text>
<text class="item-text-value">{{
currentPageStyle[item.key]
}}</text>
</view>
<view class="set-value" v-if="item.type == 'boolean'">
<switch :checked="currentPageStyle.getBoolean(item.key)"
......@@ -32,13 +47,15 @@
</view>
<view class="set-value" v-else-if="item.type == 'string'">
<radio-group class="radio-set-value" @change="radioChange(item.key, $event as RadioGroupChangeEvent)">
<radio class="radio-value" v-for="(item2, index2) in item.value" :key="index2" :value="item2">{{item2}}
<radio class="radio-value" v-for="(item2, index2) in item.value" :key="index2" :value="item2">{{ item2 }}
</radio>
</radio-group>
</view>
</view>
</template>
<button style='margin: 10px;' @click="goSetDisablePullDownRefresh">go set disable pullDownRefresh</button>
<button style="margin: 10px" @click="goSetDisablePullDownRefresh">
go set disable pullDownRefresh
</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
......@@ -60,6 +77,7 @@
pages: [] as Page[],
PageStyleArray: PageStyleArray as PageStyleItem[],
currentPageStyle: {} as UTSJSONObject,
testing: false
}
},
computed: {
......@@ -67,7 +85,15 @@
return JSON.stringify(this.currentPageStyle)
}
},
onLoad() {
onLoad(options : OnLoadOptions) {
// #ifndef APP-ANDROID
if (options instanceof UTSJSONObject) {
this.checked = true
}
// #endif
// #ifdef APP-ANDROID
this.checked = true
// #endif
this.getPageStyle();
},
onPullDownRefresh() {
......@@ -83,7 +109,7 @@
this.pages.length = 0
const pages = getCurrentPages()
this.pages.push(new Page(pages[0].route))
if (this.pages[0].route.includes('/tabBar/')) {
if (this.checked && (this.pages[0].route.includes('/tabBar/') || this.pages[0].route == '/')) {
this.checked = true
}
for (let i = 1; i < pages.length; i++) {
......@@ -112,25 +138,86 @@
getPageStyle() : UTSJSONObject {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
this.currentPageStyle = currentPage.$getPageStyle()
this.currentPageStyle = currentPage.getPageStyle()
return this.currentPageStyle;
},
setPageStyle(style : UTSJSONObject) {
console.log('setPageStyle:', style);
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage.$setPageStyle(style);
currentPage.setPageStyle(style);
},
goSetDisablePullDownRefresh() {
uni.navigateTo({
url: '/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh'
});
},
getCurrentPage() : UniPage {
const pages = getCurrentPages()
return pages[pages.length - 1]
},
check$page() : boolean {
const page = this.getCurrentPage()
let res = this.$page === page
if (this.testing && res) {
res = page.options['test'] == '123'
if (res) {
// #ifdef WEB
res = page.route == '/pages/API/get-current-pages/get-current-pages'
// #endif
// #ifndef WEB
res = page.route == 'pages/API/get-current-pages/get-current-pages'
// #endif
}
}
// getCurrentPage(): Page {
// const pages = getCurrentPages();
// const currentPage = pages[pages.length - 1];
// return currentPage;
// }
console.log('check $page', res)
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
return res
},
checkGetParentPage() : boolean {
const page = this.getCurrentPage()
const parentPage = page.getParentPage()
const res = parentPage == null
console.log('check getParentPage', res)
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
return res
},
checkGetDialogPages() : boolean {
const page = this.getCurrentPage()
const dialogPages = page.getDialogPages()
const res = Array.isArray(dialogPages) && dialogPages.length == 0
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
console.log('check getDialogPages', res)
return res
},
checkGetElementById() : boolean {
const page = this.getCurrentPage()
const element = page.getElementById('check-get-element-by-id-btn')
let res = element != null
// #ifndef APP-ANDROID
if (res) {
const elPage = element!.getPage()
console.log('elPage', elPage)
res = elPage === page
}
// #endif
console.log('check getElementById', res)
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
return res
},
checkGetAndroidView() : boolean {
const page = this.getCurrentPage()
const androidView = page.getAndroidView()
// #ifdef APP-ANDROID
const res = androidView != null
// #endif
// #ifndef APP-ANDROID
const res = androidView == null
// #endif
console.log('check getAndroidView', res)
uni.showToast(res ? { title: 'check success' } : { title: 'check fail', icon: 'error' })
return res
},
},
}
</script>
......
......@@ -2,7 +2,7 @@
export type PageStyleItem = {
key : string
type : string
value: Array<any>
value : Array<any>
}
export const PageStyleArray = [
......@@ -70,4 +70,14 @@ export const PageStyleArray = [
key: "navigationBarAutoBackButton",
type: "boolean",
value: [true, false]
},
{
key: "hideStatusBar",
type: "boolean",
value: [true, false]
},
{
key: "hideBottomNavigationIndicator",
type: "boolean",
value: [true, false]
}] as PageStyleItem[]
......@@ -44,13 +44,13 @@
getPageStyle() {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
this.currentPageStyle = currentPage.$getPageStyle();
this.currentPageStyle = currentPage.getPageStyle();
},
setPageStyle(enable : boolean) {
// 目前仅支持 enablePullDownRefresh
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage.$setPageStyle({
currentPage.setPageStyle({
enablePullDownRefresh: enable
});
this.enablePullDownRefreshStatus = enable
......
......@@ -51,7 +51,7 @@
uni.navigateTo({ url: '/pages/API/get-element-by-id/get-element-by-id-multiple-root-node' })
},
//自动化测试获取text元素的offsetLeft属性值
getTextOffsetLeft(): number {
getTextOffsetLeft() : number {
const text = uni.getElementById('text')!
return text.offsetLeft
}
......
......@@ -13,7 +13,8 @@
data() {
return {
enterOptionsString: '',
testResult: false }
testResult: false
}
},
onReady() {
const app = getApp()
......
......@@ -3,7 +3,8 @@ const PAGE_PATH = '/pages/API/get-file-system-manager/get-file-system-manager'
describe('ExtApi-FileManagerTest', () => {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW ==
'true') {
it('dummyTest', () => {
expect(1).toBe(1)
})
......@@ -427,10 +428,12 @@ describe('ExtApi-FileManagerTest', () => {
fileListComplete = await getData('fileListComplete')
fileListComplete.sort()
expect(JSON.stringify(fileListComplete)).toEqual("[\"b\",\"" + testDirName + "\",\"提前创建的目录\"]")
expect(JSON.stringify(fileListComplete)).toEqual("[\"b\",\"" + testDirName +
"\",\"提前创建的目录\"]")
fileListSuccess = await getData('fileListSuccess')
fileListSuccess.sort()
expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\",\"" + testDirName + "\",\"提前创建的目录\"]")
expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\",\"" + testDirName +
"\",\"提前创建的目录\"]")
await page.setData({
......@@ -1142,7 +1145,8 @@ describe('ExtApi-FileManagerTest', () => {
}
function isAndroid() {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW === 'true') {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW ===
'true') {
expect(1).toBe(1)
return false
}
......@@ -1307,9 +1311,10 @@ describe('ExtApi-FileManagerTest', () => {
await isDone()
let bytesWritten = await getData("bytesWritten")
let lastFailError = await getData("lastFailError")
if(bytesWritten != 7){
if (bytesWritten != 7) {
let writeData = await getData("writeData")
console.log('writeTest',lastFailError.errCode,lastFailError.errMsg,bytesWritten,writeData)
console.log('writeTest', lastFailError.errCode, lastFailError.errMsg, bytesWritten,
writeData)
}
expect(bytesWritten).toEqual(7)
......@@ -1405,4 +1410,77 @@ describe('ExtApi-FileManagerTest', () => {
expect(ftruncateRet).toEqual('ftruncate:ok')
console.log('ftruncateFileTest', '7')
});
//testAppendFileBuffer
it('testAppendFileBuffer', async () => {
if (!isAndroid()) {
return
}
var btnWrite = await page.$('#btn-appendfile-buffer')
await btnWrite.tap()
await isDone()
let arrayBufferRes = await getData("arrayBufferRes")
expect(arrayBufferRes).toEqual(21)
});
it('testAppendFileBufferSync', async () => {
if (!isAndroid()) {
return
}
var btnWrite = await page.$('#btn-appendfilesync-buffer')
await btnWrite.tap()
await isDone()
let arrayBufferRes = await getData("arrayBufferRes")
expect(arrayBufferRes).toEqual(20)
});
it('testWriteReadSyncBuffer', async () => {
if (!isAndroid()) {
return
}
var btnWrite = await page.$('#btn-writereadsync-buffer')
await btnWrite.tap()
await isDone()
let arrayBufferRes = await getData("arrayBufferRes")
expect(arrayBufferRes).toEqual(1.11)
});
it('testWriteReadBuffer', async () => {
if (!isAndroid()) {
return
}
var btnWrite = await page.$('#btn-writeread-buffer')
await btnWrite.tap()
await isDone()
let arrayBufferRes = await getData("arrayBufferRes")
expect(arrayBufferRes).toEqual(1.24)
});
it('testWriteReadFileSyncBuffer', async () => {
if (!isAndroid()) {
return
}
var btnWrite = await page.$('#btn-writereadfilesync-buffer')
await btnWrite.tap()
await isDone()
let arrayBufferRes = await getData("arrayBufferRes")
expect(arrayBufferRes).toEqual(1.333)
});
it('testReadFileBuffer', async () => {
if (!isAndroid()) {
return
}
var btnWrite = await page.$('#btn-writereadfile-buffer')
await btnWrite.tap()
await isDone()
let arrayBufferRes = await getData("arrayBufferRes")
expect(arrayBufferRes).toEqual(1.2222222)
});
});
......@@ -52,7 +52,7 @@
uni.getImageInfo({
src: res.tempFilePaths[0],
success: (_res) => {
console.log("getImageInfo success", JSON.stringify(res));
console.log("getImageInfo success", JSON.stringify(_res));
this.relativeImageInfo = `图片宽度: ${_res.width}\n图片高度: ${_res.height}\n图片路径: ${_res.path}\n图片方向: ${_res.orientation}\n图片格式: ${_res.type}`;
},
fail: (err) => {
......
......@@ -14,7 +14,6 @@
</template>
<script>
export default {
data() {
return {
......@@ -25,7 +24,7 @@
testResult: false
}
},
onReady(){
onReady() {
this.compareOnLaunchRes()
},
methods: {
......
......@@ -25,12 +25,12 @@
// #ifdef APP-IOS
viewName = "UIView"
// #endif
const msg = "检测view组件对应原生"+viewName
const msg = "检测view组件对应原生" + viewName
if (checkViewNativeView("view")) {
this.showTip(msg+"成功")
this.showTip(msg + "成功")
return true
}
this.showTip(msg+"失败")
this.showTip(msg + "失败")
return false
},
checkInputNativeView() : boolean {
......@@ -38,12 +38,12 @@
// #ifdef APP-IOS
viewName = "UITextField"
// #endif
const msg = "检测input组件对应原生"+viewName
const msg = "检测input组件对应原生" + viewName
if (checkInputNativeView("input")) {
this.showTip(msg+"成功")
this.showTip(msg + "成功")
return true
}
this.showTip(msg+"失败")
this.showTip(msg + "失败")
return false
},
checkTextareaNativeView() : boolean {
......@@ -51,12 +51,12 @@
// #ifdef APP-IOS
viewName = "UITextView"
// #endif
const msg = "检测textarea组件对应原生"+viewName
const msg = "检测textarea组件对应原生" + viewName
if (checkTextareaNativeView("textarea")) {
this.showTip(msg+"成功")
this.showTip(msg + "成功")
return true
}
this.showTip(msg+"失败")
this.showTip(msg + "失败")
return false
},
checkWebViewNativeView() : boolean {
......@@ -64,16 +64,16 @@
// #ifdef APP-IOS
viewName = "WKWebView"
// #endif
const msg = "检测webview组件对应原生"+viewName
const msg = "检测webview组件对应原生" + viewName
if (checkWebViewNativeView("webview")) {
this.showTip(msg+"成功")
this.showTip(msg + "成功")
return true
}
this.showTip(msg+"失败")
this.showTip(msg + "失败")
return false
},
showTip(title: string) {
console.log("title==="+title)
showTip(title : string) {
console.log("title===" + title)
uni.showToast({
title: title,
icon: "none"
......
......@@ -56,6 +56,13 @@ describe('ExtApi-GetSystemInfo', () => {
expect(['light', 'dark', 'auto']).toContain(value);
}
}
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (res.safeAreaInsets.bottom > 0) {
expect(res.safeAreaInsets.top + 44 + res.windowHeight).toBe(res.screenHeight);
} else {
expect(res.safeAreaInsets.top + 44 + res.windowHeight).toBe(res.safeArea.bottom);
}
}
});
it('Check GetSystemInfoSync required properties', async () => {
for (let i = 0; i < requiredProperties.length; i++) {
......
......@@ -64,11 +64,11 @@
this.wifiEnabled = (res.wifiEnabled ?? false) ? "开启" : "关闭";
this.deviceOrientation = res.deviceOrientation
if(res.bluetoothError != null){
if (res.bluetoothError != null) {
this.bluetoothEnabled = "无蓝牙权限"
}
if(res.wifiError != null){
if (res.wifiError != null) {
this.wifiEnabled = "无WiFi权限"
}
}
......
......@@ -3,6 +3,13 @@
<scroll-view style="flex:1">
<!-- #endif -->
<page-head :title="title"></page-head>
<view class="uni-padding-wrap">
<view class="uni-title">
<text class="uni-subtitle-text">获取本地相对路径视频信息</text>
</view>
<video class="video" :src="relativeVideoPath" :controls="true"></video>
<text class="margin-top-10">{{relativeVideoInfo}}</text>
</view>
<view class="uni-padding-wrap">
<view class="uni-title">
<text class="uni-subtitle-text">获取本地绝对路径视频信息</text>
......@@ -23,12 +30,30 @@
data() {
return {
title: "getVideoInfo",
relativeVideoPath: "/static/test-video/10second-demo.mp4",
relativeVideoInfo: "",
absoluteVideoPath: "",
absoluteVideoInfo: "",
// 自动化测试
videoInfoForTest: null as UTSJSONObject | null
}
},
onReady() {
uni.getVideoInfo({
src: this.relativeVideoPath,
success: (res) => {
console.log("getVideoInfo success", JSON.stringify(res));
this.relativeVideoInfo = `视频画面方向: ${res.orientation}\n视频格式: ${res.type}\n视频长度: ${res.duration}s\n视频大小: ${res.size}KB\n视频宽度: ${res.width}\n视频高度: ${res.height}\n视频帧率: ${res.fps}fps\n视频码率: ${res.bitrate}kbps`;
},
fail: (err) => {
uni.showModal({
title: "获取视频信息失败",
content: JSON.stringify(err),
showCancel: false
});
}
});
},
methods: {
chooseVideo() {
uni.chooseVideo({
......@@ -38,7 +63,7 @@
uni.getVideoInfo({
src: res.tempFilePath,
success: (_res) => {
console.log("getVideoInfo success", JSON.stringify(res));
console.log("getVideoInfo success", JSON.stringify(_res));
this.absoluteVideoInfo = `视频画面方向: ${_res.orientation}\n视频格式: ${_res.type}\n视频长度: ${_res.duration}s\n视频大小: ${_res.size}KB\n视频宽度: ${_res.width}\n视频高度: ${_res.height}\n视频帧率: ${_res.fps}fps\n视频码率: ${_res.bitrate}kbps`;
},
fail: (err) => {
......
......@@ -24,5 +24,12 @@ describe('ExtApi-GetWindowInfo', () => {
expect(value).toBeGreaterThanOrEqual(0);
}
}
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (res.safeAreaInsets.bottom > 0) {
expect(res.safeAreaInsets.top + 44 + res.windowHeight).toBe(res.screenHeight);
} else {
expect(res.safeAreaInsets.top + 44 + res.windowHeight).toBe(res.safeArea.bottom);
}
}
});
});
......@@ -15,6 +15,13 @@
<view class="uni-btn-v">
<button type="primary" @tap="getWindowInfo">获取窗口信息</button>
</view>
<!-- #ifdef APP-ANDROID -->
<view class="uni-btn-v">
<navigator url="/pages/API/get-window-info/window-area">
<button type="primary">窗口各区域示例</button>
</navigator>
</view>
<!-- #endif -->
</view>
</view>
</template>
......
<template>
<view style="flex:1;">
<view id="statusBar" class="statusBar" v-if="statusBarArea.width > 0 && statusBarArea.height > 0"
:style="{'width': statusBarArea.width,'height': statusBarArea.height}">
</view>
<view id="cutoutArea" class="cutoutArea" v-if="cutoutArea.length > 0" v-for="(item, _) in cutoutArea"
:style="{'top': item.top,'left': item.left,'width': item.width,'height': item.height}"></view>
<view id="safeArea" class="safeArea"
:style="{'top': safeArea.top,'left': safeArea.left,'width': safeArea.width,'height': safeArea.height}"></view>
<view id="bottomNavigationIndicator" class="bottomNavigationIndicator"
v-if="bottomNavigationIndicatorArea.width > 0 && bottomNavigationIndicatorArea.height > 0"
:style="{'width': bottomNavigationIndicatorArea.width,'height': bottomNavigationIndicatorArea.height}"></view>
<view style="flex: 1;justify-content: center;align-items: center;">
<view v-if="statusBarArea.width > 0 && statusBarArea.height > 0" style="margin: 5px 0;">
<text style="color: red;">系统状态栏区域</text>
</view>
<view v-if="cutoutArea.length > 0" style="margin: 5px 0;">
<text style="color: orange;">摄像头区域</text>
</view>
<view style="margin: 5px 0;">
<text style="color: green;">安全区域</text>
</view>
<view v-if="bottomNavigationIndicatorArea.width > 0 && bottomNavigationIndicatorArea.height > 0"
style="margin: 5px 0;">
<text style="color: blue;">系统导航栏区域</text>
</view>
<!-- <view style="flex-direction: row;align-items: center;margin: 5px 0">
<text>显示系统状态栏</text>
<switch :checked="isStatusBarShow" @change="statusBarChange"></switch>
</view>
<view style="flex-direction: row;align-items: center;margin: 5px 0">
<text>显示系统导航栏</text>
<switch :checked="isBottomNavigationIndicatorShow" @change="bottomNavigationIndicatorChange"></switch>
</view> -->
</view>
</view>
</template>
<script setup>
type StatusBarArea = {
width : number,
height : number
}
type CutoutArea = {
top : number,
left : number,
width : number,
height : number
}
type SafeArea = {
top : number,
left : number,
width : number,
height : number
}
type BottomNavigationIndicatorArea = {
width : number,
height : number
}
const statusBarArea = ref({ width: 0, height: 0 } as StatusBarArea);
const cutoutArea = ref([] as CutoutArea[]);
const safeArea = ref({ top: 0, left: 0, width: 0, height: 0 } as SafeArea);
const bottomNavigationIndicatorArea = ref({ width: 0, height: 0 } as BottomNavigationIndicatorArea);
const isStatusBarShow = ref(false);
const isBottomNavigationIndicatorShow = ref(false);
const getWindowInfo = () => {
const info = uni.getWindowInfo();
statusBarArea.value.width = info.windowWidth;
statusBarArea.value.height = info.safeAreaInsets.top;
cutoutArea.value.length = 0;
(info.cutoutArea ?? []).forEach((item) => {
cutoutArea.value.push({
top: item.top,
left: item.left,
width: item.right - item.left,
height: item.bottom - item.top
} as CutoutArea);
})
safeArea.value.top = info.safeArea.top;
safeArea.value.left = info.safeArea.left;
safeArea.value.width = info.safeArea.width;
safeArea.value.height = info.safeArea.height;
bottomNavigationIndicatorArea.value.width = info.windowWidth;
bottomNavigationIndicatorArea.value.height = info.safeAreaInsets.bottom;
};
const statusBarChange = (e : UniSwitchChangeEvent) => {
const pages = getCurrentPages();
pages[pages.length - 1].setPageStyle({
'hideStatusBar': !e.detail.value,
});
};
const bottomNavigationIndicatorChange = (e : UniSwitchChangeEvent) => {
const pages = getCurrentPages();
pages[pages.length - 1].setPageStyle({
'hideBottomNavigationIndicator': !e.detail.value,
});
};
onReady(() => {
const pages = getCurrentPages();
isStatusBarShow.value = !(pages[pages.length - 1].getPageStyle()['hideStatusBar'] as boolean);
isBottomNavigationIndicatorShow.value = !(pages[pages.length - 1].getPageStyle()['hideBottomNavigationIndicator'] as boolean);
getWindowInfo();
});
onResize((_ : OnResizeOptions) => {
getWindowInfo();
});
</script>
<style>
.statusBar {
position: absolute;
border-style: solid;
border-color: red;
border-width: 4px;
}
.cutoutArea {
position: absolute;
border-style: solid;
border-color: orange;
border-width: 4px;
}
.safeArea {
position: absolute;
border-style: solid;
border-color: green;
border-width: 4px;
}
.bottomNavigationIndicator {
position: absolute;
bottom: 0;
border-style: solid;
border-color: blue;
border-width: 4px;
}
</style>
......@@ -16,7 +16,7 @@
return {
title: 'makePhoneCall',
disabled: true,
inputValue:''
inputValue: ''
}
},
methods: {
......@@ -46,6 +46,6 @@
line-height: 119rpx;
font-size: 78rpx;
border-bottom: 1rpx solid #E2E2E2;
text-align:center;
text-align: center;
}
</style>
......@@ -42,7 +42,8 @@
<button @tap="navigateToErrorPage" class="uni-btn">
打开不存在的页面
</button>
<button v-for="(item, _) in animationTypeList" @tap="navigateToAnimationType(item)" class="uni-btn">navigateTo动画({{item}})</button>
<button v-for="(item, _) in animationTypeList" @tap="navigateToAnimationType(item)"
class="uni-btn">navigateTo动画({{item}})</button>
</view>
</view>
</view>
......@@ -140,7 +141,7 @@
},
})
},
navigateToAnimationType(animationType: AnimationType) {
navigateToAnimationType(animationType : AnimationType) {
uni.navigateTo({
url: '/pages/API/navigator/new-page/new-page-1?data=Hello',
animationType: animationType,
......
......@@ -10,22 +10,22 @@
</template>
<script lang="uts">
import { state } from '@/store/index.uts'
import { state } from '@/store/index.uts'
export default {
export default {
data() {
return {
data: '',
}
},
onLoad(options: OnLoadOptions) {
onLoad(options : OnLoadOptions) {
if (options['data'] != null) {
this.data = options['data']!
}
},
methods: {
// 自动化测试
getLifeCycleNum(): number {
getLifeCycleNum() : number {
return state.lifeCycleNum
},
navigateBackWithDelta2() {
......@@ -39,11 +39,11 @@ export default {
},
})
},
navigateToOnLoadWithType(type: string) {
navigateToOnLoadWithType(type : string) {
uni.navigateTo({
url: `/pages/API/navigator/new-page/onLoad?type=${type}`,
})
}
},
}
}
</script>
......@@ -16,7 +16,7 @@
</template>
<script lang="uts">
export default {
export default {
data() {
return {
isTrue: false,
......@@ -128,5 +128,5 @@ export default {
})
}
}
}
}
</script>
......@@ -49,7 +49,7 @@
</template>
<script lang="uts">
export default {
data () {
data() {
return {
title: 'openLocation'
}
......
<template>
<view class="uni-padding-wrap">
<page-head :title="title"></page-head>
<view class="item-box">
<text>当前应用隐私授权状态:</text>
<text>{{ appPrivacy }}</text>
</view>
<view>
<button class="privacy-button" type="primary" @tap="getPrivacySetting">
获取隐私协议授权状态
</button>
<button class="privacy-button" type="primary" open-type="agreePrivacyAuthorization">
同意隐私协议
</button>
<button class="privacy-button" type="primary" @tap="resetPrivacyAuthorization">
重置隐私协议授权状态
</button>
</view>
</view>
</template>
<script>
export default {
data() {
return {
title: '隐私信息授权',
appPrivacy: '未获取',
listenId: 0
}
},
onReady() {
//添加 隐私协议监听
const id = uni.onPrivacyAuthorizationChange((res) => {
this.appPrivacy = res.needAuthorization ? "未同意" : "已同意"
const privacyState = "监听到隐私协议状态已变更为 " + this.appPrivacy;
uni.showToast({
"position": "bottom",
"title": privacyState
})
})
this.listenId = id;
uni.showToast({
"position": "bottom",
"title": "开启监听隐私协议状态"
})
},
onUnload() {
//注销监听
uni.offPrivacyAuthorizationChange(this.listenId)
this.listenId = 0;
uni.showToast({
"position": "bottom",
"title": "已停止监听隐私协议状态"
})
},
methods: {
getPrivacySetting() {
uni.getPrivacySetting({
success: (res) => {
this.appPrivacy = res.needAuthorization ? "未同意" : "已同意"
}
})
},
resetPrivacyAuthorization(){
uni.resetPrivacyAuthorization()
}
}
}
</script>
<style>
.item-box {
margin-bottom: 10px;
display: flex;
flex-direction: row;
justify-content: space-between;
}
.privacy-button{
margin-top: 5px;
margin-bottom: 5px;
}
</style>
......@@ -2,7 +2,7 @@
<view class="app">
<view>
<view class="label">支付单号:</view>
<view><input class="input" v-model="out_trade_no" placeholder="点击发起支付会自动生成"/></view>
<view><input class="input" v-model="out_trade_no" placeholder="点击发起支付会自动生成" /></view>
</view>
<view>
<view class="label">支付金额(单位分,100=1元):</view>
......@@ -27,9 +27,11 @@
<!-- #endif -->
<button class="button" @click="getOrderPopup(true)">查询支付状态</button>
<button class="button" @click="pageTo('/uni_modules/uni-pay-x/pages/success/success?out_trade_no=test2024030501-1&order_no=test2024030501&total_fee=1&adpid=1000000001&return_url=/pages/API/request-payment/request-payment/order-detail')">支付成功页面示例</button>
<button class="button"
@click="pageTo('/uni_modules/uni-pay-x/pages/success/success?out_trade_no=test2024030501-1&order_no=test2024030501&total_fee=1&adpid=1000000001&return_url=/pages/API/request-payment/request-payment/order-detail')">支付成功页面示例</button>
<!-- #ifdef APP-IOS -->
<button class="button" @click="pageTo('/pages/API/virtual-payment/virtual-payment-uni-pay')">苹果虚拟支付示例(iOS内购)</button>
<button class="button"
@click="pageTo('/pages/API/virtual-payment/virtual-payment-uni-pay')">苹果虚拟支付示例(iOS内购)</button>
<!-- #endif -->
<!-- 查询支付的弹窗 -->
<uni-pay-popup ref="getOrderPopupRef" type="center">
......@@ -55,11 +57,13 @@
</view>
<view class="table-tr">
<view class="table-td label"><text class="text align-left">支付金额</text></view>
<view class="table-td"><text class="text align-right">{{ amountFormat(getOrderRes.getNumber('total_fee')) }}</text></view>
<view class="table-td"><text
class="text align-right">{{ amountFormat(getOrderRes.getNumber('total_fee')) }}</text></view>
</view>
<view class="table-tr">
<view class="table-td label"><text class="text align-left">支付方式</text></view>
<view class="table-td"><text class="text align-right">{{ providerFormat(getOrderRes['provider'] as string) }}</text></view>
<view class="table-td"><text
class="text align-right">{{ providerFormat(getOrderRes['provider'] as string) }}</text></view>
</view>
<view class="table-tr">
<view class="table-td label"><text class="text align-left">第三方交易单号</text></view>
......@@ -93,8 +97,9 @@
<button class="button" v-if="h5Env === 'h5-weixin'" @click="getWeiXinJsCode('snsapi_base')">公众号获取openid示例</button>
<!-- #endif -->
<!-- 统一支付组件,注意:vue3下ref不可以等于组件名,因此这里ref="pay" 而不能是 ref="uniPay" -->
<uni-pay ref="payRef" :adpid="adpid" height="900rpx" return-url="/pages/API/request-payment/request-payment/order-detail" logo="/static/logo.png" @success="onSuccess" @create="onCreate"
@fail="onFail" @cancel="onCancel"></uni-pay>
<uni-pay ref="payRef" :adpid="adpid" height="900rpx"
return-url="/pages/API/request-payment/request-payment/order-detail" logo="/static/logo.png" @success="onSuccess"
@create="onCreate" @fail="onFail" @cancel="onCancel"></uni-pay>
</view>
</template>
......@@ -140,7 +145,7 @@
code
});
}, 300);
} else if (!openid){
} else if (!openid) {
// 如果openid为空,则执行微信公众号的网页授权登录逻辑
setTimeout(() => {
this.getWeiXinJsCode('snsapi_base');
......@@ -327,7 +332,7 @@
}
},
// 获取公众号openid
async getOpenid(data:UTSJSONObject) : Promise<void> {
async getOpenid(data : UTSJSONObject) : Promise<void> {
const payInstance = this.$refs["payRef"] as UniPayComponentPublicInstance;
let res = await payInstance.getOpenid(data);
if (res['openid'] != null && res['openid'] != "") {
......
......@@ -77,7 +77,7 @@
// #endif
class GETDataType {
data: UTSJSONObject | null = null
data : UTSJSONObject | null = null
}
const duration = 2000
......@@ -260,7 +260,7 @@
},
});
},
jest_set_cookie_expires(){
jest_set_cookie_expires() {
uni.request({
url: this.host + "/api/http/header/setCookie?expires=5",
method: "GET",
......@@ -301,7 +301,7 @@
withCredentials: false,
firstIpv4: false,
success: (res) => {
const requestCookie = (res.data as UTSJSONObject).getJSON("data")?.getAny("requestCookie")
const requestCookie = (JSON.parse(JSON.stringify(res.data)) as UTSJSONObject).getJSON("data")?.getAny("requestCookie")
this.jest_result_data = JSON.stringify(requestCookie)
if (requestCookie instanceof Array) {
this.jest_result = needCookie ? requestCookie.length > 0 : requestCookie.length == 0
......@@ -334,7 +334,7 @@
uni.request({
url: "https://unidemo.dcloud.net.cn/api/banner/36kr",
method: "GET",
data:{
data: {
column: 'id,post_id,title,author_name,cover,published_at' //需要的字段名
},
timeout: 6000,
......@@ -357,7 +357,7 @@
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success: (res: RequestSuccess<GETDataType>) => {
success: (res : RequestSuccess<GETDataType>) => {
this.jest_result = true;
},
fail: () => {
......@@ -381,30 +381,30 @@
}
});
},
jest_uts_module_invoked(){
jest_uts_module_invoked() {
// #ifdef APP
testInovkeRequest({
success:(res: any)=>{
success: (res : any) => {
this.jest_result = true
},
fail:(err: any)=>{
fail: (err : any) => {
this.jest_result = false
}
} as CommonOptions)
// #endif
},
jest_respone_json_string(){
jest_respone_json_string() {
uni.request({
url:"https://request.dcloud.net.cn/api/http/contentType/text/json",
success:(res: RequestSuccess<any>)=>{
url: "https://request.dcloud.net.cn/api/http/contentType/text/json",
success: (res : RequestSuccess<any>) => {
this.jest_result = typeof res.data == "object"
},
fail:(e: RequestFail)=>{
fail: (e : RequestFail) => {
this.jest_result = false
}
})
},
jest_respone_with_string_generics(){
jest_respone_with_string_generics() {
uni.request<string>({
url: this.host + (methodMap['GET'] as string),
method: "GET",
......@@ -412,7 +412,7 @@
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success: (res: RequestSuccess<string>) => {
success: (res : RequestSuccess<string>) => {
this.jest_result = true;
},
fail: () => {
......
......@@ -112,12 +112,12 @@
"devicePixelContentBoxSize: \n{blockSize:" + devicePixelContentBoxSize.blockSize + ", inlineSize:" + devicePixelContentBoxSize.inlineSize + "}\n" +
"contentRect: \n{x:" + entry.contentRect.x + ", y:" + entry.contentRect.y + ", width:" + entry.contentRect.width + ", height:" + entry.contentRect.height + "}"
},
cancelListen(){
cancelListen() {
// this.resizeObserver?.unobserve()
this.resizeObserver!.unobserve(this.outBoxElement!)
this.resizeObserver!.unobserve(this.innerBoxElement!)
},
goOnListen(){
goOnListen() {
this.resizeObserver!.observe(this.outBoxElement!)
this.resizeObserver!.observe(this.innerBoxElement!)
}
......
// uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android')
describe('API-saveImageToPhotosAlbum', () => {
if (process.env.uniTestPlatformInfo.startsWith('web') || process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
if (!isAndroid) {
it('pass', async () => {
expect(1).toBe(1);
});
......@@ -14,11 +17,9 @@ describe('API-saveImageToPhotosAlbum', () => {
});
it('test saveImageToPhotosAlbum', async () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
await program.adbCommand(
'pm grant io.dcloud.uniappx android.permission.WRITE_EXTERNAL_STORAGE');
await page.waitFor(500);
}
await page.callMethod('saveImage');
expect(await page.data('success')).toBe(true);
});
......
......@@ -8,7 +8,7 @@
export default {
data() {
return {
isChange : false,
isChange: false,
currentBackgroundColorContent: "" as any | null
}
},
......@@ -16,10 +16,10 @@
changeColor() {
let pages = getCurrentPages()
let page = pages[pages.length - 1]
page.$setPageStyle({"backgroundColorContent" : this.isChange ? "" : "red"})
page.setPageStyle({ "backgroundColorContent": this.isChange ? "" : "red" })
this.isChange = !this.isChange
let pageJson = page.$getPageStyle()
let pageJson = page.getPageStyle()
this.currentBackgroundColorContent = pageJson["backgroundColorContent"]
}
}
......
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1;">
<!-- #endif -->
<view>
<page-head :title="title"></page-head>
<view class="uni-list">
......@@ -25,10 +28,14 @@
</view>
<view class="uni-padding-wrap">
<view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="actionSheetTap" id="btn-action-sheet-show">弹出action sheet</button>
<button class="uni-btn-v" type="default" @tap="actionSheetTap" id="btn-action-sheet-show">弹出action
sheet</button>
</view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="uts">
type ItemType = {
......@@ -42,7 +49,7 @@
itemColorCustom: false,
itemContentLarge: false,
itemNumLargeSelect: false,
showErrorToast:true,
showErrorToast: true,
items: [{
value: '标题',
name: '有标题'
......@@ -59,10 +66,10 @@
current: 0,
}
},
onLoad(){
onLoad() {
uni.showActionSheet({
title: "onLoad 调用示例,请手动取消",
itemList:['item1', 'item2'],
itemList: ['item1', 'item2'],
})
},
methods: {
......@@ -117,7 +124,7 @@
})
},
fail: (e) => {
if(this.showErrorToast){
if (this.showErrorToast) {
uni.showToast({
title: e.errMsg,
icon: "none"
......@@ -139,7 +146,7 @@
},
fail: (e) => {
console.log(e);
if(this.showErrorToast){
if (this.showErrorToast) {
uni.showToast({
title: e.errMsg,
icon: "none"
......
......@@ -58,11 +58,11 @@
titleSelect: "null"
}
},
onLoad(){
onLoad() {
uni.showLoading({
title:'onLoad 调用示例,2秒后消失'
title: 'onLoad 调用示例,2秒后消失'
})
setTimeout(function() {
setTimeout(function () {
uni.hideLoading()
}, 2000);
},
......
......@@ -53,6 +53,13 @@ describe('API-toast', () => {
}
})
it("icon=none-mask=true-toast-test", async () => {
await page.setData({maskSelect: true})
await page.callMethod('toast3Tap')
await page.waitFor(300);
await toScreenshot('icon=none-mask=true-toast-image')
})
it("image-toast-test", async () => {
await page.setData({imageSelect: true})
await page.waitFor(300);
......
......@@ -24,7 +24,8 @@
</view>
<view class="uni-title uni-list-cell-padding">提示的延迟时间,默认:1500(单位毫秒)</view>
<view class="uni-list-cell-padding">
<slider @change="sliderChange" foreColor="#007AFF" :value="intervalSelect" :min="1500" :max="5000" :show-value="true" />
<slider @change="sliderChange" foreColor="#007AFF" :value="intervalSelect" :min="1500" :max="5000"
:show-value="true" />
</view>
<view class="uni-btn-v">
<button class="uni-btn-v" type="default" @tap="toast1Tap" id="btn-toast-default">点击弹出toast</button>
......@@ -36,9 +37,9 @@
</view>
<view class="uni-list uni-common-pl">
<radio-group @change="radioChangePosition">
<radio class="uni-list-cell uni-list-cell-pd radio-position" v-for="(position, index) in position_enum" :key="position.value"
:class="index < position_enum.length - 1 ? 'uni-list-cell-line' : ''" :value="position.value"
:checked="index === position_current">{{position.name}}</radio>
<radio class="uni-list-cell uni-list-cell-pd radio-position" v-for="(position, index) in position_enum"
:key="position.value" :class="index < position_enum.length - 1 ? 'uni-list-cell-line' : ''"
:value="position.value" :checked="index === position_current">{{position.name}}</radio>
</radio-group>
</view>
<button class="uni-btn uni-btn-v uni-common-mb" type="default" @tap="toast2Tap">点击弹出设置position的toast</button>
......@@ -64,16 +65,16 @@
return {
title: 'toast',
exeRet: '',
imageSelect:false,
imageSelect: false,
maskSelect: false,
intervalSelect: 1500,
position_current:0,
position_current: 0,
position_enum: [
{ "value": "top", "name": "top: 居上显示(Android 暂不支持)" },
{ "value": "center", "name": "center: 居中显示(Android 暂不支持)" },
{ "value": "bottom", "name": "bottom: 居底显示" },
] as PositionItemType[],
icon_current:0,
icon_current: 0,
icon_enum: [
{
value: 'success',
......@@ -145,7 +146,23 @@
title: "默认",
icon: this.icon_enum[this.icon_current].value,
duration: this.intervalSelect,
image: this.imageSelect? "/static/uni.png" : null ,
image: this.imageSelect ? "/static/uni.png" : null,
mask: this.maskSelect,
success: (res) => {
// console.log('success:',res)
this.exeRet = "success:" + JSON.stringify(res)
},
fail: (res) => {
this.exeRet = "fail:" + JSON.stringify(res)
},
})
},
toast3Tap: function () {
uni.showToast({
title: "默认",
icon: 'none',
duration: this.intervalSelect,
image: this.imageSelect ? "/static/uni.png" : null,
mask: this.maskSelect,
success: (res) => {
// console.log('success:',res)
......@@ -177,4 +194,3 @@
}
}
</script>
......@@ -11,7 +11,8 @@
<view class="uni-label">key</view>
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" placeholder="请输入key" name="key" :value="key" maxlength="-1" @input="keyChange" />
<input class="uni-input" type="text" placeholder="请输入key" name="key" :value="key" maxlength="-1"
@input="keyChange" />
</view>
</view>
<view class="uni-list-cell">
......@@ -111,7 +112,7 @@
data: '' as any,
apiGetData: '' as any | null,
storageInfo: '',
staticComplexRet:false
staticComplexRet: false
}
},
methods: {
......@@ -160,17 +161,17 @@
},
complexStaticTest() {
uni.setStorageSync("key_complexStaticMock", {
name:"张三",
age:12
name: "张三",
age: 12
})
let savedData = uni.getStorageSync("key_complexStaticMock")
this.staticComplexRet = false
if(savedData instanceof UTSJSONObject){
if((savedData as UTSJSONObject).getNumber('age') == 12){
if (savedData instanceof UTSJSONObject) {
if ((savedData as UTSJSONObject).getNumber('age') == 12) {
this.staticComplexRet = true
uni.showToast({
icon:'success',
title:'测试通过'
icon: 'success',
title: '测试通过'
})
}
}
......
......@@ -17,8 +17,7 @@
<view class="uni-list uni-common-pl">
<radio-group @change="radioChange" class="radio-group">
<radio class="uni-list-cell uni-list-cell-pd radio" v-for="(item, index) in items" :key="item"
:class="index < items.length - 1 ? 'uni-list-cell-line' : ''" :value="item"
:checked="index === current">
:class="index < items.length - 1 ? 'uni-list-cell-line' : ''" :value="item" :checked="index === current">
{{ item }}
</radio>
</radio-group>
......@@ -45,15 +44,15 @@
}
},
methods: {
bindOsThemeChange(): number {
bindOsThemeChange() : number {
//注册osTheme变化监听
return uni.onOsThemeChange((res: OsThemeChangeResult)=> {
return uni.onOsThemeChange((res : OsThemeChangeResult) => {
this.osTheme = res.osTheme
})
},
bindAppThemeChange(): number {
bindAppThemeChange() : number {
//注册appTheme变化监听
return uni.onAppThemeChange((res: AppThemeChangeResult) => {
return uni.onAppThemeChange((res : AppThemeChangeResult) => {
this.appTheme = res.appTheme
})
},
......@@ -62,16 +61,16 @@
this.setAppTheme(theme)
uni.showToast({
icon: 'none',
title: '当前选中:'+theme,
title: '当前选中:' + theme,
})
},
setAppTheme(value: string) {
setAppTheme(value : string) {
uni.setAppTheme({
theme: value,
success: function() {
success: function () {
console.log("设置appTheme为", value, "成功")
},
fail: function(e: IAppThemeFail) {
fail: function (e : IAppThemeFail) {
console.log("设置appTheme为", value, "失败,原因:", e.errMsg)
}
})
......@@ -79,7 +78,7 @@
},
onReady() {
uni.getSystemInfo({
success: (res:GetSystemInfoResult) => {
success: (res : GetSystemInfoResult) => {
this.osTheme = res.osTheme!
this.originalTheme = res.appTheme!
this.appTheme = res.appTheme == "auto" ? res.osTheme! : res.appTheme!
......@@ -94,8 +93,8 @@
uni.offAppThemeChange(this.appThemeChangeId)
uni.offOsThemeChange(this.osThemeChangeId)
uni.showToast({
"position":"bottom",
"title":"已停止监听主题切换"
"position": "bottom",
"title": "已停止监听主题切换"
})
}
}
......@@ -107,6 +106,7 @@
flex-direction: row;
justify-content: space-between;
}
.uni-list-cell {
justify-content: flex-start;
}
......
......@@ -169,7 +169,7 @@
uni.showToast({
title: "清空应用角标数"
})
}else{
} else {
uni.showToast({
title: "请在设置中开启通知权限",
icon: "error"
......
......@@ -10,6 +10,11 @@ describe('unicloud-call-function', () => {
})
})
it('UniCloudError', async () => {
const result = await page.callMethod('jest_UniCloudError')
expect(result).toBe(false)
})
it('callFunction', async () => {
await page.callMethod('callFunction')
const {
......
......@@ -48,7 +48,7 @@
},
async callFunctionWithGeneric() : Promise<void> {
type EchoCfResult = {
showMessage: string
showMessage : string
}
uni.showLoading({
title: '加载中...'
......@@ -99,6 +99,9 @@
uni.hideLoading()
this.notify(error.errMsg, '错误')
})
},
jest_UniCloudError() {
return new Error() instanceof UniCloudError
}
}
}
......
......@@ -297,7 +297,7 @@
let successCount = 0
for (let i = 0; i < res.dataList.length; i++) {
const item = res.dataList[i]
if(item.errCode == 0) {
if (item.errCode == 0) {
console.log(`第${i}个请求查询到${item.data!.length}条数据`)
successCount++
} else {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册