提交 deddab53 编写于 作者: DCloud_iOS_XHY's avatar DCloud_iOS_XHY

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

* 'dev' of https://gitcode.net/dcloud/hello-uni-app-x:
  refactor(API): 暂时屏幕 theme change 示例
  补充电量模块异常的报错提示
  新增web端editor测试例
  调整transition示例,添加异步创建view的示例
  feat: 替换 icon-star 字体文件,避开 iconfont 字体文件名,显示效果无变化
  feat: 实现 ResizeObserver
  test: 修改测试例移除误添加的systemInfo属性
  [file]修改测试用例
  [uni-env]添加条件编译
  完善措辞
  env放开iOS
  新增web端map、label、picker测试例
  补充uts-openSchema在web端的实现
  新增web端通过url scheme打开hello uni-app x应用示例
  更新video示例
  fix: 移除调试 log
...@@ -1309,13 +1309,13 @@ ...@@ -1309,13 +1309,13 @@
"navigationBarTitleText": "日历" "navigationBarTitleText": "日历"
} }
}, },
// #endif
{ {
"path": "pages/template/schema/schema", "path": "pages/template/schema/schema",
"style": { "style": {
"navigationBarTitleText": "打开schema示例" "navigationBarTitleText": "打开schema示例"
} }
}, },
// #endif
// #ifdef APP-ANDROID // #ifdef APP-ANDROID
{ {
"path": "pages/template/share/share", "path": "pages/template/share/share",
...@@ -1380,13 +1380,13 @@ ...@@ -1380,13 +1380,13 @@
"enablePullDownRefresh": false "enablePullDownRefresh": false
} }
}, },
{ // {
"path": "pages/API/theme-change/theme-change", // "path": "pages/API/theme-change/theme-change",
"style": { // "style": {
"navigationBarTitleText": "主题切换", // "navigationBarTitleText": "主题切换",
"enablePullDownRefresh": false // "enablePullDownRefresh": false
} // }
}, // },
{ {
"path": "uni_modules/uni-pay-x/pages/success/success", "path": "uni_modules/uni-pay-x/pages/success/success",
"style": { "style": {
...@@ -1434,7 +1434,6 @@ ...@@ -1434,7 +1434,6 @@
"backgroundColorContent": "#fffae8" "backgroundColorContent": "#fffae8"
} }
}, },
// #ifdef APP-ANDROID || WEB
{ {
"path" : "pages/API/resize-observer/resize-observer", "path" : "pages/API/resize-observer/resize-observer",
"style" : "style" :
...@@ -1442,7 +1441,6 @@ ...@@ -1442,7 +1441,6 @@
"navigationBarTitleText" : "resize observer" "navigationBarTitleText" : "resize observer"
} }
}, },
// #endif
{ {
"path" : "pages/CSS/overflow/overflow-visible-event", "path" : "pages/CSS/overflow/overflow-visible-event",
"style" : "style" :
......
...@@ -33,7 +33,10 @@ ...@@ -33,7 +33,10 @@
methods: { methods: {
geAbsPath(path ?: Any) { geAbsPath(path ?: Any) {
// #ifdef APP-ANDROID
this.log += UTSAndroid.convert2AbsFullPath(path as String) + '\n' this.log += UTSAndroid.convert2AbsFullPath(path as String) + '\n'
// #endif
} }
} }
} }
......
...@@ -14,15 +14,20 @@ ...@@ -14,15 +14,20 @@
} }
}, },
onLoad() { onLoad() {
try {
uni.getBatteryInfo({ uni.getBatteryInfo({
success: res => { success: res => {
this.level = res.level; this.level = res.level;
this.isCharging = res.isCharging; this.isCharging = res.isCharging;
} }
}); });
} catch (e) {
console.error(e.message);
uni.showModal({
content: e.message,
showCancel: false
});
}
} }
} }
</script> </script>
<style>
</style>
\ No newline at end of file
...@@ -97,10 +97,10 @@ describe('ExtApi-FileManagerTest', () => { ...@@ -97,10 +97,10 @@ describe('ExtApi-FileManagerTest', () => {
let lastFailError = await getData('lastFailError') let lastFailError = await getData('lastFailError')
expect(lastFailError.errCode).toEqual(1300002) expect(lastFailError.errCode).toEqual(1300002)
expect(lastFailError.errMsg).toEqual('no such file or directory:unifile://usr/a/b/c') expect(lastFailError.errMsg).toEqual('no such file or directory')
let lastCompleteError = await getData('lastCompleteError') let lastCompleteError = await getData('lastCompleteError')
expect(lastCompleteError.errCode).toEqual(1300002) expect(lastCompleteError.errCode).toEqual(1300002)
expect(lastCompleteError.errMsg).toEqual('no such file or directory:unifile://usr/a/b/c') expect(lastCompleteError.errMsg).toEqual('no such file or directory')
// 测试 recursive = true 期望文件夹创建成功 // 测试 recursive = true 期望文件夹创建成功
......
...@@ -17,14 +17,12 @@ describe('ExtApi-GetSystemInfo', () => { ...@@ -17,14 +17,12 @@ describe('ExtApi-GetSystemInfo', () => {
'uniCompilerVersionCode', 'uniRuntimeVersionCode' 'uniCompilerVersionCode', 'uniRuntimeVersionCode'
] ]
const booleanProperties = [ const booleanProperties = [
'isUniAppX'
] ]
const requiredProperties = [ const requiredProperties = [
'uniCompilerVersion', 'uniCompilerVersion',
'uniCompilerVersionCode', 'uniCompilerVersionCode',
'uniRuntimeVersion', 'uniRuntimeVersion',
'uniRuntimeVersionCode', 'uniRuntimeVersionCode'
'isUniAppX'
] ]
beforeAll(async () => { beforeAll(async () => {
......
const PAGE_PATH = '/pages/API/map/map'
let page;
describe('web-map', () => {
console.log("uniTestPlatformInfo",process.env.uniTestPlatformInfo)
if (!process.env.uniTestPlatformInfo.startsWith('web')) {
it('app', () => {
expect(1).toBe(1)
})
return
}
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor('view');
// 等待地图加载完成
await page.waitFor(4000);
await page.setData({autoTest:true})
});
it('Check MapMethods', async () => {
const mapMethods = ['changeScale', 'addMarkers', 'addPolyline', 'addPolygons', 'addCircles',
'includePoint', 'handleTranslateMarker'
]
for (var i = 0; i < mapMethods.length; i++) {
await page.callMethod(mapMethods[i])
if (mapMethods[i] == 'handleTranslateMarker') {
await page.waitFor(2000);
} else {
await page.waitFor(500);
}
expect(await program.screenshot()).toSaveImageSnapshot();
await page.waitFor(500);
}
});
it('handleGetCenterLocation', async () => {
await page.callMethod('handleGetCenterLocation')
await page.waitFor(500);
const centerLocationRes = await page.data('getCenterLocationTest')
expect(centerLocationRes.latitude).not.toBeNull();
expect(centerLocationRes.longitude).not.toBeNull();
});
it('handleGetRegion', async () => {
await page.callMethod('handleGetRegion')
await page.waitFor(500);
const regionRes = await page.data('getRegionTest')
const getRegionExpected = {
southwest: { latitude: 39.88334279187766, longitude: 116.31050146728515 },
northeast: { latitude: 40.0149408585477, longitude: 116.56799353271484 },
errMsg: 'getRegion:ok'
}
expect(regionRes).toEqual(expect.objectContaining(getRegionExpected));
});
});
...@@ -304,7 +304,11 @@ ...@@ -304,7 +304,11 @@
includePoints: [] as Points[], includePoints: [] as Points[],
rotate: 0, rotate: 0,
skew: 0, skew: 0,
map: null as MapContext | null map: null as MapContext | null,
// 自动化测试
autoTest: false,
getCenterLocationTest:{},
getRegionTest:{},
} }
}, },
onReady() { onReady() {
...@@ -359,20 +363,26 @@ ...@@ -359,20 +363,26 @@
this.map!.getCenterLocation({ this.map!.getCenterLocation({
success: ret => { success: ret => {
console.log(JSON.stringify(ret)); console.log(JSON.stringify(ret));
this.getCenterLocationTest = ret
if(!this.autoTest){
uni.showModal({ uni.showModal({
content: JSON.stringify(ret) content: JSON.stringify(ret)
}) })
} }
}
}) })
}, },
handleGetRegion() { handleGetRegion() {
this.map!.getRegion({ this.map!.getRegion({
success: ret => { success: ret => {
console.log(JSON.stringify(ret)); console.log(JSON.stringify(ret));
this.getRegionTest = ret
if(!this.autoTest){
uni.showModal({ uni.showModal({
content: JSON.stringify(ret) content: JSON.stringify(ret)
}) })
} }
}
}) })
}, },
......
...@@ -18,8 +18,8 @@ describe("payment", () => { ...@@ -18,8 +18,8 @@ describe("payment", () => {
page = await program.reLaunch(PAGE_PATH) page = await program.reLaunch(PAGE_PATH)
await page.waitFor(600) await page.waitFor(600)
}); });
//支付失败700711 //支付失败701100
it("errorcode700711", async () => { it("errorcode701100", async () => {
let orderInfo = let orderInfo =
"service=\"mobile.securitypay.pay\"&partner=\"2088801273866834\"&_input_charset=\"UTF-8\"&out_trade_no=\"20240229115452\"&subject=\"DCloud项目捐赠\"&payment_type=\"1\"&seller_id=\"payservice@dcloud.io\"&total_fee=\"0.01\"&body=\"DCloud致力于打造HTML5最好的移动开发工具,包括终端的Runtime、云端的服务和IDE,同时提供各项配套的开发者服务。\"&it_b_pay=\"1d\"&notify_url=\"http%3A%2F%2Fdemo.dcloud.net.cn%2Fpayment%2Falipay%2Fnotify.php\"&show_url=\"http%3A%2F%2Fwww.dcloud.io%2Fhelloh5%2F\"&sign=\"diZdkTX2iIP1oZh25UCGqx%2BpkViqAN8xdvMNSJF79aq0JiunX2mtr%2BbNlDsP0YL5x85KjULsqx%2Fq%2B5wij6eMoBVeJ%2BHhyjkwt0PYuwntroJ2Ho8bdUVEybBgOjy240NbCUtKmZzNRQAGsmLztKWzsg1srsQ8Se3Qi8KGDaOhqBs%3D\"&sign_type=\"RSA\""; "service=\"mobile.securitypay.pay\"&partner=\"2088801273866834\"&_input_charset=\"UTF-8\"&out_trade_no=\"20240229115452\"&subject=\"DCloud项目捐赠\"&payment_type=\"1\"&seller_id=\"payservice@dcloud.io\"&total_fee=\"0.01\"&body=\"DCloud致力于打造HTML5最好的移动开发工具,包括终端的Runtime、云端的服务和IDE,同时提供各项配套的开发者服务。\"&it_b_pay=\"1d\"&notify_url=\"http%3A%2F%2Fdemo.dcloud.net.cn%2Fpayment%2Falipay%2Fnotify.php\"&show_url=\"http%3A%2F%2Fwww.dcloud.io%2Fhelloh5%2F\"&sign=\"diZdkTX2iIP1oZh25UCGqx%2BpkViqAN8xdvMNSJF79aq0JiunX2mtr%2BbNlDsP0YL5x85KjULsqx%2Fq%2B5wij6eMoBVeJ%2BHhyjkwt0PYuwntroJ2Ho8bdUVEybBgOjy240NbCUtKmZzNRQAGsmLztKWzsg1srsQ8Se3Qi8KGDaOhqBs%3D\"&sign_type=\"RSA\"";
await page.setData({ await page.setData({
...@@ -29,6 +29,6 @@ describe("payment", () => { ...@@ -29,6 +29,6 @@ describe("payment", () => {
await page.waitFor(async () => { await page.waitFor(async () => {
return await page.data('complete') === true; return await page.data('complete') === true;
}); });
expect((await page.data())['errorCode']).toEqual(700711) expect((await page.data())['errorCode']).toEqual(701100)
}); });
}); });
describe('api-resize-observer', () => { describe('api-resize-observer', () => {
if (
!process.env.uniTestPlatformInfo.startsWith('android') &&
!process.env.uniTestPlatformInfo.startsWith('web')
) {
it('dummyTest', async () => {
expect(1).toBe(1)
})
return
}
let page let page
beforeAll(async () => { beforeAll(async () => {
......
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
</view> </view>
<button @click="revertBoxSize">还原修改前元素宽高</button> <button @click="revertBoxSize">还原修改前元素宽高</button>
<button @click="toggleDisplay">{{boxDisplay? '隐藏元素': '显示元素'}}</button> <button @click="toggleDisplay">{{boxDisplay? '隐藏元素': '显示元素'}}</button>
<button @click='cancelListen'>停止监听</button>
<button @click='goOnListen'>恢复监听</button>
<view> <view>
<text class="info-text">蓝色方块元素:</text> <text class="info-text">蓝色方块元素:</text>
<view class="info-item"> <view class="info-item">
...@@ -47,6 +49,7 @@ ...@@ -47,6 +49,7 @@
onReady() { onReady() {
if (this.resizeObserver == null) { if (this.resizeObserver == null) {
this.resizeObserver = new UniResizeObserver((entries : Array<UniResizeObserverEntry>) => { this.resizeObserver = new UniResizeObserver((entries : Array<UniResizeObserverEntry>) => {
entries.forEach(entry => { entries.forEach(entry => {
if (entry.target == this.outBoxElement) { if (entry.target == this.outBoxElement) {
this.outBoxSizeInfo = this.analysisResizeObserverEntry(entry) this.outBoxSizeInfo = this.analysisResizeObserverEntry(entry)
...@@ -91,7 +94,7 @@ ...@@ -91,7 +94,7 @@
} }
}, },
//自动化测试专用 //自动化测试专用
setOutBoxMarginLeft(value: string) { setOutBoxMarginLeft(value : string) {
if (this.outBoxElement != null) { if (this.outBoxElement != null) {
this.outBoxElementOnResize = false this.outBoxElementOnResize = false
this.outBoxElement!.style.setProperty("margin-left", value) this.outBoxElement!.style.setProperty("margin-left", value)
...@@ -108,6 +111,15 @@ ...@@ -108,6 +111,15 @@
"contentBoxSize: \n{blockSize:" + contentBoxSize.blockSize + ", inlineSize:" + contentBoxSize.inlineSize + "}\n" + "contentBoxSize: \n{blockSize:" + contentBoxSize.blockSize + ", inlineSize:" + contentBoxSize.inlineSize + "}\n" +
"devicePixelContentBoxSize: \n{blockSize:" + devicePixelContentBoxSize.blockSize + ", inlineSize:" + devicePixelContentBoxSize.inlineSize + "}\n" + "devicePixelContentBoxSize: \n{blockSize:" + devicePixelContentBoxSize.blockSize + ", inlineSize:" + devicePixelContentBoxSize.inlineSize + "}\n" +
"contentRect: \n{x:" + entry.contentRect.x + ", y:" + entry.contentRect.y + ", width:" + entry.contentRect.width + ", height:" + entry.contentRect.height + "}" "contentRect: \n{x:" + entry.contentRect.x + ", y:" + entry.contentRect.y + ", width:" + entry.contentRect.width + ", height:" + entry.contentRect.height + "}"
},
cancelListen(){
// this.resizeObserver?.unobserve()
this.resizeObserver!.unobserve(this.outBoxElement!)
this.resizeObserver!.unobserve(this.innerBoxElement!)
},
goOnListen(){
this.resizeObserver!.observe(this.outBoxElement!)
this.resizeObserver!.observe(this.innerBoxElement!)
} }
} }
} }
......
<template> <template>
<view class="uni-padding-wrap"> <view class="uni-padding-wrap">
<view class="uni-common-mt flex justify-between flex-row"> <view class="uni-common-mt item-box">
<text>theme:</text> <text>theme:</text>
<text id="theme">{{ dataInfo.theme }}</text> <text id="theme">{{ dataInfo.theme }}</text>
</view> </view>
<view class="uni-common-mt flex justify-between flex-row"> <view class="uni-common-mt item-box">
<text>fn1 trigger num:</text> <text>fn1 trigger num:</text>
<text id="fn1-trigger-num">{{ dataInfo.fn1TriggerNum }}</text> <text id="fn1-trigger-num">{{ dataInfo.fn1TriggerNum }}</text>
</view> </view>
<view class="uni-common-mt flex justify-between flex-row"> <view class="uni-common-mt item-box">
<text>fn2 trigger num:</text> <text>fn2 trigger num:</text>
<text id="fn2-trigger-num">{{ dataInfo.fn2TriggerNum }}</text> <text id="fn2-trigger-num">{{ dataInfo.fn2TriggerNum }}</text>
</view> </view>
...@@ -73,13 +73,9 @@ onReady(() => { ...@@ -73,13 +73,9 @@ onReady(() => {
</script> </script>
<style> <style>
.flex { .item-box {
display: flex; display: flex;
}
.flex-row {
flex-direction: row; flex-direction: row;
}
.justify-between {
justify-content: space-between; justify-content: space-between;
} }
</style> </style>
// uni-app自动化测试教程: uni-app自动化测试教程: https://uniapp.dcloud.net.cn/worktile/auto/hbuilderx-extension/
jest.setTimeout(60000);
describe('editor.uvue', () => {
if (!process.env.uniTestPlatformInfo.startsWith('web')) {
it('app', () => {
expect(1).toBe(1)
})
return
}
let page, editor, options = [];
beforeAll(async () => {
page = await program.reLaunch("/pages/component/editor/editor");
await page.waitFor('view');
editor = await page.$('#editor');
await page.waitFor(3000);
await page.setData({autoTest:true})
});
it('editor-wrapper', async () => {
expect(await editor.attribute("placeholder")).toBe("开始输入...")
expect(await editor.attribute("read-only")).toBe("false")
});
it('editor-toolbar', async () => {
const iconfontsEl = await page.$$('.iconfont');
for (var i = 0; i < iconfontsEl.length - 7; i++) {
await iconfontsEl[i].tap()
// await page.waitFor(500)
const getFormats = await page.data('formats')
const name = await iconfontsEl[i].attribute('data-name')
options.push({
insert:'文本内容' + name,
attributes: getFormats
})
await page.callMethod('setContents', options)
await page.setData({
formats: {}
})
await iconfontsEl[i].tap()
}
});
it('editor-screenshot', async () => {
expect(await program.screenshot()).toSaveImageSnapshot();
await page.waitFor(500);
})
it('clear', async () => {
await page.callMethod('clear')
await page.waitFor(500)
expect(await editor.attribute("placeholder")).toBe("开始输入...")
})
it('undo-redo', async () => {
await page.callMethod('insertDate')
await page.callMethod('insertDivider')
await page.waitFor(500)
await page.callMethod('undo')
await page.waitFor(500)
expect(await page.data('undoTest')).toBe(true)
await page.callMethod('redo')
await page.waitFor(500)
expect(await page.data('redoTest')).toBe(true)
})
it('insertImage', async () => {
await page.callMethod('insertImage','https://qiniu-web-assets.dcloud.net.cn/unidoc/zh/uni-app.png')
await page.waitFor(500)
expect(await program.screenshot()).toSaveImageSnapshot();
})
it('removeFormat', async () => {
const bgcolorEl = await page.$('.icon-fontbgcolor');
await bgcolorEl.tap()
await page.waitFor(500)
const getFormats = await page.data('formats')
await page.callMethod('setContents', [
{
insert: '设置字体样式bgcolor',
attributes: getFormats
}
])
await page.waitFor(500)
await page.callMethod('removeFormat')
await page.waitFor(500)
expect(await page.data('removeFormatTest')).toBe(true)
expect(await page.data('formats')).toEqual({})
})
});
...@@ -30,7 +30,7 @@ ...@@ -30,7 +30,7 @@
data-name="marginTop" data-value="20px"></view> data-name="marginTop" data-value="20px"></view>
<view :class="formats.marginBottom ? 'ql-active' : ''" class="iconfont icon-723bianjiqi_duanhouju" <view :class="formats.marginBottom ? 'ql-active' : ''" class="iconfont icon-723bianjiqi_duanhouju"
data-name="marginBottom" data-value="20px"></view> data-name="marginBottom" data-value="20px"></view>
<view class="iconfont icon-clearedformat" @tap="removeFormat"></view>
<view :class="formats.fontFamily ? 'ql-active' : ''" class="iconfont icon-font" <view :class="formats.fontFamily ? 'ql-active' : ''" class="iconfont icon-font"
data-name="fontFamily" data-value="Pacifico"></view> data-name="fontFamily" data-value="Pacifico"></view>
<view :class="formats.fontSize === '24px' ? 'ql-active' : ''" class="iconfont icon-fontsize" <view :class="formats.fontSize === '24px' ? 'ql-active' : ''" class="iconfont icon-fontsize"
...@@ -39,27 +39,35 @@ ...@@ -39,27 +39,35 @@
data-name="color" data-value="#0000ff"></view> data-name="color" data-value="#0000ff"></view>
<view :class="formats.backgroundColor === '#00ff00' ? 'ql-active' : ''" <view :class="formats.backgroundColor === '#00ff00' ? 'ql-active' : ''"
class="iconfont icon-fontbgcolor" data-name="backgroundColor" data-value="#00ff00"></view> class="iconfont icon-fontbgcolor" data-name="backgroundColor" data-value="#00ff00"></view>
<view class="iconfont icon-date" @tap="insertDate"></view>
<view class="iconfont icon--checklist" data-name="list" data-value="check"></view> <view class="iconfont icon--checklist" data-name="list" data-value="check"></view>
<view :class="formats.list === 'ordered' ? 'ql-active' : ''" class="iconfont icon-youxupailie" <view :class="formats.list === 'ordered' ? 'ql-active' : ''" class="iconfont icon-youxupailie"
data-name="list" data-value="ordered"></view> data-name="list" data-value="ordered"></view>
<view :class="formats.list === 'bullet' ? 'ql-active' : ''" class="iconfont icon-wuxupailie" <view :class="formats.list === 'bullet' ? 'ql-active' : ''" class="iconfont icon-wuxupailie"
data-name="list" data-value="bullet"></view> data-name="list" data-value="bullet"></view>
<view class="iconfont icon-undo" @tap="undo"></view>
<view class="iconfont icon-redo" @tap="redo"></view>
<view class="iconfont icon-outdent" data-name="indent" data-value="-1"></view> <view class="iconfont icon-outdent" data-name="indent" data-value="-1"></view>
<view class="iconfont icon-indent" data-name="indent" data-value="+1"></view> <view class="iconfont icon-indent" data-name="indent" data-value="+1"></view>
<view class="iconfont icon-fengexian" @tap="insertDivider"></view>
<view class="iconfont icon-charutupian" @tap="insertImage"></view>
<view :class="formats.header === 1 ? 'ql-active' : ''" class="iconfont icon-format-header-1" <view :class="formats.header === 1 ? 'ql-active' : ''" class="iconfont icon-format-header-1"
data-name="header" :data-value="1"></view> data-name="header" :data-value="1"></view>
<view :class="formats.script === 'sub' ? 'ql-active' : ''" class="iconfont icon-zitixiabiao" <view :class="formats.script === 'sub' ? 'ql-active' : ''" class="iconfont icon-zitixiabiao"
data-name="script" data-value="sub"></view> data-name="script" data-value="sub"></view>
<view :class="formats.script === 'super' ? 'ql-active' : ''" class="iconfont icon-zitishangbiao" <view :class="formats.script === 'super' ? 'ql-active' : ''" class="iconfont icon-zitishangbiao"
data-name="script" data-value="super"></view> data-name="script" data-value="super"></view>
<view class="iconfont icon-shanchu" @tap="clear"></view>
<view :class="formats.direction === 'rtl' ? 'ql-active' : ''" class="iconfont icon-direction-rtl" <view :class="formats.direction === 'rtl' ? 'ql-active' : ''" class="iconfont icon-direction-rtl"
data-name="direction" data-value="rtl"></view> data-name="direction" data-value="rtl"></view>
<view class="iconfont icon-date" @tap="insertDate"></view>
<view class="iconfont icon-fengexian" @tap="insertDivider"></view>
<view class="iconfont icon-charutupian" @tap="chooseInsertImage"></view>
<view class="iconfont icon-clearedformat" @tap="removeFormat"></view>
<view class="iconfont icon-undo" @tap="undo"></view>
<view class="iconfont icon-redo" @tap="redo"></view>
<view class="iconfont icon-shanchu" @tap="clearShowModal"></view>
</view> </view>
<view class="editor-wrapper"> <view class="editor-wrapper">
...@@ -86,7 +94,12 @@ ...@@ -86,7 +94,12 @@
return { return {
readOnly: false, readOnly: false,
formats: {}, formats: {},
editorCtx:{} as Context editorCtx:{} as Context,
// 自动化测试
autoTest:false,
undoTest:false,
redoTest:false,
removeFormatTest:false
} }
}, },
onLoad() { onLoad() {
...@@ -110,6 +123,20 @@ ...@@ -110,6 +123,20 @@
this.editorCtx = res.context this.editorCtx = res.context
}).exec() }).exec()
}, },
// 自动化测试专用
setContents(options) {
this.editorCtx.setContents({
delta: {
ops:options
},
success: (res) => {
console.log('setContents-success', res)
},
fail: (err) => {
console.log(err)
}
})
},
getCon() { getCon() {
this.editorCtx.getContents({ this.editorCtx.getContents({
success: (res) => { success: (res) => {
...@@ -121,16 +148,27 @@ ...@@ -121,16 +148,27 @@
}) })
}, },
undo() { undo() {
this.editorCtx.undo() this.editorCtx.undo({
success: (res) => {
this.undoTest = true
},
fail: (err) => {
this.undoTest = false
}
})
}, },
redo() { redo() {
this.editorCtx.redo() this.editorCtx.redo({
success: (res) => {
this.redoTest = true
},
fail: (err) => {
this.redoTest = false
}
})
}, },
format(e) { format(e) {
let { let {name,value} = e.target.dataset
name,
value
} = e.target.dataset
if (!name) return if (!name) return
// console.log('format', name, value) // console.log('format', name, value)
this.editorCtx.format(name, value) this.editorCtx.format(name, value)
...@@ -147,22 +185,33 @@ ...@@ -147,22 +185,33 @@
}) })
}, },
clear() { clear() {
uni.showModal({
title: '清空编辑器',
content: '确定清空编辑器全部内容?',
success: res => {
if (res.confirm) {
this.editorCtx.clear({ this.editorCtx.clear({
success: function(res) { success: function(res) {
console.log("clear success") console.log("clear success")
} }
}) })
},
clearShowModal() {
uni.showModal({
title: '清空编辑器',
content: '确定清空编辑器全部内容?',
success: res => {
if (res.confirm) {
this.clear()
} }
} }
}) })
}, },
removeFormat() { removeFormat() {
this.editorCtx.removeFormat() this.editorCtx.removeFormat({
success: (res) => {
console.log('removeFormat-success', res)
this.removeFormatTest = true
},
fail: (err) => {
this.removeFormatTest = false
}
})
}, },
insertDate() { insertDate() {
const date = new Date() const date = new Date()
...@@ -171,17 +220,20 @@ ...@@ -171,17 +220,20 @@
text: formatDate text: formatDate
}) })
}, },
insertImage() { insertImage(image){
uni.chooseImage({
count: 1,
success: (res) => {
this.editorCtx.insertImage({ this.editorCtx.insertImage({
src: res.tempFilePaths[0], src:image,
alt: '图像', alt: '图像',
success: function() { success: function() {
console.log('insert image success') console.log('insert image success')
} }
}) })
},
chooseInsertImage() {
uni.chooseImage({
count: 1,
success: (res) => {
this.insertImage(res.tempFilePaths[0])
} }
}) })
} }
...@@ -201,17 +253,18 @@ ...@@ -201,17 +253,18 @@
} }
.editor-wrapper { .editor-wrapper {
height: calc(100vh - var(--window-top) - var(--status-bar-height) - 80px - 46px); height: calc(100vh - var(--window-top) - var(--status-bar-height) - 140px - 46px);
background: #fff; background: #fff;
} }
.iconfont { .iconfont {
display: inline-block; display: inline-block;
padding: 8px 8px;
width: 30px; width: 30px;
height: 30px; height: 30px;
cursor: pointer; cursor: pointer;
font-size: 20px; font-size: 20px;
margin: 0px 6px;
align-content: center;
} }
.toolbar { .toolbar {
...@@ -220,7 +273,8 @@ ...@@ -220,7 +273,8 @@
font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif; font-family: 'Helvetica Neue', 'Helvetica', 'Arial', sans-serif;
flex-direction: row; flex-direction: row;
flex-wrap: wrap; flex-wrap: wrap;
height: 110px; height: 140px;
padding-left: 10px;
} }
.ql-container { .ql-container {
......
<template> <template>
<!-- #ifdef APP --> <!-- #ifdef APP -->
<scroll-view style="flex:1;"> <scroll-view style="flex:1;" v-if="isShow">
<!-- #endif --> <!-- #endif -->
<image class="transition-transform" id="transition-transform" @transitionend="onEnd" src="/static/uni.png"></image> <image class="transition-transform" id="transition-transform" @transitionend="onEnd" src="/static/uni.png"></image>
<text class="adjust">对图片设置transform进行旋转,在旋转完成的transitionend事件后,继续旋转</text> <text class="adjust">对图片设置transform进行旋转,在旋转完成的transitionend事件后,继续旋转</text>
...@@ -18,9 +18,24 @@ ...@@ -18,9 +18,24 @@
element: null as UniElement | null, element: null as UniElement | null,
isStart: false, isStart: false,
buttonValue: "开启图片旋转", buttonValue: "开启图片旋转",
onTransitionEndTriggr: false onTransitionEndTriggr: false,
isShow: false
} }
}, },
onReady() {
// #ifdef APP-ANDROID
var that = this
class ThreadRunnable extends Runnable {
override run() {
that.isShow = true
}
}
new Thread(new ThreadRunnable()).start()
// #endif
// #ifndef APP-ANDROID
this.isShow = true
// #endif
},
methods: { methods: {
switchBtn() { switchBtn() {
if (!this.isStart) { if (!this.isStart) {
...@@ -53,10 +68,11 @@ ...@@ -53,10 +68,11 @@
</script> </script>
<style> <style>
.adjust { .adjust {
margin: 10px; margin: 10px;
} }
.transition-transform {
.transition-transform {
width: 200px; width: 200px;
height: 200px; height: 200px;
margin: 25px auto; margin: 25px auto;
...@@ -65,5 +81,5 @@ ...@@ -65,5 +81,5 @@
transition-property: transform; transition-property: transform;
transition-timing-function: linear; transition-timing-function: linear;
transform: rotate(0deg); transform: rotate(0deg);
} }
</style> </style>
let page;
describe('label.uvue', () => {
console.log(process.env.uniTestPlatformInfo,process.env.uniTestPlatformInfo.startsWith('web'))
if (!process.env.uniTestPlatformInfo.startsWith('web')) {
it('app', () => {
expect(1).toBe(1)
})
return
}
beforeAll(async () => {
page = await program.reLaunch('/pages/component/label/label')
await page.waitFor('view');
});
afterEach(async() => {
await page.setData({
checkboxValue: [],
radioValue:''
})
});
function getData(key = '') {
return new Promise(async (resolve, reject) => {
const data = await page.data()
resolve(key ? data[key] : data)
})
}
it('表单组件在label内', async () => {
expect(await getData('checkboxValue')).toEqual([])
const checkboxItems = await page.$$('.checkboxItemsTest')
await checkboxItems[0].tap()
expect(await getData('checkboxValue')).toEqual(['USA', 'CHN'])
})
it('label用for标识表单组件', async () => {
const radioItems = await page.$$('.label-2-text')
await radioItems[0].tap()
expect(await getData('radioValue')).toEqual('USA')
await radioItems[1].tap()
expect(await getData('radioValue')).toEqual('CHN')
})
it('label内有多个时选中第一个', async () => {
const labelText = await page.$('.uni-center')
await labelText.tap()
expect(await getData('checkboxValue')).toEqual([''])
})
})
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<view class="uni-form-item uni-column"> <view class="uni-form-item uni-column">
<view class="title">表单组件在label内</view> <view class="title">表单组件在label内</view>
<checkbox-group class="uni-list" @change="checkboxChange"> <checkbox-group class="uni-list" @change="checkboxChange">
<label class="uni-list-cell uni-list-cell-pd" v-for="item in checkboxItems" :key="item.name"> <label class="uni-list-cell uni-list-cell-pd checkboxItemsTest" v-for="item in checkboxItems" :key="item.name">
<view> <view>
<checkbox :value="item.name" :checked="item.checked"></checkbox> <checkbox :value="item.name" :checked="item.checked"></checkbox>
</view> </view>
...@@ -70,17 +70,19 @@ ...@@ -70,17 +70,19 @@
checked: 'true' checked: 'true'
} }
], ],
hidden: false hidden: false,
checkboxValue: [] as string[],
radioValue:''
} }
}, },
methods: { methods: {
checkboxChange: function (e) { checkboxChange: function (e : UniCheckboxGroupChangeEvent) {
var checked = e.detail.value console.log(e.detail.value)
console.log(checked) this.checkboxValue = e.detail.value
}, },
radioChange: function (e) { radioChange: function (e : UniRadioGroupChangeEvent) {
var checked = e.detail.value console.log(e.detail.value)
console.log(checked) this.radioValue = e.detail.value
} }
} }
} }
......
describe('Picker.uvue', () => {
console.log(process.env.uniTestPlatformInfo)
if (!process.env.uniTestPlatformInfo.startsWith('web')) {
it('app', () => {
expect(1).toBe(1)
})
return
}
beforeAll(async () => {
page = await program.reLaunch('/pages/component/picker/picker')
await page.waitFor('view');
});
function getData(key = '') {
return new Promise(async (resolve, reject) => {
const data = await page.data()
resolve(key ? data[key] : data)
})
}
function getValue(className,propertyValue='value') {
return new Promise(async (resolve, reject) => {
const el = await page.$(className)
const value = await el.property(propertyValue)
resolve(value)
})
}
it('普通选择器', async () => {
expect(await getValue('.picker')).toBe(await getData('index'))
await page.setData({index:1})
const pickerValueEl = await page.$('.pickerValue')
expect(await pickerValueEl.text()).toBe('美国')
})
it('多列选择器', async () => {
expect(await getValue('.pickerMulti')).toEqual(await getData('multiIndex'))
const pickerMultiValueEl = await page.$('.pickerMultiValue')
expect(await pickerMultiValueEl.text()).toStrictEqual('亚洲,中国,北京')
await page.setData({multiIndex:[0, 0, 2]})
const pickerMultiValueEl2 = await page.$('.pickerMultiValue')
expect(await pickerMultiValueEl2.text()).toStrictEqual('亚洲,中国,广州')
})
it('时间选择器', async () => {
expect(await getValue('.pickerTime')).toBe(await getData('time'))
await page.setData({time:'15:30'})
expect(await getValue('.pickerTime')).toEqual('15:30')
})
it('日期选择器', async () => {
expect(await getValue('.pickerDate')).toBe(await getData('date'))
await page.setData({date:'2028-05-20'})
expect(await getValue('.pickerDate')).toEqual('2028-05-20')
expect(await getValue('.pickerDate','start')).toStrictEqual(await getData('startDate'))
expect(await getValue('.pickerDate','end')).toStrictEqual(await getData('endDate'))
})
})
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
当前选择 当前选择
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<picker @change="bindPickerChange" :value="index" :range="array" range-key="name"> <picker class="picker" @change="bindPickerChange" :value="index" :range="array" range-key="name">
<view class="uni-input">{{array[index].name}}</view> <view class="uni-input pickerValue">{{array[index].name}}</view>
</picker> </picker>
</view> </view>
</view> </view>
...@@ -22,8 +22,8 @@ ...@@ -22,8 +22,8 @@
当前选择 当前选择
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<picker mode="multiSelector" @columnchange="bindMultiPickerColumnChange" :value="multiIndex" :range="multiArray"> <picker class="pickerMulti" mode="multiSelector" @columnchange="bindMultiPickerColumnChange" :value="multiIndex" :range="multiArray">
<view class="uni-input">{{multiArray[0][multiIndex[0]]}},{{multiArray[1][multiIndex[1]]}},{{multiArray[2][multiIndex[2]]}}</view> <view class="uni-input pickerMultiValue">{{multiArray[0][multiIndex[0]]}},{{multiArray[1][multiIndex[1]]}},{{multiArray[2][multiIndex[2]]}}</view>
</picker> </picker>
</view> </view>
</view> </view>
...@@ -36,7 +36,7 @@ ...@@ -36,7 +36,7 @@
当前选择 当前选择
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<picker mode="time" :value="time" start="09:01" end="21:01" @change="bindTimeChange"> <picker class="pickerTime" mode="time" :value="time" start="09:01" end="21:01" @change="bindTimeChange">
<view class="uni-input">{{time}}</view> <view class="uni-input">{{time}}</view>
</picker> </picker>
</view> </view>
...@@ -53,7 +53,7 @@ ...@@ -53,7 +53,7 @@
当前选择 当前选择
</view> </view>
<view class="uni-list-cell-db"> <view class="uni-list-cell-db">
<picker mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange"> <picker class="pickerDate" mode="date" :value="date" :start="startDate" :end="endDate" @change="bindDateChange">
<view class="uni-input">{{date}}</view> <view class="uni-input">{{date}}</view>
</picker> </picker>
</view> </view>
......
...@@ -33,7 +33,7 @@ export default { ...@@ -33,7 +33,7 @@ export default {
textarea_longpress() { console.log("如果一个组件被绑定了 longpress 事件,那么当用户长按这个组件时,该事件将会被触发。") }, textarea_longpress() { console.log("如果一个组件被绑定了 longpress 事件,那么当用户长按这个组件时,该事件将会被触发。") },
textarea_confirm() { console.log("点击完成时, 触发 confirm 事件,event.detail = {value: value}") }, textarea_confirm() { console.log("点击完成时, 触发 confirm 事件,event.detail = {value: value}") },
textarea_input() { console.log("当键盘输入时,触发 input 事件,event.detail = {value, cursor}, @input 处理函数的返回值并不会反映到 textarea 上") }, textarea_input() { console.log("当键盘输入时,触发 input 事件,event.detail = {value, cursor}, @input 处理函数的返回值并不会反映到 textarea 上") },
textarea_linechange(e) { console.log(e,"输入框行数变化时调用,event.detail = {height: 0, height: 0, lineCount: 0}") }, textarea_linechange() { console.log("输入框行数变化时调用,event.detail = {height: 0, height: 0, lineCount: 0}") },
textarea_blur() { console.log("输入框失去焦点时触发,event.detail = {value, cursor}") }, textarea_blur() { console.log("输入框失去焦点时触发,event.detail = {value, cursor}") },
textarea_keyboardheightchange() { console.log("键盘高度发生变化的时候触发此事件,event.detail = {height: height, duration: duration}") }, textarea_keyboardheightchange() { console.log("键盘高度发生变化的时候触发此事件,event.detail = {height: height, duration: duration}") },
textarea_focus() { console.log("输入框聚焦时触发,event.detail = { value, height },height 为键盘高度") }, textarea_focus() { console.log("输入框聚焦时触发,event.detail = { value, height },height 为键盘高度") },
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
@fullscreenclick="onFullScreenClick" @controlstoggle="onControlsToggle" @fullscreenchange="onFullScreenChange"> @fullscreenclick="onFullScreenClick" @controlstoggle="onControlsToggle" @fullscreenchange="onFullScreenChange">
</video> </video>
<scroll-view class="uni-padding-wrap uni-common-mt uni-flex-item"> <scroll-view class="uni-padding-wrap uni-common-mt uni-flex-item">
<input class="input" placeholder="输入视频地址播放" @confirm="onSrcInputConfirm"></input>
<view class="uni-btn-v"> <view class="uni-btn-v">
<navigator url="/pages/component/video/video-format"> <navigator url="/pages/component/video/video-format">
<button type="primary" @click="pause">视频格式示例</button> <button type="primary" @click="pause">视频格式示例</button>
...@@ -178,7 +179,7 @@ ...@@ -178,7 +179,7 @@
danmuBtn: false, danmuBtn: false,
enableDanmu: true, enableDanmu: true,
pageGesture: false, pageGesture: false,
direction: -90, direction: -1,
_direction: 0, _direction: 0,
requestFullScreenOptions: { requestFullScreenOptions: {
direction: -90 direction: -90
...@@ -412,6 +413,9 @@ ...@@ -412,6 +413,9 @@
onControlsToggle: function (res : UniVideoControlsToggleEvent) { onControlsToggle: function (res : UniVideoControlsToggleEvent) {
console.log(res.type + " -> " + JSON.stringify(res.detail)); console.log(res.type + " -> " + JSON.stringify(res.detail));
}, },
onSrcInputConfirm(event : UniInputConfirmEvent) {
this.src = event.detail.value;
},
// 自动化测试 // 自动化测试
downloadSource() { downloadSource() {
uni.downloadFile({ uni.downloadFile({
...@@ -434,4 +438,10 @@ ...@@ -434,4 +438,10 @@
width: 100%; width: 100%;
height: 200px; height: 200px;
} }
.input {
height: 40px;
background: #FFF;
margin: 5px 0;
}
</style> </style>
...@@ -85,15 +85,17 @@ ...@@ -85,15 +85,17 @@
name: '获取启动参数', name: '获取启动参数',
url: 'get-launch-options-sync', url: 'get-launch-options-sync',
}, },
// #ifndef WEB
{
name: 'env环境变量',
url: 'env'
},
// #endif
// #ifdef APP-ANDROID // #ifdef APP-ANDROID
{ {
name: '退出应用', name: '退出应用',
url: 'exit', url: 'exit',
}, }
{
name: 'env',
url: 'env'
},
// #endif // #endif
] as Page[], ] as Page[],
}, },
...@@ -170,12 +172,10 @@ ...@@ -170,12 +172,10 @@
api: ["Element.takeSnapshot"] api: ["Element.takeSnapshot"]
}, },
// #endif // #endif
// #ifdef APP-ANDROID || WEB
{ {
name: 'element大小变化监听', name: 'element大小变化监听',
url: 'resize-observer' url: 'resize-observer'
}, },
// #endif
{ {
name: 'node节点', name: 'node节点',
url: 'nodes-info', url: 'nodes-info',
...@@ -546,16 +546,16 @@ ...@@ -546,16 +546,16 @@
} }
] as Page[] ] as Page[]
}, },
{ // {
id: 'theme-change', // id: 'theme-change',
name: '主题切换', // name: '主题切换',
pages: [ // pages: [
{ // {
name: '主题切换', // name: '主题切换',
url: 'theme-change', // url: 'theme-change',
} // }
] as Page[] // ] as Page[]
}, // },
// #endif // #endif
/* /*
{ {
......
...@@ -184,16 +184,16 @@ ...@@ -184,16 +184,16 @@
open: false, open: false,
pages: [] as Page[], pages: [] as Page[],
}, },
// #endif
{ {
id: 'schema', id: 'schema',
url: 'schema', url: 'schema',
name: '打开外部链接', name: '打开外部链接',
open: false, open: false,
pages: [] as Page[], pages: [] as Page[],
} },
// #endif
// #ifdef APP-ANDROID // #ifdef APP-ANDROID
,{ {
id: 'share', id: 'share',
url: 'share', url: 'share',
name: '分享示例', name: '分享示例',
......
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
</list-view> </list-view>
<web-view v-if="indexView==2" src="/hybrid/html/local.html" id="webv" style="height:380px"></web-view> <web-view v-if="indexView==2" src="/hybrid/html/local.html" id="webv" style="height:380px"></web-view>
<view style="position:relative;background-color:white;" :style="{bottom: inputBottom}"> <view style="position:relative;background-color:white;" :style="{bottom: inputBottom}">
<input placeholder="滚动视图外的居底输入框" adjust-position="false" @blur="onInputBlur" @keyboardheightchange="onInputKeyboardChange" /> <input placeholder="滚动视图外的居底输入框,不上推,手动控制输入框top" adjust-position="false" @blur="onInputBlur" @keyboardheightchange="onInputKeyboardChange" />
</view> </view>
</view> </view>
......
<template> <template>
<view> <view>
<!-- #ifdef APP -->
<button class="button" @click="openSchema('https://uniapp.dcloud.io/uni-app-x')">使用外部浏览器打开指定URL</button> <button class="button" @click="openSchema('https://uniapp.dcloud.io/uni-app-x')">使用外部浏览器打开指定URL</button>
<!-- #endif -->
<!-- #ifdef APP-ANDROID --> <!-- #ifdef APP-ANDROID -->
<button class="button" @click="openSchema('market://details?id=com.tencent.mm')">使用应用商店打开指定App</button> <button class="button" @click="openSchema('market://details?id=com.tencent.mm')">使用应用商店打开指定App</button>
<button class="button" @click="openSchema('androidamap://viewMap?sourceApplication=Hello%20uni-app&poiname=DCloud&lat=39.9631018208&lon=116.3406135236&dev=0')"> <button class="button" @click="openSchema('androidamap://viewMap?sourceApplication=Hello%20uni-app&poiname=DCloud&lat=39.9631018208&lon=116.3406135236&dev=0')">
...@@ -12,6 +14,13 @@ ...@@ -12,6 +14,13 @@
<button class="button" @click="openSchema('http://maps.apple.com/?q=数字天堂公司&sll=39.9631018208,116.3406135236&z=10&t=s')">打开 iOS 地图坐标</button> <button class="button" @click="openSchema('http://maps.apple.com/?q=数字天堂公司&sll=39.9631018208,116.3406135236&z=10&t=s')">打开 iOS 地图坐标</button>
<!-- apple协议:https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html --> <!-- apple协议:https://developer.apple.com/library/archive/featuredarticles/iPhoneURLScheme_Reference/MapLinks/MapLinks.html -->
<!-- #endif --> <!-- #endif -->
<!-- #ifdef WEB -->
<view class="tip">
<text>仅Android/iOS设备的浏览器中支持使用此功能,需先安装“Hello uni-app x”应用,如未安装请前往以下网页安装:</text>
<text class="link" @click="openSchema('https://hellouniappx.dcloud.net.cn/')">https://hellouniappx.dcloud.net.cn/</text>
</view>
<button class="button" @click="openSchema('hellouniappx://')">启动 Hello uni-app x 应用</button>
<!-- #endif -->
</view> </view>
</template> </template>
...@@ -23,4 +32,12 @@ import { openSchema } from '@/uni_modules/uts-openSchema' ...@@ -23,4 +32,12 @@ import { openSchema } from '@/uni_modules/uts-openSchema'
.button { .button {
margin: 15px; margin: 15px;
} }
.tip {
padding: 8px;
}
.link {
color: #7A7E83;
font-size: 14px;
line-height: 20px;
}
</style> </style>
import { OpenSchema } from '../interface.uts'
export const openSchema: OpenSchema = function(url: string): void {
location.href = url;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册