提交 b8deac71 编写于 作者: shutao-dc's avatar shutao-dc

Revert "Merge remote-tracking branch 'remotes/origin/dev' into alpha"

This reverts commit 4f4c8ea4, reversing
changes made to f278f7ac.
上级 4f4c8ea4
......@@ -3,5 +3,4 @@ node_modules/
unpackage/
.DS_Store
.hbuilderx/
__image_snapshots__/
__snapshot__
\ No newline at end of file
__image_snapshots__/
\ 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',
......
......@@ -82,7 +82,7 @@
</view>
</view>
<view class="input-wrapper">
<input class="uni-input" :type="inputType" :value="inputClearValue" :placeholder="title" maxlength="-1" @input="input" @blur="blur"
<input class="uni-input" :type="inputType" :value="inputClearValue" :placeholder="title" @input="input" @blur="blur"
@focus="focus" />
<image class="input-wrapper_image" src="/static/icons/clear.png" v-if="showClearIcon" @click="clearIcon">
</image>
......
......@@ -40,13 +40,6 @@
<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 fs = require("fs");
// 自动化测试
const path = require('path');
const {
configureToMatchImageSnapshot
configureToMatchImageSnapshot
} = require('jest-image-snapshot');
let saveImageSnapshotDir = process.env.saveImageSnapshotDir || path.join(__dirname, '__snapshot__');
expect.extend({
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();
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}__`
function checkSnapshotDir(snapshotDir) {
if (!fs.existsSync(snapshotDir)) {
fs.mkdirSync(snapshotDir, {
recursive: true,
});
}
}
const timesCalled = new Map();
expect.extend({
toMatchImageSnapshot: configureToMatchImageSnapshot({
customSnapshotIdentifier(args) {
return args.currentTestName.replace(/\//g, '-').replace(' ', '-');
},
customSnapshotsDir: path.join(__dirname, baseFolderName),
customDiffDir: path.join(__dirname, `${folderName}/`, 'diff'),
}),
});
// 自动化测试
// 自动化测试
module.exports = {
testTimeout: 30000,
reporters: ['default'],
......@@ -6,12 +6,6 @@ module.exports = {
moduleFileExtensions: ['js', 'json'],
rootDir: __dirname,
testMatch: ["<rootDir>/pages/**/*test.[jt]s?(x)"],
testPathIgnorePatterns: [
'/node_modules/',
'<rootDir>/pages/API/download-file/download-file.test.js',
'<rootDir>/pages/API/upload-file/upload-file.test.js',
'<rootDir>/pages/API/get-battery-info/get-battery-info.test.js',
'<rootDir>/pages/webview-screenshot-comparison/webview-screenshot-comparison.test.js'
],
testPathIgnorePatterns: ['/node_modules/'],
setupFilesAfterEnv: ['<rootDir>/jest-setup.js'],
}
// 仅测试 console.log 时机问题
import './test-main-console.uts'
import App from './App.uvue'
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 uni-app x",
"name": "hello-uniapp x",
"appid": "__UNI__3584C99",
"description": "",
"versionName": "1.0.23",
......
......@@ -269,6 +269,7 @@
"navigationBarTitleText": "web-view-local"
}
},
// #ifndef APP-IOS
{
"path": "pages/component/unicloud-db-contacts/list",
"style": {
......@@ -300,6 +301,7 @@
"navigationBarTitleText": "mixinDatacom"
}
},
// #endif
{
"path": "pages/component/general-attribute/general-attribute",
"style": {
......@@ -535,6 +537,7 @@
"navigationBarTitleText": "websocket-global"
}
},
// #ifndef APP-IOS
{
"path": "pages/API/unicloud-call-function/unicloud-call-function",
"style": {
......@@ -547,6 +550,7 @@
"navigationBarTitleText": ""
}
},
// #endif
{
"path": "pages/API/get-system-info/get-system-info",
"style": {
......@@ -572,13 +576,8 @@
"navigationBarTitleText": "get-system-setting"
}
},
{
"path": "pages/API/element-takesnapshot/element-takesnapshot",
"style": {
"navigationBarTitleText": "takeSnapshot",
"enablePullDownRefresh": false
}
},
// #endif
// #ifndef WEB
{
"path": "pages/API/get-app-authorize-setting/get-app-authorize-setting",
"style": {
......@@ -622,6 +621,7 @@
"navigationBarTitleText": "event-bus"
}
},
// #ifndef APP-IOS
{
"path": "pages/API/unicloud-file-api/unicloud-file-api",
"style": {
......@@ -640,24 +640,32 @@
"navigationBarTitleText": "电量"
}
},
// #endif
{
"path": "pages/API/get-window-info/get-window-info",
"style": {
"navigationBarTitleText": "get-window-info"
}
},
// #ifdef APP-ANDROID
{
"path": "pages/API/element-draw/element-draw",
"path": "pages/API/facial-recognition-verify/facial-recognition-verify",
"style": {
"navigationBarTitleText": "getDrawableContext",
"navigationBarTitleText": "",
"enablePullDownRefresh": false
}
},
// #ifdef APP
{
"path": "pages/API/facial-recognition-verify/facial-recognition-verify",
"path": "pages/API/element-takesnapshot/element-takesnapshot",
"style": {
"navigationBarTitleText": "实人认证",
"navigationBarTitleText": "takeSnapshot",
"enablePullDownRefresh": false
}
},
{
"path": "pages/API/element-draw/element-draw",
"style": {
"navigationBarTitleText": "getDrawableContext",
"enablePullDownRefresh": false
}
},
......@@ -1046,7 +1054,7 @@
{
"path": "pages/template/list-news/list-news",
"style": {
"navigationBarTitleText": "列表到详情示例(吸顶)"
"navigationBarTitleText": "列表到详情示例"
}
},
{
......@@ -1109,21 +1117,14 @@
{
"path": "pages/template/long-list/long-list",
"style": {
"navigationBarTitleText": "Android顶部搜索框随时下移长列表",
"navigationBarTitleText": "顶部搜索框随时下移长列表",
"enablePullDownRefresh": true
}
},
{
"path": "pages/template/long-list2/long-list2",
"style": {
"navigationBarTitleText": "顶部banner长列表嵌套滚动示例",
"enablePullDownRefresh": true
}
},
{
"path": "pages/template/long-list-nested/long-list-nested",
"style": {
"navigationBarTitleText": "顶部banner长列表嵌套滚动示例",
"navigationBarTitleText": "顶部banner长列表",
"enablePullDownRefresh": true
}
},
......@@ -1154,15 +1155,13 @@
}
},
// #endif
// #ifdef APP
// #ifdef APP-ANDROID
{
"path": "pages/template/calendar/calendar",
"style": {
"navigationBarTitleText": "日历"
}
},
// #endif
// #ifdef APP-ANDROID
{
"path": "pages/template/schema/schema",
"style": {
......@@ -1206,27 +1205,6 @@
"enablePullDownRefresh": false
}
},
{
"path": "pages/component/list-view/list-view-refresh",
"style": {
"navigationBarTitleText": "list-view-refresh",
"enablePullDownRefresh": false
}
},
{
"path": "pages/component/nested-scroll-header/nested-scroll-header",
"style": {
"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": {
......@@ -1235,48 +1213,11 @@
}
},
{
"path": "pages/API/request-payment-uni-pay/request-payment-uni-pay",
"style": {
"navigationBarTitleText": "uni-pay示例",
"enablePullDownRefresh": false
}
},
{
"path": "pages/API/request-payment-uni-pay/order-detail",
"path": "pages/component/list-view/list-view-refresh",
"style": {
"navigationBarTitleText": "订单详情示例",
"navigationBarTitleText": "list-view-refresh",
"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
}
}
// #endif
],
......
......@@ -3,7 +3,7 @@
describe('API-loading', () => {
let page;
const isApp = process.env.UNI_OS_NAME === "android" || process.env.UNI_OS_NAME === "ios";
const isAndroid = process.env.UNI_OS_NAME === "android";
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 (isApp) {
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -27,13 +27,13 @@ describe('API-loading', () => {
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -57,9 +57,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -67,13 +67,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
......@@ -99,9 +99,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -109,13 +109,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
......@@ -140,9 +140,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -150,13 +150,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
......@@ -181,9 +181,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -191,13 +191,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -222,9 +222,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -232,13 +232,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
......@@ -266,9 +266,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -276,13 +276,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
......@@ -307,9 +307,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -317,13 +317,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
......@@ -348,9 +348,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -358,13 +358,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -389,9 +389,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -399,13 +399,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
......@@ -431,9 +431,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -441,13 +441,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
......@@ -472,9 +472,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -482,13 +482,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
......@@ -513,9 +513,9 @@ describe('API-loading', () => {
await btnToastDurationButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -523,13 +523,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......
......@@ -116,13 +116,7 @@
icon: "none"
})
},
fail: (e) => {
if(this.showErrorToast){
uni.showToast({
title: e.errMsg,
icon: "none"
})
}
fail: (e) => {
console.log(e);
}
})
......
......@@ -46,7 +46,7 @@
图片质量(%)
</view>
<view class="uni-list-cell-right">
<input :value="cropPercent" @confirm="cropPercentConfim" type="number" maxlength="-1"/>
<input :value="cropPercent" @confirm="cropPercentConfim" type="number" />
</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" maxlength="-1"/>
<input :value="cropWidth" @confirm="cropWidthConfim" type="number" />
</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" maxlength="-1"/>
<input :value="cropHeight" @confirm="cropHeightConfim" type="number" />
</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') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
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,7 +68,6 @@
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 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1) {
it('dummyTest', () => {
expect(1).toBe(1)
})
......
......@@ -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="姓名" maxlength="-1"/>
placeholder="姓名" />
</view>
<view class="uni-btn-v uni-common-mt">
<input class="uni-input" type="text" v-model="idCard" name="id-card"
placeholder="身份证号" maxlength="-1"/>
placeholder="身份证号" />
</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 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
describe('ExtApi-GetAppAuthorizeSetting', () => {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1) {
it('dummyTest', () => {
expect(1).toBe(1)
})
......
<template>
<page-head :title="title"></page-head>
<view class="uni-common-mt">
<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">
<view class="uni-list-cell">
<view class="uni-pd">
<view class="uni-label" style="width:180px;">是否授权使用摄像头</view>
......@@ -51,8 +33,7 @@
<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>
......@@ -60,34 +41,7 @@
<view class="uni-list-cell-db">
<input type="text" :disabled="true" placeholder="未获取" :value="notificationAuthorized" />
</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>
<view class="uni-padding-wrap">
<view class="uni-btn-v">
......@@ -101,16 +55,11 @@
data() {
return {
title: 'getAppAuthorizeSetting',
cameraAuthorized: "",
albumAuthorized: "",
cameraAuthorized: "",
locationAuthorized: "",
locationAccuracy: "",
microphoneAuthorized: "",
bluetoothAuthorized: "",
notificationAuthorized: "",
notificationAlertAuthorized: "",
notificationBadgeAuthorized: "",
notificationSoundAuthorized: ""
microphoneAuthorized: "",
notificationAuthorized: ""
}
},
onUnload: function () {
......@@ -122,15 +71,7 @@
this.locationAuthorized = res.locationAuthorized;
this.locationAccuracy = res.locationAccuracy ?? "unsupported";
this.microphoneAuthorized = res.microphoneAuthorized;
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
this.notificationAuthorized = res.notificationAuthorized;
}
}
}
......
......@@ -6,11 +6,14 @@ describe('ExtApi-GetAppBaseInfo', () => {
let res;
const stringProperties = [
'appId', 'appName', 'appVersion', 'appVersionCode', 'appLanguage',
'language', 'uniCompilerVersion', 'uniPlatform', 'uniRuntimeVersion',
'language', 'uniCompileVersion', 'uniPlatform', 'uniRuntimeVersion',
]
const numberProperties = [
'uniCompilerVersionCode', 'uniRuntimeVersionCode'
]
'uniCompileVersionCode', 'uniRuntimeVersionCode'
]
if (process.env.uniTestPlatformInfo.indexOf('web') === -1) {
stringProperties.push('version')
}
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(600);
......
......@@ -35,16 +35,8 @@
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[];
keys.sort().forEach( key => {
for(const key in res){
const value = res[key];
if(value != null){
const item = {
......@@ -53,8 +45,7 @@
} as Item;
this.items.push(item);
}
});
}
}
}
}
......
......@@ -51,25 +51,17 @@
const res = uni.getDeviceInfo();
// 获取像素比, 供截图对比使用
setDevicePixelRatio(res.devicePixelRatio !== null ? parseFloat(res.devicePixelRatio!) : 1)
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);
}
});
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);
}
}
}
}
}
......
......@@ -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');
......@@ -17,6 +17,6 @@ describe("getElementByIdForMultipleRootNode", () => {
await page.callMethod("changeViewStyle");
await page.waitFor(500);
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
});
});
});
......@@ -16,6 +16,6 @@ describe("getElementById", () => {
await page.callMethod("changeViewStyle");
await page.waitFor(500);
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
});
});
......@@ -2,7 +2,7 @@ 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) {
it('dummyTest', () => {
expect(1).toBe(1)
})
......@@ -116,11 +116,9 @@ describe('ExtApi-FileManagerTest', () => {
await btnReadDirButton.tap()
await isDone()
fileListComplete = await getData('fileListComplete')
fileListComplete.sort()
expect(JSON.stringify(fileListComplete)).toEqual("[\"1.txt\",\"b\"]")
expect(JSON.stringify(fileListComplete)).toEqual("[\"b\",\"1.txt\"]")
fileListSuccess = await getData('fileListSuccess')
fileListSuccess.sort()
expect(JSON.stringify(fileListSuccess)).toEqual("[\"1.txt\",\"b\"]")
expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\",\"1.txt\"]")
// 获取和对比 文件内容
const btnReadFileButton = await page.$('#btn-read-file')
await btnReadFileButton.tap()
......@@ -178,11 +176,9 @@ describe('ExtApi-FileManagerTest', () => {
// 1.txt 2.txt 两个文件都存在
fileListComplete = await getData('fileListComplete')
fileListComplete.sort()
expect(JSON.stringify(fileListComplete)).toEqual("[\"1.txt\",\"2.txt\",\"b\"]")
expect(JSON.stringify(fileListComplete)).toEqual("[\"b\",\"1.txt\",\"2.txt\"]")
fileListSuccess = await getData('fileListSuccess')
fileListSuccess.sort()
expect(JSON.stringify(fileListSuccess)).toEqual("[\"1.txt\",\"2.txt\",\"b\"]")
expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\",\"1.txt\",\"2.txt\"]")
// 测试 rename
await page.setData({
......@@ -199,11 +195,10 @@ describe('ExtApi-FileManagerTest', () => {
// 1.txt 3.txt 两个文件都存在
fileListComplete = await getData('fileListComplete')
fileListComplete.sort()
expect(JSON.stringify(fileListComplete)).toEqual("[\"1.txt\",\"3.txt\",\"b\"]")
expect(JSON.stringify(fileListComplete)).toEqual("[\"b\",\"1.txt\",\"3.txt\"]")
fileListSuccess = await getData('fileListSuccess')
fileListSuccess.sort()
expect(JSON.stringify(fileListSuccess)).toEqual("[\"1.txt\",\"3.txt\",\"b\"]")
expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\",\"1.txt\",\"3.txt\"]")
});
it('TEMP_PATH test', async () => {
......@@ -286,10 +281,8 @@ describe('ExtApi-FileManagerTest', () => {
// 期望通过 recursive = true的 文件夹删除,得到一个空的 /a 目录
fileListComplete = await getData('fileListComplete')
fileListComplete.sort()
expect(JSON.stringify(fileListComplete)).toEqual("[\"b\",\"" + testDirName + "\"]")
fileListSuccess = await getData('fileListSuccess')
fileListSuccess.sort()
expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\",\"" + testDirName + "\"]")
/**
......@@ -413,14 +406,13 @@ describe('ExtApi-FileManagerTest', () => {
await isDone()
fileListComplete = await getData('fileListComplete')
fileListComplete.sort()
expect(JSON.stringify(fileListComplete)).toEqual("[\"b\",\"" + testDirName + "\",\"提前创建的目录\"]")
fileListSuccess = await getData('fileListSuccess')
fileListSuccess.sort()
expect(JSON.stringify(fileListSuccess)).toEqual("[\"b\",\"" + testDirName + "\",\"提前创建的目录\"]")
await page.setData({
copyFromFile:"a/" + testDirName + "/中文路径/张三/name/中文文件.mock",
copyToFile:"a/提前创建的目录/4.txt"
})
......@@ -743,7 +735,6 @@ describe('ExtApi-FileManagerTest', () => {
recursiveVal: true,
copyToBasePath:globalRootPath,
basePath: globalRootPath,
globalTempPath:globalRootPath,
rmDirFile:'a',
mkdirFile:'a',
unlinkFile:'a/1.txt',
......@@ -809,7 +800,7 @@ describe('ExtApi-FileManagerTest', () => {
// 读取单个文件信息
let statsRet = await getData('statsRet')
expect(statsRet.length).toEqual(1)
expect(statsRet[0].path).toMatch(new RegExp('.*/a/1.txt$'))
expect(statsRet[0].path).toMatch(new RegExp('/storage/\\S+/Android/data/io.dcloud.uniappx/a/1.txt'))
expect(statsRet[0].stats.size).toEqual(69)
/**
......@@ -837,7 +828,7 @@ describe('ExtApi-FileManagerTest', () => {
await page.setData({
// asset 只能正式版测试,这里只能模拟返回路径
basePath:'',
copyFromFile:'static/test-image/logo.ico',
copyFromFile:'file:///android_asset/uni-uts/uni-prompt/toast_error.png',
copyToFile:'a/m/3.txt',
})
const btnCopyFileButton = await page.$('#btn-copy-file')
......@@ -856,25 +847,16 @@ describe('ExtApi-FileManagerTest', () => {
// 读取全部文件信息
statsRet = await getData('statsRet')
statsRet.sort(function(a, b){
if (a.path > b.path){
return 1
} else if (a.path < b.path){
return -1
}
return 0
})
console.log(statsRet)
expect(statsRet.length).toEqual(5)
expect(statsRet[0].path).toMatch(new RegExp('.*/a$'))
// expect(statsRet[0].stats.size).toEqual(0)
expect(statsRet[0].path).toMatch(new RegExp('/storage/\\S+/Android/data/io.dcloud.uniappx/a'))
expect(statsRet[0].stats.size).toEqual(0)
expect(statsRet[2].path).toMatch(new RegExp('.*/a/2.txt$'))
expect(statsRet[2].path).toMatch(new RegExp('/storage/\\S+/Android/data/io.dcloud.uniappx/a/2.txt'))
expect(statsRet[2].stats.size).toEqual(10)
expect(statsRet[4].path).toMatch(new RegExp('.*/a/m/3.txt$'))
expect(statsRet[4].stats.size).toEqual(156406)
expect(statsRet[4].path).toMatch(new RegExp('/storage/\\S+/Android/data/io.dcloud.uniappx/a/m/3.txt'))
expect(statsRet[4].stats.size).toEqual(5842)
// 清理文件,避免影响其他测试用例
......
......@@ -78,10 +78,9 @@
const fileManager = uni.getFileSystemManager()
fileManager.stat({
// path: `${this.basePath}${this.statFile}`, //USER_DATA_PATH
path: `${this.globalTempPath}${this.statFile}`, //CACHE_PATH
path: `${this.basePath}${this.statFile}`,
recursive: this.recursiveVal,
success: (res : StatSuccessResult) => {
success: function (res : StatSuccessResult) {
if (this.logAble) {
this.log += 'statFileInfoTest success:' + JSON.stringify(res) + '\n\n'
}
......@@ -89,14 +88,14 @@
this.statsRet = res.stats
console.log('this.statsRet', this.statsRet)
},
fail: (res : UniError) => {
fail: function (res : UniError) {
if (this.logAble) {
this.log += 'statFileInfoTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('statFileInfoTest fail', res)
this.lastFailError = res
},
complete: (res : any) => {
complete: function (res : any) {
console.log("statFileInfoTest complete", res)
this.done = true
if (res instanceof UniError) {
......@@ -112,7 +111,7 @@
fileManager.getFileInfo({
filePath: `${this.basePath}${this.getFileInfoFile}`,
digestAlgorithm: this.getFileInfoAlgorithm,
success: (res : GetFileInfoSuccessResult) => {
success: function (res : GetFileInfoSuccessResult) {
if (this.logAble) {
this.log += 'getFileInfoTest success:' + JSON.stringify(res) + '\n\n'
}
......@@ -120,14 +119,14 @@
this.getFileInfoSize = res.size
this.getFileInfoDigest = res.digest
},
fail: (res : UniError) => {
fail: function (res : UniError) {
if (this.logAble) {
this.log += 'getFileInfoTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: (res : any) => {
complete: function (res : any) {
console.log("complete", res)
this.done = true
if (res instanceof UniError) {
......@@ -143,20 +142,20 @@
fileManager.copyFile({
srcPath: `${this.basePath}${this.copyFromFile}`,
destPath: `${this.copyToBasePath}${this.copyToFile}`,
success: (res : FileManagerSuccessResult) => {
success: function (res : FileManagerSuccessResult) {
if (this.logAble) {
this.log += 'copyFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: function (res : UniError) {
if (this.logAble) {
this.log += 'copyFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: (res : any) => {
complete: function (res : any) {
console.log("complete", res)
this.done = true
if (res instanceof UniError) {
......@@ -172,20 +171,20 @@
fileManager.rename({
oldPath: `${this.basePath}${this.renameFromFile}`,
newPath: `${this.basePath}${this.renameToFile}`,
success: (res : FileManagerSuccessResult) => {
success: function (res : FileManagerSuccessResult) {
if (this.logAble) {
this.log += 'renameFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: function (res : UniError) {
if (this.logAble) {
this.log += 'renameFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: (res : any) => {
complete: function (res : any) {
this.done = true
console.log("complete", res)
if (res instanceof UniError) {
......@@ -199,27 +198,28 @@
const fileManager = uni.getFileSystemManager()
fileManager.readdir({
dirPath: `${this.basePath}${this.readDir}`,
success: (res : ReadDirSuccessResult) => {
success: function (res : ReadDirSuccessResult) {
if (this.logAble) {
this.log += 'readDirTest success:' + JSON.stringify(res) + '\n\n'
}
console.log("success", res)
this.fileListSuccess = res.files
},
fail: (res : UniError) => {
fail: function (res : UniError) {
if (this.logAble) {
this.log += 'readDirTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: (res : any) => {
complete: function (res : any) {
console.log("complete", res)
this.done = true
if (res instanceof ReadDirSuccessResult) {
this.fileListComplete = res.files
}
if (res instanceof UniError) {
this.lastCompleteError = res
} else {
this.fileListComplete = (res as ReadDirSuccessResult).files
}
}
} as ReadDirOptions)
......@@ -232,20 +232,20 @@
filePath: `${this.basePath}${this.writeFile}`,
data: this.writeFileContent,
encoding: this.writeFileEncoding,
success: (res : FileManagerSuccessResult) => {
success: function (res : FileManagerSuccessResult) {
if (this.logAble) {
this.log += 'writeFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: function (res : UniError) {
if (this.logAble) {
this.log += 'writeFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail')
this.lastFailError = res
},
complete: (res : any) => {
complete: function (res : any) {
this.done = true
console.log("complete")
if (res instanceof UniError) {
......@@ -261,21 +261,21 @@
fileManager.readFile({
filePath: `${this.basePath}${this.readFile}`,
encoding: this.readFileEncoding,
success: (res : ReadFileSuccessResult) => {
success: function (res : ReadFileSuccessResult) {
if (this.logAble) {
this.log += 'readFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
this.readFileRet = res.data
},
fail: (res : UniError) => {
fail: function (res : UniError) {
if (this.logAble) {
this.log += 'readFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: (res : any) => {
complete: function (res : any) {
console.log("complete", res)
this.done = true
if (res instanceof UniError) {
......@@ -290,20 +290,20 @@
fileManager.rmdir({
dirPath: `${this.basePath}${this.rmDirFile}`,
recursive: this.recursiveVal,
success: (res : FileManagerSuccessResult) => {
success: function (res : FileManagerSuccessResult) {
if (this.logAble) {
this.log += 'rmdirTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: function (res : UniError) {
if (this.logAble) {
this.log += 'rmdirTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: (res : any) => {
complete: function (res : any) {
console.log("complete", res)
this.done = true
if (res instanceof UniError) {
......@@ -320,20 +320,20 @@
fileManager.mkdir({
dirPath: `${this.basePath}${this.mkdirFile}`,
recursive: this.recursiveVal,
success: (res : FileManagerSuccessResult) => {
success: function (res : FileManagerSuccessResult) {
if (this.logAble) {
this.log += 'mkdirTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: function (res : UniError) {
if (this.logAble) {
this.log += 'mkdirTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: (res : any) => {
complete: function (res : any) {
if (res instanceof UniError) {
this.lastCompleteError = res
}
......@@ -348,21 +348,21 @@
const fileManager = uni.getFileSystemManager()
fileManager.access({
path: `${this.basePath}${this.accessFile}`,
success: (res : FileManagerSuccessResult) => {
success: function (res : FileManagerSuccessResult) {
if (this.logAble) {
this.log += 'accessFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
this.accessFileRet = res.errMsg
},
fail: (res : UniError) => {
fail: function (res : UniError) {
if (this.logAble) {
this.log += 'accessFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: (res : any) => {
complete: function (res : any) {
if (res instanceof UniError) {
this.lastCompleteError = res
}
......@@ -377,20 +377,20 @@
fileManager.unlink({
filePath: `${this.basePath}${this.unlinkFile}`,
success: (res : FileManagerSuccessResult) => {
success: function (res : FileManagerSuccessResult) {
if (this.logAble) {
this.log += 'unlinkTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: function (res : UniError) {
if (this.logAble) {
this.log += 'unlinkTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: (res : any) => {
complete: function (res : any) {
if (res instanceof UniError) {
this.lastCompleteError = res
}
......@@ -403,26 +403,26 @@
const fileManager = uni.getFileSystemManager()
fileManager.readdir({
dirPath: `${this.basePath}${this.rmDirFile}`,
success: (res : ReadDirSuccessResult) => {
success: function (res : ReadDirSuccessResult) {
console.log("success to readdir", res)
res.files.forEach(element => {
console.log(element)
fileManager.unlink({
filePath: `${this.basePath}${this.rmDirFile}/${element}`,
success: (res : FileManagerSuccessResult) => {
success: function (res : FileManagerSuccessResult) {
if (this.logAble) {
this.log += 'unlinkAllFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success unlink', res)
},
fail: (res : UniError) => {
fail: function (res : UniError) {
if (this.logAble) {
this.log += 'unlinkAllFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail unlink', res)
this.lastFailError = res
},
complete : (res : any) => {
complete: function (res : any) {
if (res instanceof UniError) {
this.lastCompleteError = res
}
......@@ -432,18 +432,19 @@
} as UnLinkOptions)
});
},
fail : (res : UniError) => {
fail: function (res : UniError) {
this.log += 'unlinkAllFileTest fail:' + JSON.stringify(res) + '\n\n'
console.log('fail to readdir', res)
this.lastFailError = res
},
complete : (res : any) => {
complete: function (res : any) {
console.log("complete readdir", res)
this.done = true
if (res instanceof ReadDirSuccessResult) {
this.fileListComplete = res.files
}
if (res instanceof UniError) {
this.lastCompleteError = res
} else {
this.fileListComplete = (res as ReadDirSuccessResult).files
}
}
} as ReadDirOptions)
......@@ -452,22 +453,22 @@
const fileManager = uni.getFileSystemManager()
fileManager.copyFile({
srcPath: "/static/list-mock/mock.json",
srcPath: UTSAndroid.getResourcePath("static/list-mock/mock.json"),
destPath: `${this.copyToBasePath}/a/mock.json`,
success: (res : FileManagerSuccessResult) => {
success: function (res : FileManagerSuccessResult) {
if (this.logAble) {
this.log += 'copyFileTest success:' + JSON.stringify(res) + '\n\n'
}
console.log('success', res)
},
fail: (res : UniError) => {
fail: function (res : UniError) {
if (this.logAble) {
this.log += 'copyFileTest fail:' + JSON.stringify(res) + '\n\n'
}
console.log('fail', res)
this.lastFailError = res
},
complete: (res : any) => {
complete: function (res : any) {
console.log("complete", res)
this.done = true
if (res instanceof UniError) {
......
<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,15 +7,20 @@ describe('ExtApi-GetSystemInfo', () => {
const stringProperties = [
'appId', 'appLanguage', 'appName', 'appVersion', 'appVersionCode',
'brand', 'deviceId', 'deviceBrand', 'deviceModel', 'deviceType', 'language',
'model', 'osName', 'osVersion', 'osLanguage', 'platform', 'system', 'ua', 'uniCompilerVersion',
'model', 'osName', 'osVersion', 'osLanguage', 'platform', 'system', 'ua', 'uniCompileVersion',
'uniPlatform', 'uniRuntimeVersion', 'romName', 'romVersion',
]
const numberProperties = [
'osAndroidAPILevel', 'devicePixelRatio', 'pixelRatio', 'screenWidth', 'screenHeight', 'statusBarHeight',
'windowWidth',
'windowHeight', 'windowTop', 'windowBottom', 'screenTop',
'uniCompilerVersionCode', 'uniRuntimeVersionCode'
]
'uniCompileVersionCode', 'uniRuntimeVersionCode'
]
if (process.env.uniTestPlatformInfo.indexOf('web') === -1) {
stringProperties.push('version')
}
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
......
......@@ -51,47 +51,33 @@
getSystemInfo: function () {
uni.getSystemInfo({
success: (res) => {
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);
}
});
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);
}
}
},
})
},
getSystemInfoSync: function () {
this.items = [] as 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);
}
});
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);
}
}
},
//自动化测试例专用
jest_getSystemInfo() : GetSystemInfoResult {
......
const PAGE_PATH = '/pages/API/get-system-setting/get-system-setting'
describe('ExtApi-GetSystemSetting', () => {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1) {
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 || res['bluetoothEnabled'] === false) {
expect(res['bluetoothError']).not.toBe("")
} else {
expect(res['bluetoothError'] == undefined).toBe(true)
if (res['bluetoothEnabled'] == undefined) {
expect(res['bluetoothError']).not.toBe("")
} else {
expect(res['bluetoothError'] == undefined).toBe(true)
}
if (res['wifiEnabled'] == undefined) {
......
......@@ -19,10 +19,7 @@
</view>
</template>
<script>
import { setStatusBarHeight, setSafeArea } from '@/store/index.uts'
// #ifdef APP-ANDROID
import type { SafeArea } from '@/store/index.uts'
// #endif
import { setStatusBarHeight } from '@/store/index.uts'
type Item = {
label : string,
......@@ -36,46 +33,17 @@
}
},
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[];
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 => {
for (const key in res) {
const value = res[key];
if (value != null) {
const item = {
......@@ -84,7 +52,7 @@
} as Item;
this.items.push(item);
}
});
}
},
//自动化测试例专用
jest_getWindowInfo() : GetWindowInfoResult {
......
......@@ -8,12 +8,12 @@ describe("loadFontFace", () => {
});
it("parent screenshot", async () => {
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
});
it("child screenshot", async () => {
const page = await program.navigateTo(CHILD_PAGE_PATH);
await page.waitFor(3000);
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
});
});
......@@ -3,7 +3,7 @@
describe('API-loading', () => {
let page;
const isApp = process.env.UNI_OS_NAME === "android" || process.env.UNI_OS_NAME === "ios";
const isAndroid = process.env.UNI_OS_NAME === "android";
beforeAll(async () => {
page = await program.reLaunch('/pages/API/modal/modal')
......@@ -13,14 +13,13 @@ describe('API-loading', () => {
it("onload-modal-test", async () => {
if (isApp) {
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -28,13 +27,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -54,13 +53,13 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -68,13 +67,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -95,13 +94,13 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -109,13 +108,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -136,13 +135,13 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -150,13 +149,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -177,13 +176,13 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -191,13 +190,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -218,12 +217,12 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -231,13 +230,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -258,12 +257,12 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -271,13 +270,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -298,12 +297,12 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -311,13 +310,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -338,12 +337,12 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -351,13 +350,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -378,13 +377,13 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -392,13 +391,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -419,13 +418,13 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -433,13 +432,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -460,13 +459,13 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -474,13 +473,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -501,13 +500,13 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -515,13 +514,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -542,13 +541,13 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -556,13 +555,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -583,13 +582,13 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -597,13 +596,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -625,12 +624,12 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -638,13 +637,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -665,13 +664,13 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -679,13 +678,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -706,12 +705,12 @@ describe('API-loading', () => {
await btnModalButton.tap()
await page.waitFor(500);
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -719,13 +718,13 @@ describe('API-loading', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......
......@@ -11,7 +11,7 @@ describe("onLoad", () => {
await page.callMethod("navigateToOnLoadWithType", "adjustData");
await page.waitFor(1000);
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
});
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') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
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({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
height: 2140,
},
});
expect(image).toSaveImageSnapshot({
expect(image).toMatchImageSnapshot({
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({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
height: 2140,
},
});
expect(image).toSaveImageSnapshot({
expect(image).toMatchImageSnapshot({
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({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
height: 2140,
},
});
expect(image).toSaveImageSnapshot({
expect(image).toMatchImageSnapshot({
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({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
height: 2140,
},
});
expect(image).toSaveImageSnapshot({
expect(image).toMatchImageSnapshot({
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,11 +53,6 @@ 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
......
<template>
<view class="page" id="page">
<page-head :title="title"></page-head>
<button class="btn btn-get-node-info" @click="getNodeInfo">getNodeInfo</button>
<button class="btn btn-get-all-node-info" @click="getAllNodeInfo">getAllNodeInfo</button>
<view id="rect-1-2" class="rect-1-2">
<view class="rect rect1"></view>
<view class="rect rect2"></view>
</view>
<view class="rect-info-1-2">
<view class="rect-info" v-for="(nodeInfo, index) in nodeInfoList" :key="index">
<view class="node-info-item">
<text class="node-info-item-k">left: </text>
<text class="node-info-item-v">{{nodeInfo.left}}</text>
</view>
<view class="node-info-item">
<text class="node-info-item-k">top: </text>
<text class="node-info-item-v">{{nodeInfo.top}}</text>
</view>
<view class="node-info-item">
<text class="node-info-item-k">right: </text>
<text class="node-info-item-v">{{nodeInfo.right}}</text>
</view>
<view class="node-info-item">
<text class="node-info-item-k">bottom: </text>
<text class="node-info-item-v">{{nodeInfo.bottom}}</text>
</view>
<view class="node-info-item">
<text class="node-info-item-k">width: </text>
<text class="node-info-item-v">{{nodeInfo.width}}</text>
</view>
<view class="node-info-item">
<text class="node-info-item-k">height: </text>
<text class="node-info-item-v">{{nodeInfo.height}}</text>
</view>
</view>
<template>
<view class="page" id="page">
<page-head :title="title"></page-head>
<button class="btn btn-get-node-info" @click="getNodeInfo">getNodeInfo</button>
<button class="btn btn-get-all-node-info" @click="getAllNodeInfo">getAllNodeInfo</button>
<view id="rect-1-2" class="rect-1-2">
<view class="rect rect1"></view>
<view class="rect rect2"></view>
</view>
<node-child class="node-child"></node-child>
</view>
</template>
<script>
import nodeChild from './nodes-info-child.uvue'
type NodeInfoType = {
left : number | null,
top : number | null,
right : number | null,
bottom : number | null,
width : number | null,
height : number | null,
}
export default {
components: {
nodeChild
},
data() {
return {
title: 'createSelectorQuery',
nodeInfoList: [] as NodeInfoType[],
// 仅用于自动化测试
rootNodeInfo: null as NodeInfoType | null,
//供自动化测试使用
// resizeRectValid: false
}
},
onResize() {
//供自动化测试使用
/* var rect12Element = uni.getElementById("rect-1-2")
if(rect12Element != null) {
var domRect = rect12Element.getBoundingClientRect()
if(domRect.width > 100) {
this.resizeRectValid = true
}
} */
},
methods: {
// 仅用于自动化测试
getRootNodeInfo(selector : string) {
uni.createSelectorQuery().select(selector).boundingClientRect().exec((ret) => {
if (ret.length == 1) {
const nodeInfo = ret[0] as NodeInfo;
const nodeType = {
left: nodeInfo.left,
top: nodeInfo.top,
right: nodeInfo.right,
bottom: nodeInfo.bottom,
width: nodeInfo.width,
height: nodeInfo.height,
} as NodeInfoType;
this.rootNodeInfo = nodeType
}
})
},
getNodeInfo() {
uni.createSelectorQuery().select('.rect1').boundingClientRect().exec((ret) => {
this.nodeInfoList.length = 0
const i = ret[0] as NodeInfo
this.nodeInfoList.push({
left: i.left,
top: i.top,
right: i.right,
bottom: i.bottom,
width: i.width,
height: i.height,
} as NodeInfoType)
})
},
getAllNodeInfo() {
uni.createSelectorQuery().selectAll('.rect').boundingClientRect().exec((ret) => {
this.nodeInfoList.length = 0
const array = ret[0] as NodeInfo[]
array.forEach((i) => {
this.nodeInfoList.push({
left: i.left,
top: i.top,
right: i.right,
bottom: i.bottom,
width: i.width,
height: i.height,
} as NodeInfoType)
})
})
}
}
}
</script>
<style>
.page {
padding: 15px;
flex: 1;
}
.btn {
margin-top: 15px;
}
.rect-1-2 {
flex-direction: row;
margin-top: 15px;
}
.rect {
width: 150px;
height: 100px;
}
.rect1 {
background-color: dodgerblue;
}
.rect2 {
margin-left: auto;
background-color: seagreen;
}
.rect-info-1-2 {
flex-direction: row;
margin-top: 15px;
}
.rect-info {
flex: 1;
flex-direction: column;
}
.node-info-item {
flex-direction: row;
}
.node-info-item-k {
width: 72px;
line-height: 2;
}
.node-info-item-v {
font-weight: bold;
line-height: 2;
}
<view class="rect-info-1-2">
<view class="rect-info" v-for="(nodeInfo, index) in nodeInfoList" :key="index">
<view class="node-info-item">
<text class="node-info-item-k">left: </text>
<text class="node-info-item-v">{{nodeInfo.left}}</text>
</view>
<view class="node-info-item">
<text class="node-info-item-k">top: </text>
<text class="node-info-item-v">{{nodeInfo.top}}</text>
</view>
<view class="node-info-item">
<text class="node-info-item-k">right: </text>
<text class="node-info-item-v">{{nodeInfo.right}}</text>
</view>
<view class="node-info-item">
<text class="node-info-item-k">bottom: </text>
<text class="node-info-item-v">{{nodeInfo.bottom}}</text>
</view>
<view class="node-info-item">
<text class="node-info-item-k">width: </text>
<text class="node-info-item-v">{{nodeInfo.width}}</text>
</view>
<view class="node-info-item">
<text class="node-info-item-k">height: </text>
<text class="node-info-item-v">{{nodeInfo.height}}</text>
</view>
</view>
</view>
</view>
</template>
<script>
type NodeInfoType = {
left : number | null,
top : number | null,
right : number | null,
bottom : number | null,
width : number | null,
height : number | null,
}
export default {
data() {
return {
title: 'createSelectorQuery',
nodeInfoList: [] as NodeInfoType[],
// 仅用于自动化测试
rootNodeInfo: null as NodeInfoType | null,
//供自动化测试使用
// resizeRectValid: false
}
},
onResize() {
//供自动化测试使用
/* var rect12Element = uni.getElementById("rect-1-2")
if(rect12Element != null) {
var domRect = rect12Element.getBoundingClientRect()
if(domRect.width > 100) {
this.resizeRectValid = true
}
} */
},
methods: {
// 仅用于自动化测试
getRootNodeInfo(selector: string) {
uni.createSelectorQuery().select(selector).boundingClientRect().exec((ret) => {
if (ret.length == 1) {
const nodeInfo = ret[0] as NodeInfo;
const nodeType = {
left: nodeInfo.left,
top: nodeInfo.top,
right: nodeInfo.right,
bottom: nodeInfo.bottom,
width: nodeInfo.width,
height: nodeInfo.height,
} as NodeInfoType;
this.rootNodeInfo = nodeType
}
})
},
getNodeInfo() {
uni.createSelectorQuery().select('.rect1').boundingClientRect().exec((ret) => {
this.nodeInfoList.length = 0
const i = ret[0] as NodeInfo
this.nodeInfoList.push({
left: i.left,
top: i.top,
right: i.right,
bottom: i.bottom,
width: i.width,
height: i.height,
} as NodeInfoType)
})
},
getAllNodeInfo() {
uni.createSelectorQuery().selectAll('.rect').boundingClientRect().exec((ret) => {
this.nodeInfoList.length = 0
const array = ret[0] as NodeInfo[]
array.forEach((i) => {
this.nodeInfoList.push({
left: i.left,
top: i.top,
right: i.right,
bottom: i.bottom,
width: i.width,
height: i.height,
} as NodeInfoType)
})
})
}
}
}
</script>
<style>
.page {
padding: 15px;
flex: 1;
}
.btn {
margin-top: 15px;
}
.rect-1-2 {
flex-direction: row;
margin-top: 15px;
}
.rect {
width: 150px;
height: 100px;
}
.rect1 {
background-color: dodgerblue;
}
.rect2 {
margin-left: auto;
background-color: seagreen;
}
.rect-info-1-2 {
flex-direction: row;
margin-top: 15px;
}
.rect-info {
flex: 1;
flex-direction: column;
}
.node-info-item {
flex-direction: row;
}
.node-info-item-k {
width: 72px;
line-height: 2;
}
.node-info-item-v {
font-weight: bold;
line-height: 2;
}
</style>
......@@ -17,8 +17,7 @@
max: 0
}
},
onReady() {
uni.startPullDownRefresh();
onLoad() {
this.initData();
},
onReachBottom() {
......@@ -48,7 +47,7 @@
}
this.data = this.data.concat(data);
uni.stopPullDownRefresh();
}, 1000);
}, 300);
},
setListData() {
let data:Array<number> = [];
......
<template>
<view class="app">
<view>
<text>你自己的业务系统订单详情页面</text>
</view>
<view style="margin-top: 20rpx;">
<text>order_no:{{ myOptions['order_no'] }}</text>
</view>
<view style="margin-top: 20rpx;">
<text>out_trade_no:{{ myOptions['out_trade_no'] }}</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
myOptions: {} as UTSJSONObject,
}
},
onLoad(options) {
console.log('options: ', options)
this.myOptions['order_no'] = options['order_no'] as string;
this.myOptions['out_trade_no'] = options['out_trade_no'] as string;
},
methods: {
}
}
</script>
<style lang="scss" scoped>
.app {
padding: 30rpx;
}
</style>
\ No newline at end of file
<template>
<view class="app">
<view>
<text style="color: red;">注意:uni-app x暂不支持微信支付</text>
</view>
<view>
<view class="label">支付单号:</view>
<view><input class="input" v-model="out_trade_no" placeholder="点击发起支付会自动生成"/></view>
</view>
<view>
<view class="label">支付金额(单位分,100=1元):</view>
<view><input class="input" v-model.number="total_fee" /></view>
</view>
<button class="button" @click="open()">打开收银台(弹窗模式)</button>
<!-- #ifdef APP || H5 -->
<view v-if="!isPcCom">
<button class="button" @click="toPayDesk">打开收银台(新页面模式)</button>
</view>
<!-- #endif -->
<!-- #ifdef MP-WEIXIN || H5 || APP -->
<button class="button" @click="createOrder('wxpay')">发起支付(微信)</button>
<!-- #endif -->
<!-- #ifdef MP-ALIPAY || H5 || APP -->
<button class="button" @click="createOrder('alipay')">发起支付(支付宝)</button>
<!-- #endif -->
<!-- #ifdef APP -->
<button class="button" @click="createQRcode('alipay')">APP扫码支付(支付宝)</button>
<!-- #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-uni-pay/order-detail')">支付成功页面示例</button>
<!-- 查询支付的弹窗 -->
<uni-pay-popup ref="getOrderPopupRef" type="bottom">
<scroll-view direction="vertical" class="get-order-popup">
<view class="label">插件支付单号:</view>
<view class="mt20">
<input class="input pd2030" v-model="out_trade_no" placeholder="请输入" />
<view><text class="tips">插件支付单号和第三方交易单号2选1填即可</text> </view>
</view>
<view class="label">第三方交易单号:</view>
<view class="mt20">
<input class="input pd2030" v-model="transaction_id" placeholder="请输入" />
<view class="tips"><text class="tips">可从支付宝账单(订单号)、微信账单(交易单号)中复制</text></view>
</view>
<view class="mt20">
<button class="button" @click="getOrder">查询支付状态</button>
</view>
<view class="mt20" v-if="getOrderRes['transaction_id']">
<view class="table">
<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">{{ getOrderRes['description'] }}</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">{{ 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>
<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">{{ getOrderRes['transaction_id'] }}</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">{{ getOrderRes['out_trade_no'] }}</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">{{ getOrderRes.getBoolean('user_order_success') != null && getOrderRes.getBoolean('user_order_success') == true ? "成功" : "异常" }}</text>
</view>
</view>
</view>
</view>
</scroll-view>
</uni-pay-popup>
<!-- #ifdef APP -->
<!-- <button class="button" v-if="isIosAppCom" @click="pageTo('/pages/iosiap/iosiap')">苹果内购示例</button> -->
<!-- #endif -->
<!-- <button class="button" @click="refund">发起退款</button>
<view><text class="tips">发起退款需要admin权限,本示例未对接登录功能</text></view>
<button class="button" @click="getRefund">查询退款状态</button>
<button class="button" @click="closeOrder">关闭订单</button> -->
<!-- #ifdef H5 -->
<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-uni-pay/order-detail" logo="/static/logo.png" @success="onSuccess" @create="onCreate"
@fail="onFail" @cancel="onCancel"></uni-pay>
</view>
</template>
<script>
export default {
data() {
return {
total_fee: 1, // 支付金额,单位分 100 = 1元
order_no: "", // 业务系统订单号(即你自己业务系统的订单表的订单号)
out_trade_no: "", // 插件支付单号
description: "测试订单", // 支付描述
type: "test", // 支付回调类型 如 recharge 代表余额充值 goods 代表商品订单(可自定义,任意英文单词都可以,只要你在 uni-pay-co/notify/目录下创建对应的 xxx.js文件进行编写对应的回调逻辑即可)
openid: "", // 微信公众号需要
custom: {
a: "a",
b: 1
} as UTSJSONObject,
adpid: "1000000001", // uni-ad的广告位id
transaction_id: "", // 查询订单接口的查询条件
getOrderRes: {} as UTSJSONObject, // 查询订单支付成功后的返回值
}
},
onLoad(options) {
console.log('onLoad: ', options)
// #ifdef H5
// 微信公众号特殊逻辑开始-----------------------------------------------------------
// 以下代码仅为获取openid,正常你自己项目应该是登录后才能支付,登录后已经拿到openid,无需编写下面的代码
if (this.h5Env == 'h5-weixin') {
let openid = uni.getStorageSync("uni-pay-weixin-h5-openid");
let oldCode = uni.getStorageSync("uni-pay-weixin-h5-code");
if (openid != null && openid != "") {
this.openid = openid;
}
let code = options['code'] as string;
let state = options['state'] as string;
// 如果code和state有值,且此code没有被使用过,则执行获取微信公众号的openid
if (code != null && code != "" && state != null && state != "" && code != oldCode) {
// 获取微信公众号的openid
setTimeout(() => {
this.getOpenid({
provider: "wxpay",
code
});
}, 300);
} else if (!openid){
// 如果openid为空,则执行微信公众号的网页授权登录逻辑
setTimeout(() => {
this.getWeiXinJsCode('snsapi_base');
}, 300);
}
}
// 微信公众号特殊逻辑结束-----------------------------------------------------------
// #endif
},
methods: {
/**
* 发起支付(唤起收银台,如果只有一种支付方式,则收银台不会弹出来,会直接使用此支付方式)
* 在调用此api前,你应该先创建自己的业务系统订单,并获得订单号 order_no,把order_no当参数传给此api,而示例中为了简化跟支付插件无关的代码,这里直接已时间戳生成了order_no
*/
open() {
this.order_no = `test` + Date.now();
this.out_trade_no = `${this.order_no}-1`;
// 打开支付收银台
const payInstance = this.$refs["payRef"] as UniPayComponentPublicInstance;
payInstance.open({
total_fee: this.total_fee, // 支付金额,单位分 100 = 1元
order_no: this.order_no, // 业务系统订单号(即你自己业务系统的订单表的订单号)
out_trade_no: this.out_trade_no, // 插件支付单号
description: this.description, // 支付描述
type: this.type, // 支付回调类型
openid: this.openid, // 微信公众号需要
custom: this.custom, // 自定义数据
});
},
/**
* 发起支付(不唤起收银台,手动指定支付方式)
* 在调用此api前,你应该先创建自己的业务系统订单,并获得订单号 order_no,把order_no当参数传给此api,而示例中为了简化跟支付插件无关的代码,这里直接已时间戳生成了order_no
*/
createOrder(provider : string) {
this.order_no = `test` + Date.now();
this.out_trade_no = `${this.order_no}-1`;
// 发起支付
const payInstance = this.$refs["payRef"] as UniPayComponentPublicInstance;
payInstance.createOrder({
provider: provider, // 支付供应商
total_fee: this.total_fee, // 支付金额,单位分 100 = 1元
order_no: this.order_no, // 业务系统订单号(即你自己业务系统的订单表的订单号)
out_trade_no: this.out_trade_no, // 插件支付单号
description: this.description, // 支付描述
type: this.type, // 支付回调类型
openid: this.openid, // 微信公众号需要
custom: this.custom, // 自定义数据
});
},
/**
* 生成支付独立二维码(只返回支付二维码)
* 在调用此api前,你应该先创建自己的业务系统订单,并获得订单号 order_no,把order_no当参数传给此api,而示例中为了简化跟支付插件无关的代码,这里直接已时间戳生成了order_no
*/
createQRcode(provider : string) {
this.order_no = `test` + Date.now();
this.out_trade_no = `${this.order_no}-1`;
// 发起支付
const payInstance = this.$refs["payRef"] as UniPayComponentPublicInstance;
payInstance.createOrder({
provider: provider, // 支付供应商
total_fee: this.total_fee, // 支付金额,单位分 100 = 1元
order_no: this.order_no, // 业务系统订单号(即你自己业务系统的订单表的订单号)
out_trade_no: this.out_trade_no, // 插件支付单号
description: this.description, // 支付描述
type: this.type, // 支付回调类型
qr_code: true, // 强制扫码支付
openid: this.openid, // 微信公众号需要
custom: this.custom, // 自定义数据
});
},
/**
* 前往自定义收银台页面
* 在调用此api前,你应该先创建自己的业务系统订单,并获得订单号 order_no,把order_no当参数传给此api,而示例中为了简化跟支付插件无关的代码,这里直接已时间戳生成了order_no
*/
toPayDesk() {
this.order_no = `test` + Date.now();
this.out_trade_no = `${this.order_no}-1`;
let options = {
total_fee: this.total_fee, // 支付金额,单位分 100 = 1元
order_no: this.order_no, // 业务系统订单号(即你自己业务系统的订单表的订单号)
out_trade_no: this.out_trade_no, // 插件支付单号
description: this.description, // 支付描述
type: this.type, // 支付回调类型
openid: this.openid, // 微信公众号需要
custom: this.custom, // 自定义数据
};
let optionsStr = encodeURI(JSON.stringify(options));
uni.navigateTo({
url: `/uni_modules/uni-pay-x/pages/pay-desk/pay-desk?options=${optionsStr}`
});
},
// 打开查询订单的弹窗
getOrderPopup(key : boolean) {
const getOrderPopupInstance = this.$refs["getOrderPopupRef"] as UniPayPopupComponentPublicInstance;
if (key) {
getOrderPopupInstance.open();
} else {
getOrderPopupInstance.close();
}
},
// 查询支付状态
async getOrder() : Promise<void> {
this.getOrderRes = {} as UTSJSONObject;
const payInstance = this.$refs["payRef"] as UniPayComponentPublicInstance;
let getOrderData = {
await_notify: true
} as UTSJSONObject;
if (this.transaction_id != "") {
getOrderData['transaction_id'] = this.transaction_id;
} else if (this.out_trade_no != "") {
getOrderData['out_trade_no'] = this.out_trade_no;
}
let res = await payInstance.getOrder(getOrderData);
if (res != null && res['errCode'] == 0) {
this.getOrderRes = res.getJSON('pay_order') as UTSJSONObject;
let obj = {
"-1": "已关闭",
"1": "已支付",
"0": "未支付",
"2": "已部分退款",
"3": "已全额退款"
} as UTSJSONObject;
let status = res['status'] as number;
let statusStr = status + "";
let title = obj[statusStr] as string;
uni.showToast({
title: title,
icon: "none"
});
}
},
// 发起退款
async refund() : Promise<void> {
const payInstance = this.$refs["payRef"] as UniPayComponentPublicInstance;
let res = await payInstance.refund({
out_trade_no: this.out_trade_no, // 插件支付单号
});
if (res != null && res['errCode'] == 0) {
uni.showToast({
title: res['errMsg'] as string,
icon: "none"
});
}
},
// 查询退款状态
async getRefund() : Promise<void> {
const payInstance = this.$refs["payRef"] as UniPayComponentPublicInstance;
let res = await payInstance.getRefund({
out_trade_no: this.out_trade_no, // 插件支付单号
});
if (res != null && res['errCode'] == 0) {
uni.showModal({
content: res['errMsg'] as string,
showCancel: false
});
}
},
// 关闭订单
async closeOrder() : Promise<void> {
const payInstance = this.$refs["payRef"] as UniPayComponentPublicInstance;
let res = await payInstance.closeOrder({
out_trade_no: this.out_trade_no, // 插件支付单号
});
if (res != null && res['errCode'] == 0) {
uni.showModal({
content: res['errMsg'] as string,
showCancel: false
});
}
},
// #ifdef H5
// 获取公众号code
async getWeiXinJsCode(scope = "snsapi_base") : Promise<void> {
const payInstance = this.$refs["payRef"] as UniPayComponentPublicInstance;
let res = await payInstance.getProviderAppId({
provider: "wxpay",
provider_pay_type: "jsapi"
});
if (res != null && res['appid'] != null && res['appid'] != "") {
let appid = res['appid'] as string;
let redirect_uri = window.location.href.split("?")[0];
let url = `https://open.weixin.qq.com/connect/oauth2/authorize?appid=${appid}&redirect_uri=${redirect_uri}&response_type=code&scope=${scope}&state=STATE#wechat_redirect`;
window.location.href = url;
}
},
// 获取公众号openid
async getOpenid(data:UTSJSONObject) : Promise<void> {
const payInstance = this.$refs["payRef"] as UniPayComponentPublicInstance;
let res = await payInstance.getOpenid(data);
if (res != null && res['openid'] != null && res['openid'] != "") {
let openid = res['openid'] as string;
let code = data['code'] as string;
this.openid = openid;
console.log('openid: ', openid)
// 将openid缓存到本地
uni.setStorageSync("uni-pay-weixin-h5-openid", openid);
uni.setStorageSync("uni-pay-weixin-h5-code", code);
uni.showToast({
title: "已获取到openid,可以开始支付",
icon: "none"
});
}
},
// #endif
// 监听事件 - 支付订单创建成功(此时用户还未支付)
onCreate(res : UTSJSONObject) {
console.log('create: ', res);
// 如果只是想生成支付二维码,不需要组件自带的弹窗,则在这里可以获取到支付二维码 qr_code_image
},
// 监听事件 - 支付成功
onSuccess(res : UTSJSONObject) {
console.log('success: ', res);
let user_order_success = res.getBoolean('user_order_success');
if (user_order_success != null && user_order_success != true) {
// 代表用户已付款,且你自己写的回调成功并正确执行了
} else {
// 代表用户已付款,但你自己写的回调执行失败(通常是因为你的回调代码有问题)
}
},
// 监听事件 - 支付失败
onFail(err : RequestPaymentFail) {
console.log('fail: ', err)
},
// 监听事件 - 取消支付
onCancel(err : RequestPaymentFail) {
console.log('cancel: ', err)
},
// 页面跳转
pageTo(url : string) {
uni.navigateTo({
url
});
},
// provider格式化
providerFormat(provider ?: string) : string {
if (provider == null) {
return "";
}
let providerObj = {
"wxpay": "微信支付",
"alipay": "支付宝支付",
"appleiap": "ios内购"
} as UTSJSONObject;
let providerStr = providerObj[provider] as string;
return providerStr;
},
// amount格式化
amountFormat(totalFee : number | null) : string {
if (totalFee == null) {
return "0";
} else {
return (totalFee / 100).toFixed(2)
}
}
},
computed: {
// 计算当前H5环境
h5Env() : string {
// #ifdef H5
const ua = window.navigator.userAgent.toLowerCase();
const isWeixin = /micromessenger/i.test(ua);
const isAlipay = /alipay/i.test(ua);
const isMiniProgram = /miniprogram/i.test(ua);
if (isWeixin) {
if (isMiniProgram) {
return "mp-weixin";
} else {
return "h5-weixin";
}
} else if (isAlipay) {
if (isMiniProgram) {
return "mp-alipay";
} else {
return "h5-alipay";
}
}
return "h5";
// #endif
return "";
},
// 计算当前是否是ios app
isIosAppCom() : boolean {
let info = uni.getSystemInfoSync();
return info.uniPlatform === 'app' && info.osName === 'ios' ? true : false;
},
// 计算当前是否是PC环境
isPcCom() : boolean {
let isPC = false;
// #ifdef H5
let info = uni.getSystemInfoSync();
isPC = info.deviceType === 'pc' ? true : false;
// #endif
return isPC;
}
},
}
</script>
<style lang="scss" scoped>
.app {
padding: 30rpx;
}
.input {
border: 1px solid #f3f3f3;
padding: 10rpx;
width: 100%;
box-sizing: border-box;
height: 80rpx;
background: #FFF;
}
.button {
margin-top: 20rpx;
}
.label {
margin: 10rpx 0;
}
.tips {
margin: 20rpx 0;
font-size: 24rpx;
color: #565656;
}
.get-order-popup {
background-color: #ffffff;
padding: 30rpx;
height: 900rpx;
border-radius: 20rpx;
width: 690rpx;
}
.mt20 {
margin-top: 20rpx;
}
.pd2030 {
padding: 20rpx 30rpx;
}
.table {
.table-tr {
display: flex;
flex-direction: row;
justify-content: center;
align-items: center;
padding: 10rpx 0;
}
.table-td {
flex: 1;
}
.align-left {
text-align: left;
}
.align-right {
text-align: right;
}
.label {
width: 180rpx;
}
.text {
font-size: 24rpx;
}
}
</style>
......@@ -86,7 +86,7 @@ describe('ExtApi-Request', () => {
});
let shouldTestCookie = false
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
let version = process.env.uniTestPlatformInfo
version = parseInt(version.split(" ")[1])
shouldTestCookie = version > 9
......@@ -108,10 +108,4 @@ describe('ExtApi-Request', () => {
res = await page.data('jest_result');
expect(res).toBe(true)
});
it('Check Get With Data', async () => {
res = await page.callMethod('jest_get_with_data')
await page.waitFor(2000);
res = await page.data('jest_result');
expect(res).toBe(true)
})
});
});
......@@ -2,7 +2,7 @@
<view style="flex: 1;">
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-common-mt" style="border-width: 2px;border-style: solid; border-radius: 4px;">
<textarea :value="res" class="uni-textarea" style="width: 100%;"></textarea>
<textarea :value="res" class="uni-textarea"></textarea>
</view>
<view>
<text>地址 : {{ host + url}}</text>
......@@ -300,25 +300,6 @@
this.jest_result = false;
},
});
},
jest_get_with_data() {
uni.request({
url: "https://unidemo.dcloud.net.cn/api/banner/36kr",
method: "GET",
data:{
column: 'id,post_id,title,author_name,cover,published_at' //需要的字段名
},
timeout: 6000,
sslVerify: false,
withCredentials: false,
firstIpv4: false,
success: () => {
this.jest_result = true;
},
fail: () => {
this.jest_result = false;
},
});
},
}
}
......
......@@ -19,14 +19,14 @@ describe('setNavigationBarColor', () => {
it("setNavigationBarColor1", async () => {
await page.callMethod("setNavigationBarColor1");
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
expect(lifeCycleNum - originLifeCycleNum).toBe(2);
});
it("setNavigationBarColor2", async () => {
await page.callMethod("setNavigationBarColor2");
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
expect(lifeCycleNum - originLifeCycleNum).toBe(4);
});
......
......@@ -19,13 +19,13 @@ describe("setNavigationBarColor", () => {
it("setNavigationBarNewTitle", async () => {
await page.callMethod("setNavigationBarNewTitle");
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
expect(lifeCycleNum - originLifeCycleNum).toBe(2);
});
it("setNavigationBarLongTitle", async () => {
await page.callMethod("setNavigationBarLongTitle");
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
});
});
......@@ -11,7 +11,7 @@
<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" @input="keyChange" />
</view>
</view>
<view class="uni-list-cell">
......@@ -20,7 +20,7 @@
</view>
<view class="uni-list-cell-db">
<input class="uni-input" type="text" placeholder="请输入value" name="data"
:value="typeof data === 'string' ? data : JSON.stringify(data)" maxlength="-1" @input="dataChange" />
:value="typeof data === 'string' ? data : JSON.stringify(data)" @input="dataChange" />
</view>
</view>
</view>
......
......@@ -3,7 +3,7 @@
describe('API-toast', () => {
let page;
const isApp = process.env.UNI_OS_NAME === "android" || process.env.UNI_OS_NAME === "ios";
const isAndroid = process.env.UNI_OS_NAME === "android";
beforeAll(async () => {
......@@ -16,14 +16,14 @@ describe('API-toast', () => {
it("onload-toast-test", async () => {
if (isApp) {
await page.waitFor(500);
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -31,13 +31,13 @@ describe('API-toast', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -47,14 +47,14 @@ describe('API-toast', () => {
const btnToastDefaultButton = await page.$('#btn-toast-default')
await btnToastDefaultButton.tap()
await page.waitFor(200)
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -62,13 +62,13 @@ describe('API-toast', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -78,12 +78,12 @@ describe('API-toast', () => {
const btnToastDurationButton = await page.$('#btn-toast-duration')
await btnToastDurationButton.tap()
await page.waitFor(2000)
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -91,13 +91,13 @@ describe('API-toast', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -105,12 +105,12 @@ describe('API-toast', () => {
const btnToastErrorIconButton = await page.$('#btn-toast-errorIcon')
await btnToastErrorIconButton.tap()
await page.waitFor(200)
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -118,13 +118,13 @@ describe('API-toast', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -138,12 +138,12 @@ describe('API-toast', () => {
await btnToastHideButton.tap()
await page.waitFor(1000)
if (isApp) {
if (isAndroid) {
const res = await page.callMethod('jest_getWindowInfo')
const windowHeight = res.windowHeight * res.pixelRatio;
const windowWidth = res.windowWidth * res.pixelRatio;
const image = await program.screenshot({
deviceShot: true,
adb: true,
area: {
x: 0,
y: 200,
......@@ -151,13 +151,13 @@ describe('API-toast', () => {
width:windowWidth
},
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}else{
const image = await program.screenshot({
deviceShot: true,
adb: true,
fullPage: true
});
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
}
})
......@@ -166,11 +166,11 @@ describe('API-toast', () => {
// const btnToastButton = await page.$('#btn-toast-postion-bottom')
// await btnToastButton.tap()
// await page.waitFor(200)
// if (isApp) {
// if (isAndroid) {
// const windowHeight = uni.getWindowInfo().windowHeight;
// const windowWidth = uni.getWindowInfo().windowWidth;
// const image = await program.screenshot({
// deviceShot: true,
// adb: true,
// area: {
// x: 0,
// y: 200,
......@@ -178,13 +178,13 @@ describe('API-toast', () => {
// width:windowWidth
// },
// });
// expect(image).toSaveImageSnapshot();
// expect(image).toMatchImageSnapshot();
// }else{
// const image = await program.screenshot({
// deviceShot: true,
// adb: true,
// fullPage: true
// });
// expect(image).toSaveImageSnapshot()
// expect(image).toMatchImageSnapshot()
// }
// })
......
......@@ -10,7 +10,7 @@
<!-- #ifndef MP-ALIPAY -->
<button class="uni-btn-v" type="default" @tap="toast4Tap">点击弹出显示自定义图片的toast</button>
<!-- #endif -->
<!-- #ifdef APP -->
<!-- #ifdef APP-ANDROID -->
<button class="uni-btn-v" type="default" @tap="toast5Tap" id="btn-toast-postion-bottom">点击显示无图标的居底toast</button>
<!-- #endif -->
<button class="uni-btn-v" type="default" @tap="hideToast" id="btn-toast-hide">点击隐藏toast</button>
......@@ -101,7 +101,7 @@
},
})
},
// #ifdef APP
// #ifdef APP-ANDROID
toast5Tap: function () {
uni.showToast({
title: "显示一段轻提示",
......
......@@ -27,17 +27,17 @@ describe('ExtApi-UploadFile', () => {
it('Check ', async () => {
expect(res).toBe(true);
});
it('Check files upload', async () => {
res = await page.callMethod('jest_files_upload')
await page.waitFor(2000);
res = await page.data('jest_result');
expect(res).toBe(true)
});
it('Check files upload', async () => {
res = await page.callMethod('jest_files_upload')
await page.waitFor(2000);
res = await page.data('jest_result');
expect(res).toBe(true)
});
let shouldTestCookie = false
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
let version = process.env.uniTestPlatformInfo
version = parseInt(version.split(" ")[1])
shouldTestCookie = version > 9
......@@ -59,4 +59,4 @@ describe('ExtApi-UploadFile', () => {
res = await page.data('jest_result');
expect(res).toBe(true)
});
});
});
describe('background-image-test', () => {
let page;
beforeAll(async () => {
page = await program.reLaunch('/pages/CSS/background/background-image');
await page.waitFor(600);
});
it('background-image-screenshot', async () => {
await page.waitFor(300);
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
});
it('background-image-select', async () => {
await page.callMethod('updateBackgroundSelect')
await page.waitFor(300);
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
});
});
......@@ -6,7 +6,7 @@
<text>不支持背景图片,仅支持linear-gradient方法</text>
<view v-for="(direction) in directionData">
<text>background-image: linear-gradient({{direction}}, red, yellow)</text>
<view class="common" :style="{'background-image': backgroundSelect ?'linear-gradient('+direction+', red, yellow)':''}"></view>
<view class="common" :style="{'background-image': 'linear-gradient('+direction+', red, yellow)'}"></view>
</view>
</view>
<!-- #ifdef APP -->
......@@ -18,15 +18,8 @@
export default {
data(){
return {
backgroundSelect : true,
directionData: ['to right', 'to left', 'to bottom', 'to top', 'to bottom left', 'to bottom right', 'to top left', 'to top right']
}
},
methods: {
//供自动化测试使用
updateBackgroundSelect() {
this.backgroundSelect = !this.backgroundSelect
}
}
}
</script>
......
......@@ -42,22 +42,6 @@
style="border-bottom-width: 5px; border-bottom-style: dotted"
></view>
</view>
<view>
<text>border-style: solid (缺省 border-width)</text>
<view
class="common"
style="border-style: solid;"
></view>
</view>
<view>
<text>border-style: none</text>
<view
class="common"
style="border-style: none; border-width: 5px;"
></view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
......
describe('component-native-overflow', () => {
let page
describe('component-native-overflow', () => {
let page
beforeAll(async () => {
//打开list-view测试页
page = await program.reLaunch('/pages/CSS/overflow/overflow')
await page.waitFor("image")
//打开list-view测试页
page = await program.reLaunch('/pages/CSS/overflow/overflow')
await page.waitFor("image")
})
//检测overflow设置hidden,visible
it('check_view_overflow', async () => {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
let version = process.env.uniTestPlatformInfo
version = parseInt(version.split(" ")[1])
//安卓7模拟器不截图 导致闪退
......@@ -20,6 +20,6 @@ describe('component-native-overflow', () => {
const image = await program.screenshot({
fullPage: true,
});
expect(image).toSaveImageSnapshot();
})
expect(image).toMatchImageSnapshot();
})
})
......@@ -11,6 +11,6 @@ describe('css-font-family', () => {
const image = await program.screenshot({
fullPage: true
})
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
});
});
describe('css-font-size', () => {
let page;
beforeAll(async () => {
page = await program.reLaunch('/pages/CSS/text/font-size');
});
it('screenshot', async () => {
await page.callMethod("setFontSize");
await page.waitFor(100);
const image = await program.screenshot({ fullPage: true });
expect(image).toSaveImageSnapshot();
});
});
<template>
<view style="flex-grow: 1;">
<view style="height: 250px;background-color: gray;justify-content: center;align-items: center;">
<text ref="text" style="font-size: 15px;">{{fontSize}}</text>
<text style="font-size: 15px;">font-size: 15px</text>
<text style="font-size: 30px;">font-size: 30px</text>
</view>
</view>
</template>
<script>
export default {
data() {
return {
fontSize: 'font-size: 15px'
}
},
methods: {
// 自动化测试
setFontSize() {
this.fontSize = 'font-size: 30px';
(this.$refs['text'] as UniElement).style.setProperty('font-size', '30px');
}
}
}
</script>
<style>
</style>
</style>
\ No newline at end of file
......@@ -3,16 +3,15 @@
<view style="height: 250px;padding: 0 30px; background-color: gray;justify-content: center;">
<view class="margin-bottom-10">
<text class="font-weight-bold">text-overflow:clip white-space:nowrap</text>
<text class="font-size-20" style="text-overflow: clip;white-space: nowrap;">{{multiLineText}}</text>
<text class="font-size-20" style="text-overflow: clip;white-space: nowrap;">{{text}}</text>
</view>
<view class="margin-bottom-10">
<text class="font-weight-bold">text-overflow:ellipsis white-space:nowrap</text>
<text class="font-size-20" style="text-overflow: ellipsis;white-space: nowrap;">{{singleLineText}}</text>
<text class="font-size-20" style="text-overflow: ellipsis;white-space: nowrap;">{{multiLineText}}</text>
<text class="font-size-20" style="text-overflow: ellipsis;white-space: nowrap;">{{text}}</text>
</view>
<view class="margin-bottom-10">
<text class="font-weight-bold">white-space:normal</text>
<text class="font-size-20" style="white-space: normal;">{{multiLineText}}</text>
<text class="font-size-20" style="white-space: normal;">{{text}}</text>
</view>
</view>
</view>
......@@ -22,8 +21,7 @@
export default {
data() {
return {
multiLineText: 'HBuilderX,轻巧、极速,极客编辑器;uni-app x,终极跨平台方案;uts,大一统语言',
singleLineText: 'uts,大一统语言(单行文本)'
text: 'HBuilderX,轻巧、极速,极客编辑器;uni-app x,终极跨平台方案;uts,大一统语言'
}
}
}
......
......@@ -93,7 +93,7 @@
methods: {
changeWidthOrHeight() {
this.widthOrHeight?.style?.setProperty("width", this.isTranstionWidthOrHeight
? '200px'
? '190px'
: '300px')
this.isTranstionWidthOrHeight = !this.isTranstionWidthOrHeight
},
......
......@@ -9,6 +9,6 @@ describe('css-variable', () => {
const image = await program.screenshot({
fullPage: true
})
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
});
});
......@@ -6,7 +6,7 @@
<form @submit="onFormSubmit" @reset="onFormReset">
<view class="uni-form-item">
<view class="title">姓名</view>
<input class="uni-input" name="nickname" :value="nickname" placeholder="请输入姓名" maxlength="-1"/>
<input class="uni-input" name="nickname" :value="nickname" placeholder="请输入姓名" />
</view>
<view class="uni-form-item">
<view class="title">性别</view>
......
......@@ -9,7 +9,7 @@ describe('general attribute', () => {
})
it("class & style", async () => {
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
});
it('validateGeneralAttributes', async () => {
const button = await page.$(".btn-style");
......@@ -22,6 +22,6 @@ describe('general attribute', () => {
await button.tap();
await page.waitFor(500);
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
});
})
......@@ -10,7 +10,7 @@ describe('event trigger sequence', () => {
})
it('touch', async () => {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
await el.touchstart({
touches: [{
identifier: 1,
......@@ -56,10 +56,10 @@ describe('event trigger sequence', () => {
})
it('longPress', async () => {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
await el.longpress()
const data = await page.data()
expect(data.onLongPressTime).toBeGreaterThan(0)
}
})
})
})
......@@ -30,7 +30,7 @@ describe('component-native-image', () => {
expect(await page.data('loadError')).toBe(true)
})
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
it('check-cookie', async () => {
await page.setData({
autoTest: true,
......@@ -55,7 +55,7 @@ describe('component-native-image', () => {
const image = await program.screenshot({
fullPage: true
})
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
});
it('mode-screenshot', async () => {
......@@ -65,6 +65,6 @@ describe('component-native-image', () => {
const image = await program.screenshot({
fullPage: true
})
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
});
});
......@@ -12,7 +12,7 @@ describe('component-native-input', () => {
// const image = await program.screenshot({
// fullPage: true
// })
// expect(image).toSaveImageSnapshot()
// expect(image).toMatchImageSnapshot()
// })
// 测试焦点及键盘弹起
it('focus', async () => {
......@@ -147,35 +147,10 @@ describe('component-native-input', () => {
expect(await (await page.$('#uni-input-cursor-color')).attribute("cursor-color")).toBe("red")
})
it("maxlength", async () => {
const input = await page.$('#uni-input-maxlength');
let str = "";
for(let i = 0;i < 200;i++){
str += `${i}`
}
await page.setData({
inputMaxLengthValue: str
})
let length = (await input.attribute("value")).length
expect(length).toBe(10)
await page.setData({
inputMaxLengthValue: ""
})
})
it("password and value order", async () => {
const input = await page.$('#uni-input-password');
let length = (await input.attribute("value")).length
expect(length).toBe(6)
await page.setData({
inputPasswordValue: ""
})
})
it("afterAllTestScreenshot", async () => {
const image = await program.screenshot({
fullPage: true
})
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
})
});
......@@ -51,11 +51,7 @@
<view class="input-wrapper">
<input id="uni-input-placeholder2" class="uni-input" :placeholder-class="inputPlaceHolderClass"
placeholder="占位符字体大小为10px" />
</view>
<view class="input-wrapper">
<input class="uni-input" :placeholder-style="inputPlaceHolderStyle"
value="不设置placeholder只设置placeholder-style" />
</view>
</view>
</view>
<view>
......@@ -63,7 +59,7 @@
<text class="uni-title-text">设置禁用输入框</text>
</view>
<view class="input-wrapper">
<input id="uni-input-disable" class="uni-input" :disabled="true"/>
<input id="uni-input-disable" class="uni-input" :disabled="true" />
</view>
</view>
......@@ -267,9 +263,9 @@
inputMaxLengthValue: "",
onMaxLengthInputValue: "",
inputMaxLengthFocus: false,
inputPasswordValue: "cipher",
inputPasswordValue: "",
inputFocusKeyBoardChangeValue: true,
holdKeyboard: false,
holdKeyboard: false
}
},
methods: {
......
describe('component-native-list-view', () => {
let page
beforeAll(async () => {
//打开list-view-multiplex测试页
page = await program.reLaunch('/pages/component/list-view/list-view-multiplex')
await page.waitFor('list-view')
})
//滚动list-view到底部 加载更多 如果异常则直接闪退
it('check_list_item_multiplex', async () => {
await page.callMethod('listViewScrollByY', 5000)
await page.waitFor(400)
await page.callMethod('listViewScrollByY', 100)
describe('component-native-list-view', () => {
let page
beforeAll(async () => {
//打开list-view-multiplex测试页
page = await program.reLaunch('/pages/component/list-view/list-view-multiplex')
await page.waitFor('list-view')
})
//滚动list-view到底部 加载更多 如果异常则直接闪退
it('check_list_item_multiplex', async () => {
await page.callMethod('listViewScrollByY', 5000)
await page.waitFor(400)
await page.callMethod('listViewScrollByY', 100)
})
//检测延迟显示listv-view后list-item是否正常显示
......@@ -21,7 +21,7 @@ describe('component-native-list-view', () => {
});
await page.waitFor(200)
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
})
//检测修改item子元素后,item是否正常调整高度
......@@ -32,6 +32,6 @@ describe('component-native-list-view', () => {
});
await page.waitFor(600)
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
})
expect(image).toMatchImageSnapshot();
})
})
describe('component-native-list-view-refresh', () => {
if (process.env.uniTestPlatformInfo.startsWith('web')) {
it('dummyTest', async () => {
expect(1).toBe(1)
it('dummyTest', async () => {
expect(1).toBe(1)
})
return
}
let page
}
let page
beforeAll(async () => {
//打开list-view测试页
page = await program.reLaunch('/pages/component/list-view/list-view-refresh')
await page.waitFor(600)
//打开list-view测试页
page = await program.reLaunch('/pages/component/list-view/list-view-refresh')
await page.waitFor(600)
})
it('check_list_view_refresh', async () => {
......@@ -19,6 +19,6 @@ describe('component-native-list-view-refresh', () => {
//等待下拉刷新结束
await page.waitFor(500)
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
})
expect(image).toMatchImageSnapshot();
})
})
......@@ -26,7 +26,7 @@ describe('component-native-list-view', () => {
})
//检测横向scrollLeft属性赋值 备注:iOS不支持list-view横向滚动
//检测横向scrollLeft属性赋值
it('check_scroll_left', async () => {
if(await page.data('scroll_x_boolean') === false) {
await page.callMethod('change_scroll_x_boolean', true)
......@@ -44,12 +44,8 @@ describe('component-native-list-view', () => {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1) {
return
}
if(process.env.uniTestPlatformInfo.startsWith('IOS_SIMULATOR')) {
return
}
//检测横向可滚动区域 备注:iOS不支持list-view横向滚动
//检测横向可滚动区域
it('check_scroll_width', async () => {
if(await page.data('scroll_x_boolean') === false) {
await page.callMethod('change_scroll_x_boolean', true)
......@@ -63,7 +59,7 @@ describe('component-native-list-view', () => {
expect(value).toBe(true)
})
//检测下拉刷新 备注:iOS本地测试结果正确,但是自动化测试结果错误
//检测下拉刷新
it('check_refresher', async () => {
if(await page.data('scroll_y_boolean') === false) {
await page.callMethod('change_scroll_y_boolean', true)
......@@ -78,7 +74,7 @@ describe('component-native-list-view', () => {
expect(await page.data('refresherrefresh')).toBe(true)
})
//检测竖向scroll_into_view属性赋值 备注:iOS本地测试结果正确,但是自动化测试结果错误
//检测竖向scroll_into_view属性赋值
it('check_scroll_into_view_top', async () => {
if(await page.data('scroll_y_boolean') === false) {
await page.callMethod('change_scroll_y_boolean', true)
......@@ -94,7 +90,7 @@ describe('component-native-list-view', () => {
expect(scrollTop-690).toBeGreaterThanOrEqual(0)
})
//检测横向scroll_into_view属性赋值 备注:iOS不支持list-view横向滚动
//检测横向scroll_into_view属性赋值
it('check_scroll_into_view_left', async () => {
if(await page.data('scroll_x_boolean') === false) {
await page.callMethod('change_scroll_x_boolean', true)
......
......@@ -7,10 +7,6 @@
<navigator class="navigator redirect" url="redirect?title=redirect" open-type="redirect">
<button type="default">在当前页打开</button>
</navigator>
<navigator style="flex-direction: row;justify-content: space-between;">
<text>两端对齐样式测试</text>
<view style="width: 20px;height: 20px; background-color: aqua;"></view>
</navigator>
</view>
</template>
......
describe('component-native-nested-scroll-body', () => {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
it('dummyTest', () => {
expect(1).toBe(1)
})
return
}
let page
beforeAll(async () => {
//打开lnested-scroll-body测试页
page = await program.reLaunch('/pages/component/nested-scroll-body/nested-scroll-body')
await page.waitFor(600)
})
//检测横向scroll_into_view属性赋值
it('check_scroll_into_view_left', async () => {
await page.callMethod('testBodyScrollBy', 400)
await page.waitFor(300)
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
})
})
<template>
<scroll-view style="flex:1" type="nested" direction="vertical" refresher-enabled="true" refresher-default-style="none"
bounces="false" :refresher-triggered="refresherTriggered" @refresherpulling="onRefresherpulling" @refresherrefresh="onRefresherrefresh" @refresherrestore="onRefreshrestore">
<nested-scroll-header>
<swiper ref="header" indicator-dots="true" circular="true">
<swiper-item v-for="i in 3" :item-id="i">
<image src="/static/shuijiao.jpg" style="width:100% ;height: 240px;"></image>
</swiper-item>
</swiper>
</nested-scroll-header>
<nested-scroll-body>
<view style="flex:1">
<view style="flex-direction: row;">
<text style="padding: 12px 15px;">nested-scroll-body</text>
</view>
<!-- 嵌套滚动仅可能关闭bounces效果 会影响嵌套滚动不连贯 -->
<list-view bounces="false" id="body-list" :scroll-top="scrollTop" style="flex:1" associative-container="nested-scroll-view">
<list-item v-for="key in scrollData">
<view class="scroll-item">
<text class="scroll-item-title">{{key}}</text>
</view>
</list-item>
</list-view>
</view>
<text>不会渲染,因为 nested-scroll-body 只会渲染第一个子节点</text>
</nested-scroll-body>
<!-- 支持自定义样式下拉刷新slot组件 -->
<refresh-box slot="refresher" :state="state"></refresh-box>
</scroll-view>
</template>
<script>
import refreshBox from '../../template/custom-refresher/refresh-box/refresh-box.uvue';
export default {
components: { refreshBox },
data() {
return {
scrollData: [] as Array<string>,
scrollTop: 0,
refresherTriggered: false,
pullingDistance: 0,
resetting: false
}
},
computed: {
state() : number {
if (this.resetting) {
return 3;
}
if (this.refresherTriggered) {
return 2
}
if (this.pullingDistance > 45) {
return 1
} else {
return 0;
}
}
},
onLoad() {
let lists : Array<string> = []
for (let i = 0; i < 30; i++) {
lists.push("item---" + i)
}
this.scrollData = lists
},
methods: {
onRefresherpulling(e : RefresherEvent) {
this.pullingDistance = e.detail.dy;
},
onRefresherrefresh() {
this.refresherTriggered = true
setTimeout(() => {
this.refresherTriggered = false
this.resetting = true;
}, 1500)
},
onRefreshrestore() {
this.pullingDistance = 0
this.resetting = false;
},
//自动化测试使用
testBodyScrollBy(y: number) {
this.scrollTop = y
}
}
}
</script>
<style>
.scroll-item {
margin-left: 6px;
margin-right: 6px;
margin-top: 6px;
background-color: #fff;
border-radius: 4px;
}
.scroll-item-title {
width: 100%;
height: 60px;
line-height: 60px;
text-align: center;
color: #555;
}
.scroll-header-tiem {
height: 200px;
background-color: #66ccff;
align-items: center;
justify-content: center;
}
</style>
describe('component-native-nested-scroll-header', () => {
if (process.env.uniTestPlatformInfo.indexOf('web') > -1 || process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
it('dummyTest', () => {
expect(1).toBe(1)
})
return
}
let page
beforeAll(async () => {
//打开lnested-scroll-header测试页
page = await program.reLaunch('/pages/component/nested-scroll-header/nested-scroll-header')
await page.waitFor(600)
})
it('check_nested-scroll-header', async () => {
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
})
})
<template>
<scroll-view style="flex:1" type="nested" direction="vertical">
<nested-scroll-header>
<view class="scroll-header-tiem1">
<text>会渲染的nested-scroll-header</text>
</view>
<view class="scroll-header-tiem1">
<text>不会渲染nested-scroll-header,因为 nested-scroll-header 只会渲染第一个子节点</text>
</view>
</nested-scroll-header>
<nested-scroll-header>
<swiper ref="header" indicator-dots="true" circular="true">
<swiper-item v-for="i in 3" :item-id="i">
<view class="scroll-header-tiem2">
<text>如果存在多个头部节点,那么就使用多个 nested-scroll-header 来将其包裹</text>
</view>
</swiper-item>
</swiper>
</nested-scroll-header>
<nested-scroll-body>
<scroll-view style="flex:1" associative-container="nested-scroll-view">
<view v-for="key in scrollData">
<view class="scroll-item">
<text class="scroll-item-title">{{key}}</text>
</view>
</view>
</scroll-view>
</nested-scroll-body>
</scroll-view>
</template>
<script>
export default {
data() {
return {
scrollData: [] as Array<string>,
}
},
onLoad() {
let lists : Array<string> = []
for (let i = 0; i < 30; i++) {
lists.push("item---" + i)
}
this.scrollData = lists
},
methods: {
}
}
</script>
<style>
.scroll-item {
margin-left: 6px;
margin-right: 6px;
margin-top: 6px;
background-color: #fff;
border-radius: 4px;
}
.scroll-item-title {
width: 100%;
height: 60px;
line-height: 60px;
text-align: center;
color: #555;
}
.scroll-header-tiem1 {
height: 200px;
background-color: #66ccff;
align-items: center;
justify-content: center;
}
.scroll-header-tiem2 {
height: 100px;
background-color: #89ff8d;
align-items: center;
justify-content: center;
}
</style>
<template>
<scroll-view style="flex:1;" :refresher-enabled="true" :refresher-triggered="refresherTriggered"
refresher-default-style="none" @refresherpulling="onRefresherpulling" @refresherrefresh="onRefresherrefresh" @refresherrestore="onRefreshrestore" refresher-max-drag-distance="200px">
refresher-default-style="none" @refresherpulling="onRefresherpulling" @refresherrefresh="onRefresherrefresh">
<view style="height: 25px;"></view>
<view v-for="i in 20" class="content-item">
<text class="text">item-{{i}}</text>
......@@ -38,6 +38,9 @@
methods: {
onRefresherpulling(e : RefresherEvent) {
this.pullingDistance = e.detail.dy;
if (this.pullingDistance.toDouble() == 0.0) {
this.resetting = false;
}
},
onRefresherrefresh() {
this.refresherTriggered = true
......@@ -45,11 +48,7 @@
this.refresherTriggered = false
this.resetting = true;
}, 1500)
},
onRefreshrestore() {
this.pullingDistance = 0
this.resetting = false;
}
},
}
}
</script>
......
......@@ -90,7 +90,7 @@ describe('component-native-scroll-view-props', () => {
})
await page.waitFor(300);
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
})
});
......@@ -25,11 +25,7 @@
</scroll-view>
</view>
<scroll-view class="uni-list" :showScrollbar="true" :scroll-y="true">
<view class="uni-list-cell uni-list-cell-padding">
<text>点击状态栏回到顶部(仅iOS)</text>
<switch :checked="enableBackToTop" @change="enableBackToTop=!enableBackToTop"></switch>
</view>
<scroll-view class="uni-list" :showScrollbar="true" :scroll-y="true">
<view class="uni-list-cell uni-list-cell-padding">
<text>是否显示滚动条</text>
<switch :checked="showScrollbar" @change="showScrollbar=!showScrollbar"></switch>
......
......@@ -64,10 +64,10 @@
data() {
return {
items: [] as Item[],
refresherEnabled: true,
refresherEnabled: false,
refresherTriggered: false,
refresherThreshold: 45,
refresherDefaultStyle: "black",
refresherDefaultStyle: "white",
refresherBackground: "transparent",
}
},
......
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('component-native-scroll-view-refresher', () => {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
let page;
beforeAll(async () => {
page = await program.reLaunch('/pages/component/scroll-view/scroll-view-refresher');
await page.waitFor(300);
});
it('scroll-view-refresher-screenshot', async () => {
//禁止滚动条
await page.setData({
showScrollbar: false
})
await page.waitFor(300);
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
it('scroll-view-refresher-screenshot', async () => {
//禁止滚动条
await page.setData({
showScrollbar: false
})
await page.waitFor(300);
const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
})
it('check_refresher', async () => {
......@@ -30,4 +30,4 @@ describe('component-native-scroll-view-refresher', () => {
expect(1).toBe(1)
})
}
});
});
......@@ -48,7 +48,7 @@
console.log("onRefresherrestore------下拉刷新被复位")
},
onRefresherpulling(e : RefresherEvent) {
console.log("onRefresherpulling------拉刷新控件被下拉-dy=" + e.detail.dy)
console.log("onRefresherrestore------拉刷新控件被下拉-dy=" + e.detail.dy)
},
onScrolltolower(e : ScrollToLowerEvent) {
console.log("onScrolltolower 滚动到底部-----" + e.detail.direction)
......
describe('component-native-scroll-view', () => {
describe('component-native-scroll-view', () => {
let page;
beforeAll(async () => {
page = await program.reLaunch('/pages/component/scroll-view/scroll-view');
......@@ -13,6 +13,6 @@ describe('component-native-scroll-view', () => {
})
await page.waitFor(300);
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
});
expect(image).toMatchImageSnapshot();
});
});
......@@ -9,6 +9,6 @@ describe('component-native-sticky-header', () => {
it('check_sticky_header', async () => {
await page.callMethod('confirm_scroll_top_input', 600)
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
})
})
})
......@@ -9,11 +9,11 @@ describe('component-native-sticky-section', () => {
it('check_sticky_section', async () => {
await page.callMethod('listViewScrollByY', 1000)
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
})
if (process.env.uniTestPlatformInfo.startsWith('web') || process.env.UNI_AUTOMATOR_APP_WEBVIEW === 'true') {
return
expect(image).toMatchImageSnapshot();
})
if (process.env.uniTestPlatformInfo.startsWith('web')) {
return
}
it('check_goto_sticky_header', async () => {
......@@ -23,7 +23,7 @@ describe('component-native-sticky-section', () => {
await page.setData({
scrolling: 'true'
})
if (!process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
//跳转到id为C的StickyHeader位置
await page.callMethod('gotoStickyHeader', 'C')
}
......@@ -31,6 +31,6 @@ describe('component-native-sticky-section', () => {
return await page.data('scrolling') === false;
});
const image = await program.screenshot();
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
})
})
})
jest.setTimeout(20000);
jest.setTimeout(20000);
function getData(key = '') {
return new Promise(async (resolve, reject) => {
const data = await page.data()
......@@ -30,38 +30,35 @@ describe('test swiper', () => {
});
it('check autoplay loop', async () => {
// iOS平台此测试用例 等待时长不准确 导致用例过不了
if (!process.env.uniTestPlatformInfo.startsWith('IOS_SIMULATOR')) {
await page.setData({
autoplaySelect: true,
currentValChange: 0,
})
await page.waitFor(600)
expect(await getData('currentValChange')).toEqual(0)
await page.waitFor(1600)
expect(await getData('currentValChange')).toEqual(1)
await page.waitFor(2000)
expect(await getData('currentValChange')).toEqual(2)
await page.waitFor(2000)
expect(await getData('currentValChange')).toEqual(0)
await page.setData({
circularSelect: true,
currentValChange: 0,
})
await page.waitFor(600)
expect(await getData('currentValChange')).toEqual(0)
await page.waitFor(1600)
expect(await getData('currentValChange')).toEqual(1)
await page.waitFor(2000)
expect(await getData('currentValChange')).toEqual(2)
await page.waitFor(2000)
expect(await getData('currentValChange')).toEqual(0)
await page.setData({
circularSelect: false,
autoplaySelect: false
})
await page.waitFor(300)
}
await page.setData({
autoplaySelect: true,
currentValChange: 0,
})
await page.waitFor(600)
expect(await getData('currentValChange')).toEqual(0)
await page.waitFor(1600)
expect(await getData('currentValChange')).toEqual(1)
await page.waitFor(2000)
expect(await getData('currentValChange')).toEqual(2)
await page.waitFor(2000)
expect(await getData('currentValChange')).toEqual(0)
await page.setData({
circularSelect: true,
currentValChange: 0,
})
await page.waitFor(600)
expect(await getData('currentValChange')).toEqual(0)
await page.waitFor(1600)
expect(await getData('currentValChange')).toEqual(1)
await page.waitFor(2000)
expect(await getData('currentValChange')).toEqual(2)
await page.waitFor(2000)
expect(await getData('currentValChange')).toEqual(0)
await page.setData({
circularSelect: false,
autoplaySelect: false
})
await page.waitFor(300)
});
......
......@@ -9,7 +9,7 @@ describe('text-props', () => {
it('screenshot', async () => {
const image = await program.screenshot({ fullPage: true })
expect(image).toSaveImageSnapshot()
expect(image).toMatchImageSnapshot()
})
it('empty text', async () => {
......
......@@ -16,7 +16,7 @@
</view>
<view class="form-item">
<text class="form-item-label">备注</text>
<textarea class="form-item-input" placeholder="备注" name="comment" maxlength="-1"/>
<textarea class="form-item-input" placeholder="备注" name="comment" />
</view>
<view class="form-item">
<text class="form-item-label">性别</text>
......
......@@ -19,7 +19,7 @@
</view>
<view class="form-item">
<text class="form-item-label">备注</text>
<textarea class="form-item-input" placeholder="备注" name="comment" maxlength="-1" :value="data[0].getString('comment')" />
<textarea class="form-item-input" placeholder="备注" name="comment" :value="data[0].getString('comment')" />
</view>
<view class="form-item">
<text class="form-item-label">性别</text>
......
......@@ -50,7 +50,7 @@
src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.mov'
},
{
format: 'webm(iOS和Safari不支持)',
format: 'webm',
src: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.webm'
},
{
......
......@@ -24,20 +24,6 @@ describe('component-native-video', () => {
expect(await page.data('isPause')).toBe(true);
});
it('test local source', async () => {
await page.callMethod('downloadSource');
await page.waitFor(5000);
expect(await page.data('isError')).toBe(false);
await page.setData({
localSrc: '/static/test-video/2minute-demo.m3u8'
});
await page.waitFor(100);
expect(await page.data('isError')).toBe(false);
await page.setData({
autoTest: false
});
});
it('test format', async () => {
page = await program.navigateTo('/pages/component/video/video-format');
await page.waitFor(1000);
......
......@@ -131,7 +131,6 @@
<button type="primary" @click="setHeader(_header)">设置header</button>
</view>
</scroll-view>
<video v-if="autoTest" :src="localSrc" @error="onError"></video>
</view>
</template>
......@@ -218,11 +217,9 @@
color: '#FF0000'
} as Danmu,
// 自动化测试
autoTest: false,
isPlaying: false,
isPause: false,
isError: false,
localSrc: ''
isError: false
}
},
onLoad() {
......@@ -410,19 +407,6 @@
},
onControlsToggle: function (res : UniVideoControlsToggleEvent) {
console.log(res.type + " -> " + JSON.stringify(res.detail));
},
// 自动化测试
downloadSource() {
uni.downloadFile({
url: 'https://qiniu-web-assets.dcloud.net.cn/video/sample/2minute-demo.mp4',
success: (res) => {
this.localSrc = res.tempFilePath;
this.autoTest = true;
},
fail: (_) => {
this.isError = true;
}
})
}
}
}
......
......@@ -12,14 +12,14 @@ describe('component-native-web-view', () => {
});
it('screenshot', async () => {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
await page.waitFor(async () => {
return await page.data('loadFinish') === true;
});
const image = await program.screenshot({
fullPage: true
});
expect(image).toSaveImageSnapshot();
expect(image).toMatchImageSnapshot();
}
});
});
\ No newline at end of file
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
describe('component-native-web-view', () => {
if (process.env.uniTestPlatformInfo.startsWith('android') && !process.env.UNI_AUTOMATOR_APP_WEBVIEW) {
if (process.env.uniTestPlatformInfo.startsWith('android')) {
let page;
beforeAll(async () => {
page = await program.reLaunch('/pages/component/web-view/web-view');
......
<template>
<view class="uni-flex-item">
<web-view id="web-view" class="uni-flex-item" :src="src" :webview-styles="webview_styles"
:horizontalScrollBarAccess="horizontalScrollBarAccess" :verticalScrollBarAccess="verticalScrollBarAccess"
@message="message" @error="error" @loading="loading" @load="load" @download="download">
<web-view id="web-view" class="uni-flex-item" :src="src" :webview-styles="webview_styles" @message="message"
@error="error" @loading="loading" @load="load" @download="download">
</web-view>
<!-- #ifdef APP -->
<view class="uni-padding-wrap uni-common-mt">
<view class="uni-input-v">
<input class="uni-input" confirmType="go" placeholder="输入网址跳转" @confirm="confirm" maxlength="-1"/>
<input class="uni-input" confirmType="go" placeholder="输入网址跳转" @confirm="confirm" />
</view>
<view class="uni-row uni-btn-v">
<button class="uni-flex-item" type="primary" @click="back">后退</button>
......@@ -20,12 +19,6 @@
<view class="uni-btn-v">
<button type="primary" @click="nativeToWeb">原生和Web通信</button>
</view>
<!-- #ifdef APP-ANDROID -->
<view class="uni-row">
<boolean-data :defaultValue="true" title="显示横向滚动条" @change="changeHorizontalScrollBarAccess"></boolean-data>
<boolean-data :defaultValue="true" title="显示竖向滚动条" @change="changeVerticalScrollBarAccess"></boolean-data>
</view>
<!-- #endif -->
</view>
<!-- #endif -->
</view>
......@@ -42,9 +35,7 @@
}
},
webviewContext: null as WebviewContext | null,
loadError: false,
horizontalScrollBarAccess: true,
verticalScrollBarAccess: true
loadError: false
}
},
onReady() {
......@@ -96,12 +87,6 @@
url = 'https://' + url;
}
this.src = url;
},
changeHorizontalScrollBarAccess(checked : boolean) {
this.horizontalScrollBarAccess = checked;
},
changeVerticalScrollBarAccess(checked : boolean) {
this.verticalScrollBarAccess = checked;
}
}
}
......
此差异已折叠。
此差异已折叠。
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1" enable-back-to-top="true">
<scroll-view style="flex: 1">
<!-- #endif -->
<view class="uni-container">
<view class="uni-header-logo">
......
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
此差异已折叠。
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册