提交 7f69bda0 编写于 作者: DCloud-WZF's avatar DCloud-WZF 💬

Merge branch 'dev' into alpha

...@@ -263,6 +263,12 @@ ...@@ -263,6 +263,12 @@
"navigationBarTitleText": "设置导航条颜色" "navigationBarTitleText": "设置导航条颜色"
} }
}, },
{
"path": "pages/API/set-navigation-bar-title/set-navigation-bar-title",
"style": {
"navigationBarTitleText": "设置导航条标题"
}
},
{ {
"path": "pages/API/set-navigation-bar-color/set-custom-navigation-bar-color", "path": "pages/API/set-navigation-bar-color/set-custom-navigation-bar-color",
"style": { "style": {
...@@ -276,13 +282,6 @@ ...@@ -276,13 +282,6 @@
"navigationBarTitleText": "新页面-1" "navigationBarTitleText": "新页面-1"
} }
}, },
{
"path": "pages/API/navigator/new-page/new-page-2",
"style": {
"navigationBarTitleText": "新页面-2",
"enablePullDownRefresh": true
}
},
{ {
"path": "pages/API/navigator/new-page/new-page-3", "path": "pages/API/navigator/new-page/new-page-3",
"style": { "style": {
...@@ -1040,6 +1039,14 @@ ...@@ -1040,6 +1039,14 @@
"navigationBarTitleText" : "transitionend事件", "navigationBarTitleText" : "transitionend事件",
"enablePullDownRefresh" : false "enablePullDownRefresh" : false
} }
},
{
"path" : "pages/API/install-apk/install-apk",
"style" :
{
"navigationBarTitleText" : "install-apk",
"enablePullDownRefresh" : false
}
} }
], ],
......
...@@ -4,7 +4,7 @@ describe('event-bus', () => { ...@@ -4,7 +4,7 @@ describe('event-bus', () => {
let page let page
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH) page = await program.reLaunch(PAGE_PATH)
await page.waitFor(500) await page.waitFor('view')
}) })
it('on', async () => { it('on', async () => {
......
...@@ -5,7 +5,7 @@ let page; ...@@ -5,7 +5,7 @@ let page;
describe("getElementByIdForMultipleRootNode", () => { describe("getElementByIdForMultipleRootNode", () => {
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH); page = await program.reLaunch(PAGE_PATH);
await page.waitFor(1000); await page.waitFor('view');
}); });
it("getElementByNotExistId", async () => { it("getElementByNotExistId", async () => {
const res = await page.callMethod("getElementByNotExistId"); const res = await page.callMethod("getElementByNotExistId");
......
...@@ -4,7 +4,7 @@ let page; ...@@ -4,7 +4,7 @@ let page;
describe("getElementById", () => { describe("getElementById", () => {
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH); page = await program.reLaunch(PAGE_PATH);
await page.waitFor(1000); await page.waitFor('view');
}); });
it("getElementByNotExistId", async () => { it("getElementByNotExistId", async () => {
const res = await page.callMethod("getElementByNotExistId"); const res = await page.callMethod("getElementByNotExistId");
......
...@@ -3,7 +3,7 @@ const PAGE_PATH = '/pages/API/get-launch-options-sync/get-launch-options-sync' ...@@ -3,7 +3,7 @@ const PAGE_PATH = '/pages/API/get-launch-options-sync/get-launch-options-sync'
describe('getLaunchOptionsSync', () => { describe('getLaunchOptionsSync', () => {
it('getLaunchOptionsSync', async () => { it('getLaunchOptionsSync', async () => {
const page = await program.navigateTo(PAGE_PATH) const page = await program.navigateTo(PAGE_PATH)
await page.waitFor(1000) await page.waitFor('view')
await page.callMethod('getLaunchOptionsSync') await page.callMethod('getLaunchOptionsSync')
const data = await page.data() const data = await page.data()
expect(data.checked).toBe(true) expect(data.checked).toBe(true)
......
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view>
<page-head :title="title"></page-head>
<view class="uni-common-mt">
<view class="uni-padding-wrap">
<view class="uni-btn-v">
<button type="primary" @tap="installApk">
installApk
</button>
</view>
</view>
</view>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script>
export default {
data() {
return {
title: 'installApk'
}
},
onUnload: function () {
},
methods: {
installApk: function () {
uni.installApk({
filePath: "/static/test-apk/test.apk",
complete(res : any) {
console.log(res);
}
})
},
}
}
</script>
<style>
.uni-pd {
padding-left: 30rpx;
}
</style>
const PAGE_PATH = '/pages/API/load-font-face/load-font-face-child'
describe('loadFontFace global', () => {
beforeAll(async () => {
const page = await program.navigateTo(PAGE_PATH)
await page.waitFor(2000)
})
it('screenshot', async () => {
const image = await program.screenshot()
expect(image).toMatchImageSnapshot()
})
})
const PAGE_PATH = '/pages/API/load-font-face/load-font-face' const PAGE_PATH = '/pages/API/load-font-face/load-font-face'
const CHILD_PAGE_PATH = "/pages/API/load-font-face/load-font-face-child";
describe('loadFontFace', () => { describe("loadFontFace", () => {
beforeAll(async () => { beforeAll(async () => {
const page = await program.navigateTo(PAGE_PATH) const page = await program.navigateTo(PAGE_PATH);
await page.waitFor(4000) await page.waitFor(3000);
}) });
it('screenshot', async () => { it("parent screenshot", async () => {
const image = await program.screenshot() const image = await program.screenshot();
expect(image).toMatchImageSnapshot() expect(image).toMatchImageSnapshot();
}) });
}) it("child screenshot", async () => {
const page = await program.navigateTo(CHILD_PAGE_PATH);
await page.waitFor("view");
const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
});
});
jest.setTimeout(80000)
const CURRENT_PAGE_PATH = '/pages/API/navigator/navigator'
const CHILD1_PAGE_PATH = '/pages/API/navigator/new-page/new-page-1'
const CHILD2_PAGE_PATH = '/pages/API/navigator/new-page/new-page-2'
describe('navigator', () => {
let page
let lifeCycleNum
afterAll(async () => {
page = await program.reLaunch(CURRENT_PAGE_PATH)
const resetLifecycleNum = 1100
await page.callMethod('setLifeCycleNum', resetLifecycleNum)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(resetLifecycleNum)
})
it('reLaunch', async () => {
page = await program.navigateTo(CURRENT_PAGE_PATH)
await page.waitFor(500)
await page.callMethod('setLifeCycleNum', 0)
await page.callMethod('reLaunch')
await page.waitFor(500)
page = await program.navigateTo(CURRENT_PAGE_PATH)
await page.waitFor(500)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(2)
})
it('navigateTo', async () => {
await page.callMethod('setLifeCycleNum', 0)
await page.callMethod('navigateTo')
await page.waitFor(500)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(2)
page = await program.navigateBack()
await page.waitFor(500)
})
it('navigateTo error page', async () => {
await page.callMethod('setLifeCycleNum', 0)
await page.callMethod('navigateToErrorPage')
await page.waitFor(500)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(2)
})
it('navigateTo debounce', async () => {
await page.callMethod('setLifeCycleNum', 0)
await page.callMethod('navigateToDebounce')
await page.waitFor(500)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(4)
page = await program.navigateBack()
await page.waitFor(500)
})
it('navigateTo relative path', async () => {
await page.callMethod('setLifeCycleNum', 0)
await page.callMethod('navigateToRelativePath1')
page = await program.navigateBack()
await page.waitFor(500)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(2)
await page.waitFor(500)
})
it('navigateTo relative path ./', async () => {
await page.callMethod('setLifeCycleNum', 0)
await page.callMethod('navigateToRelativePath2')
page = await program.navigateBack()
await page.waitFor(500)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(2)
await page.waitFor(500)
})
it('navigateTo relative path ../', async () => {
await page.callMethod('setLifeCycleNum', 0)
await page.callMethod('navigateToRelativePath3')
page = await program.navigateBack()
await page.waitFor(500)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(2)
await page.waitFor(500)
})
it('navigateBack', async () => {
await page.callMethod('setLifeCycleNum', 0)
await page.callMethod('navigateBack')
await page.waitFor(500)
page = await program.navigateTo(CURRENT_PAGE_PATH)
await page.waitFor(500)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(2)
})
it('navigateBackWithDelta1', async () => {
await page.callMethod('setLifeCycleNum', 0)
await page.callMethod('navigateBackWithDelta1')
await page.waitFor(1000)
page = await program.currentPage()
expect(`/${page.path}`).toBe(CURRENT_PAGE_PATH)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(2)
})
it('navigateBackWithDelta2', async () => {
await page.callMethod('setLifeCycleNum', 0)
await program.navigateTo(CHILD2_PAGE_PATH)
await page.waitFor(500)
page = await program.navigateTo(CHILD1_PAGE_PATH)
await page.waitFor(500)
await page.callMethod('navigateBackWithDelta2')
await page.waitFor(500)
page = await program.currentPage()
expect(`/${page.path}`).toBe(CURRENT_PAGE_PATH)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(10)
})
it('navigateBackWithDelta100', async () => {
page = await program.reLaunch(CURRENT_PAGE_PATH)
await page.callMethod('setLifeCycleNum', 0)
await page.callMethod('navigateBackWithDelta100')
await page.waitFor(1000)
page = await program.currentPage()
expect(`/${page.path}`).toBe(CURRENT_PAGE_PATH)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(2)
})
it('redirectTo', async () => {
await page.callMethod('setLifeCycleNum', 0)
await page.callMethod('redirectTo')
await page.waitFor(500)
page = await program.redirectTo(CURRENT_PAGE_PATH)
await page.waitFor(500)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(2)
})
it('switchTab', async () => {
page = await program.reLaunch(CURRENT_PAGE_PATH)
await page.callMethod('setLifeCycleNum', 0)
await page.callMethod('switchTab')
await page.waitFor(500)
page = await program.navigateTo(CURRENT_PAGE_PATH)
await page.waitFor(500)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(2)
})
it('20 times navigateTo', async () => {
const originPageStack = await program.pageStack()
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD1_PAGE_PATH)
expect(page.path).toBe(CHILD1_PAGE_PATH.substring(1))
page = await program.navigateTo(CHILD2_PAGE_PATH)
expect(page.path).toBe(CHILD2_PAGE_PATH.substring(1))
const newPageStack = await program.pageStack()
expect(newPageStack.length - originPageStack.length).toBe(20)
})
})
jest.setTimeout(30000)
const PAGE_PATH = '/pages/API/navigator/new-page/new-page-2'
const INTERMEDIATE_PAGE_PATH = '/pages/API/navigator/navigator'
let page
let lifeCycleNum
describe('app-lifecycle', () => {
it('onLaunch onShow', async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH)
await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(1100)
})
it('onLastPageBackPress', async () => {
page = await program.navigateBack()
await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(100)
await page.callMethod('setLifeCycleNum', 0)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(0)
})
})
describe('page-lifecycle', () => {
it('onLoad onShow onReady', async () => {
page = await program.reLaunch(PAGE_PATH)
await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(120)
await page.callMethod('setLifeCycleNum', 0)
})
it('onPullDownRefresh', async () => {
await page.callMethod('pullDownRefresh')
await page.waitFor(1500)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(10)
await page.callMethod('setLifeCycleNum', 0)
})
it('onPageScroll onReachBottom', async () => {
await program.pageScrollTo(2000)
const data = await page.data()
expect(data.isScrolled).toBe(true)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(10)
await page.callMethod('setLifeCycleNum', 0)
})
it('onHide', async () => {
page = await program.navigateTo(INTERMEDIATE_PAGE_PATH)
await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(-10)
page = await program.navigateBack()
await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(0)
})
it('onUnload', async () => {
page = await program.redirectTo(INTERMEDIATE_PAGE_PATH)
await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(-100)
await page.callMethod('setLifeCycleNum', 0)
})
it('onBackPress', async () => {
page = await program.navigateTo(PAGE_PATH)
await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(120)
page = await program.navigateBack()
await page.waitFor(1000)
lifeCycleNum = await page.callMethod('getLifeCycleNum')
expect(lifeCycleNum).toBe(10)
await page.callMethod('setLifeCycleNum', 0)
})
})
<template>
<!-- #ifdef APP -->
<scroll-view style="flex: 1">
<!-- #endif -->
<view class="uni-padding-wrap container">
<page-head title="new-page-2" />
<button @click="scrollToBottom">scrollToBottom</button>
</view>
<!-- #ifdef APP -->
</scroll-view>
<!-- #endif -->
</template>
<script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
data() {
return {
isScrolled: false,
}
},
onLoad(_ : Map<string, string>) {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 100)
},
onShow() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onReady() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onPullDownRefresh() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onPageScroll(_) {
// 自动化测试
this.isScrolled = true
},
onReachBottom() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum + 10)
},
onBackPress(_ : OnBackPressOptions) : boolean | null {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 10)
return null
},
onHide() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 10)
},
onUnload() {
// 自动化测试
setLifeCycleNum(state.lifeCycleNum - 100)
},
methods: {
// 自动化测试
getLifeCycleNum() : number {
return state.lifeCycleNum
},
// 自动化测试
setLifeCycleNum(num : number) {
setLifeCycleNum(num)
},
pullDownRefresh() {
uni.startPullDownRefresh({
success() {
setTimeout(() => {
uni.stopPullDownRefresh()
}, 1000)
},
})
},
scrollToBottom() {
uni.pageScrollTo({
scrollTop: 2000
})
},
},
}
</script>
<style>
.container {
height: 1200px;
}
</style>
...@@ -7,50 +7,50 @@ let page; ...@@ -7,50 +7,50 @@ let page;
describe("onLoad", () => { describe("onLoad", () => {
it("adjustData", async () => { it("adjustData", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor(500); await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "adjustData"); await page.callMethod("navigateToOnLoadWithType", "adjustData");
await page.waitFor(1000); await page.waitFor(500);
const image = await program.screenshot(); const image = await program.screenshot();
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
}); });
it("navigateTo", async () => { it("navigateTo", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor(500); await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "navigateTo"); await page.callMethod("navigateToOnLoadWithType", "navigateTo");
await page.waitFor(1000); await page.waitFor(500);
page = await program.currentPage(); page = await program.currentPage();
expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
}); });
it("navigateBack", async () => { it("navigateBack", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor(500); await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "navigateBack"); await page.callMethod("navigateToOnLoadWithType", "navigateBack");
await page.waitFor(1000);
page = await program.currentPage(); page = await program.currentPage();
await page.waitFor('view');
expect(page.path).toBe(INTERMEDIATE_PAGE_PATH.substring(1)); expect(page.path).toBe(INTERMEDIATE_PAGE_PATH.substring(1));
}); });
it("redirectTo", async () => { it("redirectTo", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor(500); await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "redirectTo"); await page.callMethod("navigateToOnLoadWithType", "redirectTo");
await page.waitFor(1000); await page.waitFor(500);
page = await program.currentPage(); page = await program.currentPage();
expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
}); });
it("reLaunch", async () => { it("reLaunch", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor(500); await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "reLaunch"); await page.callMethod("navigateToOnLoadWithType", "reLaunch");
await page.waitFor(1000); await page.waitFor(500);
page = await program.currentPage(); page = await program.currentPage();
expect(page.path).toBe(TARGET_PAGE_PATH.substring(1)); expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
}); });
it("switchTab", async () => { it("switchTab", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
await page.waitFor(500); await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "switchTab"); await page.callMethod("navigateToOnLoadWithType", "switchTab");
await page.waitFor(1000);
page = await program.currentPage(); page = await program.currentPage();
await page.waitFor('view');
expect(page.path).toBe("pages/tabBar/component"); expect(page.path).toBe("pages/tabBar/component");
}); });
// toast 出现在 INTERMEDIATE_PAGE_PATH 页面(非 onLoad 生命周期所在页面) // toast 出现在 INTERMEDIATE_PAGE_PATH 页面(非 onLoad 生命周期所在页面)
...@@ -66,7 +66,7 @@ describe("onLoad", () => { ...@@ -66,7 +66,7 @@ describe("onLoad", () => {
// 同 toast // 同 toast
// it("showLoading", async () => { // it("showLoading", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
// await page.waitFor(500); // await page.waitFor('view');
// await page.callMethod("navigateToOnLoadWithType", "showLoading"); // await page.callMethod("navigateToOnLoadWithType", "showLoading");
// await page.waitFor(1000); // await page.waitFor(1000);
// const image = await program.screenshot(); // const image = await program.screenshot();
...@@ -75,7 +75,7 @@ describe("onLoad", () => { ...@@ -75,7 +75,7 @@ describe("onLoad", () => {
// 同 toast // 同 toast
// it("showModal", async () => { // it("showModal", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
// await page.waitFor(500); // await page.waitFor('view');
// await page.callMethod("navigateToOnLoadWithType", "showModal"); // await page.callMethod("navigateToOnLoadWithType", "showModal");
// await page.waitFor(1000); // await page.waitFor(1000);
// const image = await program.screenshot(); // const image = await program.screenshot();
...@@ -84,7 +84,7 @@ describe("onLoad", () => { ...@@ -84,7 +84,7 @@ describe("onLoad", () => {
// 同 toast // 同 toast
// it("showActionSheet", async () => { // it("showActionSheet", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH); // page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
// await page.waitFor(500); // await page.waitFor('view');
// await page.callMethod("navigateToOnLoadWithType", "showActionSheet"); // await page.callMethod("navigateToOnLoadWithType", "showActionSheet");
// await page.waitFor(1000); // await page.waitFor(1000);
// const image = await program.screenshot(); // const image = await program.screenshot();
......
...@@ -24,6 +24,8 @@ describe("setCustomNavigationBarColor", () => { ...@@ -24,6 +24,8 @@ describe("setCustomNavigationBarColor", () => {
area: { x: 880, y: 0, width: 100, height: 60 }, area: { x: 880, y: 0, width: 100, height: 60 },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
expect(lifeCycleNum - originLifeCycleNum).toBe(2);
}); });
it("setNavigationBarColor1", async () => { it("setNavigationBarColor1", async () => {
...@@ -34,5 +36,7 @@ describe("setCustomNavigationBarColor", () => { ...@@ -34,5 +36,7 @@ describe("setCustomNavigationBarColor", () => {
area: { x: 880, y: 0, width: 100, height: 60 }, area: { x: 880, y: 0, width: 100, height: 60 },
}); });
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
expect(lifeCycleNum - originLifeCycleNum).toBe(4);
}); });
}); });
...@@ -50,12 +50,15 @@ export default { ...@@ -50,12 +50,15 @@ export default {
success() { success() {
this.navigationBarTextColor = '#fff' this.navigationBarTextColor = '#fff'
console.log('setNavigationBarColor success') console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}, },
fail() { fail() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
}, },
complete() { complete() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
} }
}) })
}, },
...@@ -66,12 +69,15 @@ export default { ...@@ -66,12 +69,15 @@ export default {
success() { success() {
this.navigationBarTextColor = '#000' this.navigationBarTextColor = '#000'
console.log('setNavigationBarColor success') console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}, },
fail() { fail() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
}, },
complete() { complete() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
} }
}) })
}, },
......
...@@ -16,14 +16,18 @@ describe('setNavigationBarColor', () => { ...@@ -16,14 +16,18 @@ describe('setNavigationBarColor', () => {
expect(lifeCycleNum).toBe(originLifeCycleNum) expect(lifeCycleNum).toBe(originLifeCycleNum)
}) })
it('setNavigationBarColor1', async () => { it("setNavigationBarColor1", async () => {
await page.callMethod('setNavigationBarColor1') await page.callMethod("setNavigationBarColor1");
const image = await program.screenshot() const image = await program.screenshot();
expect(image).toMatchImageSnapshot() expect(image).toMatchImageSnapshot();
}) const lifeCycleNum = await page.callMethod("getLifeCycleNum");
it('setNavigationBarColor2', async () => { expect(lifeCycleNum - originLifeCycleNum).toBe(2);
await page.callMethod('setNavigationBarColor2') });
const image = await program.screenshot() it("setNavigationBarColor2", async () => {
expect(image).toMatchImageSnapshot() await page.callMethod("setNavigationBarColor2");
}) const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
expect(lifeCycleNum - originLifeCycleNum).toBe(4);
});
}) })
...@@ -26,12 +26,15 @@ export default { ...@@ -26,12 +26,15 @@ export default {
backgroundColor: '#00ff00', backgroundColor: '#00ff00',
success() { success() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}, },
fail() { fail() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
}, },
complete() { complete() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
} }
}) })
}, },
...@@ -41,12 +44,15 @@ export default { ...@@ -41,12 +44,15 @@ export default {
backgroundColor: '#ff0000', backgroundColor: '#ff0000',
success() { success() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}, },
fail() { fail() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor fail')
this.setLifeCycleNum(state.lifeCycleNum - 1)
}, },
complete() { complete() {
console.log('setNavigationBarColor success') console.log('setNavigationBarColor complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
} }
}) })
}, },
...@@ -66,12 +72,3 @@ export default { ...@@ -66,12 +72,3 @@ export default {
}, },
} }
</script> </script>
<style>
.direction-row {
flex-direction: row;
}
.label {
width: 190px;
}
</style>
const CURRENT_PAGE_PATH =
"/pages/API/set-navigation-bar-title/set-navigation-bar-title";
describe("setNavigationBarColor", () => {
let page;
let originLifeCycleNum;
beforeAll(async () => {
page = await program.navigateTo(CURRENT_PAGE_PATH);
await page.waitFor(1000);
originLifeCycleNum = await page.callMethod("getLifeCycleNum");
});
afterAll(async () => {
await page.callMethod("setLifeCycleNum", originLifeCycleNum);
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
expect(lifeCycleNum).toBe(originLifeCycleNum);
});
it("setNavigationBarTitle", async () => {
await page.callMethod("setNavigationBarTitle");
const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
const lifeCycleNum = await page.callMethod("getLifeCycleNum");
expect(lifeCycleNum - originLifeCycleNum).toBe(2);
});
});
<template>
<view>
<page-head title="setNavigationBarTitle"></page-head>
<view class="uni-padding-wrap uni-common-mt">
<button @tap="setNavigationBarTitle" class="uni-btn">
设置当前页面的标题为 {{ newTitle }}
</button>
</view>
</view>
</template>
<script lang="uts">
import { state, setLifeCycleNum } from '@/store/index.uts'
export default {
data(){
return {
newTitle: 'new title'
}
},
methods: {
setNavigationBarTitle() {
uni.setNavigationBarTitle({
title: this.newTitle,
success() {
console.log('setNavigationBarTitle success')
this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
console.log('setNavigationBarTitle success')
this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
console.log('setNavigationBarTitle complete')
this.setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
// 自动化测试
getLifeCycleNum(): number {
return state.lifeCycleNum
},
// 自动化测试
setLifeCycleNum(num: number) {
setLifeCycleNum(num)
}
},
}
</script>
...@@ -4,7 +4,7 @@ describe('Button.uvue', () => { ...@@ -4,7 +4,7 @@ describe('Button.uvue', () => {
let page let page
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH) page = await program.reLaunch(PAGE_PATH)
await page.waitFor(500) await page.waitFor('view')
}) })
it('click', async () => { it('click', async () => {
// TODO 待测试框架支持text的dispatchEvent // TODO 待测试框架支持text的dispatchEvent
...@@ -41,12 +41,10 @@ describe('Button.uvue', () => { ...@@ -41,12 +41,10 @@ describe('Button.uvue', () => {
await page.setData({ await page.setData({
type_enum_current: 1, type_enum_current: 1,
}) })
await page.waitFor(500)
expect(await btn.property('type')).toBe('primary') expect(await btn.property('type')).toBe('primary')
await page.setData({ await page.setData({
type_enum_current: 2, type_enum_current: 2,
}) })
await page.waitFor(500)
expect(await btn.property('type')).toBe('warn') expect(await btn.property('type')).toBe('warn')
}) })
it('size', async () => { it('size', async () => {
...@@ -55,7 +53,6 @@ describe('Button.uvue', () => { ...@@ -55,7 +53,6 @@ describe('Button.uvue', () => {
await page.setData({ await page.setData({
size_enum_current: 1, size_enum_current: 1,
}) })
await page.waitFor(500)
expect(await btn.property('size')).toBe('mini') expect(await btn.property('size')).toBe('mini')
}) })
it('plain', async () => { it('plain', async () => {
...@@ -64,7 +61,6 @@ describe('Button.uvue', () => { ...@@ -64,7 +61,6 @@ describe('Button.uvue', () => {
await page.setData({ await page.setData({
plain_boolean: true, plain_boolean: true,
}) })
await page.waitFor(500)
expect(await btn.property('plain')).toBe(true) expect(await btn.property('plain')).toBe(true)
}) })
it('disabled', async () => { it('disabled', async () => {
...@@ -73,7 +69,6 @@ describe('Button.uvue', () => { ...@@ -73,7 +69,6 @@ describe('Button.uvue', () => {
await page.setData({ await page.setData({
disabled_boolean: true, disabled_boolean: true,
}) })
await page.waitFor(500)
expect(await btn.property('disabled')).toBe(true) expect(await btn.property('disabled')).toBe(true)
}) })
}) })
...@@ -8,7 +8,7 @@ function getData(key = '') { ...@@ -8,7 +8,7 @@ function getData(key = '') {
let page let page
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch('/pages/component/checkbox/checkbox') page = await program.reLaunch('/pages/component/checkbox/checkbox')
await page.waitFor(1000) await page.waitFor('view')
}) })
describe('Checkbox.uvue', () => { describe('Checkbox.uvue', () => {
...@@ -46,7 +46,6 @@ describe('Checkbox.uvue', () => { ...@@ -46,7 +46,6 @@ describe('Checkbox.uvue', () => {
await page.setData({ await page.setData({
checked: false, checked: false,
}) })
await page.waitFor(500)
expect(await cb.property('checked')).toBe(false) expect(await cb.property('checked')).toBe(false)
}) })
it('color', async () => { it('color', async () => {
...@@ -55,7 +54,6 @@ describe('Checkbox.uvue', () => { ...@@ -55,7 +54,6 @@ describe('Checkbox.uvue', () => {
await page.setData({ await page.setData({
color: '#63acfc', color: '#63acfc',
}) })
await page.waitFor(500)
expect(await cb.property('color')).toBe('#63acfc') expect(await cb.property('color')).toBe('#63acfc')
}) })
it('disabled', async () => { it('disabled', async () => {
...@@ -64,7 +62,6 @@ describe('Checkbox.uvue', () => { ...@@ -64,7 +62,6 @@ describe('Checkbox.uvue', () => {
await page.setData({ await page.setData({
disabled: false, disabled: false,
}) })
await page.waitFor(500)
expect(await cb.property('disabled')).toBe(false) expect(await cb.property('disabled')).toBe(false)
}) })
}) })
...@@ -5,7 +5,7 @@ describe('general attribute', () => { ...@@ -5,7 +5,7 @@ describe('general attribute', () => {
beforeAll(async () => { beforeAll(async () => {
page = await program.navigateTo(PAGE_PATH) page = await program.navigateTo(PAGE_PATH)
await page.waitFor(1000) await page.waitFor('view')
}) })
it("class & style", async () => { it("class & style", async () => {
const image = await program.screenshot(); const image = await program.screenshot();
...@@ -20,7 +20,7 @@ describe('general attribute', () => { ...@@ -20,7 +20,7 @@ describe('general attribute', () => {
it("ref", async () => { it("ref", async () => {
const button = await page.$(".btn-ref"); const button = await page.$(".btn-ref");
await button.tap(); await button.tap();
await page.waitFor(1000); await page.waitFor(500);
const image = await program.screenshot(); const image = await program.screenshot();
expect(image).toMatchImageSnapshot(); expect(image).toMatchImageSnapshot();
}); });
......
...@@ -5,7 +5,7 @@ describe('event trigger sequence', () => { ...@@ -5,7 +5,7 @@ describe('event trigger sequence', () => {
let el let el
beforeAll(async () => { beforeAll(async () => {
page = await program.navigateTo(PAGE_PATH) page = await program.navigateTo(PAGE_PATH)
await page.waitFor(1000) await page.waitFor('view')
el = await page.$('.target') el = await page.$('.target')
}) })
......
...@@ -73,54 +73,54 @@ describe('component-native-input', () => { ...@@ -73,54 +73,54 @@ describe('component-native-input', () => {
// }) // })
// }) // })
// 测试placeholder // 测试placeholder
it("placeholder", async () => { // it("placeholder", async () => {
const placeholder1 = await page.$('.uni-input-placeholder1'); // const placeholder1 = await page.$('.uni-input-placeholder1');
expect(await placeholder1.property("placeholder-style")).toMatchObject({ // expect(await placeholder1.property("placeholder-style")).toMatchObject({
"color": "red" // "color": "red"
}) // })
expect(await placeholder1.property("placeholder")).toEqual("占位符文字颜色为红色") // expect(await placeholder1.property("placeholder")).toEqual("占位符文字颜色为红色")
await page.setData({ // await page.setData({
inputPlaceHolderStyle: "color:#CC00CC", // inputPlaceHolderStyle: "color:#CC00CC",
}) // })
expect(await placeholder1.property("placeholder-style")).toMatchObject({ // expect(await placeholder1.property("placeholder-style")).toMatchObject({
"color": "#CC00CC" // "color": "#CC00CC"
}) // })
await page.setData({ // await page.setData({
inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0", // inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0",
}) // })
expect(await placeholder1.property("placeholder-style")).toMatchObject({ // expect(await placeholder1.property("placeholder-style")).toMatchObject({
"color": "#CC19CC", // "color": "#CC19CC",
"backgroundColor": "#00b1c0" // "backgroundColor": "#00b1c0"
}) // })
await page.setData({ // await page.setData({
inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0;text-align:center;font-size:44px;font-weight:900", // inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0;text-align:center;font-size:44px;font-weight:900",
}) // })
expect(await placeholder1.property("placeholder-style")).toEqual({ // expect(await placeholder1.property("placeholder-style")).toEqual({
"backgroundColor": "#00b1c0", // "backgroundColor": "#00b1c0",
"color": "#CC19CC", // "color": "#CC19CC",
"fontSize": "44px", // "fontSize": "44px",
"fontWeight": "900", // "fontWeight": "900",
"textAlign": "center" // "textAlign": "center"
}) // })
const placeholder2 = await page.$('.uni-input-placeholder2'); // const placeholder2 = await page.$('.uni-input-placeholder2');
expect(await placeholder2.property("placeholder-class")).toMatchObject({ // expect(await placeholder2.property("placeholder-class")).toMatchObject({
"backgroundColor": "#008000" // "backgroundColor": "#008000"
}) // })
await page.setData({ // await page.setData({
inputPlaceHolderClass: "uni-input-placeholder-class-ts", // inputPlaceHolderClass: "uni-input-placeholder-class-ts",
}) // })
expect(await placeholder2.property("placeholder-class")).toMatchObject({ // expect(await placeholder2.property("placeholder-class")).toMatchObject({
"backgroundColor": "#FFA500" // "backgroundColor": "#FFA500"
}) // })
expect(await placeholder2.property("placeholder")).toEqual("占位符背景色为绿色") // expect(await placeholder2.property("placeholder")).toEqual("占位符背景色为绿色")
}) // })
it("disable", async () => { it("disable", async () => {
const input = await page.$('.uni-input-disable'); const input = await page.$('.uni-input-disable');
expect(await input.property("disabled")).toBe(true) expect(await input.property("disabled")).toBe("true")
}) })
it("confirm-type", async () => { it("confirm-type", async () => {
...@@ -139,10 +139,10 @@ describe('component-native-input', () => { ...@@ -139,10 +139,10 @@ describe('component-native-input', () => {
// await page.waitFor(500) // await page.waitFor(500)
// }) // })
// it("afterAllTestScreenshot", async () => { it("afterAllTestScreenshot", async () => {
// const image = await program.screenshot({ const image = await program.screenshot({
// fullPage: true fullPage: true
// }) })
// expect(image).toMatchImageSnapshot() expect(image).toMatchImageSnapshot()
// }) })
}); });
...@@ -8,7 +8,7 @@ function getData(key = '') { ...@@ -8,7 +8,7 @@ function getData(key = '') {
let page let page
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch('/pages/component/picker-view/picker-view') page = await program.reLaunch('/pages/component/picker-view/picker-view')
await page.waitFor(1000) await page.waitFor('view')
}) })
describe('PickerView.uvue', () => { describe('PickerView.uvue', () => {
...@@ -44,7 +44,6 @@ describe('PickerView.uvue', () => { ...@@ -44,7 +44,6 @@ describe('PickerView.uvue', () => {
await page.setData({ await page.setData({
maskTopStyle: 'background: #ffffff;', maskTopStyle: 'background: #ffffff;',
}) })
await page.waitFor(500)
expect(await el.property('mask-top-style')).toBe('background: #ffffff;') expect(await el.property('mask-top-style')).toBe('background: #ffffff;')
}) })
it('mask-bottom-style', async () => { it('mask-bottom-style', async () => {
...@@ -52,7 +51,6 @@ describe('PickerView.uvue', () => { ...@@ -52,7 +51,6 @@ describe('PickerView.uvue', () => {
await page.setData({ await page.setData({
maskBottomStyle: 'background: #ffffff;', maskBottomStyle: 'background: #ffffff;',
}) })
await page.waitFor(500)
expect(await el.property('mask-bottom-style')).toBe('background: #ffffff;') expect(await el.property('mask-bottom-style')).toBe('background: #ffffff;')
}) })
}) })
...@@ -8,7 +8,7 @@ function getData(key = '') { ...@@ -8,7 +8,7 @@ function getData(key = '') {
let page let page
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch('/pages/component/progress/progress') page = await program.reLaunch('/pages/component/progress/progress')
await page.waitFor(1000) await page.waitFor('view')
}) })
describe('Progress.uvue', () => { describe('Progress.uvue', () => {
...@@ -17,14 +17,14 @@ describe('Progress.uvue', () => { ...@@ -17,14 +17,14 @@ describe('Progress.uvue', () => {
const p1 = await page.$('.p1') const p1 = await page.$('.p1')
const p2 = await page.$('.p2') const p2 = await page.$('.p2')
const p3 = await page.$('.p3') const p3 = await page.$('.p3')
page.callMethod('setProgress') await page.callMethod('setProgress')
await page.waitFor(1000) await page.waitFor(1000)
expect(await p.property('percent')).toEqual(20) expect(await p.property('percent')).toEqual(20)
expect(await p1.property('percent')).toEqual(40) expect(await p1.property('percent')).toEqual(40)
expect(await p2.property('percent')).toEqual(60) expect(await p2.property('percent')).toEqual(60)
expect(await p3.property('percent')).toEqual(80) expect(await p3.property('percent')).toEqual(80)
expect(await getData('curPercent')).toEqual(20) expect(await getData('curPercent')).toEqual(20)
page.callMethod('clearProgress') await page.callMethod('clearProgress')
await page.waitFor(1000) await page.waitFor(1000)
expect(await p.property('percent')).toEqual(0) expect(await p.property('percent')).toEqual(0)
expect(await p1.property('percent')).toEqual(0) expect(await p1.property('percent')).toEqual(0)
...@@ -42,7 +42,6 @@ describe('Progress.uvue', () => { ...@@ -42,7 +42,6 @@ describe('Progress.uvue', () => {
await page.setData({ await page.setData({
showInfo: false showInfo: false
}) })
await page.waitFor(500)
expect(await el.property('show-info')).toEqual(false) expect(await el.property('show-info')).toEqual(false)
}) })
it('border-radius', async () => { it('border-radius', async () => {
...@@ -51,7 +50,6 @@ describe('Progress.uvue', () => { ...@@ -51,7 +50,6 @@ describe('Progress.uvue', () => {
await page.setData({ await page.setData({
borderRadius: 5 borderRadius: 5
}) })
await page.waitFor(500)
expect(await el.property('border-radius')).toEqual(5) expect(await el.property('border-radius')).toEqual(5)
}) })
it('font-size', async () => { it('font-size', async () => {
...@@ -60,7 +58,6 @@ describe('Progress.uvue', () => { ...@@ -60,7 +58,6 @@ describe('Progress.uvue', () => {
await page.setData({ await page.setData({
fontSize: 18 fontSize: 18
}) })
await page.waitFor(500)
expect(await el.property('font-size')).toEqual(18) expect(await el.property('font-size')).toEqual(18)
}) })
it('stroke-width', async () => { it('stroke-width', async () => {
...@@ -69,7 +66,6 @@ describe('Progress.uvue', () => { ...@@ -69,7 +66,6 @@ describe('Progress.uvue', () => {
await page.setData({ await page.setData({
strokeWidth: 6 strokeWidth: 6
}) })
await page.waitFor(500)
expect(await el.property('stroke-width')).toEqual(6) expect(await el.property('stroke-width')).toEqual(6)
}) })
it('backgroundColor', async () => { it('backgroundColor', async () => {
...@@ -78,7 +74,6 @@ describe('Progress.uvue', () => { ...@@ -78,7 +74,6 @@ describe('Progress.uvue', () => {
await page.setData({ await page.setData({
backgroundColor: "#007aff" backgroundColor: "#007aff"
}) })
await page.waitFor(500)
expect(await el.property('background-color')).toEqual('#007aff') expect(await el.property('background-color')).toEqual('#007aff')
}) })
}) })
...@@ -8,7 +8,7 @@ function getData(key = '') { ...@@ -8,7 +8,7 @@ function getData(key = '') {
let page let page
beforeAll(async () => { beforeAll(async () => {
page = await program.reLaunch('/pages/component/radio/radio') page = await program.reLaunch('/pages/component/radio/radio')
await page.waitFor(1000) await page.waitFor('view')
}) })
describe('Radio.uvue', () => { describe('Radio.uvue', () => {
...@@ -44,7 +44,6 @@ describe('Radio.uvue', () => { ...@@ -44,7 +44,6 @@ describe('Radio.uvue', () => {
await page.setData({ await page.setData({
checked: false, checked: false,
}) })
await page.waitFor(500)
expect(await radio.property('checked')).toBe(false) expect(await radio.property('checked')).toBe(false)
}) })
it('color', async () => { it('color', async () => {
...@@ -53,7 +52,6 @@ describe('Radio.uvue', () => { ...@@ -53,7 +52,6 @@ describe('Radio.uvue', () => {
await page.setData({ await page.setData({
color: '#63acfc', color: '#63acfc',
}) })
await page.waitFor(500)
expect(await radio.property('color')).toBe('#63acfc') expect(await radio.property('color')).toBe('#63acfc')
}) })
it('disabled', async () => { it('disabled', async () => {
...@@ -62,7 +60,6 @@ describe('Radio.uvue', () => { ...@@ -62,7 +60,6 @@ describe('Radio.uvue', () => {
await page.setData({ await page.setData({
disabled: false, disabled: false,
}) })
await page.waitFor(500)
expect(await radio.property('disabled')).toBe(false) expect(await radio.property('disabled')).toBe(false)
}) })
}) })
...@@ -12,12 +12,12 @@ describe('component-native-textarea', () => { ...@@ -12,12 +12,12 @@ describe('component-native-textarea', () => {
}); });
it('focus', async () => { it('focus', async () => {
expect(await textarea.property("focus")).toBe(false) expect(await textarea.property("focus")).toBe("false")
await page.setData({ await page.setData({
focus_boolean: true, focus_boolean: true,
}) })
await page.waitFor(500) await page.waitFor(500)
expect(await textarea.property("focus")).toBe(true) expect(await textarea.property("focus")).toBe("true")
}); });
/* it("auto-height", async () => { /* it("auto-height", async () => {
await page.setData({ await page.setData({
......
...@@ -223,7 +223,8 @@ ...@@ -223,7 +223,8 @@
}, },
pause: function () { pause: function () {
console.log("pause"); console.log("pause");
this.videoContext?.pause(); (uni.getElementById("video") as UniVideoElement).pause(); //as写法测试。注意id不对时as会崩溃
// this.videoContext?.pause();
}, },
seek: function (pos : number) { seek: function (pos : number) {
console.log("seek -> " + pos); console.log("seek -> " + pos);
...@@ -239,7 +240,8 @@ ...@@ -239,7 +240,8 @@
}, },
stop: function () { stop: function () {
console.log("stop"); console.log("stop");
this.videoContext?.stop(); uni.getElementById<UniVideoElement>("video")?.stop(); //泛型写法测试
// this.videoContext?.stop();
}, },
sendDanmu: function (danmu : Danmu) { sendDanmu: function (danmu : Danmu) {
console.log("sendDanmu -> " + danmu); console.log("sendDanmu -> " + danmu);
......
...@@ -102,12 +102,11 @@ ...@@ -102,12 +102,11 @@
url: 'navigator', url: 'navigator',
api: ["navigateTo", "reLaunch", "navigateBack", "redirectTo", "switchTab"] api: ["navigateTo", "reLaunch", "navigateBack", "redirectTo", "switchTab"]
}, },
/*
{ {
name: '设置导航条标题', name: '设置导航条标题',
url: 'set-navigation-bar-title', url: 'set-navigation-bar-title',
enable: false, },
}, */
{ {
name: '设置导航条颜色', name: '设置导航条颜色',
url: 'set-navigation-bar-color', url: 'set-navigation-bar-color',
...@@ -254,6 +253,10 @@ ...@@ -254,6 +253,10 @@
name: '电量', name: '电量',
url: 'get-battery-info', url: 'get-battery-info',
}, },
{
name: '安装Apk',
url: 'install-apk'
}
/* { /* {
name: "打电话", name: "打电话",
url: "make-phone-call", url: "make-phone-call",
......
...@@ -35,7 +35,7 @@ ...@@ -35,7 +35,7 @@
uni.$emit('tabchange', e.detail.scrollTop) uni.$emit('tabchange', e.detail.scrollTop)
}, },
scrollTop(top : number) { scrollTop(top : number) {
(this.$refs["listView"] as Element).setAttribute('scrollTop', top) (this.$refs["listView"] as Element).scrollTop = top
} }
} }
} }
......
<template> <template>
<list-view ref="listView" class="list" :rebound="false" :scroll-y="true" :custom-nested-scroll="true" <list-view ref="listView" :id=id class="list" :rebound="false" :scroll-y="true" :custom-nested-scroll="true"
@scrolltolower="loadData(null)"> @scrolltolower="loadData(null)">
<list-item class="list-item" v-for="(item, _) in dataList" :key="item.plugin_id"> <list-item class="list-item" v-for="(item, _) in dataList" :key="item.plugin_id">
<view class="list-item-icon"> <view class="list-item-icon">
...@@ -60,6 +60,10 @@ ...@@ -60,6 +60,10 @@
preload: { preload: {
type: Boolean, type: Boolean,
default: false default: false
},
id: {
type: String,
default: ''
} }
}, },
data() { data() {
......
...@@ -206,7 +206,9 @@ ...@@ -206,7 +206,9 @@
// 滚动到水平中心位置 // 滚动到水平中心位置
const scroll_x = x - this.$swiperWidth / 2 const scroll_x = x - this.$swiperWidth / 2
this.$tabScrollView?.setAttribute('scrollLeft', scroll_x) if(this.$tabScrollView !== null){
this.$tabScrollView!.scrollLeft = scroll_x
}
}, },
initSwiperItemData(index : number) { initSwiperItemData(index : number) {
if (!this.swiperList[index].preload) { if (!this.swiperList[index].preload) {
......
<template> <template>
<scroll-view ref="pageScrollView" class="page" :scroll-y="true" :rebound="false" <scroll-view ref="pageScrollView" class="page" :scroll-y="true" :rebound="false"
@startnestedscroll="onStartNestedScroll" @nestedprescroll="onNestedPreScroll"> @startnestedscroll="onStartNestedScroll" @nestedprescroll="onNestedPreScroll"
:nested-scroll-child="nestedScrollChildId"
>
<swiper ref="header" indicator-dots="true" circular="true"> <swiper ref="header" indicator-dots="true" circular="true">
<swiper-item v-for="i in 3" :item-id="i"> <swiper-item v-for="i in 3" :item-id="i">
<image src="/static/shuijiao.jpg" style="height: 240px;"></image> <image src="/static/shuijiao.jpg" style="height: 240px;"></image>
...@@ -20,7 +22,7 @@ ...@@ -20,7 +22,7 @@
<swiper ref="swiper" class="swiper-view" :current="swiperIndex" @transition="onSwiperTransition" <swiper ref="swiper" class="swiper-view" :current="swiperIndex" @transition="onSwiperTransition"
@animationfinish="onSwiperAnimationfinish"> @animationfinish="onSwiperAnimationfinish">
<swiper-item class="swiper-item" v-for="(item, index) in swiperList" :key="index"> <swiper-item class="swiper-item" v-for="(item, index) in swiperList" :key="index">
<long-page ref="longPage" :type="item.type" :preload="item.preload"></long-page> <long-page ref="longPage" :id="item.id" :type="item.type" :preload="item.preload"></long-page>
</swiper-item> </swiper-item>
</swiper> </swiper>
</view> </view>
...@@ -39,6 +41,7 @@ ...@@ -39,6 +41,7 @@
type SwiperViewItem = { type SwiperViewItem = {
type : string, type : string,
name : string, name : string,
id: string,
preload : boolean, preload : boolean,
} }
...@@ -64,19 +67,23 @@ ...@@ -64,19 +67,23 @@
{ {
type: 'UpdatedDate', type: 'UpdatedDate',
name: '最新上架', name: '最新上架',
id: "list-id-1",
preload: true preload: true
} as SwiperViewItem, } as SwiperViewItem,
{ {
type: 'FreeHot', type: 'FreeHot',
name: '免费热榜' name: '免费热榜',
id: "list-id-2"
} as SwiperViewItem, } as SwiperViewItem,
{ {
type: 'PaymentHot', type: 'PaymentHot',
name: '付费热榜' name: '付费热榜',
id: "list-id-3"
} as SwiperViewItem, } as SwiperViewItem,
{ {
type: 'HotList', type: 'HotList',
name: '热门总榜' name: '热门总榜',
id: "list-id-4"
} as SwiperViewItem } as SwiperViewItem
] as SwiperViewItem[], ] as SwiperViewItem[],
swiperIndex: -1, swiperIndex: -1,
...@@ -86,7 +93,8 @@ ...@@ -86,7 +93,8 @@
$tabScrollView: null as null | Element, $tabScrollView: null as null | Element,
$indicatorNode: null as null | Element, $indicatorNode: null as null | Element,
$swiperWidth: 0, $swiperWidth: 0,
$swiperTabsRect: [] as SwiperTabsItem[] $swiperTabsRect: [] as SwiperTabsItem[],
nestedScrollChildId: ""
} }
}, },
onReady() { onReady() {
...@@ -201,13 +209,19 @@ ...@@ -201,13 +209,19 @@
// 滚动到水平中心位置 // 滚动到水平中心位置
const scroll_x = x - this.$swiperWidth / 2 const scroll_x = x - this.$swiperWidth / 2
this.$tabScrollView?.setAttribute('scrollLeft', scroll_x) if(this.$tabScrollView !== null){
this.$tabScrollView!.scrollLeft = scroll_x
}
}, },
initSwiperItemData(index : number) { initSwiperItemData(index : number) {
if (!this.swiperList[index].preload) { if (!this.swiperList[index].preload) {
this.swiperList[index].preload = true; this.swiperList[index].preload = true;
(this.$refs["longPage"]! as ComponentPublicInstance[])[index].$callMethod('loadData', null) (this.$refs["longPage"]! as ComponentPublicInstance[])[index].$callMethod('loadData', null)
} }
//swiper页面切换需要重新赋值嵌套滚动子元素的id
if (this.swiperList[index].id != null) {
this.nestedScrollChildId = this.swiperList[index].id
}
} }
} }
} }
......
...@@ -164,7 +164,9 @@ ...@@ -164,7 +164,9 @@
// 滚动到水平中心位置 // 滚动到水平中心位置
const scroll_x = x - this.$swiperWidth / 2 const scroll_x = x - this.$swiperWidth / 2
this.$tabScrollView?.setAttribute('scrollLeft', scroll_x) if(this.$tabScrollView !== null){
this.$tabScrollView!.scrollLeft = scroll_x
}
} }
} }
} }
......
...@@ -122,7 +122,9 @@ ...@@ -122,7 +122,9 @@
// 滚动到水平中心位置 // 滚动到水平中心位置
const target_x = lerpNumber(current_node.offsetLeft, move_to_node.offsetLeft, percentage) const target_x = lerpNumber(current_node.offsetLeft, move_to_node.offsetLeft, percentage)
const center_x = target_x + move_to_node.offsetWidth / 2 - this.$swiperWidth / 2 const center_x = target_x + move_to_node.offsetWidth / 2 - this.$swiperWidth / 2
this.$tabScrollView?.setAttribute('scrollLeft', center_x) if(this.$tabScrollView !== null){
this.$tabScrollView!.scrollLeft = center_x
}
} }
} }
} }
......
...@@ -2,4 +2,14 @@ hello uni-app x 是 uni-app x 项目的演示工程。 ...@@ -2,4 +2,14 @@ hello uni-app x 是 uni-app x 项目的演示工程。
uni-app x [开发文档](https://uniapp.dcloud.net.cn/uni-app-x/) uni-app x [开发文档](https://uniapp.dcloud.net.cn/uni-app-x/)
### 自动化测试
项目下的js文件为自动化测试的nodejs文件,uni-app x手机端没有js引擎,是纯原生的。[自动化测试详见](https://uniapp.dcloud.net.cn/worktile/auto/quick-start.html) 项目下的js文件为自动化测试的nodejs文件,uni-app x手机端没有js引擎,是纯原生的。[自动化测试详见](https://uniapp.dcloud.net.cn/worktile/auto/quick-start.html)
#### 页面截图对比测试
测试用例文件路径:pages/pages.test.js
其中 pages 变量中保存了所有需要截图对比测试的页面地址,如果有新增示例页面需要截图对比测试将页面地址添加到此变量即可。
**注意**
- 添加到截图对比测试的页面列表,修改内容涉及到变更,需要在测试平台删除基准图
- 动态内容页面不适合截图对比测试,不要添加到截图对比测试的页面列表中
## 1.0.3(2023-10-27)
遵循UniError规范
## 1.0.2(2023-10-27)
修改文档
## 1.0.1(2023-10-27)
支持js层调用
## 1.0.0(2023-10-26)
安装apk的插件
{
"id": "uni-installApk",
"displayName": "uni-installApk",
"version": "1.0.3",
"description": "uni-installApk",
"keywords": [
"uni-installApk"
],
"repository": "",
"engines": {
"HBuilderX": "^3.94"
},
"dcloudext": {
"type": "uts",
"sale": {
"regular": {
"price": "0.00"
},
"sourcecode": {
"price": "0.00"
}
},
"contact": {
"qq": ""
},
"declaration": {
"ads": "无",
"data": "无",
"permissions": "android.permission.REQUEST_INSTALL_PACKAGES"
},
"npmurl": ""
},
"uni_modules": {
"dependencies": [],
"uni-ext-api": {
"uni": {
"installApk": {
"name": "installApk",
"app": {
"js": true,
"kotlin": true,
"swift": false
}
}
}
},
"encrypt": [],
"platforms": {
"cloud": {
"tcb": "y",
"aliyun": "y"
},
"client": {
"Vue": {
"vue2": "y",
"vue3": "y"
},
"App": {
"app-android": "y",
"app-ios": "n"
},
"H5-mobile": {
"Safari": "n",
"Android Browser": "n",
"微信浏览器(Android)": "n",
"QQ浏览器(Android)": "n"
},
"H5-pc": {
"Chrome": "n",
"IE": "n",
"Edge": "n",
"Firefox": "n",
"Safari": "n"
},
"小程序": {
"微信": "n",
"阿里": "n",
"百度": "n",
"字节跳动": "n",
"QQ": "n",
"钉钉": "n",
"快手": "n",
"飞书": "n",
"京东": "n"
},
"快应用": {
"华为": "n",
"联盟": "n"
}
}
}
}
}
\ No newline at end of file
# uni-installApk
## 使用说明
Android平台安装Apk
**注意: 3.95以下需要自定义基座**
### uni.installApk(options : InstallApkOptions):void
安装apk
参数说明
```
type InstallApkOptions = {
/**
* apk文件地址
*/
filePath : string,
/**
* 接口调用成功的回调函数
* @defaultValue null
*/
success ?: (res : any) => void,
/**
* 接口调用失败的回调函数
* @defaultValue null
*/
fail ?: (err : any) => void,
/**
* 接口调用结束的回调函数(调用成功、失败都会执行)
* @defaultValue null
*/
complete ?: (res : any) => void,
}
```
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"
package="io.dcloud.uni.installApk">
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />
</manifest>
\ No newline at end of file
import { InstallApkOptions, InstallApkSuccess } from "../interface.uts"
import { InstallApkFailImpl } from "../unierror.uts"
import Intent from 'android.content.Intent';
import Build from 'android.os.Build';
import File from 'java.io.File';
import FileProvider from 'androidx.core.content.FileProvider';
import Context from 'android.content.Context';
import Uri from 'android.net.Uri';
export function installApk(options : InstallApkOptions) : void {
const context = UTSAndroid.getAppContext() as Context
const filePath = UTSAndroid.convert2AbsFullPath(options.filePath)
const apkFile = new File(filePath)
if (!apkFile.exists() && !apkFile.isFile()) {
let error = new InstallApkFailImpl(1300002);
options.fail?.(error)
options.complete?.(error)
return
}
const intent = new Intent()
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
intent.setAction(Intent.ACTION_VIEW)
if (Build.VERSION.SDK_INT >= 24) {
const authority = context.getPackageName() + ".dc.fileprovider"
const apkUri = FileProvider.getUriForFile(context, authority, apkFile)
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
intent.setDataAndType(apkUri, "application/vnd.android.package-archive");
} else {
intent.setDataAndType(Uri.fromFile(apkFile), "application/vnd.android.package-archive");
}
context.startActivity(intent)
const success : InstallApkSuccess = {
errMsg: "success"
}
options.success?.(success)
options.complete?.(success)
}
\ No newline at end of file
export interface Uni {
/**
* installApk()
* @description
* 安装apk
* @param {InstallApkOptions}
* @return {void}
* @uniPlatform {
* "app": {
* "android": {
* "osVer": "4.4",
* "uniVer": "3.94+",
* "unixVer": "3.94+"
* },
* "ios": {
* "osVer": "x",
* "uniVer": "x",
* "unixVer": "x"
* }
* }
* }
* @example
```typescript
uni.installApk({
filePath: "/xx/xx/xx.apk",
complete: (res: any) => {
console.log("complete => " + JSON.stringify(res));
}
});
```
*/
installApk(options : InstallApkOptions) : void
}
export type InstallApkSuccess = {
/**
* 安装成功消息
*/
errMsg : string
}
export type InstallApkComplete = any
export type InstallApkSuccessCallback = (res : InstallApkSuccess) => void
/**
* 错误码
* - 1300002 找不到文件
*/
export type InstallApkErrorCode = 1300002
/**
* 网络请求失败的错误回调参数
*/
export interface InstallApkFail extends IUniError {
errCode : InstallApkErrorCode
};
export type InstallApkFailCallback = (err : InstallApkFail) => void
export type InstallApkCompleteCallback = (res : InstallApkComplete) => void
export type InstallApkOptions = {
/**
* apk文件地址
*/
filePath : string,
/**
* 接口调用成功的回调函数
* @defaultValue null
*/
success ?: InstallApkSuccessCallback | null,
/**
* 接口调用失败的回调函数
* @defaultValue null
*/
fail ?: InstallApkFailCallback | null,
/**
* 接口调用结束的回调函数(调用成功、失败都会执行)
* @defaultValue null
*/
complete ?: InstallApkCompleteCallback | null
}
\ No newline at end of file
import { InstallApkErrorCode, InstallApkFail } from "./interface.uts"
/**
* 错误主题
*/
export const UniErrorSubject = 'uni-installApk';
/**
* 错误码
* @UniError
*/
export const UniErrors : Map<InstallApkErrorCode, string> = new Map([
/**
* 找不到文件
*/
[1300002, 'No such file'],
]);
export class InstallApkFailImpl extends UniError implements InstallApkFail {
constructor(errCode : InstallApkErrorCode) {
super();
this.errSubject = UniErrorSubject;
this.errCode = errCode;
this.errMsg = UniErrors[errCode] ?? "";
}
}
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册