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

refactor: 处理小程序兼容问题

上级 70b54085
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
isWeixin = platformInfo == 'mp-weixin' const isMP = platformInfo.startsWith('mp')
describe('dialog page', () => { describe('dialog page', () => {
if (process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') { if (process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true') {
...@@ -8,8 +8,8 @@ describe('dialog page', () => { ...@@ -8,8 +8,8 @@ describe('dialog page', () => {
}) })
return return
} }
if (isWeixin) { if (isMP) {
it('skip app-webview', () => { it('skip mp', () => {
expect(1).toBe(1) expect(1).toBe(1)
}) })
return return
......
...@@ -3,6 +3,7 @@ jest.setTimeout(20000) ...@@ -3,6 +3,7 @@ jest.setTimeout(20000)
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isWeb = platformInfo.startsWith('web') const isWeb = platformInfo.startsWith('web')
const isAndroid = platformInfo.startsWith('android') const isAndroid = platformInfo.startsWith('android')
const isMP = platformInfo.startsWith('mp')
const FIRST_PAGE_PATH = '/pages/API/dialog-page/dialog-page' const FIRST_PAGE_PATH = '/pages/API/dialog-page/dialog-page'
const NEXT_PAGE_PATH = '/pages/API/dialog-page/next-page' const NEXT_PAGE_PATH = '/pages/API/dialog-page/next-page'
...@@ -13,6 +14,12 @@ describe('dialog page', () => { ...@@ -13,6 +14,12 @@ describe('dialog page', () => {
}) })
return return
} }
if (isMP) {
it('skip mp', () => {
expect(1).toBe(1)
})
return
}
let page; let page;
let initLifeCycleNum; let initLifeCycleNum;
......
const PAGE_PATH = '/pages/API/get-app/get-app' const PAGE_PATH = '/pages/API/get-app/get-app'
const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase() const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
const isAndroid = platformInfo.startsWith('android') const isAndroid = platformInfo.startsWith('android')
const isMP = platformInfo.startsWith('mp')
describe('getApp', () => { describe('getApp', () => {
let page = null let page = null
...@@ -49,8 +50,10 @@ describe('getApp', () => { ...@@ -49,8 +50,10 @@ describe('getApp', () => {
expect(newLifeCycleNum - oldLifeCycleNum).toBe(100) expect(newLifeCycleNum - oldLifeCycleNum).toBe(100)
await page.callMethod('setLifeCycleNum', oldLifeCycleNum) await page.callMethod('setLifeCycleNum', oldLifeCycleNum)
}) })
if (!isMP) {
it('getAndroidApplication', async () => { it('getAndroidApplication', async () => {
const res = await page.callMethod('getAndroidApplication') const res = await page.callMethod('getAndroidApplication')
expect(res).toBe(isAndroid) expect(res).toBe(isAndroid)
}) })
}
}) })
...@@ -39,10 +39,12 @@ ...@@ -39,10 +39,12 @@
increase lifeCycleNum increase lifeCycleNum
</button> </button>
<text class="uni-common-mt">lifeCycleNum: {{ lifeCycleNum }}</text> <text class="uni-common-mt">lifeCycleNum: {{ lifeCycleNum }}</text>
<!-- #ifndef MP -->
<button class="uni-common-mt" @click="getAndroidApplication"> <button class="uni-common-mt" @click="getAndroidApplication">
getAndroidApplication getAndroidApplication
</button> </button>
<text class="uni-common-mt">androidApplication is null: {{ androidApplication == null }}</text> <text class="uni-common-mt">androidApplication is null: {{ androidApplication == null }}</text>
<!-- #endif -->
</view> </view>
</view> </view>
<!-- #ifdef APP --> <!-- #ifdef APP -->
...@@ -173,11 +175,13 @@ ...@@ -173,11 +175,13 @@
setLifeCycleNum(num : number) { setLifeCycleNum(num : number) {
setLifeCycleNum(num) setLifeCycleNum(num)
}, },
// #ifndef MP
getAndroidApplication() : boolean { getAndroidApplication() : boolean {
const app = getApp() const app = getApp()
this.androidApplication = app.getAndroidApplication() this.androidApplication = app.getAndroidApplication()
return this.androidApplication !== null return this.androidApplication !== null
} }
// #endif
}, },
} }
</script> </script>
......
...@@ -93,12 +93,12 @@ ...@@ -93,12 +93,12 @@
} }
}, },
onLoad(options : OnLoadOptions) { onLoad(options : OnLoadOptions) {
// #ifndef APP-ANDROID // #ifdef APP-IOS || WEB
if (options instanceof UTSJSONObject) { if (options instanceof UTSJSONObject) {
this.checked = true this.checked = true
} }
// #endif // #endif
// #ifdef APP-ANDROID // #ifndef APP-IOS || WEB
this.checked = true this.checked = true
// #endif // #endif
this.getPageStyle(); this.getPageStyle();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册