diff --git a/pages.json b/pages.json
index f48ef91acdb02850c1df0ff76e71a765b7e1a353..2fc32d33258f9f90664cc241d4c268a230c95a6f 100644
--- a/pages.json
+++ b/pages.json
@@ -257,11 +257,17 @@
"navigationBarTitleText": "页面跳转"
}
},
- {
- "path": "pages/API/set-navigation-bar-color/set-navigation-bar-color",
- "style": {
- "navigationBarTitleText": "设置导航条颜色"
- }
+ {
+ "path": "pages/API/set-navigation-bar-color/set-navigation-bar-color",
+ "style": {
+ "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",
@@ -276,13 +282,6 @@
"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",
"style": {
@@ -1040,6 +1039,14 @@
"navigationBarTitleText" : "transitionend事件",
"enablePullDownRefresh" : false
}
+ },
+ {
+ "path" : "pages/API/install-apk/install-apk",
+ "style" :
+ {
+ "navigationBarTitleText" : "install-apk",
+ "enablePullDownRefresh" : false
+ }
}
],
diff --git a/pages/API/event-bus/event-bus.test.js b/pages/API/event-bus/event-bus.test.js
index 35d3e36644cf81c5be73373ec095c365021de612..699466dea86f00260d57c933d260540b3d3d09fa 100644
--- a/pages/API/event-bus/event-bus.test.js
+++ b/pages/API/event-bus/event-bus.test.js
@@ -4,7 +4,7 @@ describe('event-bus', () => {
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
- await page.waitFor(500)
+ await page.waitFor('view')
})
it('on', async () => {
diff --git a/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js b/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js
index c7863eb97bf1e8162ee2e593138ac71e5829a995..7311bbde478ea075d1c187e6742f074fa62607aa 100644
--- a/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js
+++ b/pages/API/get-element-by-id/get-element-by-id-multiple-root-node.test.js
@@ -5,7 +5,7 @@ let page;
describe("getElementByIdForMultipleRootNode", () => {
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH);
- await page.waitFor(1000);
+ await page.waitFor('view');
});
it("getElementByNotExistId", async () => {
const res = await page.callMethod("getElementByNotExistId");
diff --git a/pages/API/get-element-by-id/get-element-by-id.test.js b/pages/API/get-element-by-id/get-element-by-id.test.js
index 00a5f2e78b5a9b162277838a30b2ff502e656ae0..a04f1b1ded90c1768b20e19bb357570782d5d6be 100644
--- a/pages/API/get-element-by-id/get-element-by-id.test.js
+++ b/pages/API/get-element-by-id/get-element-by-id.test.js
@@ -4,7 +4,7 @@ let page;
describe("getElementById", () => {
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH);
- await page.waitFor(1000);
+ await page.waitFor('view');
});
it("getElementByNotExistId", async () => {
const res = await page.callMethod("getElementByNotExistId");
diff --git a/pages/API/get-launch-options-sync/get-launch-options-sync.test.js b/pages/API/get-launch-options-sync/get-launch-options-sync.test.js
index 1c603c6859c06fe41ea1d7ac0716dc18e7c34853..480279377a1a208aa7a9554205ba1505eaa1721b 100644
--- a/pages/API/get-launch-options-sync/get-launch-options-sync.test.js
+++ b/pages/API/get-launch-options-sync/get-launch-options-sync.test.js
@@ -3,7 +3,7 @@ const PAGE_PATH = '/pages/API/get-launch-options-sync/get-launch-options-sync'
describe('getLaunchOptionsSync', () => {
it('getLaunchOptionsSync', async () => {
const page = await program.navigateTo(PAGE_PATH)
- await page.waitFor(1000)
+ await page.waitFor('view')
await page.callMethod('getLaunchOptionsSync')
const data = await page.data()
expect(data.checked).toBe(true)
diff --git a/pages/API/install-apk/install-apk.uvue b/pages/API/install-apk/install-apk.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..af849b8debea300eb30ca0bc0cc05a505287de8f
--- /dev/null
+++ b/pages/API/install-apk/install-apk.uvue
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/API/load-font-face/load-font-face-child.test.js b/pages/API/load-font-face/load-font-face-child.test.js
deleted file mode 100644
index ad479f5b30c66289750754aacf9f3810799408d3..0000000000000000000000000000000000000000
--- a/pages/API/load-font-face/load-font-face-child.test.js
+++ /dev/null
@@ -1,12 +0,0 @@
-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()
- })
-})
diff --git a/pages/API/load-font-face/load-font-face.test.js b/pages/API/load-font-face/load-font-face.test.js
index 548343c03b463c9db70cbc2aca8f1bda91076837..df73df3320f6379f9183248ec5506fe3cf4a0158 100644
--- a/pages/API/load-font-face/load-font-face.test.js
+++ b/pages/API/load-font-face/load-font-face.test.js
@@ -1,12 +1,19 @@
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 () => {
- const page = await program.navigateTo(PAGE_PATH)
- await page.waitFor(4000)
- })
- it('screenshot', async () => {
- const image = await program.screenshot()
- expect(image).toMatchImageSnapshot()
- })
-})
+ const page = await program.navigateTo(PAGE_PATH);
+ await page.waitFor(3000);
+ });
+ it("parent screenshot", async () => {
+ const image = await program.screenshot();
+ 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();
+ });
+});
diff --git a/pages/API/navigator/navigator.test.js b/pages/API/navigator/navigator.test.js
deleted file mode 100644
index 45c4efc021bac4de92266b8a4a8a93f744c5bfb9..0000000000000000000000000000000000000000
--- a/pages/API/navigator/navigator.test.js
+++ /dev/null
@@ -1,199 +0,0 @@
-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)
- })
-})
diff --git a/pages/API/navigator/new-page/new-page-2.test.js b/pages/API/navigator/new-page/new-page-2.test.js
deleted file mode 100644
index 2ea7cadc05aaa00df4b62bb7280d8ed665b61755..0000000000000000000000000000000000000000
--- a/pages/API/navigator/new-page/new-page-2.test.js
+++ /dev/null
@@ -1,77 +0,0 @@
-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)
- })
-})
diff --git a/pages/API/navigator/new-page/new-page-2.uvue b/pages/API/navigator/new-page/new-page-2.uvue
deleted file mode 100644
index 661f8bfcbf0d77dafd52163931c3d5e6f100b42f..0000000000000000000000000000000000000000
--- a/pages/API/navigator/new-page/new-page-2.uvue
+++ /dev/null
@@ -1,91 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/pages/API/navigator/new-page/onLoad.test.js b/pages/API/navigator/new-page/onLoad.test.js
index 933193ac4e66d8256654faf0f219ef64fbb9dd38..7708452ba04273098bec9bd9bc41a5b0e2c8e4a0 100644
--- a/pages/API/navigator/new-page/onLoad.test.js
+++ b/pages/API/navigator/new-page/onLoad.test.js
@@ -7,50 +7,50 @@ let page;
describe("onLoad", () => {
it("adjustData", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
- await page.waitFor(500);
+ await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "adjustData");
- await page.waitFor(1000);
+ await page.waitFor(500);
const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
});
it("navigateTo", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
- await page.waitFor(500);
+ await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "navigateTo");
- await page.waitFor(1000);
+ await page.waitFor(500);
page = await program.currentPage();
expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
});
it("navigateBack", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
- await page.waitFor(500);
+ await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "navigateBack");
- await page.waitFor(1000);
page = await program.currentPage();
+ await page.waitFor('view');
expect(page.path).toBe(INTERMEDIATE_PAGE_PATH.substring(1));
});
it("redirectTo", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
- await page.waitFor(500);
+ await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "redirectTo");
- await page.waitFor(1000);
+ await page.waitFor(500);
page = await program.currentPage();
expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
});
it("reLaunch", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
- await page.waitFor(500);
+ await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "reLaunch");
- await page.waitFor(1000);
+ await page.waitFor(500);
page = await program.currentPage();
expect(page.path).toBe(TARGET_PAGE_PATH.substring(1));
});
it("switchTab", async () => {
page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
- await page.waitFor(500);
+ await page.waitFor('view');
await page.callMethod("navigateToOnLoadWithType", "switchTab");
- await page.waitFor(1000);
page = await program.currentPage();
+ await page.waitFor('view');
expect(page.path).toBe("pages/tabBar/component");
});
// toast 出现在 INTERMEDIATE_PAGE_PATH 页面(非 onLoad 生命周期所在页面)
@@ -66,7 +66,7 @@ describe("onLoad", () => {
// 同 toast
// it("showLoading", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
- // await page.waitFor(500);
+ // await page.waitFor('view');
// await page.callMethod("navigateToOnLoadWithType", "showLoading");
// await page.waitFor(1000);
// const image = await program.screenshot();
@@ -75,7 +75,7 @@ describe("onLoad", () => {
// 同 toast
// it("showModal", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
- // await page.waitFor(500);
+ // await page.waitFor('view');
// await page.callMethod("navigateToOnLoadWithType", "showModal");
// await page.waitFor(1000);
// const image = await program.screenshot();
@@ -84,7 +84,7 @@ describe("onLoad", () => {
// 同 toast
// it("showActionSheet", async () => {
// page = await program.reLaunch(INTERMEDIATE_PAGE_PATH);
- // await page.waitFor(500);
+ // await page.waitFor('view');
// await page.callMethod("navigateToOnLoadWithType", "showActionSheet");
// await page.waitFor(1000);
// const image = await program.screenshot();
diff --git a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js
index 78e2ea174ded707b878bae3f8a9f274f9793587a..54cb43f3fe07110f4b75b8d6b253586bb03bd77a 100644
--- a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js
+++ b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.test.js
@@ -24,6 +24,8 @@ describe("setCustomNavigationBarColor", () => {
area: { x: 880, y: 0, width: 100, height: 60 },
});
expect(image).toMatchImageSnapshot();
+ const lifeCycleNum = await page.callMethod("getLifeCycleNum");
+ expect(lifeCycleNum - originLifeCycleNum).toBe(2);
});
it("setNavigationBarColor1", async () => {
@@ -34,5 +36,7 @@ describe("setCustomNavigationBarColor", () => {
area: { x: 880, y: 0, width: 100, height: 60 },
});
expect(image).toMatchImageSnapshot();
+ const lifeCycleNum = await page.callMethod("getLifeCycleNum");
+ expect(lifeCycleNum - originLifeCycleNum).toBe(4);
});
});
diff --git a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue
index dac025f6657c59c6d8354594fe969a577324e887..5ba29c1c43c9a2d0394664d6bf2faac1709dc73b 100644
--- a/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue
+++ b/pages/API/set-navigation-bar-color/set-custom-navigation-bar-color.uvue
@@ -50,12 +50,15 @@ export default {
success() {
this.navigationBarTextColor = '#fff'
console.log('setNavigationBarColor success')
+ this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
- console.log('setNavigationBarColor success')
+ console.log('setNavigationBarColor fail')
+ this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
- console.log('setNavigationBarColor success')
+ console.log('setNavigationBarColor complete')
+ this.setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
@@ -66,12 +69,15 @@ export default {
success() {
this.navigationBarTextColor = '#000'
console.log('setNavigationBarColor success')
+ this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
- console.log('setNavigationBarColor success')
+ console.log('setNavigationBarColor fail')
+ this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
- console.log('setNavigationBarColor success')
+ console.log('setNavigationBarColor complete')
+ this.setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
diff --git a/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js b/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js
index a293b96b61498f6afbb943c7b787affcb1313045..455947abd9aad6a7f347f5d7d3ffa0726ecf6aa0 100644
--- a/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js
+++ b/pages/API/set-navigation-bar-color/set-navigation-bar-color.test.js
@@ -16,14 +16,18 @@ describe('setNavigationBarColor', () => {
expect(lifeCycleNum).toBe(originLifeCycleNum)
})
- it('setNavigationBarColor1', async () => {
- await page.callMethod('setNavigationBarColor1')
- const image = await program.screenshot()
- expect(image).toMatchImageSnapshot()
- })
- it('setNavigationBarColor2', async () => {
- await page.callMethod('setNavigationBarColor2')
- const image = await program.screenshot()
- expect(image).toMatchImageSnapshot()
- })
+ it("setNavigationBarColor1", async () => {
+ await page.callMethod("setNavigationBarColor1");
+ const image = await program.screenshot();
+ expect(image).toMatchImageSnapshot();
+ const lifeCycleNum = await page.callMethod("getLifeCycleNum");
+ expect(lifeCycleNum - originLifeCycleNum).toBe(2);
+ });
+ it("setNavigationBarColor2", async () => {
+ await page.callMethod("setNavigationBarColor2");
+ const image = await program.screenshot();
+ expect(image).toMatchImageSnapshot();
+ const lifeCycleNum = await page.callMethod("getLifeCycleNum");
+ expect(lifeCycleNum - originLifeCycleNum).toBe(4);
+ });
})
diff --git a/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue b/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue
index 913daf0a1c8f9c0d26cbd0c0831207abf84ae9ea..30efdc466659500bd55ac62980043bb890201600 100644
--- a/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue
+++ b/pages/API/set-navigation-bar-color/set-navigation-bar-color.uvue
@@ -26,12 +26,15 @@ export default {
backgroundColor: '#00ff00',
success() {
console.log('setNavigationBarColor success')
+ this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
- console.log('setNavigationBarColor success')
+ console.log('setNavigationBarColor fail')
+ this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
- console.log('setNavigationBarColor success')
+ console.log('setNavigationBarColor complete')
+ this.setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
@@ -41,12 +44,15 @@ export default {
backgroundColor: '#ff0000',
success() {
console.log('setNavigationBarColor success')
+ this.setLifeCycleNum(state.lifeCycleNum + 1)
},
fail() {
- console.log('setNavigationBarColor success')
+ console.log('setNavigationBarColor fail')
+ this.setLifeCycleNum(state.lifeCycleNum - 1)
},
complete() {
- console.log('setNavigationBarColor success')
+ console.log('setNavigationBarColor complete')
+ this.setLifeCycleNum(state.lifeCycleNum + 1)
}
})
},
@@ -66,12 +72,3 @@ export default {
},
}
-
-
diff --git a/pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js b/pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..d16c75a23fcfb80571a41b5679169b5413977046
--- /dev/null
+++ b/pages/API/set-navigation-bar-title/set-navigation-bar-title.test.js
@@ -0,0 +1,26 @@
+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);
+ });
+});
diff --git a/pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue b/pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue
new file mode 100644
index 0000000000000000000000000000000000000000..5f917f3190b5911750b37f11499a7ee2b8c3ac69
--- /dev/null
+++ b/pages/API/set-navigation-bar-title/set-navigation-bar-title.uvue
@@ -0,0 +1,49 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/pages/component/button/button.test.js b/pages/component/button/button.test.js
index 76cb4fcf97225bab7c747ef39e81aa1bb3c21c30..7fb1a9084f0cdff2e33403316f61baa702e69b2e 100644
--- a/pages/component/button/button.test.js
+++ b/pages/component/button/button.test.js
@@ -4,7 +4,7 @@ describe('Button.uvue', () => {
let page
beforeAll(async () => {
page = await program.reLaunch(PAGE_PATH)
- await page.waitFor(500)
+ await page.waitFor('view')
})
it('click', async () => {
// TODO 待测试框架支持text的dispatchEvent
@@ -41,12 +41,10 @@ describe('Button.uvue', () => {
await page.setData({
type_enum_current: 1,
})
- await page.waitFor(500)
expect(await btn.property('type')).toBe('primary')
await page.setData({
type_enum_current: 2,
})
- await page.waitFor(500)
expect(await btn.property('type')).toBe('warn')
})
it('size', async () => {
@@ -55,7 +53,6 @@ describe('Button.uvue', () => {
await page.setData({
size_enum_current: 1,
})
- await page.waitFor(500)
expect(await btn.property('size')).toBe('mini')
})
it('plain', async () => {
@@ -64,7 +61,6 @@ describe('Button.uvue', () => {
await page.setData({
plain_boolean: true,
})
- await page.waitFor(500)
expect(await btn.property('plain')).toBe(true)
})
it('disabled', async () => {
@@ -73,7 +69,6 @@ describe('Button.uvue', () => {
await page.setData({
disabled_boolean: true,
})
- await page.waitFor(500)
expect(await btn.property('disabled')).toBe(true)
})
-})
\ No newline at end of file
+})
diff --git a/pages/component/checkbox/checkbox.test.js b/pages/component/checkbox/checkbox.test.js
index c3a31094fc9de4ca992c0b4b016e18d83338f226..103e48bd033d0ed9ed308d55af95a62442f65507 100644
--- a/pages/component/checkbox/checkbox.test.js
+++ b/pages/component/checkbox/checkbox.test.js
@@ -8,7 +8,7 @@ function getData(key = '') {
let page
beforeAll(async () => {
page = await program.reLaunch('/pages/component/checkbox/checkbox')
- await page.waitFor(1000)
+ await page.waitFor('view')
})
describe('Checkbox.uvue', () => {
@@ -46,7 +46,6 @@ describe('Checkbox.uvue', () => {
await page.setData({
checked: false,
})
- await page.waitFor(500)
expect(await cb.property('checked')).toBe(false)
})
it('color', async () => {
@@ -55,7 +54,6 @@ describe('Checkbox.uvue', () => {
await page.setData({
color: '#63acfc',
})
- await page.waitFor(500)
expect(await cb.property('color')).toBe('#63acfc')
})
it('disabled', async () => {
@@ -64,7 +62,6 @@ describe('Checkbox.uvue', () => {
await page.setData({
disabled: false,
})
- await page.waitFor(500)
expect(await cb.property('disabled')).toBe(false)
})
})
diff --git a/pages/component/general-attribute/general-attribute.test.js b/pages/component/general-attribute/general-attribute.test.js
index 2b3d46985745ce2e4d1aef67e61bc07671bb98f9..290b16a577a9149b69d37540c2f0e5075aeefc5a 100644
--- a/pages/component/general-attribute/general-attribute.test.js
+++ b/pages/component/general-attribute/general-attribute.test.js
@@ -5,7 +5,7 @@ describe('general attribute', () => {
beforeAll(async () => {
page = await program.navigateTo(PAGE_PATH)
- await page.waitFor(1000)
+ await page.waitFor('view')
})
it("class & style", async () => {
const image = await program.screenshot();
@@ -20,7 +20,7 @@ describe('general attribute', () => {
it("ref", async () => {
const button = await page.$(".btn-ref");
await button.tap();
- await page.waitFor(1000);
+ await page.waitFor(500);
const image = await program.screenshot();
expect(image).toMatchImageSnapshot();
});
diff --git a/pages/component/general-event/general-event.test.js b/pages/component/general-event/general-event.test.js
index be05d4892f91fa854c239fd86c192cdf622ecd3f..ded3853e3ade9b306bb989785cc3cd324494c9e9 100644
--- a/pages/component/general-event/general-event.test.js
+++ b/pages/component/general-event/general-event.test.js
@@ -5,7 +5,7 @@ describe('event trigger sequence', () => {
let el
beforeAll(async () => {
page = await program.navigateTo(PAGE_PATH)
- await page.waitFor(1000)
+ await page.waitFor('view')
el = await page.$('.target')
})
diff --git a/pages/component/input/input.test.js b/pages/component/input/input.test.js
index ab54276ea525e125c9cade9e66af3cab19cf2ee6..d419ddccac41c2ee20159e84c0f624a22ca3d2cc 100644
--- a/pages/component/input/input.test.js
+++ b/pages/component/input/input.test.js
@@ -73,54 +73,54 @@ describe('component-native-input', () => {
// })
// })
// 测试placeholder
- it("placeholder", async () => {
- const placeholder1 = await page.$('.uni-input-placeholder1');
- expect(await placeholder1.property("placeholder-style")).toMatchObject({
- "color": "red"
- })
- expect(await placeholder1.property("placeholder")).toEqual("占位符文字颜色为红色")
- await page.setData({
- inputPlaceHolderStyle: "color:#CC00CC",
- })
- expect(await placeholder1.property("placeholder-style")).toMatchObject({
- "color": "#CC00CC"
- })
+ // it("placeholder", async () => {
+ // const placeholder1 = await page.$('.uni-input-placeholder1');
+ // expect(await placeholder1.property("placeholder-style")).toMatchObject({
+ // "color": "red"
+ // })
+ // expect(await placeholder1.property("placeholder")).toEqual("占位符文字颜色为红色")
+ // await page.setData({
+ // inputPlaceHolderStyle: "color:#CC00CC",
+ // })
+ // expect(await placeholder1.property("placeholder-style")).toMatchObject({
+ // "color": "#CC00CC"
+ // })
- await page.setData({
- inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0",
- })
- expect(await placeholder1.property("placeholder-style")).toMatchObject({
- "color": "#CC19CC",
- "backgroundColor": "#00b1c0"
- })
+ // await page.setData({
+ // inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0",
+ // })
+ // expect(await placeholder1.property("placeholder-style")).toMatchObject({
+ // "color": "#CC19CC",
+ // "backgroundColor": "#00b1c0"
+ // })
- await page.setData({
- inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0;text-align:center;font-size:44px;font-weight:900",
- })
- expect(await placeholder1.property("placeholder-style")).toEqual({
- "backgroundColor": "#00b1c0",
- "color": "#CC19CC",
- "fontSize": "44px",
- "fontWeight": "900",
- "textAlign": "center"
- })
+ // await page.setData({
+ // inputPlaceHolderStyle: "color:#CC19CC;background-color:#00b1c0;text-align:center;font-size:44px;font-weight:900",
+ // })
+ // expect(await placeholder1.property("placeholder-style")).toEqual({
+ // "backgroundColor": "#00b1c0",
+ // "color": "#CC19CC",
+ // "fontSize": "44px",
+ // "fontWeight": "900",
+ // "textAlign": "center"
+ // })
- const placeholder2 = await page.$('.uni-input-placeholder2');
- expect(await placeholder2.property("placeholder-class")).toMatchObject({
- "backgroundColor": "#008000"
- })
- await page.setData({
- inputPlaceHolderClass: "uni-input-placeholder-class-ts",
- })
- expect(await placeholder2.property("placeholder-class")).toMatchObject({
- "backgroundColor": "#FFA500"
- })
- expect(await placeholder2.property("placeholder")).toEqual("占位符背景色为绿色")
- })
+ // const placeholder2 = await page.$('.uni-input-placeholder2');
+ // expect(await placeholder2.property("placeholder-class")).toMatchObject({
+ // "backgroundColor": "#008000"
+ // })
+ // await page.setData({
+ // inputPlaceHolderClass: "uni-input-placeholder-class-ts",
+ // })
+ // expect(await placeholder2.property("placeholder-class")).toMatchObject({
+ // "backgroundColor": "#FFA500"
+ // })
+ // expect(await placeholder2.property("placeholder")).toEqual("占位符背景色为绿色")
+ // })
it("disable", async () => {
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 () => {
@@ -139,10 +139,10 @@ describe('component-native-input', () => {
// await page.waitFor(500)
// })
- // it("afterAllTestScreenshot", async () => {
- // const image = await program.screenshot({
- // fullPage: true
- // })
- // expect(image).toMatchImageSnapshot()
- // })
+ it("afterAllTestScreenshot", async () => {
+ const image = await program.screenshot({
+ fullPage: true
+ })
+ expect(image).toMatchImageSnapshot()
+ })
});
diff --git a/pages/component/picker-view/picker-view.test.js b/pages/component/picker-view/picker-view.test.js
index da7cb110b08cc9bd0dfbac50f4e48ba1255f403d..a4e515bf015885788dc6072db790bdb6718290cd 100644
--- a/pages/component/picker-view/picker-view.test.js
+++ b/pages/component/picker-view/picker-view.test.js
@@ -8,18 +8,18 @@ function getData(key = '') {
let page
beforeAll(async () => {
page = await program.reLaunch('/pages/component/picker-view/picker-view')
- await page.waitFor(1000)
+ await page.waitFor('view')
})
describe('PickerView.uvue', () => {
it('value', async () => {
const el = await page.$('.picker-view')
- await page.callMethod('setValue')
+ await page.callMethod('setValue')
await page.waitFor(1000)
expect(await el.property('value')).toEqual([0, 0, 0])
expect(await getData('result')).toEqual([0, 0, 0])
- await page.callMethod('setValue1')
+ await page.callMethod('setValue1')
await page.waitFor(1000)
expect(await el.property('value')).toEqual([10, 10, 10])
expect(await getData('result')).toEqual([10, 10, 10])
@@ -35,7 +35,7 @@ describe('PickerView.uvue', () => {
const el = await page.$('.picker-view')
await page.setData({
indicatorStyle: 'height: 100px;',
- })
+ })
await page.waitFor(500)
expect(await el.property('indicatorStyle')).toBe('height: 100px;')
})
@@ -44,7 +44,6 @@ describe('PickerView.uvue', () => {
await page.setData({
maskTopStyle: 'background: #ffffff;',
})
- await page.waitFor(500)
expect(await el.property('mask-top-style')).toBe('background: #ffffff;')
})
it('mask-bottom-style', async () => {
@@ -52,7 +51,6 @@ describe('PickerView.uvue', () => {
await page.setData({
maskBottomStyle: 'background: #ffffff;',
})
- await page.waitFor(500)
expect(await el.property('mask-bottom-style')).toBe('background: #ffffff;')
})
})
diff --git a/pages/component/progress/progress.test.js b/pages/component/progress/progress.test.js
index de652ae73b3cab09f68bae62d319a6d359bd8da1..66247251350f608ad78412423dc0aa92463cc79b 100644
--- a/pages/component/progress/progress.test.js
+++ b/pages/component/progress/progress.test.js
@@ -8,7 +8,7 @@ function getData(key = '') {
let page
beforeAll(async () => {
page = await program.reLaunch('/pages/component/progress/progress')
- await page.waitFor(1000)
+ await page.waitFor('view')
})
describe('Progress.uvue', () => {
@@ -17,14 +17,14 @@ describe('Progress.uvue', () => {
const p1 = await page.$('.p1')
const p2 = await page.$('.p2')
const p3 = await page.$('.p3')
- page.callMethod('setProgress')
+ await page.callMethod('setProgress')
await page.waitFor(1000)
expect(await p.property('percent')).toEqual(20)
expect(await p1.property('percent')).toEqual(40)
expect(await p2.property('percent')).toEqual(60)
expect(await p3.property('percent')).toEqual(80)
expect(await getData('curPercent')).toEqual(20)
- page.callMethod('clearProgress')
+ await page.callMethod('clearProgress')
await page.waitFor(1000)
expect(await p.property('percent')).toEqual(0)
expect(await p1.property('percent')).toEqual(0)
@@ -42,7 +42,6 @@ describe('Progress.uvue', () => {
await page.setData({
showInfo: false
})
- await page.waitFor(500)
expect(await el.property('show-info')).toEqual(false)
})
it('border-radius', async () => {
@@ -51,7 +50,6 @@ describe('Progress.uvue', () => {
await page.setData({
borderRadius: 5
})
- await page.waitFor(500)
expect(await el.property('border-radius')).toEqual(5)
})
it('font-size', async () => {
@@ -60,7 +58,6 @@ describe('Progress.uvue', () => {
await page.setData({
fontSize: 18
})
- await page.waitFor(500)
expect(await el.property('font-size')).toEqual(18)
})
it('stroke-width', async () => {
@@ -69,7 +66,6 @@ describe('Progress.uvue', () => {
await page.setData({
strokeWidth: 6
})
- await page.waitFor(500)
expect(await el.property('stroke-width')).toEqual(6)
})
it('backgroundColor', async () => {
@@ -78,7 +74,6 @@ describe('Progress.uvue', () => {
await page.setData({
backgroundColor: "#007aff"
})
- await page.waitFor(500)
expect(await el.property('background-color')).toEqual('#007aff')
})
-})
\ No newline at end of file
+})
diff --git a/pages/component/radio/radio.test.js b/pages/component/radio/radio.test.js
index e5e175f120bcf0753bc14a5c3f300c5c573ed150..b0642430e5add02f6a5ac0d87ae8708541b5376b 100644
--- a/pages/component/radio/radio.test.js
+++ b/pages/component/radio/radio.test.js
@@ -8,7 +8,7 @@ function getData(key = '') {
let page
beforeAll(async () => {
page = await program.reLaunch('/pages/component/radio/radio')
- await page.waitFor(1000)
+ await page.waitFor('view')
})
describe('Radio.uvue', () => {
@@ -44,7 +44,6 @@ describe('Radio.uvue', () => {
await page.setData({
checked: false,
})
- await page.waitFor(500)
expect(await radio.property('checked')).toBe(false)
})
it('color', async () => {
@@ -53,7 +52,6 @@ describe('Radio.uvue', () => {
await page.setData({
color: '#63acfc',
})
- await page.waitFor(500)
expect(await radio.property('color')).toBe('#63acfc')
})
it('disabled', async () => {
@@ -62,7 +60,6 @@ describe('Radio.uvue', () => {
await page.setData({
disabled: false,
})
- await page.waitFor(500)
expect(await radio.property('disabled')).toBe(false)
})
})
diff --git a/pages/component/textarea/textarea.test.js b/pages/component/textarea/textarea.test.js
index 7f7f57c00f23afd45087878be4fdcc3371ea3ea1..dc97a1e478313c75f5f9b85408cf5b9cd00247af 100644
--- a/pages/component/textarea/textarea.test.js
+++ b/pages/component/textarea/textarea.test.js
@@ -12,12 +12,12 @@ describe('component-native-textarea', () => {
});
it('focus', async () => {
- expect(await textarea.property("focus")).toBe(false)
+ expect(await textarea.property("focus")).toBe("false")
await page.setData({
focus_boolean: true,
})
await page.waitFor(500)
- expect(await textarea.property("focus")).toBe(true)
+ expect(await textarea.property("focus")).toBe("true")
});
/* it("auto-height", async () => {
await page.setData({
diff --git a/pages/component/video/video.uvue b/pages/component/video/video.uvue
index 0d0cccc3af9eca3175257b19dad1f6f414051c6c..30a3084c68e2ee7566e14da1b808c87858426d6a 100644
--- a/pages/component/video/video.uvue
+++ b/pages/component/video/video.uvue
@@ -223,7 +223,8 @@
},
pause: function () {
console.log("pause");
- this.videoContext?.pause();
+ (uni.getElementById("video") as UniVideoElement).pause(); //as写法测试。注意id不对时as会崩溃
+ // this.videoContext?.pause();
},
seek: function (pos : number) {
console.log("seek -> " + pos);
@@ -239,7 +240,8 @@
},
stop: function () {
console.log("stop");
- this.videoContext?.stop();
+ uni.getElementById("video")?.stop(); //泛型写法测试
+ // this.videoContext?.stop();
},
sendDanmu: function (danmu : Danmu) {
console.log("sendDanmu -> " + danmu);
diff --git a/pages/tabBar/API.uvue b/pages/tabBar/API.uvue
index 46c4a3fa88d98c9287dc5148ef4bf8d82395bdc7..a002cb775d8a7d192aaaab6bdabcdf8547f41cf7 100644
--- a/pages/tabBar/API.uvue
+++ b/pages/tabBar/API.uvue
@@ -102,12 +102,11 @@
url: 'navigator',
api: ["navigateTo", "reLaunch", "navigateBack", "redirectTo", "switchTab"]
},
- /*
+
{
name: '设置导航条标题',
url: 'set-navigation-bar-title',
- enable: false,
- }, */
+ },
{
name: '设置导航条颜色',
url: 'set-navigation-bar-color',
@@ -253,7 +252,11 @@
{
name: '电量',
url: 'get-battery-info',
- },
+ },
+ {
+ name: '安装Apk',
+ url: 'install-apk'
+ }
/* {
name: "打电话",
url: "make-phone-call",
diff --git a/pages/template/custom-tab-bar/custom-tab-bar-tab1.uvue b/pages/template/custom-tab-bar/custom-tab-bar-tab1.uvue
index 8d399308bfeda2b1c5b343cc46fdeda17e5e640f..c0b2f1528e3b10055108a75fb03d5e0dfc384cdc 100644
--- a/pages/template/custom-tab-bar/custom-tab-bar-tab1.uvue
+++ b/pages/template/custom-tab-bar/custom-tab-bar-tab1.uvue
@@ -35,7 +35,7 @@
uni.$emit('tabchange', e.detail.scrollTop)
},
scrollTop(top : number) {
- (this.$refs["listView"] as Element).setAttribute('scrollTop', top)
+ (this.$refs["listView"] as Element).scrollTop = top
}
}
}
diff --git a/pages/template/long-list/long-list-page.uvue b/pages/template/long-list/long-list-page.uvue
index cfa34b28da3e36e4ab2481f161e08cfe8fd2340b..bec3a4234b4bfefc2489935f19cd458cb6bcea2c 100644
--- a/pages/template/long-list/long-list-page.uvue
+++ b/pages/template/long-list/long-list-page.uvue
@@ -1,5 +1,5 @@
-
@@ -60,6 +60,10 @@
preload: {
type: Boolean,
default: false
+ },
+ id: {
+ type: String,
+ default: ''
}
},
data() {
diff --git a/pages/template/long-list/long-list.uvue b/pages/template/long-list/long-list.uvue
index 97f1c131ec88c53eeefec3f304803992d53fb87d..4c95a7599430a38b2477e181b0ba4aa9445091be 100644
--- a/pages/template/long-list/long-list.uvue
+++ b/pages/template/long-list/long-list.uvue
@@ -205,8 +205,10 @@
this.$indicatorNode?.style?.setProperty('transform', `translateX(${x}px) scaleX(${indicator_line_w})`)
// 滚动到水平中心位置
- const scroll_x = x - this.$swiperWidth / 2
- this.$tabScrollView?.setAttribute('scrollLeft', scroll_x)
+ const scroll_x = x - this.$swiperWidth / 2
+ if(this.$tabScrollView !== null){
+ this.$tabScrollView!.scrollLeft = scroll_x
+ }
},
initSwiperItemData(index : number) {
if (!this.swiperList[index].preload) {
diff --git a/pages/template/long-list2/long-list2.uvue b/pages/template/long-list2/long-list2.uvue
index 7836996260bc3a03905dc8c402ec1e62df12df1d..f911606e4ae6af6a09840257164a5ed0b5a8aa94 100644
--- a/pages/template/long-list2/long-list2.uvue
+++ b/pages/template/long-list2/long-list2.uvue
@@ -1,6 +1,8 @@
+ @startnestedscroll="onStartNestedScroll" @nestedprescroll="onNestedPreScroll"
+ :nested-scroll-child="nestedScrollChildId"
+ >
@@ -20,7 +22,7 @@
-
+
@@ -38,7 +40,8 @@
type SwiperViewItem = {
type : string,
- name : string,
+ name : string,
+ id: string,
preload : boolean,
}
@@ -63,20 +66,24 @@
swiperList: [
{
type: 'UpdatedDate',
- name: '最新上架',
+ name: '最新上架',
+ id: "list-id-1",
preload: true
} as SwiperViewItem,
{
type: 'FreeHot',
- name: '免费热榜'
+ name: '免费热榜',
+ id: "list-id-2"
} as SwiperViewItem,
{
type: 'PaymentHot',
- name: '付费热榜'
+ name: '付费热榜',
+ id: "list-id-3"
} as SwiperViewItem,
{
type: 'HotList',
- name: '热门总榜'
+ name: '热门总榜',
+ id: "list-id-4"
} as SwiperViewItem
] as SwiperViewItem[],
swiperIndex: -1,
@@ -86,7 +93,8 @@
$tabScrollView: null as null | Element,
$indicatorNode: null as null | Element,
$swiperWidth: 0,
- $swiperTabsRect: [] as SwiperTabsItem[]
+ $swiperTabsRect: [] as SwiperTabsItem[],
+ nestedScrollChildId: ""
}
},
onReady() {
@@ -201,12 +209,18 @@
// 滚动到水平中心位置
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) {
if (!this.swiperList[index].preload) {
this.swiperList[index].preload = true;
(this.$refs["longPage"]! as ComponentPublicInstance[])[index].$callMethod('loadData', null)
+ }
+ //swiper页面切换需要重新赋值嵌套滚动子元素的id
+ if (this.swiperList[index].id != null) {
+ this.nestedScrollChildId = this.swiperList[index].id
}
}
}
diff --git a/pages/template/swiper-list/swiper-list.uvue b/pages/template/swiper-list/swiper-list.uvue
index cd40b4521afbef0201c72d475cfe34935130351e..e7dcdabed727f5d58b03581a996533f798ec5f7b 100644
--- a/pages/template/swiper-list/swiper-list.uvue
+++ b/pages/template/swiper-list/swiper-list.uvue
@@ -164,7 +164,9 @@
// 滚动到水平中心位置
const scroll_x = x - this.$swiperWidth / 2
- this.$tabScrollView?.setAttribute('scrollLeft', scroll_x)
+ if(this.$tabScrollView !== null){
+ this.$tabScrollView!.scrollLeft = scroll_x
+ }
}
}
}
diff --git a/pages/template/swiper-list2/swiper-list2.uvue b/pages/template/swiper-list2/swiper-list2.uvue
index 18b82f54bbc5ed536fca99f166372a09d93eea62..ded942b7f9e87599a1297cf8efbc36d1956839d7 100644
--- a/pages/template/swiper-list2/swiper-list2.uvue
+++ b/pages/template/swiper-list2/swiper-list2.uvue
@@ -122,7 +122,9 @@
// 滚动到水平中心位置
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
- this.$tabScrollView?.setAttribute('scrollLeft', center_x)
+ if(this.$tabScrollView !== null){
+ this.$tabScrollView!.scrollLeft = center_x
+ }
}
}
}
diff --git a/readme.md b/readme.md
index 9c51765ecf746a0fb07b61d5cb7832ffea29404c..933137058e221dcf123b6e0419ca43a4a6dce650 100644
--- a/readme.md
+++ b/readme.md
@@ -2,4 +2,14 @@ hello uni-app x 是 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)
+
+#### 页面截图对比测试
+测试用例文件路径:pages/pages.test.js
+
+其中 pages 变量中保存了所有需要截图对比测试的页面地址,如果有新增示例页面需要截图对比测试将页面地址添加到此变量即可。
+
+**注意**
+- 添加到截图对比测试的页面列表,修改内容涉及到变更,需要在测试平台删除基准图
+- 动态内容页面不适合截图对比测试,不要添加到截图对比测试的页面列表中
diff --git a/static/test-apk/test.apk b/static/test-apk/test.apk
new file mode 100644
index 0000000000000000000000000000000000000000..19c5e6c121de52104c6349f81a05f7c8c5fd4f91
Binary files /dev/null and b/static/test-apk/test.apk differ
diff --git a/uni_modules/uni-installApk/changelog.md b/uni_modules/uni-installApk/changelog.md
new file mode 100644
index 0000000000000000000000000000000000000000..f6c958315f645b5da63f7296755c1493e57d5c20
--- /dev/null
+++ b/uni_modules/uni-installApk/changelog.md
@@ -0,0 +1,8 @@
+## 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的插件
diff --git a/uni_modules/uni-installApk/package.json b/uni_modules/uni-installApk/package.json
new file mode 100644
index 0000000000000000000000000000000000000000..c3889207923f11964792eb3bd7659e39427e6ab8
--- /dev/null
+++ b/uni_modules/uni-installApk/package.json
@@ -0,0 +1,93 @@
+{
+ "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
diff --git a/uni_modules/uni-installApk/readme.md b/uni_modules/uni-installApk/readme.md
new file mode 100644
index 0000000000000000000000000000000000000000..898834d79b542157a264adc6401bce2076c7768e
--- /dev/null
+++ b/uni_modules/uni-installApk/readme.md
@@ -0,0 +1,37 @@
+# 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
diff --git a/uni_modules/uni-installApk/utssdk/app-android/AndroidManifest.xml b/uni_modules/uni-installApk/utssdk/app-android/AndroidManifest.xml
new file mode 100644
index 0000000000000000000000000000000000000000..5cf3ce22599398429807a3305a5a549277079dc2
--- /dev/null
+++ b/uni_modules/uni-installApk/utssdk/app-android/AndroidManifest.xml
@@ -0,0 +1,5 @@
+
+
+
+
\ No newline at end of file
diff --git a/uni_modules/uni-installApk/utssdk/app-android/index.uts b/uni_modules/uni-installApk/utssdk/app-android/index.uts
new file mode 100644
index 0000000000000000000000000000000000000000..cfdef2ed5ce2368b42ad73e9152d2dadf2ddc9cb
--- /dev/null
+++ b/uni_modules/uni-installApk/utssdk/app-android/index.uts
@@ -0,0 +1,39 @@
+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
diff --git a/uni_modules/uni-installApk/utssdk/app-ios/index.uts b/uni_modules/uni-installApk/utssdk/app-ios/index.uts
new file mode 100644
index 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
diff --git a/uni_modules/uni-installApk/utssdk/interface.uts b/uni_modules/uni-installApk/utssdk/interface.uts
new file mode 100644
index 0000000000000000000000000000000000000000..35edfcd7eaeddfd4f192803385829389bac78689
--- /dev/null
+++ b/uni_modules/uni-installApk/utssdk/interface.uts
@@ -0,0 +1,76 @@
+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
diff --git a/uni_modules/uni-installApk/utssdk/unierror.uts b/uni_modules/uni-installApk/utssdk/unierror.uts
new file mode 100644
index 0000000000000000000000000000000000000000..a10c730d262388e3a2f945208c69f2cc66bee40c
--- /dev/null
+++ b/uni_modules/uni-installApk/utssdk/unierror.uts
@@ -0,0 +1,25 @@
+import { InstallApkErrorCode, InstallApkFail } from "./interface.uts"
+
+/**
+ * 错误主题
+ */
+export const UniErrorSubject = 'uni-installApk';
+/**
+ * 错误码
+ * @UniError
+ */
+export const UniErrors : Map = 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