提交 11c82593 编写于 作者: dcloud_wdl's avatar dcloud_wdl

[转正] 合并origin/alpha

......@@ -3,4 +3,5 @@ node_modules/
unpackage/
.DS_Store
.hbuilderx/
__image_snapshots__/
\ No newline at end of file
__image_snapshots__/
__snapshot__
\ No newline at end of file
<script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts'
// #ifdef APP-ANDROID
let firstBackTime = 0
// #endif
export default {
globalData: {
str: 'default globalData str',
......@@ -81,10 +83,4 @@
<style>
/*每个页面公共css */
@import "./common/uni.css";
/* #ifdef WEB */
/* web版暂未支持backgroundColorContent使用此样式替代 */
page {
background-color: #efeff4;
}
/* #endif */
</style>
## 1.0.12
* update 4.08.2024040123
## 1.0.19
* update 4.14.2024042905-alpha
## 1.0.11
* update 4.07.2024032720
## 1.0.10
* update 4.06.2024032513
## 1.0.16
* update 4.06.2024032403-alpha
## 1.0.15
* update 4.05.2024032021-alpha
## 1.0.14
* update 4.04.2024031519-alpha
## 1.0.13
* update 4.03.2024031101-alpha
## 1.0.18
* update 4.13.2024042321-alpha
## 1.0.12
* update 4.02.2024030621-alpha
## 1.0.17
* update 4.12.2024041009-alpha
## 1.0.11
* update 4.01.2024020211-alpha
......
......@@ -82,7 +82,7 @@
</view>
</view>
<view class="input-wrapper">
<input class="uni-input" :type="inputType" :value="inputClearValue" :placeholder="title" @input="input" @blur="blur"
<input class="uni-input" :type="inputType" :value="inputClearValue" :placeholder="title" maxlength="-1" @input="input" @blur="blur"
@focus="focus" />
<image class="input-wrapper_image" src="/static/icons/clear.png" v-if="showClearIcon" @click="clearIcon">
</image>
......
......@@ -40,6 +40,13 @@
<div class="btn-list">
<button class="btn btn-red" type="button" id="postMessage">postMessage</button>
</div>
<p class="desc">文件选择</p>
<div style="padding: 0 10px;">
<p style="font-size: 14px;">&lt;input type="file" /&gt;</p>
<input type="file" />
<p style="font-size: 14px;">&lt;input type="file" accept="image/*" multiple /&gt;</p>
<input type="file" accept="image/*" multiple />
</div>
<!-- uni 的 SDK -->
<script type="text/javascript" src="uni.webview.1.5.5.js"></script>
<script type="text/javascript">
......
// 自动化测试
const path = require('path');
const path = require("path");
const fs = require("fs");
const {
configureToMatchImageSnapshot
configureToMatchImageSnapshot
} = require('jest-image-snapshot');
const hbuilderx_version = process.env.HX_Version
const uniTestPlatformInfo = process.env.uniTestPlatformInfo ? process.env.uniTestPlatformInfo.replace(/\s/g,'_') : ''
const folderName = `__image_snapshots__/${hbuilderx_version}/__${uniTestPlatformInfo}__`
let environment = 'official'
if(hbuilderx_version.includes('dev')){
environment = 'dev'
}else if(hbuilderx_version.includes('alpha')){
environment = 'alpha'
}
const baseFolderName = `__image_snapshots__/base/${environment}/__${uniTestPlatformInfo}__`
let saveImageSnapshotDir = process.env.saveImageSnapshotDir || path.join(__dirname, '__snapshot__');
expect.extend({
toMatchImageSnapshot: configureToMatchImageSnapshot({
customSnapshotIdentifier(args) {
return args.currentTestName.replace(/\//g, '-').replace(' ', '-');
},
customSnapshotsDir: path.join(__dirname, baseFolderName),
customDiffDir: path.join(__dirname, `${folderName}/`, 'diff'),
}),
toMatchImageSnapshot: configureToMatchImageSnapshot({
customSnapshotIdentifier(args) {
return args.currentTestName.replace(/\//g, "-").replace(" ", "-");
},
customSnapshotsDir: process.env.saveImageSnapshotDir,
customDiffDir: path.join(saveImageSnapshotDir, "diff"),
}),
toSaveSnapshot,
toSaveImageSnapshot,
});
const testCaseToSnapshotFilePath =
process.env.testCaseToSnapshotFilePath || "./testCaseToSnapshotFilePath.json";
if (!fs.existsSync(testCaseToSnapshotFilePath)) {
fs.writeFileSync(testCaseToSnapshotFilePath, "{}");
}
function writeTestCaseToSnapshotFile(testCaseName, snapshotFilePath) {
const data = JSON.parse(fs.readFileSync(testCaseToSnapshotFilePath));
if (testCaseName.includes(__dirname)) {
testCaseName = testCaseName.substring(`${__dirname}`.length);
if (testCaseName[0] == '/' || testCaseName[0] == '\\') {
testCaseName = testCaseName.substring(1);
};
};
if (!data[testCaseName]) {
data[testCaseName] = [snapshotFilePath];
} else {
data[testCaseName].push(snapshotFilePath);
}
fs.writeFileSync(testCaseToSnapshotFilePath, JSON.stringify(data, null, 2));
}
function toSaveSnapshot(received, {
customSnapshotsDir,
fileName
} = {}) {
const {
snapshotState: {
_rootDir
},
testPath,
currentTestName,
} = this;
const SNAPSHOTS_DIR = "__file_snapshots__";
const snapshotDir =
process.env.saveSnapshotDir ||
createSnapshotDir({
customSnapshotsDir,
testPath,
SNAPSHOTS_DIR,
});
const _fileName = createFileName({
fileName,
testPath,
currentTestName,
});
const filePath = path.join(snapshotDir, _fileName);
let message = () => `${currentTestName} toSaveSnapshot success`;
let pass = true;
try {
checkSnapshotDir(path.dirname(filePath));
fs.writeFileSync(filePath, received);
writeTestCaseToSnapshotFile(testPath.replace(`${_rootDir}/`, ""), filePath);
} catch (e) {
console.log("toSaveSnapshot fail", e);
message = () => e.message;
pass = false;
}
return {
message,
pass,
};
}
function toSaveImageSnapshot(
received, {
customSnapshotsDir,
customSnapshotIdentifier
} = {}
) {
const {
snapshotState: {
_rootDir
},
testPath,
currentTestName,
} = this;
const SNAPSHOTS_DIR = "__image_snapshots__";
const snapshotDir =
process.env.saveImageSnapshotDir ||
createSnapshotDir({
customSnapshotsDir,
testPath,
SNAPSHOTS_DIR,
});
const _fileName = createFileName({
fileName: customSnapshotIdentifier ? `${customSnapshotIdentifier()}.png` : "",
testPath,
currentTestName,
fileType: "png",
});
const filePath = path.join(snapshotDir, _fileName);
let message = () => `${currentTestName} toSaveImageSnapshot success`;
let pass = true;
try {
checkSnapshotDir(path.dirname(filePath));
fs.writeFileSync(filePath, Buffer.from(received, "base64"));
writeTestCaseToSnapshotFile(testPath.replace(`${_rootDir}/`, ""), filePath);
} catch (e) {
console.log("toSaveImageSnapshot fail", e);
message = () => e.message;
pass = false;
}
return {
message,
pass,
};
}
function createSnapshotDir({
customSnapshotsDir,
testPath,
SNAPSHOTS_DIR
}) {
return customSnapshotsDir || path.join(path.dirname(testPath), SNAPSHOTS_DIR);
}
function createFileName({
fileName,
testPath,
currentTestName,
fileType
}) {
return (
fileName ||
createSnapshotIdentifier({
testPath,
currentTestName,
fileType,
})
);
}
function createSnapshotIdentifier({
testPath,
currentTestName,
fileType = "txt",
}) {
const snapshotIdentifier = kebabCase(
`${path.basename(testPath)}-${currentTestName}`
);
const counter = timesCalled.get(`${snapshotIdentifier}-${fileType}`) || 1;
timesCalled.set(`${snapshotIdentifier}-${fileType}`, counter + 1);
return `${snapshotIdentifier}-${counter}.${fileType}`;
}
function kebabCase(str) {
return str
.replaceAll(/([a-z])([A-Z])/g, "$1-$2")
.replaceAll(/\s+/g, "-")
.replaceAll(/_+/g, "-")
.replaceAll(/\/+/g, "-")
.replaceAll(/\.+/g, "-")
.toLowerCase();
}
function checkSnapshotDir(snapshotDir) {
if (!fs.existsSync(snapshotDir)) {
fs.mkdirSync(snapshotDir, {
recursive: true,
});
}
}
const timesCalled = new Map();
// 自动化测试
// 备注:
//
// 1. testPathIgnorePatterns 忽略/pages/API的几条用例,是因为在ios设备上,运行会导致app崩溃。后期完成后,再去除。
// 2. testPathIgnorePatterns 忽略webview相关用例, 是因为采用app-webview方式后,不需要这两个用例。请勿修改和提交到Git。
//
module.exports = {
testTimeout: 30000,
reporters: ['default'],
......@@ -6,6 +13,10 @@ module.exports = {
moduleFileExtensions: ['js', 'json'],
rootDir: __dirname,
testMatch: ["<rootDir>/pages/**/*test.[jt]s?(x)"],
testPathIgnorePatterns: ['/node_modules/'],
testPathIgnorePatterns: [
'/node_modules/',
'<rootDir>/pages/webview-screenshot-comparison/webview-screenshot-comparison.test.js',
'<rootDir>/pages/webview-screenshot/webview-screenshot.test.js'
],
setupFilesAfterEnv: ['<rootDir>/jest-setup.js'],
}
import App from './App.uvue'
// 仅测试 console.log 时机问题
import './test-main-console.uts'
import App from './App.uvue'
import { createSSRApp } from 'vue'
export function createApp() {
const app = createSSRApp(App)
app.config.errorHandler = (err, vm, info) => {
console.log(err, vm, info)
}
// app.mixin({
// onReady() {
// setTimeout(() => {
// console.log((this as BasePage).$nativePage!.getDomJson())
// }, 100)
// }
// })
return {
app
}
......
{
"name" : "hello-uniapp x",
"appid" : "__UNI__3584C99",
"description" : "",
"versionName" : "1.0.23",
"versionCode" : 10023,
"uni-app-x" : {},
/* 快应用特有相关 */
"quickapp" : {},
/* 小程序特有相关 */
"mp-weixin" : {
"appid" : "",
"setting" : {
"urlCheck" : false
{
"name": "Hello uni-app x",
"appid": "__UNI__HelloUniAppX",
"description": "",
"versionName": "1.2.2",
"versionCode": 10202,
"uni-app-x": {},
/* 快应用特有相关 */
"quickapp": {},
/* 小程序特有相关 */
"mp-weixin": {
"appid": "",
"setting": {
"urlCheck": false
},
"usingComponents": true
},
"mp-alipay": {
"usingComponents": true
},
"mp-baidu": {
"usingComponents": true
},
"mp-toutiao": {
"usingComponents": true
},
"uniStatistics": {
"enable": false
},
"app": {
"distribute": {
/* android打包配置 */
"modules": {
"uni-payment":{
"alipay":{},
"wxpay":{}
},
"usingComponents" : true
},
"mp-alipay" : {
"usingComponents" : true
},
"mp-baidu" : {
"usingComponents" : true
},
"mp-toutiao" : {
"usingComponents" : true
},
"uniStatistics" : {
"enable" : false
},
"app" : {},
"vueVersion" : "3",
"h5" : {
"router" : {
"base" : "/web/"
"uni-ad": {
"gdt": {}
}
}
}
}
},
"vueVersion": "3",
"h5": {
"router": {
"base": "/web/"
}
}
}
{
"id": "hello-uniapp-x",
"name": "hello-uniapp-x",
"displayName": "hello-uniapp-x",
"version": "1.0.12",
"id": "hello-uniapp-x-alpha",
"name": "hello-uniapp-x-alpha",
"displayName": "hello-uniapp-x-alpha",
"version": "1.0.19",
"description": "演示 uni-app x 框架的组件、接口、模板",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
......
......@@ -269,7 +269,6 @@
"navigationBarTitleText": "web-view-local"
}
},
// #ifndef APP-IOS
{
"path": "pages/component/unicloud-db-contacts/list",
"style": {
......@@ -301,7 +300,6 @@
"navigationBarTitleText": "mixinDatacom"
}
},
// #endif
{
"path": "pages/component/general-attribute/general-attribute",
"style": {
......@@ -363,7 +361,15 @@
{
"path": "pages/API/get-current-pages/get-current-pages",
"style": {
"navigationBarTitleText": "getCurrentPages"
"navigationBarTitleText": "getCurrentPages",
"enablePullDownRefresh": true
}
},
{
"path": "pages/API/get-current-pages/set-page-style-disable-pull-down-refresh",
"style": {
"navigationBarTitleText": "setPageStyle pull default false",
"enablePullDownRefresh": false
}
},
{
......@@ -537,7 +543,6 @@
"navigationBarTitleText": "websocket-global"
}
},
// #ifndef APP-IOS
{
"path": "pages/API/unicloud-call-function/unicloud-call-function",
"style": {
......@@ -550,7 +555,6 @@
"navigationBarTitleText": ""
}
},
// #endif
{
"path": "pages/API/get-system-info/get-system-info",
"style": {
......@@ -576,8 +580,13 @@
"navigationBarTitleText": "get-system-setting"
}
},
// #endif
// #ifndef WEB
{
"path": "pages/API/element-takesnapshot/element-takesnapshot",
"style": {
"navigationBarTitleText": "takeSnapshot",
"enablePullDownRefresh": false
}
},
{
"path": "pages/API/get-app-authorize-setting/get-app-authorize-setting",
"style": {
......@@ -621,7 +630,6 @@
"navigationBarTitleText": "event-bus"
}
},
// #ifndef APP-IOS
{
"path": "pages/API/unicloud-file-api/unicloud-file-api",
"style": {
......@@ -640,32 +648,24 @@
"navigationBarTitleText": "电量"
}
},
// #endif
{
"path": "pages/API/get-window-info/get-window-info",
"style": {
"navigationBarTitleText": "get-window-info"
}
},
// #ifdef APP-ANDROID
{
"path": "pages/API/facial-recognition-verify/facial-recognition-verify",
"style": {
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
{
"path": "pages/API/element-takesnapshot/element-takesnapshot",
"path": "pages/API/element-draw/element-draw",
"style": {
"navigationBarTitleText": "takeSnapshot",
"navigationBarTitleText": "getDrawableContext",
"enablePullDownRefresh": false
}
},
// #ifdef APP
{
"path": "pages/API/element-draw/element-draw",
"path": "pages/API/facial-recognition-verify/facial-recognition-verify",
"style": {
"navigationBarTitleText": "getDrawableContext",
"navigationBarTitleText": "实人认证",
"enablePullDownRefresh": false
}
},
......@@ -1021,6 +1021,12 @@
"navigationBarTitleText": "Transition"
}
},
{
"path": "pages/CSS/pointer-events/pointer-events",
"style": {
"navigationBarTitleText": "pointer-events"
}
},
{
"path": "pages/CSS/transform/translate",
"style": {
......@@ -1054,7 +1060,7 @@
{
"path": "pages/template/list-news/list-news",
"style": {
"navigationBarTitleText": "列表到详情示例"
"navigationBarTitleText": "列表到详情示例(吸顶)"
}
},
{
......@@ -1117,14 +1123,21 @@
{
"path": "pages/template/long-list/long-list",
"style": {
"navigationBarTitleText": "顶部搜索框随时下移长列表",
"navigationBarTitleText": "Android顶部搜索框随时下移长列表",
"enablePullDownRefresh": true
}
},
{
"path": "pages/template/long-list2/long-list2",
"style": {
"navigationBarTitleText": "顶部banner长列表",
"navigationBarTitleText": "顶部banner长列表嵌套滚动示例",
"enablePullDownRefresh": true
}
},
{
"path": "pages/template/long-list-nested/long-list-nested",
"style": {
"navigationBarTitleText": "顶部banner长列表嵌套滚动示例",
"enablePullDownRefresh": true
}
},
......@@ -1155,7 +1168,7 @@
}
},
// #endif
// #ifdef APP-ANDROID
// #ifdef APP
{
"path": "pages/template/calendar/calendar",
"style": {
......@@ -1168,6 +1181,8 @@
"navigationBarTitleText": "打开schema示例"
}
},
// #endif
// #ifdef APP-ANDROID
{
"path": "pages/template/share/share",
"style": {
......@@ -1176,35 +1191,42 @@
}
},
// #endif
// #ifdef APP
{
"path": "pages/webview-screenshot-comparison/webview-screenshot-comparison",
"path": "pages/API/rewarded-video-ad/rewarded-video-ad",
"style": {
"navigationBarTitleText": "截图对比测试",
"navigationStyle": "custom"
"navigationBarTitleText": "激励视频广告",
"enablePullDownRefresh": false
}
},
{
"path": "pages/webview-screenshot/webview-screenshot",
"path": "pages/API/create-request-permission-listener/create-request-permission-listener",
"style": {
"navigationBarTitleText": "webview 截图测试",
"navigationStyle": "custom"
"navigationBarTitleText": "权限申请监听",
"enablePullDownRefresh": false
}
},
// #ifdef APP
{
"path": "pages/API/rewarded-video-ad/rewarded-video-ad",
"path": "pages/component/list-view/list-view-refresh",
"style": {
"navigationBarTitleText": "激励视频广告",
"navigationBarTitleText": "list-view-refresh",
"enablePullDownRefresh": false
}
},
{
"path": "pages/API/create-request-permission-listener/create-request-permission-listener",
"path": "pages/component/nested-scroll-header/nested-scroll-header",
"style": {
"navigationBarTitleText": "权限申请监听",
"enablePullDownRefresh": false
"navigationBarTitleText": "nested-scroll-header"
}
},
{
"path": "pages/component/nested-scroll-body/nested-scroll-body",
"style": {
"navigationBarTitleText": "nested-scroll-body"
}
},
// #endif
// #ifdef APP || WEB
{
"path": "pages/API/request-payment/request-payment",
"style": {
......@@ -1213,11 +1235,80 @@
}
},
{
"path": "pages/component/list-view/list-view-refresh",
"path": "pages/API/request-payment-uni-pay/request-payment-uni-pay",
"style": {
"navigationBarTitleText": "list-view-refresh",
"navigationBarTitleText": "uni-pay示例",
"enablePullDownRefresh": false
}
},
{
"path": "pages/API/request-payment-uni-pay/order-detail",
"style": {
"navigationBarTitleText": "订单详情示例",
"enablePullDownRefresh": false
}
},
{
"path": "uni_modules/uni-pay-x/pages/success/success",
"style": {
"navigationBarTitleText": "",
"backgroundColor": "#F8F8F8",
"navigationBarBackgroundColor": "#007aff",
"navigationBarTextStyle": "white"
}
},
{
"path": "uni_modules/uni-pay-x/pages/ad-interactive-webview/ad-interactive-webview",
"style": {
"navigationBarTitleText": "收银台",
"backgroundColor": "#F8F8F8"
}
},
{
"path": "uni_modules/uni-pay-x/pages/pay-desk/pay-desk",
"style": {
"navigationBarTitleText": "ad",
"backgroundColor": "#F8F8F8"
}
},
{
"path" : "pages/template/custom-long-list/custom-long-list",
"style" : {
"navigationBarTitleText" : "自定义虚拟长列表",
"enablePullDownRefresh" : false
}
},
{
"path" : "pages/component/swiper/swiper-list-view",
"style" :
{
"navigationBarTitleText" : "swiper嵌套list-view",
"enablePullDownRefresh" : false
}
},
{
"path" : "pages/template/test-background-color-content/test-background-color-content",
"style" :
{
"navigationBarTitleText" : "",
"backgroundColorContent": "#fffae8"
}
}
// #endif
// #ifdef APP-ANDROID
,{
"path" : "pages/API/resize-observer/resize-observer",
"style" :
{
"navigationBarTitleText" : "resize0bserver"
}
},
{
"path" : "pages/CSS/overflow/overflow-visible-event",
"style" :
{
"navigationBarTitleText" : "overflow-visible-event"
}
}
// #endif
],
......
......@@ -3,7 +3,7 @@
describe('API-loading', () => {
let page;
const isAndroid = process.env.UNI_OS_NAME === "android";
const isApp = process.env.UNI_OS_NAME === "android" || process.env.UNI_OS_NAME === "ios";
beforeAll(async () => {
page = await program.reLaunch('/pages/API/action-sheet/action-sheet')
......@@ -12,13 +12,13 @@ describe('API-loading', () => {
it("onload-action-sheet-test", async () => {
if (isAndroid) {
if (isApp) {
await page.waitFor(500);
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
......@@ -27,13 +27,13 @@ describe('API-loading', () => {
},
});
expect(image).toMatchImageSnapshot();
expect(image).toSaveImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
deviceShot: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
expect(image).toSaveImageSnapshot()
}
})
......@@ -57,9 +57,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
if (isApp) {
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
......@@ -67,13 +67,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
expect(image).toSaveImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
deviceShot: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
expect(image).toSaveImageSnapshot()
}
......@@ -99,9 +99,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
if (isApp) {
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
......@@ -109,13 +109,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
expect(image).toSaveImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
deviceShot: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
expect(image).toSaveImageSnapshot()
}
......@@ -140,9 +140,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
if (isApp) {
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
......@@ -150,13 +150,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
expect(image).toSaveImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
deviceShot: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
expect(image).toSaveImageSnapshot()
}
......@@ -181,9 +181,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
if (isApp) {
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
......@@ -191,13 +191,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
expect(image).toSaveImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
deviceShot: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
expect(image).toSaveImageSnapshot()
}
})
......@@ -222,9 +222,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
if (isApp) {
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
......@@ -232,13 +232,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
expect(image).toSaveImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
deviceShot: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
expect(image).toSaveImageSnapshot()
}
......@@ -266,9 +266,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
if (isApp) {
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
......@@ -276,13 +276,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
expect(image).toSaveImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
deviceShot: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
expect(image).toSaveImageSnapshot()
}
......@@ -307,9 +307,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
if (isApp) {
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
......@@ -317,13 +317,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
expect(image).toSaveImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
deviceShot: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
expect(image).toSaveImageSnapshot()
}
......@@ -348,9 +348,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
if (isApp) {
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
......@@ -358,13 +358,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
expect(image).toSaveImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
deviceShot: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
expect(image).toSaveImageSnapshot()
}
})
......@@ -389,9 +389,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
if (isApp) {
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
......@@ -399,13 +399,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
expect(image).toSaveImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
deviceShot: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
expect(image).toSaveImageSnapshot()
}
......@@ -431,9 +431,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
if (isApp) {
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
......@@ -441,13 +441,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
expect(image).toSaveImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
deviceShot: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
expect(image).toSaveImageSnapshot()
}
......@@ -472,9 +472,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
if (isApp) {
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
......@@ -482,13 +482,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
expect(image).toSaveImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
deviceShot: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
expect(image).toSaveImageSnapshot()
}
......@@ -513,9 +513,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isAndroid) {
if (isApp) {
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
......@@ -523,13 +523,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toMatchImageSnapshot();
expect(image).toSaveImageSnapshot();
}else{
const image = await program.screenshot({
adb: true,
deviceShot: true,
fullPage: true
});
expect(image).toMatchImageSnapshot()
expect(image).toSaveImageSnapshot()
}
})
......
......@@ -116,7 +116,13 @@
icon: "none"
})
},
fail: (e) => {
fail: (e) => {
if(this.showErrorToast){
uni.showToast({
title: e.errMsg,
icon: "none"
})
}
console.log(e);
}
})
......
......@@ -46,7 +46,7 @@
图片质量(%)
</view>
<view class="uni-list-cell-right">
<input :value="cropPercent" @confirm="cropPercentConfim" type="number" />
<input :value="cropPercent" @confirm="cropPercentConfim" type="number" maxlength="-1"/>
</view>
</view>
<view class="uni-list-cell cell-pd">
......@@ -54,7 +54,7 @@
裁剪宽度(px)
</view>
<view class="uni-list-cell-right">
<input :value="cropWidth" @confirm="cropWidthConfim" type="number" />
<input :value="cropWidth" @confirm="cropWidthConfim" type="number" maxlength="-1"/>
</view>
</view>
<view class="uni-list-cell cell-pd">
......@@ -62,7 +62,7 @@
裁剪高度(px)
</view>
<view class="uni-list-cell-right">
<input :value="cropHeight" @confirm="cropHeightConfim" type="number" />
<input :value="cropHeight" @confirm="cropHeightConfim" type="number" maxlength="-1"/>
</view>
</view>
<view class="uni-list-cell cell-pd">
......
......@@ -23,7 +23,7 @@ describe('ExtApi-DownloadFile', () => {
});
let shouldTestCookie = false
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
let version = process.env.uniTestPlatformInfo
version = parseInt(version.split(" ")[1])
shouldTestCookie = version > 9
......@@ -47,4 +47,4 @@ describe('ExtApi-DownloadFile', () => {
res = await page.data('jest_result');
expect(res).toBe(true)
});
});
});
......@@ -68,6 +68,7 @@
if (i % 2 == 0) {
ctx.fillText(value, width / 2, (20 * (i + 1)))
} else {
ctx.lineWidth = 0.5
ctx.strokeText(value, width / 2, (20 * (i + 1)))
}
}
......
......@@ -2,7 +2,7 @@ const PAGE_PATH = "/pages/API/element-takesnapshot/element-takesnapshot";
describe("element-takesnapshot", () => {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1) {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
it('dummyTest', () => {
expect(1).toBe(1)
})
......
......@@ -50,5 +50,23 @@ describe('event-bus', () => {
await page.callMethod('emit')
const l3 = (await page.data()).log.length
expect(l3).toBe(0)
})
})
// it('off-all', async () => {
// await page.callMethod('clear')
// await page.callMethod('on')
// await page.callMethod('on2')
// await page.callMethod('emit')
// const l1 = (await page.data()).log.length
// expect(l1).toBe(2)
// await page.callMethod('clear')
// const l2 = (await page.data()).log.length
// expect(l2).toBe(0)
// await page.callMethod('offAll')
// await page.callMethod('emit')
// const l3 = (await page.data()).log.length
// expect(l3).toBe(0)
// })
})
......@@ -5,7 +5,8 @@
<view>
<button @click="on">开始监听</button>
<button @click="once">监听一次</button>
<button @click="off">取消监听</button>
<button @click="off">取消监听</button>
<!-- <button @click="offAll">取消全部监听</button> -->
<button @click="emit">触发监听</button>
<button @click="clear">清空消息</button>
<view class="box">
......@@ -30,15 +31,25 @@
methods: {
fn(res : string) {
this.log.push(res)
},
fn2(res : string) {
this.log.push(res)
},
on() {
uni.$on('test', this.fn)
},
on2() {
uni.$on('test', this.fn2)
},
once() {
uni.$once('test', this.fn)
},
off() {
uni.$off('test', this.fn)
},
offAll() {
// TODO 第二个参数为可选,后续优化后可不传递
//uni.$off('test', null)
},
emit() {
uni.$emit('test', 'msg:' + Date.now())
......
......@@ -7,11 +7,11 @@
<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="姓名" />
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="身份证号" />
placeholder="身份证号" maxlength="-1"/>
</view>
<view class="uni-btn-v uni-common-mt">
<button type="primary" @click="facialRecognition">开始人脸识别</button>
......
const PAGE_PATH = '/pages/API/get-app-authorize-setting/get-app-authorize-setting'
describe('ExtApi-GetAppAuthorizeSetting', () => {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1) {
describe('ExtApi-GetAppAuthorizeSetting', () => {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
it('dummyTest', () => {
expect(1).toBe(1)
})
......
<template>
<page-head :title="title"></page-head>
<view class="uni-common-mt">
<view class="uni-list">
<view class="uni-list">
<!-- #ifdef APP-IOS -->
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">是否授权使用相册</view>
</view>
<view class="uni-list-cell-db">
<input type="text" :disabled="true" placeholder="未获取" :value="albumAuthorized" />
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">是否授权使用蓝牙</view>
</view>
<view class="uni-list-cell-db">
<input type="text" :disabled="true" placeholder="未获取" :value="bluetoothAuthorized" />
</view>
</view>
<!-- #endif -->
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">是否授权使用摄像头</view>
......@@ -33,7 +51,8 @@
<view class="uni-list-cell-db">
<input type="text" :disabled="true" placeholder="未获取" :value="microphoneAuthorized" />
</view>
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">是否授权通知</view>
......@@ -41,7 +60,34 @@
<view class="uni-list-cell-db">
<input type="text" :disabled="true" placeholder="未获取" :value="notificationAuthorized" />
</view>
</view>
</view>
<!-- #ifdef APP-IOS -->
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">是否允许通知带有提醒</view>
</view>
<view class="uni-list-cell-db">
<input type="text" :disabled="true" placeholder="未获取" :value="notificationAlertAuthorized" />
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">是否允许通知带有标记</view>
</view>
<view class="uni-list-cell-db">
<input type="text" :disabled="true" placeholder="未获取" :value="notificationBadgeAuthorized" />
</view>
</view>
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">是否允许通知带有声音</view>
</view>
<view class="uni-list-cell-db">
<input type="text" :disabled="true" placeholder="未获取" :value="notificationSoundAuthorized" />
</view>
</view>
<!-- #endif -->
</view>
<view class="uni-padding-wrap">
<view class="uni-btn-v">
......@@ -55,11 +101,16 @@
data() {
return {
title: 'getAppAuthorizeSetting',
cameraAuthorized: "",
cameraAuthorized: "",
albumAuthorized: "",
locationAuthorized: "",
locationAccuracy: "",
microphoneAuthorized: "",
notificationAuthorized: ""
microphoneAuthorized: "",
bluetoothAuthorized: "",
notificationAuthorized: "",
notificationAlertAuthorized: "",
notificationBadgeAuthorized: "",
notificationSoundAuthorized: ""
}
},
onUnload: function () {
......@@ -71,7 +122,15 @@
this.locationAuthorized = res.locationAuthorized;
this.locationAccuracy = res.locationAccuracy ?? "unsupported";
this.microphoneAuthorized = res.microphoneAuthorized;
this.notificationAuthorized = res.notificationAuthorized;
this.notificationAuthorized = res.notificationAuthorized;
// #ifdef APP-IOS
this.notificationAlertAuthorized = res.notificationAlertAuthorized;
this.notificationBadgeAuthorized = res.notificationBadgeAuthorized;
this.notificationSoundAuthorized = res.notificationSoundAuthorized;
this.bluetoothAuthorized = res.bluetoothAuthorized;
this.albumAuthorized = res.albumAuthorized;
// #endif
}
}
}
......
......@@ -6,14 +6,11 @@ describe('ExtApi-GetAppBaseInfo', () => {
let res;
const stringProperties = [
'appId', 'appName', 'appVersion', 'appVersionCode', 'appLanguage',
'language', 'uniCompileVersion', 'uniPlatform', 'uniRuntimeVersion',
'language', 'uniCompilerVersion', 'uniPlatform', 'uniRuntimeVersion',
]
const numberProperties = [
'uniCompileVersionCode', 'uniRuntimeVersionCode'
]
if (process.env.uniTestPlatformInfo.indexOf('web') === -1) {
stringProperties.push('version')
}
'uniCompilerVersionCode', 'uniRuntimeVersionCode'
]
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(600);
......
......@@ -35,8 +35,16 @@
methods: {
getAppBaseInfo: function () {
const res = uni.getAppBaseInfo();
const res_str = JSON.stringify(res);
const res_obj = JSON.parseObject(res_str);
const res_map = res_obj!.toMap();
let keys = [] as string[]
res_map.forEach((_, key) => {
keys.push(key);
});
this.items = [] as Item[];
for(const key in res){
keys.sort().forEach( key => {
const value = res[key];
if(value != null){
const item = {
......@@ -45,7 +53,8 @@
} as Item;
this.items.push(item);
}
}
});
}
}
}
......
<template>
<!-- #ifdef APP -->
<scroll-view style="flex:1;padding-bottom: 20px;">
<!-- #endif -->
<view>
<page-head title="getApp"></page-head>
<view class="uni-padding-wrap">
<button @click="getGlobalData">get globalData</button>
<template v-if="originGlobalData.str.length">
<text class="uni-common-mt bold">初始的 globalData:</text>
<text class="uni-common-mt">globalData string: {{ originGlobalData.str }}</text>
<text class="uni-common-mt">globalData number: {{ originGlobalData.num }}</text>
<text class="uni-common-mt">globalData boolean: {{ originGlobalData.bool }}</text>
<text class="uni-common-mt">globalData object: {{ originGlobalData.obj }}</text>
<text class="uni-common-mt">globalData null: {{ originGlobalData.null }}</text>
<text class="uni-common-mt">globalData array: {{ originGlobalData.arr }}</text>
<text class="uni-common-mt">globalData Set: {{ originGlobalData.mySet }}</text>
<text class="uni-common-mt">globalData Map: {{ originGlobalData.myMap }}</text>
<text class="uni-common-mt">globalData func 返回值: {{ originGlobalDataFuncRes }}</text>
</template>
<button @click="setGlobalData" class="uni-common-mt">set globalData</button>
<template v-if="newGlobalData.bool">
<text class="uni-common-mt bold">更新后的 globalData:</text>
<text class="uni-common-mt">globalData string: {{ newGlobalData.str }}</text>
<text class="uni-common-mt">globalData number: {{ newGlobalData.num }}</text>
<text class="uni-common-mt">globalData boolean: {{ newGlobalData.bool }}</text>
<text class="uni-common-mt">globalData object: {{ newGlobalData.obj }}</text>
<text class="uni-common-mt">globalData null: {{ newGlobalData.null }}</text>
<text class="uni-common-mt">globalData array: {{ newGlobalData.arr }}</text>
<text class="uni-common-mt">globalData Set: {{ newGlobalData.mySet }}</text>
<text class="uni-common-mt">globalData Map: {{ newGlobalData.myMap }}</text>
<text class="uni-common-mt">globalData func 返回值: {{ newGlobalDataFuncRes }}</text>
</template>
<text class="uni-common-mt">点击按钮调用 App.uvue methods</text>
<text class="margin-top:6px;">increasetLifeCycleNum 方法</text>
<button class="uni-common-mt" @click="_increasetLifeCycleNum">
increase lifeCycleNum
</button>
<text class="uni-common-mt">lifeCycleNum: {{ lifeCycleNum }}</text>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts'
type MyGlobalData = {
str : string,
num : number,
bool : boolean,
obj : UTSJSONObject,
null : string | null,
arr : number[],
mySet : string[],
myMap : UTSJSONObject,
func : () => string
}
export default {
data() {
return {
originGlobalData: {
str: '',
num: 0,
bool: false,
obj: {
str: '',
num: 0,
bool: false
} as UTSJSONObject,
null: null,
arr: [] as number[],
mySet: [] as string[],
myMap: {},
func: () : string => ''
} as MyGlobalData,
originGlobalDataFuncRes: '',
newGlobalData: {
str: '',
num: 0,
bool: false,
obj: {
str: '',
num: 0,
bool: false
} as UTSJSONObject,
null: null,
arr: [] as number[],
mySet: [] as string[],
myMap: {},
func: () : string => ''
} as MyGlobalData,
newGlobalDataFuncRes: '',
lifeCycleNum: 0,
}
},
onReady() {
this.lifeCycleNum = state.lifeCycleNum
},
methods: {
getGlobalData() {
const app = getApp()
this.originGlobalData.str = app.globalData.str
this.originGlobalData.num = app.globalData.num
this.originGlobalData.bool = app.globalData.bool
this.originGlobalData.obj = app.globalData.obj
this.originGlobalData.null = app.globalData.null
this.originGlobalData.arr = app.globalData.arr
app.globalData.mySet.forEach((value : string) => {
this.originGlobalData.mySet.push(value)
})
app.globalData.myMap.forEach((value : any, key : string) => {
this.originGlobalData.myMap[key] = value
})
this.originGlobalData.func = app.globalData.func
this.originGlobalDataFuncRes = this.originGlobalData.func()
},
setGlobalData() {
const app = getApp()
app.globalData.str = 'new globalData str'
app.globalData.num = 100
app.globalData.bool = true
app.globalData.obj = {
str: 'new globalData obj str',
num: 200,
bool: true
}
app.globalData.null = 'not null'
app.globalData.arr = [1, 2, 3]
app.globalData.mySet = new Set(['a', 'b', 'c'])
app.globalData.myMap = new Map([
['a', 1],
['b', 2],
['c', 3]
])
app.globalData.func = () : string => {
return 'new globalData func'
}
this.newGlobalData.str = app.globalData.str
this.newGlobalData.num = app.globalData.num
this.newGlobalData.bool = app.globalData.bool
this.newGlobalData.obj = app.globalData.obj
this.newGlobalData.null = app.globalData.null
this.newGlobalData.arr = app.globalData.arr
app.globalData.mySet.forEach((value : string) => {
this.newGlobalData.mySet.push(value)
})
app.globalData.myMap.forEach((value : any, key : string) => {
this.newGlobalData.myMap[key] = value
})
this.newGlobalData.func = app.globalData.func
this.newGlobalDataFuncRes = this.newGlobalData.func()
},
_increasetLifeCycleNum: function () {
const app = getApp()
app.increasetLifeCycleNum()
this.lifeCycleNum = state.lifeCycleNum
},
// 自动化测试
setLifeCycleNum(num : number) {
setLifeCycleNum(num)
}
},
}
</script>
<style>
.bold {
font-weight: bold;
}
.hr {
border-bottom: 1px solid #ccc;
}
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1; padding-bottom: 20px">
<!-- #endif -->
<view>
<page-head title="getApp"></page-head>
<view class="uni-padding-wrap">
<button @click="getGlobalData">get globalData</button>
<template v-if="originGlobalData.str.length">
<text class="uni-common-mt bold">初始的 globalData:</text>
<text class="uni-common-mt">globalData string: {{ originGlobalData.str }}</text>
<text class="uni-common-mt">globalData number: {{ originGlobalData.num }}</text>
<text class="uni-common-mt">globalData boolean: {{ originGlobalData.bool }}</text>
<text class="uni-common-mt">globalData object: {{ originGlobalData.obj }}</text>
<text class="uni-common-mt">globalData null: {{ originGlobalData.null }}</text>
<text class="uni-common-mt">globalData array: {{ originGlobalData.arr }}</text>
<text class="uni-common-mt">globalData Set: {{ originGlobalData.mySet }}</text>
<text class="uni-common-mt">globalData Map: {{ originGlobalData.myMap }}</text>
<text class="uni-common-mt">globalData func 返回值: {{ originGlobalDataFuncRes }}</text>
</template>
<button @click="setGlobalData" class="uni-common-mt">
set globalData
</button>
<template v-if="newGlobalData.bool">
<text class="uni-common-mt bold">更新后的 globalData:</text>
<text class="uni-common-mt">globalData string: {{ newGlobalData.str }}</text>
<text class="uni-common-mt">globalData number: {{ newGlobalData.num }}</text>
<text class="uni-common-mt">globalData boolean: {{ newGlobalData.bool }}</text>
<text class="uni-common-mt">globalData object: {{ newGlobalData.obj }}</text>
<text class="uni-common-mt">globalData null: {{ newGlobalData.null }}</text>
<text class="uni-common-mt">globalData array: {{ newGlobalData.arr }}</text>
<text class="uni-common-mt">globalData Set: {{ newGlobalData.mySet }}</text>
<text class="uni-common-mt">globalData Map: {{ newGlobalData.myMap }}</text>
<text class="uni-common-mt">globalData func 返回值: {{ newGlobalDataFuncRes }}</text>
</template>
<text class="uni-common-mt">点击按钮调用 App.uvue methods</text>
<text class="uni-common-mt">increasetLifeCycleNum 方法</text>
<button class="uni-common-mt" @click="_increasetLifeCycleNum">
increase lifeCycleNum
</button>
<text class="uni-common-mt">lifeCycleNum: {{ lifeCycleNum }}</text>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts'
type MyGlobalData = {
str : string,
num : number,
bool : boolean,
obj : UTSJSONObject,
null : string | null,
arr : number[],
mySet : string[],
myMap : UTSJSONObject,
func : () => string
}
export default {
data() {
return {
originGlobalData: {
str: '',
num: 0,
bool: false,
obj: {
str: '',
num: 0,
bool: false
} as UTSJSONObject,
null: null,
arr: [] as number[],
mySet: [] as string[],
myMap: {},
func: () : string => ''
} as MyGlobalData,
originGlobalDataFuncRes: '',
newGlobalData: {
str: '',
num: 0,
bool: false,
obj: {
str: '',
num: 0,
bool: false
} as UTSJSONObject,
null: null,
arr: [] as number[],
mySet: [] as string[],
myMap: {},
func: () : string => ''
} as MyGlobalData,
newGlobalDataFuncRes: '',
lifeCycleNum: 0,
}
},
onReady() {
this.lifeCycleNum = state.lifeCycleNum
},
methods: {
getGlobalData() {
const app = getApp()
this.originGlobalData.str = app.globalData.str
this.originGlobalData.num = app.globalData.num
this.originGlobalData.bool = app.globalData.bool
this.originGlobalData.obj = app.globalData.obj
this.originGlobalData.null = app.globalData.null
this.originGlobalData.arr = app.globalData.arr
app.globalData.mySet.forEach((value : string) => {
this.originGlobalData.mySet.push(value)
})
app.globalData.myMap.forEach((value : any, key : string) => {
this.originGlobalData.myMap[key] = value
})
this.originGlobalData.func = app.globalData.func
this.originGlobalDataFuncRes = this.originGlobalData.func()
},
setGlobalData() {
const app = getApp()
app.globalData.str = 'new globalData str'
app.globalData.num = 100
app.globalData.bool = true
app.globalData.obj = {
str: 'new globalData obj str',
num: 200,
bool: true
}
app.globalData.null = 'not null'
app.globalData.arr = [1, 2, 3]
app.globalData.mySet = new Set(['a', 'b', 'c'])
app.globalData.myMap = new Map([
['a', 1],
['b', 2],
['c', 3]
])
app.globalData.func = () : string => {
return 'new globalData func'
}
this.newGlobalData.str = app.globalData.str
this.newGlobalData.num = app.globalData.num
this.newGlobalData.bool = app.globalData.bool
this.newGlobalData.obj = app.globalData.obj
this.newGlobalData.null = app.globalData.null
this.newGlobalData.arr = app.globalData.arr
app.globalData.mySet.forEach((value : string) => {
this.newGlobalData.mySet.push(value)
})
app.globalData.myMap.forEach((value : any, key : string) => {
this.newGlobalData.myMap[key] = value
})
this.newGlobalData.func = app.globalData.func
this.newGlobalDataFuncRes = this.newGlobalData.func()
},
_increasetLifeCycleNum: function () {
const app = getApp()
app.increasetLifeCycleNum()
this.lifeCycleNum = state.lifeCycleNum
},
// 自动化测试
setLifeCycleNum(num : number) {
setLifeCycleNum(num)
}
},
}
</script>
<style>
.bold {
font-weight: bold;
}
.hr {
border-bottom: 1px solid #ccc;
}
</style>
......@@ -7,6 +7,12 @@ describe('ExtApi-GetBatteryInfo', () => {
})
return
}
if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
it('dummyTest', () => {
expect(1).toBe(1)
})
return
}
let page;
let res;
......
const HOME_PAGE_PATH = '/pages/tabBar/component'
const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages'
describe('getCurrentPages', () => {
let page
it('getCurrentPages', async () => {
// web 端等待应用首页加载完成
if (process.env.uniTestPlatformInfo.startsWith('web')) {
const waitTime = process.env.uniTestPlatformInfo.includes('safari')
? 5000
: 1000
await new Promise((resolve) => {
setTimeout(() => {
resolve()
}, waitTime)
})
}
page = await program.switchTab(HOME_PAGE_PATH)
await page.waitFor(1000)
const HOME_PAGE_PATH = '/pages/tabBar/component'
const PAGE_PATH = '/pages/API/get-current-pages/get-current-pages'
describe('getCurrentPages', () => {
let page
it('getCurrentPages', async () => {
// web 端等待应用首页加载完成
if (process.env.uniTestPlatformInfo.startsWith('web')) {
const waitTime = process.env.uniTestPlatformInfo.includes('safari') ?
5000 :
3000
await new Promise((resolve) => {
setTimeout(() => {
resolve()
}, waitTime)
})
}
page = await program.switchTab(HOME_PAGE_PATH)
await page.waitFor(1000)
page = await program.navigateTo(PAGE_PATH)
await page.waitFor(1000)
await page.callMethod('_getCurrentPages')
await page.waitFor(200)
const data = await page.data()
expect(data.checked).toBe(true)
})
it('page-style', async () => {
page = await program.navigateTo(PAGE_PATH)
await page.waitFor(1000)
await page.callMethod('_getCurrentPages')
await page.callMethod('getPageStyle')
await page.waitFor(200)
const data = await page.data()
expect(data.checked).toBe(true)
})
const isEnablePullDownRefresh1 = (await page.data()).currentPageStyle.enablePullDownRefresh
expect(isEnablePullDownRefresh1).toBe(true)
// setPageStyle
await page.callMethod('setPageStyle', false)
await page.waitFor(200)
await page.callMethod('getPageStyle')
await page.waitFor(200)
const isEnablePullDownRefresh2 = (await page.data()).currentPageStyle.enablePullDownRefresh
expect(isEnablePullDownRefresh2).toBe(false)
await page.callMethod('startPullDownRefresh')
await page.waitFor(500)
const image2 = await program.screenshot({fullPage: true});
expect(image2).toSaveImageSnapshot();
await page.waitFor(3500)
await page.callMethod('setPageStyle', true)
await page.waitFor(200)
await page.callMethod('startPullDownRefresh')
await page.waitFor(500)
const image3 = await program.screenshot({fullPage: true});
expect(image3).toSaveImageSnapshot();
})
})
<template>
<page-head title="getCurrentPages"></page-head>
<view class="uni-padding-wrap">
<button @click="_getCurrentPages">getCurrentPages</button>
<view v-if="pages.length" style="padding: 15px 0px">
<text>当前页面栈中 {{ pages.length }} 个页面,列表如下:</text>
<template v-for="(page, index) in pages" :key="page.route">
<text style="margin-top: 5px">index: {{ index }}, route: {{ page.route }}</text>
</template>
</view>
</view>
</template>
<template>
<page-head title="getCurrentPages"></page-head>
<view class="uni-padding-wrap">
<button @click="_getCurrentPages">getCurrentPages</button>
<view v-if="pages.length" style="padding: 15px 0px">
<text>当前页面栈中 {{ pages.length }} 个页面,列表如下:</text>
<template v-for="(page, index) in pages" :key="page.route">
<text style="margin-top: 5px">index: {{ index }}, route: {{ page.route }}</text>
</template>
</view>
<button class="btn btn-get-page-style" type="default" @click="getPageStyle">getPageStyle</button>
<button class="btn btn-set-page-style-1" type="default" @click="setPageStyle(true)">setPageStyle(true)</button>
<button class="btn btn-set-page-style-0" type="default" @click="setPageStyle(false)">setPageStyle(false)</button>
<text class="page-style">当前 PageStyle</text>
<text class="page-style-value">{{pageStyleText}}</text>
<text class="status">状态:</text>
<view class="status-list">
<text>enablePullDownRefresh: {{enablePullDownRefreshStatus}}</text>
</view>
<text class="tips">当前版本仅支持设置属性 enablePullDownRefresh</text>
</view>
</template>
<script>
class Page {
constructor(public route : string) {
}
}
export default {
data() {
return {
checked: false,
pages: [] as Page[],
currentPageStyle: {} as UTSJSONObject,
// TODO
enablePullDownRefreshStatus: true
}
},
computed: {
pageStyleText() : string {
return JSON.stringify(this.currentPageStyle)
}
},
onPullDownRefresh() {
setTimeout(() => {
uni.stopPullDownRefresh()
}, 3000)
},
methods: {
_getCurrentPages: function () {
this.pages.length = 0
const pages = getCurrentPages()
this.pages.push(new Page(pages[0].route))
if (this.pages[0].route.includes('/tabBar/')) {
this.checked = true
}
for (let i = 1; i < pages.length; i++) {
this.pages.push(new Page(pages[i].route))
if (pages[i].route.includes('/tabBar/')) {
this.checked = false
}
}
},
getPageStyle() {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
this.currentPageStyle = currentPage.$getPageStyle();
},
setPageStyle(enable : boolean) {
// 目前仅支持 enablePullDownRefresh
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage.$setPageStyle({
enablePullDownRefresh: enable
});
this.enablePullDownRefreshStatus = enable
},
startPullDownRefresh() {
uni.startPullDownRefresh()
}
// getCurrentPage(): Page {
// const pages = getCurrentPages();
// const currentPage = pages[pages.length - 1];
// return currentPage;
// }
},
}
</script>
<style>
.btn {
margin-top: 10px;
}
<script>
class Page {
constructor(public route : string) {
}
.page-style {
margin-top: 15px;
}
.page-style-value {
margin-top: 5px;
padding: 5px;
background-color: #fff;
width: 100%;
/* #ifdef WEB */
overflow-wrap: break-word;
/* #endif */
}
export default {
data() {
return {
checked: false,
pages: [] as Page[],
}
},
methods: {
_getCurrentPages: function () {
this.pages.length = 0
const pages = getCurrentPages()
this.pages.push(new Page(pages[0].route))
if (this.pages[0].route.includes('/tabBar/')) {
this.checked = true
}
for (let i = 1; i < pages.length; i++) {
this.pages.push(new Page(pages[i].route))
if (pages[i].route.includes('/tabBar/')) {
this.checked = false
}
}
},
},
.status {
margin-top: 20px;
}
</script>
.status-list {
margin-top: 5px;
}
.tips {
font-size: 12px;
margin-top: 15px;
opacity: .8;
}
</style>
const PAGE_PATH = '/pages/API/get-current-pages/set-page-style-disable-pull-down-refresh'
describe('getCurrentPages', () => {
if (process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) {
it('not-support', async () => {
expect(1).toBe(1)
})
return
}
let page
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
expect(isEnablePullDownRefresh1).toBe(false)
await page.callMethod('setPageStyle', true)
await page.waitFor(200)
await page.callMethod('getPageStyle')
await page.waitFor(200)
const isEnablePullDownRefresh2 = (await page.data()).currentPageStyle.enablePullDownRefresh
expect(isEnablePullDownRefresh2).toBe(true)
await page.callMethod('startPullDownRefresh')
await page.waitFor(500)
const image3 = await program.screenshot({
fullPage: true
});
expect(image3).toSaveImageSnapshot();
await page.waitFor(3500)
// setPageStyle
await page.callMethod('setPageStyle', false)
await page.waitFor(200)
await page.callMethod('startPullDownRefresh')
await page.waitFor(500)
const image2 = await program.screenshot({
fullPage: true
});
expect(image2).toSaveImageSnapshot();
})
})
<template>
<page-head title="getCurrentPages"></page-head>
<view class="uni-padding-wrap">
<button class="btn btn-get-page-style" type="default" @click="getPageStyle">getPageStyle</button>
<button class="btn btn-set-page-style-1" type="default" @click="setPageStyle(true)">setPageStyle(true)</button>
<button class="btn btn-set-page-style-0" type="default" @click="setPageStyle(false)">setPageStyle(false)</button>
<text class="page-style">当前 PageStyle</text>
<text class="page-style-value">{{pageStyleText}}</text>
<text class="status">状态:</text>
<view class="status-list">
<text>enablePullDownRefresh: {{enablePullDownRefreshStatus}}</text>
</view>
<text class="tips">当前版本仅支持设置属性 enablePullDownRefresh</text>
</view>
</template>
<script>
class Page {
constructor(public route : string) {
}
}
export default {
data() {
return {
checked: false,
pages: [] as Page[],
currentPageStyle: {} as UTSJSONObject,
// TODO
enablePullDownRefreshStatus: true
}
},
computed: {
pageStyleText() : string {
return JSON.stringify(this.currentPageStyle)
}
},
onPullDownRefresh() {
setTimeout(() => {
uni.stopPullDownRefresh()
}, 3000)
},
methods: {
getPageStyle() {
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
this.currentPageStyle = currentPage.$getPageStyle();
},
setPageStyle(enable : boolean) {
// 目前仅支持 enablePullDownRefresh
const pages = getCurrentPages();
const currentPage = pages[pages.length - 1];
currentPage.$setPageStyle({
enablePullDownRefresh: enable
});
this.enablePullDownRefreshStatus = enable
},
startPullDownRefresh() {
uni.startPullDownRefresh()
}
},
}
</script>
<style>
.btn {
margin-top: 10px;
}
.page-style {
margin-top: 15px;
}
.page-style-value {
margin-top: 5px;
padding: 5px;
background-color: #fff;
width: 100%;
/* #ifdef WEB */
overflow-wrap: break-word;
/* #endif */
}
.status {
margin-top: 20px;
}
.status-list {
margin-top: 5px;
}
.tips {
font-size: 12px;
margin-top: 15px;
opacity: .8;
}
</style>
......@@ -51,17 +51,25 @@
const res = uni.getDeviceInfo();
// 获取像素比, 供截图对比使用
setDevicePixelRatio(res.devicePixelRatio !== null ? parseFloat(res.devicePixelRatio!) : 1)
this.items = [] as Item[];
for (const key in res) {
const value = res[key];
if (value != null) {
const item = {
label: key,
value: "" + ((typeof value == "object") ? JSON.stringify(value) : value)
} as Item;
this.items.push(item);
}
}
this.items = [] as Item[];
const res_str = JSON.stringify(res);
const res_obj = JSON.parseObject(res_str);
const res_map = res_obj!.toMap();
let keys = [] as string[]
res_map.forEach((_, key) => {
keys.push(key);
});
keys.sort().forEach( key => {
const value = res[key];
if(value != null){
const item = {
label: key,
value: "" + ((typeof value == "object")? JSON.stringify(value) : value)
} as Item;
this.items.push(item);
}
});
}
}
}
......
......@@ -2,7 +2,7 @@ const PAGE_PATH =
"/pages/API/get-element-by-id/get-element-by-id-multiple-root-node";
let page;
describe("getElementByIdForMultipleRootNode", () => {
describe("getElementByIdForMultipleRootNode", () => {
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH);
await page.waitFor('view');
......@@ -16,7 +16,7 @@ describe("getElementByIdForMultipleRootNode", () => {
await page.callMethod("changeTextColor");
await page.callMethod("changeViewStyle");
await page.waitFor(500);
const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
const image = await program.screenshot({fullPage: true});
expect(image).toSaveImageSnapshot();
});
});
});
......@@ -15,7 +15,7 @@ describe("getElementById", () => {
await page.callMethod("changeTextColor");
await page.callMethod("changeViewStyle");
await page.waitFor(500);
const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
const image = await program.screenshot({fullPage: true});
expect(image).toSaveImageSnapshot();
});
});
<template>
<!-- #ifdef APP -->
<scroll-view class="page-scroll-view">
<!-- #endif -->
<view class="page">
<page-head :title="title"></page-head>
<view class="service-item" v-for="(item, index) in serviceList" :key="index">
<text class="service-name">{{item.name}}:</text>
<view class="provider-list">
<text class="provider-item" v-for="(item2, index2) in item.provider" :key="index2">{{item2}}</text>
</view>
</view>
<button class="btn-get-provider" type="primary" @click="getProvider">getProvider</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
type ProviderItem = {
service : string,
name : string,
provider : string[]
}
export default {
data() {
return {
title: 'provider',
serviceList: [
{ service: "oauth", name: "登陆", provider: [] },
{ service: "share", name: "分享", provider: [] },
{ service: "payment", name: "支付", provider: [] },
{ service: "push", name: "推送", provider: [] },
{ service: "location", name: "定位", provider: [] }
] as ProviderItem[]
}
},
methods: {
getProvider() {
this.serviceList.forEach((item : ProviderItem) => {
uni.getProvider({
service: item.service,
success: (e) => {
this.updateProvider(e.service, e.provider);
}
})
})
},
updateProvider(service : string, provider : string[]) {
const item : ProviderItem | null = this.serviceList.find((item : ProviderItem) : boolean => {
return item.service == service
});
if (item != null) {
item.provider = provider
}
}
}
}
</script>
<style>
.page {
padding: 15px;
}
.service-item {
margin-top: 10px;
}
.service-name {
font-weight: bold;
}
.provider-list {
margin-left: 32px;
}
.provider-item {
line-height: 1.5;
}
.btn-get-provider {
margin-top: 30px;
}
</style>
......@@ -7,20 +7,15 @@ describe('ExtApi-GetSystemInfo', () => {
const stringProperties = [
'appId', 'appLanguage', 'appName', 'appVersion', 'appVersionCode',
'brand', 'deviceId', 'deviceBrand', 'deviceModel', 'deviceType', 'language',
'model', 'osName', 'osVersion', 'osLanguage', 'platform', 'system', 'ua', 'uniCompileVersion',
'model', 'osName', 'osVersion', 'osLanguage', 'platform', 'system', 'ua', 'uniCompilerVersion',
'uniPlatform', 'uniRuntimeVersion', 'romName', 'romVersion',
]
const numberProperties = [
'osAndroidAPILevel', 'devicePixelRatio', 'pixelRatio', 'screenWidth', 'screenHeight', 'statusBarHeight',
'windowWidth',
'windowHeight', 'windowTop', 'windowBottom', 'screenTop',
'uniCompileVersionCode', 'uniRuntimeVersionCode'
]
if (process.env.uniTestPlatformInfo.indexOf('web') === -1) {
stringProperties.push('version')
}
'uniCompilerVersionCode', 'uniRuntimeVersionCode'
]
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
......
......@@ -51,33 +51,47 @@
getSystemInfo: function () {
uni.getSystemInfo({
success: (res) => {
this.items = [] as Item[];
for (const key in res) {
const value = res[key];
if (value != null) {
const item = {
label: key,
value: "" + ((typeof value == "object") ? JSON.stringify(value) : value)
} as Item;
this.items.push(item);
}
}
this.items = [] as Item[];
const res_str = JSON.stringify(res);
const res_obj = JSON.parseObject(res_str);
const res_map = res_obj!.toMap();
let keys = [] as string[]
res_map.forEach((_, key) => {
keys.push(key);
});
keys.sort().forEach( key => {
const value = res[key];
if(value != null){
const item = {
label: key,
value: "" + ((typeof value == "object")? JSON.stringify(value) : value)
} as Item;
this.items.push(item);
}
});
},
})
},
getSystemInfoSync: function () {
this.items = [] as Item[];
const res = uni.getSystemInfoSync()
for (const key in res) {
const value = res[key];
if (value != null) {
const item = {
label: key,
value: "" + ((typeof value == "object") ? JSON.stringify(value) : value)
} as Item;
this.items.push(item);
}
}
const res = uni.getSystemInfoSync()
const res_str = JSON.stringify(res);
const res_obj = JSON.parseObject(res_str);
const res_map = res_obj!.toMap();
let keys = [] as string[]
res_map.forEach((_, key) => {
keys.push(key);
});
keys.sort().forEach( key => {
const value = res[key];
if(value != null){
const item = {
label: key,
value: "" + ((typeof value == "object")? JSON.stringify(value) : value)
} as Item;
this.items.push(item);
}
});
},
//自动化测试例专用
jest_getSystemInfo() : GetSystemInfoResult {
......
const PAGE_PATH = '/pages/API/get-system-setting/get-system-setting'
describe('ExtApi-GetSystemSetting', () => {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1) {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
it('web', () => {
expect(1).toBe(1)
})
......@@ -18,10 +18,10 @@ describe('ExtApi-GetSystemSetting', () => {
it('Check GetSystemSetting', async () => {
for (const key in res) {
const value = res[key];
if (res['bluetoothEnabled'] == undefined) {
expect(res['bluetoothError']).not.toBe("")
} else {
expect(res['bluetoothError'] == undefined).toBe(true)
if (res['bluetoothEnabled'] == undefined || res['bluetoothEnabled'] === false) {
expect(res['bluetoothError']).not.toBe("")
} else {
expect(res['bluetoothError'] == undefined).toBe(true)
}
if (res['wifiEnabled'] == undefined) {
......
......@@ -19,7 +19,10 @@
</view>
</template>
<script>
import { setStatusBarHeight } from '@/store/index.uts'
import { setStatusBarHeight, setSafeArea } from '@/store/index.uts'
// #ifdef APP-ANDROID
import type { SafeArea } from '@/store/index.uts'
// #endif
type Item = {
label : string,
......@@ -33,17 +36,46 @@
}
},
onUnload: function () {
},
onReady() {
this.getWindowInfo()
},
onReady() {
this.getWindowInfo()
},
methods: {
getWindowInfo: function () {
const res = uni.getWindowInfo();
// 获取状态栏+导航栏高度, 供截图对比使用
// 获取状态栏高度, 供截图对比使用
setStatusBarHeight(res.statusBarHeight);
// 获取安全区信息,供截图使用
// #ifdef APP-ANDROID
setSafeArea({
top: res.safeArea.top,
left: res.safeArea.left,
right: res.safeArea.right,
bottom: res.safeArea.bottom,
width: res.safeArea.width,
height: res.safeArea.height,
} as SafeArea);
// #endif
// #ifdef APP-IOS
setSafeArea({
top: res.safeArea.top,
left: res.safeArea.left,
right: res.safeArea.right,
bottom: res.safeArea.bottom,
width: res.safeArea.width,
height: res.safeArea.height,
});
// #endif
this.items = [] as Item[];
for (const key in res) {
const res_str = JSON.stringify(res);
const res_obj = JSON.parseObject(res_str);
const res_map = res_obj!.toMap();
let keys = [] as string[]
res_map.forEach((_, key) => {
keys.push(key);
});
keys.sort().forEach(key => {
const value = res[key];
if (value != null) {
const item = {
......@@ -52,7 +84,7 @@
} as Item;
this.items.push(item);
}
}
});
},
//自动化测试例专用
jest_getWindowInfo() : GetWindowInfoResult {
......
......@@ -7,13 +7,13 @@ describe("loadFontFace", () => {
await page.waitFor(4000);
});
it("parent screenshot", async () => {
const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
const image = await program.screenshot({fullPage: true});
expect(image).toSaveImageSnapshot();
});
it("child screenshot", async () => {
const page = await program.navigateTo(CHILD_PAGE_PATH);
await page.waitFor(3000);
const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
const image = await program.screenshot({fullPage: true});
expect(image).toSaveImageSnapshot();
});
});
此差异已折叠。
......@@ -10,8 +10,8 @@ describe("onLoad", () => {
await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "adjustData");
await page.waitFor(1000);
const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
const image = await program.screenshot({fullPage: true});
expect(image).toSaveImageSnapshot();
});
it("navigateTo", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
......@@ -22,7 +22,7 @@ describe("onLoad", () => {
expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
});
it("navigateBack", async () => {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "navigateBack");
......@@ -61,14 +61,14 @@ describe("onLoad", () => {
await page.callMethod("navigateToOnLoadWithType", "showToast");
await page.waitFor(1000);
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
height: 2140,
},
});
expect(image).toMatchImageSnapshot({
expect(image).toSaveImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: "percent",
});
......@@ -79,17 +79,17 @@ describe("onLoad", () => {
await page.callMethod("navigateToOnLoadWithType", "showLoading");
await page.waitFor(1000);
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
height: 2140,
},
});
expect(image).toMatchImageSnapshot({
expect(image).toSaveImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: "percent",
});
});
});
it("showModal", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
......@@ -97,14 +97,14 @@ describe("onLoad", () => {
await page.callMethod("navigateToOnLoadWithType", "showModal");
await page.waitFor(1000);
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
height: 2140,
},
});
expect(image).toMatchImageSnapshot({
expect(image).toSaveImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: "percent",
});
......@@ -115,16 +115,16 @@ describe("onLoad", () => {
await page.callMethod("navigateToOnLoadWithType", "showActionSheet");
await page.waitFor(1000);
const image = await program.screenshot({
adb: true,
deviceShot: true,
area: {
x: 0,
y: 200,
height: 2140,
},
});
expect(image).toMatchImageSnapshot({
expect(image).toSaveImageSnapshot({
failureThreshold: 0.05,
failureThresholdType: "percent",
});
});
});
});
<template>
<view class="selector-query-child-view">
<text class="selector-query-child-text">selector-query-child</text>
</view>
</template>
<script>
export default {
data() {
return {
top: 0
}
},
mounted() {
uni.createSelectorQuery().in(this).select('.selector-query-child-view').boundingClientRect().exec((ret) => {
if (ret.length == 1) {
const nodeInfo = ret[0] as NodeInfo;
this.top = nodeInfo.top!
}
})
}
}
</script>
<style>
.selector-query-child-view {
margin-top: 15px;
}
</style>
......@@ -53,6 +53,11 @@ describe('nodes-info', () => {
expect(nodeInfo2.top > 220).toBe(true)
expect(Math.round(nodeInfo2.width)).toBe(RECT_WIDTH)
expect(Math.round(nodeInfo2.height)).toBe(RECT_HEIGHT)
})
it('get-node-info-child', async () => {
const child = await page.$('.node-child')
const childData = await child.data()
expect(childData.top > 100).toBe(true)
})
// #ifdef APP
......
......@@ -17,7 +17,8 @@
max: 0
}
},
onLoad() {
onReady() {
uni.startPullDownRefresh();
this.initData();
},
onReachBottom() {
......@@ -47,7 +48,7 @@
}
this.data = this.data.concat(data);
uni.stopPullDownRefresh();
}, 300);
}, 1000);
},
setListData() {
let data:Array<number> = [];
......
此差异已折叠。
......@@ -2,11 +2,17 @@ const PAGE_PATH =
"/pages/API/request-payment/request-payment";
describe("payment", () => {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1) {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW === 'true') {
it('web', () => {
expect(1).toBe(1)
})
return
}
if (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('ios')) {
it('ios', () => {
expect(1).toBe(1)
})
return
}
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
const PAGE_PATH = '/pages/API/storage/storage'
jest.setTimeout(50000);
const PAGE_PATH = '/pages/API/storage/storage'
describe('ExtApi-StorageInfoTest', () => {
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
......@@ -11,6 +11,6 @@ describe('css-font-family', () => {
const image = await program.screenshot({
fullPage: true
})
expect(image).toMatchImageSnapshot()
expect(image).toSaveImageSnapshot()
});
});
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册