dialog-page.test.js 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635
  1. jest.setTimeout(50000)
  2. const platformInfo = process.env.uniTestPlatformInfo.toLocaleLowerCase()
  3. const isWeb = platformInfo.startsWith('web')
  4. const isAndroid = platformInfo.startsWith('android')
  5. const isIos = platformInfo.startsWith('ios')
  6. const isMP = platformInfo.startsWith('mp')
  7. const isHarmony = platformInfo.startsWith('harmony')
  8. const isApp = isAndroid || isIos || isHarmony
  9. const isAppWebView = process.env.UNI_AUTOMATOR_APP_WEBVIEW == 'true'
  10. const FIRST_PAGE_PATH = '/pages/API/dialog-page/dialog-page'
  11. const NEXT_PAGE_PATH = '/pages/API/dialog-page/next-page'
  12. describe('dialog page', () => {
  13. if (isAppWebView || isMP) {
  14. it('not support', () => {
  15. expect(1).toBe(1)
  16. })
  17. return
  18. }
  19. let topSafeArea = 0;
  20. let page;
  21. let initLifeCycleNum;
  22. let lifecycleNum;
  23. beforeAll(async () => {
  24. const windowInfo = await program.callUniMethod('getWindowInfo');
  25. topSafeArea = windowInfo.safeAreaInsets.top;
  26. page = await program.reLaunch(FIRST_PAGE_PATH)
  27. await page.waitFor('view');
  28. initLifeCycleNum = await page.callMethod('getLifeCycleNum');
  29. await page.callMethod('setLifeCycleNum', 0)
  30. lifecycleNum = await page.callMethod('getLifeCycleNum')
  31. expect(lifecycleNum).toBe(0)
  32. });
  33. it('page pageBody safeAreaInsets', async () => {
  34. const pageBodyWidth = await page.$('#page-body-width')
  35. expect(parseInt(await pageBodyWidth.text())).toBeGreaterThan(0)
  36. const pageBodyHeight = await page.$('#page-body-height')
  37. expect(parseInt(await pageBodyHeight.text())).toBeGreaterThan(0)
  38. const pageBodyLeft = await page.$('#page-body-left')
  39. const pageBodyRight = await page.$('#page-body-right')
  40. const expectRightValue = parseInt(await pageBodyLeft.text()) + parseInt(await pageBodyWidth.text())
  41. expect(parseInt(await pageBodyRight.text())).toBe(expectRightValue)
  42. const pageBodyTop = await page.$('#page-body-top')
  43. const pageBodyBottom = await page.$('#page-body-bottom')
  44. const expectBottomValue = parseInt(await pageBodyTop.text()) + parseInt(await pageBodyHeight.text())
  45. expect(parseInt(await pageBodyBottom.text())).toBe(expectBottomValue)
  46. pageSafeAreaInsetsTop = await page.$('#page-safe-area-insets-top')
  47. if(isWeb){
  48. expect(await pageSafeAreaInsetsTop.text()).toBe('44')
  49. } else {
  50. expect(await pageSafeAreaInsetsTop.text()).toBe('0')
  51. }
  52. pageSafeAreaInsetsBottom = await page.$('#page-safe-area-insets-bottom')
  53. if(isWeb){
  54. expect(await pageSafeAreaInsetsBottom.text()).toBe('0')
  55. }
  56. if(isIos || isAndroid){
  57. expect(parseInt(await pageSafeAreaInsetsBottom.text())).toBeGreaterThanOrEqual(0)
  58. }
  59. pageSafeAreaInsetsLeft = await page.$('#page-safe-area-insets-left')
  60. expect(await pageSafeAreaInsetsLeft.text()).toBe('0')
  61. pageSafeAreaInsetsRight = await page.$('#page-safe-area-insets-right')
  62. expect(await pageSafeAreaInsetsRight.text()).toBe('0')
  63. const pageWidth = await page.$('#page-width')
  64. expect(parseInt(await pageWidth.text())).toBeGreaterThan(0)
  65. const pageHeight = await page.$('#page-height')
  66. expect(parseInt(await pageHeight.text())).toBeGreaterThan(0)
  67. const pageStatusBarHeight = await page.$('#page-statusBarHeight')
  68. expect(parseInt(await pageStatusBarHeight.text())).toBeGreaterThanOrEqual(0)
  69. })
  70. it('dialogPage pageBody safeAreaInsets', async () => {
  71. await page.callMethod('openDialogCheckMoreAttribute')
  72. await page.waitFor(1000)
  73. if (isWeb) {
  74. await page.waitFor(2000)
  75. }
  76. const image = await program.screenshot({
  77. deviceShot: true,
  78. area: {
  79. x: 0,
  80. y: topSafeArea + 44
  81. }
  82. });
  83. expect(image).toSaveImageSnapshot();
  84. await page.callMethod('closeDialog');
  85. lifecycleNum = await page.callMethod('getLifeCycleNum');
  86. expect(lifecycleNum).toBe(2);
  87. await page.callMethod('setLifeCycleNum', 0);
  88. })
  89. it('open dialog1', async () => {
  90. await page.callMethod('openDialog1');
  91. // 无法通过获取 dom 元素来判断是否打开了 dialogPage
  92. await page.waitFor(1000)
  93. if (isWeb) {
  94. await page.waitFor(2000)
  95. }
  96. const image = await program.screenshot({
  97. deviceShot: true,
  98. area: {
  99. x: 0,
  100. y: topSafeArea + 44
  101. }
  102. });
  103. expect(image).toSaveImageSnapshot();
  104. lifecycleNum = await page.callMethod('getLifeCycleNum')
  105. // 不应触发父页面的生命周期,应该触发:
  106. // 1. openDialogPage success & complete callback
  107. // 2. dialog page 生命周期
  108. expect(lifecycleNum).toBe(7)
  109. await page.callMethod('setLifeCycleNum', 0)
  110. const dialogPageRoute = await page.callMethod('getDialogPageRoute')
  111. expect(dialogPageRoute).toBe('pages/API/dialog-page/dialog-1')
  112. });
  113. it('check dialogPage methods', async () => {
  114. expect(await page.callMethod('dialogPageCheckGetDialogPages')).toBe(true)
  115. let dialogPageStyle = await page.callMethod('dialogPageGetPageStyle')
  116. expect(dialogPageStyle.backgroundColorContent).not.toBe('red')
  117. await page.callMethod('dialogPageSetPageStyle')
  118. dialogPageStyle = await page.callMethod('dialogPageGetPageStyle')
  119. expect(dialogPageStyle.backgroundColorContent).toBe('red')
  120. expect(await page.callMethod('dialogPageCheckGetElementById')).toBe(true)
  121. expect(await page.callMethod('dialogCheckGetAndroidView')).toBe(isAndroid)
  122. expect(await page.callMethod('dialogCheckGetIOSView')).toBe(false)
  123. expect(await page.callMethod('dialogCheckGetHTMLElement')).toBe(isWeb)
  124. })
  125. it('closeDialogPage', async () => {
  126. await page.callMethod('closeDialog');
  127. const image = await program.screenshot({
  128. deviceShot: true,
  129. area: {
  130. x: 0,
  131. y: topSafeArea + 44
  132. }
  133. });
  134. expect(image).toSaveImageSnapshot();
  135. // closeDialogPage success & complete callback 应被触发
  136. // dialogPage onUnload 应被触发
  137. lifecycleNum = await page.callMethod('getLifeCycleNum')
  138. expect(lifecycleNum).toBe(-3)
  139. await page.callMethod('setLifeCycleNum', 0)
  140. })
  141. it('openDialog with wrong path', async () => {
  142. await page.callMethod('openDialog1WrongPath')
  143. lifecycleNum = await page.callMethod('getLifeCycleNum')
  144. expect(lifecycleNum).toBe(-3)
  145. await page.callMethod('setLifeCycleNum', 0)
  146. })
  147. it('navigateTo nextPage & open Dialog', async () => {
  148. await page.callMethod('goNextPageOpenDialog1')
  149. await page.waitFor(2500)
  150. if (isWeb) {
  151. await page.waitFor(3000)
  152. }
  153. page = await program.currentPage()
  154. expect(page.path).toBe(NEXT_PAGE_PATH.substring(1))
  155. await page.waitFor(1000)
  156. if (isWeb) {
  157. await page.waitFor(2000)
  158. }
  159. const image = await program.screenshot({
  160. deviceShot: true,
  161. area: {
  162. x: 0,
  163. y: topSafeArea + 44
  164. }
  165. });
  166. expect(image).toSaveImageSnapshot();
  167. lifecycleNum = await page.callMethod('getLifeCycleNum')
  168. expect(lifecycleNum).toBe(-4)
  169. await page.callMethod('setLifeCycleNum', 0)
  170. })
  171. it('dialog1 navigateBack', async () => {
  172. await program.navigateBack()
  173. page = await program.currentPage()
  174. // dialogPage onBackPress 返回 true, 应可以拦截 navigateBack
  175. expect(page.path).toBe(NEXT_PAGE_PATH.substring(1))
  176. const image = await program.screenshot({
  177. deviceShot: true,
  178. area: {
  179. x: 0,
  180. y: topSafeArea + 44
  181. }
  182. });
  183. expect(image).toSaveImageSnapshot();
  184. lifecycleNum = await page.callMethod('getLifeCycleNum')
  185. // onBackPress 生命周期应该被触发
  186. expect(lifecycleNum).toBe(1)
  187. await page.callMethod('setLifeCycleNum', 0)
  188. })
  189. it('open dialog2', async () => {
  190. await page.callMethod('openDialog2')
  191. await page.waitFor(1000)
  192. if (isWeb) {
  193. await page.waitFor(2000)
  194. }
  195. lifecycleNum = await page.callMethod('getLifeCycleNum')
  196. // 应触发前一个 dialogPage 的 onHide
  197. expect(lifecycleNum).toBe(4)
  198. await page.callMethod('setLifeCycleNum', 0)
  199. })
  200. it('closeDialogPage', async () => {
  201. await page.callMethod('closeDialog')
  202. await page.waitFor(1000)
  203. lifecycleNum = await page.callMethod('getLifeCycleNum')
  204. // 应触发 success & complete 回调
  205. // 应触发 dialogPage 的 unload,下层的 dialogPage 会先 show 再 unload
  206. expect(lifecycleNum).toBe(-7)
  207. const image = await program.screenshot({
  208. deviceShot: true,
  209. area: {
  210. x: 0,
  211. y: topSafeArea + 44
  212. }
  213. });
  214. expect(image).toSaveImageSnapshot();
  215. await page.callMethod('setLifeCycleNum', 0)
  216. })
  217. it('open multiple dialog page', async () => {
  218. await page.callMethod('openDialog1')
  219. await page.waitFor(1000)
  220. if (isWeb) {
  221. await page.waitFor(2000)
  222. }
  223. const image1 = await program.screenshot({
  224. deviceShot: true,
  225. area: {
  226. x: 0,
  227. y: topSafeArea + 44
  228. }
  229. });
  230. expect(image1).toSaveImageSnapshot();
  231. lifecycleNum = await page.callMethod('getLifeCycleNum')
  232. expect(lifecycleNum).toBe(4)
  233. await page.callMethod('openDialog2')
  234. await page.waitFor(1000)
  235. if (isWeb) {
  236. await page.waitFor(2000)
  237. }
  238. const image2 = await program.screenshot({
  239. deviceShot: true,
  240. area: {
  241. x: 0,
  242. y: topSafeArea + 44
  243. }
  244. });
  245. expect(image2).toSaveImageSnapshot();
  246. lifecycleNum = await page.callMethod('getLifeCycleNum')
  247. expect(lifecycleNum).toBe(8)
  248. await page.callMethod('setLifeCycleNum', 0)
  249. })
  250. it('openDialogPage to home page', async () => {
  251. // 本测试例中是在 FIRST_PAGE_PATH 中打开
  252. await page.callMethod('openDialogPage1ToHomePage')
  253. await page.waitFor(1000)
  254. if (isWeb) {
  255. await page.waitFor(2000)
  256. }
  257. lifecycleNum = await page.callMethod('getLifeCycleNum')
  258. expect(lifecycleNum).toBe(4)
  259. await page.callMethod('setLifeCycleNum', 0)
  260. })
  261. it('dialog2 navigateBack', async () => {
  262. await program.navigateBack()
  263. page = await program.currentPage()
  264. expect(page.path).toBe(FIRST_PAGE_PATH.substring(1))
  265. const image = await program.screenshot({
  266. deviceShot: true,
  267. area: {
  268. x: 0,
  269. y: topSafeArea + 44
  270. }
  271. });
  272. expect(image).toSaveImageSnapshot();
  273. lifecycleNum = await page.callMethod('getLifeCycleNum')
  274. // dialogPage2 onBackPress +1 dialogPage1 show +1 dialogPage unload -5*2 firstPage show +10
  275. expect(lifecycleNum).toBe(2)
  276. await page.callMethod('setLifeCycleNum', 0)
  277. })
  278. it('close specified dialogPage', async () => {
  279. await page.callMethod('openDialog2')
  280. await page.waitFor(1000)
  281. if (isWeb) {
  282. await page.waitFor(2000)
  283. }
  284. const image1 = await program.screenshot({
  285. deviceShot: true,
  286. area: {
  287. x: 0,
  288. y: topSafeArea + 44
  289. }
  290. });
  291. expect(image1).toSaveImageSnapshot();
  292. lifecycleNum = await page.callMethod('getLifeCycleNum')
  293. expect(lifecycleNum).toBe(4)
  294. await page.callMethod('openDialog1')
  295. await page.waitFor(1000)
  296. if (isWeb) {
  297. await page.waitFor(2000)
  298. }
  299. const image2 = await program.screenshot({
  300. deviceShot: true,
  301. area: {
  302. x: 0,
  303. y: topSafeArea + 44
  304. }
  305. });
  306. expect(image2).toSaveImageSnapshot();
  307. lifecycleNum = await page.callMethod('getLifeCycleNum')
  308. expect(lifecycleNum).toBe(10)
  309. await page.callMethod('closeSpecifiedDialog', 0)
  310. const image3 = await program.screenshot({
  311. deviceShot: true,
  312. area: {
  313. x: 0,
  314. y: topSafeArea + 44
  315. }
  316. });
  317. expect(image3).toSaveImageSnapshot();
  318. lifecycleNum = await page.callMethod('getLifeCycleNum')
  319. expect(lifecycleNum).toBe(7)
  320. await page.callMethod('closeSpecifiedDialog', 1)
  321. const image4 = await program.screenshot({
  322. deviceShot: true,
  323. area: {
  324. x: 0,
  325. y: topSafeArea + 44
  326. }
  327. });
  328. expect(image4).toSaveImageSnapshot();
  329. lifecycleNum = await page.callMethod('getLifeCycleNum')
  330. expect(lifecycleNum).toBe(5)
  331. await page.callMethod('closeSpecifiedDialog', 0)
  332. const image5 = await program.screenshot({
  333. deviceShot: true,
  334. area: {
  335. x: 0,
  336. y: topSafeArea + 44
  337. }
  338. });
  339. expect(image5).toSaveImageSnapshot();
  340. lifecycleNum = await page.callMethod('getLifeCycleNum')
  341. expect(lifecycleNum).toBe(2)
  342. await page.callMethod('setLifeCycleNum', 0)
  343. })
  344. it('check triggerParentHide', async () => {
  345. // no triggerParentHide should not trigger parent hide
  346. await page.callMethod('openDialog4')
  347. await page.waitFor(1000)
  348. if (isWeb) {
  349. await page.waitFor(2000)
  350. }
  351. // dialog4 show +1
  352. expect(await page.callMethod('getLifeCycleNum')).toBe(1)
  353. await page.callMethod('closeDialog')
  354. await page.waitFor(200)
  355. // dialog4 unload -5 closeDialog callback +2
  356. expect(await page.callMethod('getLifeCycleNum')).toBe(-2)
  357. // triggerParentHide should trigger parent hide
  358. await page.callMethod('openDialogWithTriggerParentHide')
  359. await page.waitFor(1000)
  360. if (isWeb) {
  361. await page.waitFor(2000)
  362. }
  363. // openDialog callback +2 dialog4 show +1 parent hide -10
  364. expect(await page.callMethod('getLifeCycleNum')).toBe(-9)
  365. await page.callMethod('closeDialog')
  366. await page.waitFor(200)
  367. // dialog4 unload -5 parent show +10 closeDialog callback +2
  368. expect(await page.callMethod('getLifeCycleNum')).toBe(-2)
  369. // triggerParentHide should trigger parent hide
  370. await page.callMethod('openDialogWithTriggerParentHide')
  371. await page.waitFor(1000)
  372. if (isWeb) {
  373. await page.waitFor(2000)
  374. }
  375. // openDialog callback +2 dialog4 show +1 parent hide -10
  376. expect(await page.callMethod('getLifeCycleNum')).toBe(-9)
  377. // second triggerParentHide should not trigger parent hide
  378. await page.callMethod('openDialogWithTriggerParentHide')
  379. await page.waitFor(1000)
  380. if (isWeb) {
  381. await page.waitFor(2000)
  382. }
  383. // openDialog callback +2 dialog4 show +1
  384. expect(await page.callMethod('getLifeCycleNum')).toBe(-6)
  385. await page.callMethod('closeSpecifiedDialog', 1)
  386. await page.waitFor(200)
  387. // close not last triggerParentHide should not trigger parent show
  388. // close callback +2 dialog4 unload -5 dialog4 show +1
  389. expect(await page.callMethod('getLifeCycleNum')).toBe(-8)
  390. await page.callMethod('closeSpecifiedDialog', 0)
  391. await page.waitFor(200)
  392. // close last triggerParentHide should trigger parent show
  393. // close callback +2 dialog4 unload -5 parent show +10
  394. expect(await page.callMethod('getLifeCycleNum')).toBe(-1)
  395. // no triggerParentHide should not trigger parent hide
  396. await page.callMethod('openDialog4')
  397. await page.waitFor(1000)
  398. if (isWeb) {
  399. await page.waitFor(2000)
  400. }
  401. // dialog4 show +1
  402. expect(await page.callMethod('getLifeCycleNum')).toBe(0)
  403. // triggerParentHide should trigger parent hide
  404. await page.callMethod('openDialogWithTriggerParentHide')
  405. await page.waitFor(1000)
  406. if (isWeb) {
  407. await page.waitFor(2000)
  408. }
  409. // openDialog callback +2 dialog4 show +1 parent hide -10
  410. expect(await page.callMethod('getLifeCycleNum')).toBe(-7)
  411. // second triggerParentHide should not trigger parent hide
  412. await page.callMethod('openDialogWithTriggerParentHide')
  413. await page.waitFor(1000)
  414. if (isWeb) {
  415. await page.waitFor(2000)
  416. }
  417. // openDialog callback +2 dialog4 show +1
  418. expect(await page.callMethod('getLifeCycleNum')).toBe(-4)
  419. // close middle triggerParentHide dialogPage
  420. await page.callMethod('closeSpecifiedDialog', 1)
  421. await page.waitFor(200)
  422. // close callback +2 dialog4 unload -5
  423. expect(await page.callMethod('getLifeCycleNum')).toBe(-7)
  424. // close last triggerParentHide dialogPage shoud trigger parent show
  425. await page.callMethod('closeSpecifiedDialog', 1)
  426. await page.waitFor(200)
  427. // close callback +2 dialog4 unload -5 dialog4 show +1 parent show +10
  428. expect(await page.callMethod('getLifeCycleNum')).toBe(1)
  429. await page.callMethod('closeDialog')
  430. await page.waitFor(200)
  431. // close callback +2 dialog4 unload -5
  432. expect(await page.callMethod('getLifeCycleNum')).toBe(-2)
  433. })
  434. if (isApp) {
  435. it('after closeDialogPage reset statusBar color', async () => {
  436. const screenShotArea = {
  437. x: 342,
  438. y:18,
  439. width: 40,
  440. height: 20
  441. };
  442. if (isIos) {
  443. screenShotArea.x = 310
  444. screenShotArea.y = 20
  445. screenShotArea.width = 40
  446. screenShotArea.height = 20
  447. } else if (platformInfo.startsWith('android 6')) {
  448. screenShotArea.x = 204
  449. screenShotArea.width = 34
  450. screenShotArea.height = 16
  451. } else if (platformInfo.startsWith('android 12')) {
  452. screenShotArea.x = 336
  453. screenShotArea.y = 3
  454. screenShotArea.width = 50
  455. screenShotArea.height = 20
  456. } else if (isHarmony) {
  457. screenShotArea.x = 295
  458. screenShotArea.y = 14
  459. screenShotArea.width = 40
  460. screenShotArea.height = 20
  461. }
  462. const imageForParentInit = await program.screenshot({
  463. deviceShot: true,
  464. area: screenShotArea,
  465. });
  466. expect(imageForParentInit).toSaveImageSnapshot();
  467. await page.callMethod('openDialog4')
  468. await page.waitFor(1000)
  469. const imageForDialog4_1 = await program.screenshot({
  470. deviceShot: true,
  471. area: screenShotArea,
  472. });
  473. expect(imageForDialog4_1).toSaveImageSnapshot();
  474. await page.callMethod('openDialog3')
  475. await page.waitFor(1000)
  476. const imageForDialog3 = await program.screenshot({
  477. deviceShot: true,
  478. area: screenShotArea,
  479. });
  480. expect(imageForDialog3).toSaveImageSnapshot();
  481. await page.callMethod('closeSpecifiedDialog', 1)
  482. await page.waitFor(1000)
  483. const imageForDialog4_2 = await program.screenshot({
  484. deviceShot: true,
  485. area: screenShotArea,
  486. });
  487. expect(imageForDialog4_2).toSaveImageSnapshot();
  488. await page.callMethod('closeSpecifiedDialog', 0)
  489. await page.waitFor(1000)
  490. const imageForParentEnd = await program.screenshot({
  491. deviceShot: true,
  492. area: screenShotArea,
  493. });
  494. expect(imageForParentEnd).toSaveImageSnapshot();
  495. })
  496. }
  497. it('input-hold-keyboard in dialog', async () => {
  498. await page.callMethod('jest_OpenDialog1')
  499. await page.waitFor(2000);
  500. await page.callMethod('jest_getTapPoint')
  501. const point_x = await page.data('jest_click_x');
  502. const point_y = await page.data('jest_click_y');
  503. await program.tap({
  504. x: Math.round(point_x),
  505. y: Math.round(point_y)
  506. })
  507. await page.waitFor(1000);
  508. const image = await program.screenshot({
  509. deviceShot: true,
  510. area: {
  511. x: 0,
  512. y: topSafeArea + 44
  513. }
  514. })
  515. expect(image).toSaveImageSnapshot()
  516. await page.waitFor(2000);
  517. await page.callMethod('jest_CloseDialog1')
  518. })
  519. it('dialogPage hideStatusBar hideBottomNavigationIndicator', async () => {
  520. if (isAndroid) {
  521. await page.callMethod('openDialog2ForTest');
  522. await page.waitFor(1000);
  523. await page.callMethod('setPageStyleForTest', {
  524. hideStatusBar: true,
  525. hideBottomNavigationIndicator: true
  526. });
  527. await page.waitFor(2000);
  528. const image = await program.screenshot({
  529. deviceShot: true
  530. });
  531. expect(image).toSaveImageSnapshot();
  532. await page.waitFor(2000);
  533. await page.callMethod('closeDialog2ForTest');
  534. await page.waitFor(1000);
  535. await page.callMethod('setPageStyleForTest2', {
  536. hideStatusBar: true,
  537. hideBottomNavigationIndicator: true
  538. });
  539. await page.waitFor(1000);
  540. await page.callMethod('openDialog2ForTest');
  541. await page.waitFor(1000);
  542. await page.callMethod('closeDialog2ForTest');
  543. await page.waitFor(1000);
  544. const image2 = await program.screenshot({
  545. deviceShot: true
  546. });
  547. expect(image2).toSaveImageSnapshot();
  548. }
  549. });
  550. if (isAndroid) {
  551. it('dialogPage androidThreeButtonNavigationTranslucent', async () => {
  552. await page.callMethod('openDialog2ForTest');
  553. await page.waitFor(1000);
  554. await page.callMethod('setPageStyleForTest', {
  555. androidThreeButtonNavigationTranslucent: false
  556. });
  557. await page.waitFor(2000);
  558. const image = await program.screenshot({
  559. deviceShot: true
  560. });
  561. expect(image).toSaveImageSnapshot();
  562. await page.waitFor(2000);
  563. await page.callMethod('closeDialog2ForTest');
  564. });
  565. }
  566. if ('open dialogPage with relative path', async () => {
  567. await page.callMethod('closeDialog')
  568. await page.waitFor(1000);
  569. await page.callMethod('setLifeCycleNum', 0)
  570. await page.callMethod('openDialogWithRelativePath');
  571. await page.waitFor(1000);
  572. if (isWeb) {
  573. await page.waitFor(2000);
  574. }
  575. lifecycleNum = await page.callMethod('getLifeCycleNum')
  576. expect(lifecycleNum).toBe(6)
  577. await page.callMethod('setLifeCycleNum', 0)
  578. })
  579. afterAll(async () => {
  580. await page.callMethod('setLifeCycleNum', initLifeCycleNum)
  581. });
  582. });