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

refactor: 处理小程序兼容问题

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