diff --git a/pages.json b/pages.json index f350052c3ece2abd3ea37e185cb858160716067b..0db6cc829cb3d21ff76a54c0155338ba34091254 100644 --- a/pages.json +++ b/pages.json @@ -1091,6 +1091,15 @@ "navigationBarTitleText": "createSelectorQuery | 创建 SelectorQuery 实例" } }, + // #ifdef APP-IOS + { + "path": "pages/API/create-canvas-context-async/create-canvas-context-async", + "group": "1,3,2", + "style": { + "navigationBarTitleText": "createCanvasContextAsync | 创建 Canvas 实例" + } + }, + // #endif { "path": "pages/API/resize-observer/resize-observer", "group": "1,30", @@ -2084,6 +2093,10 @@ { "id": "api.dom.createSelectorQuery", "name": "createSelectorQuery" + }, + { + "id": "api.dom.createCanvasContextAsync", + "name": "createCanvasContextAsync" } ] }, diff --git a/pages/API/create-canvas-context-async/child-canvas.uvue b/pages/API/create-canvas-context-async/child-canvas.uvue new file mode 100644 index 0000000000000000000000000000000000000000..3b76215d7c7b6b02ec0ebdf48a9866a2f1eff6f3 --- /dev/null +++ b/pages/API/create-canvas-context-async/child-canvas.uvue @@ -0,0 +1,44 @@ + + + diff --git a/pages/API/create-canvas-context-async/create-canvas-context-async.test.js b/pages/API/create-canvas-context-async/create-canvas-context-async.test.js new file mode 100644 index 0000000000000000000000000000000000000000..7eef070df8d1d15038a8fdaf0f8b7d86cdf8428c --- /dev/null +++ b/pages/API/create-canvas-context-async/create-canvas-context-async.test.js @@ -0,0 +1,32 @@ +const PAGE_PATH = '/pages/API/create-canvas-context-async/create-canvas-context-async' + +describe('create-canvas-context-async', () => { + if (!process.env.uniTestPlatformInfo.toLowerCase().startsWith('ios')) { + it('ios only', () => { + expect(1).toBe(1) + }) + return + } + let page + beforeAll(async () => { + page = await program.reLaunch(PAGE_PATH) + await page.waitFor('view') + }) + + it('page canvas', async () => { + await page.waitFor(100) + const data = await page.callMethod('getContext') + expect(data.ctx).toBe('object') + expect(data.hasFillRect).toBe(true) + }) + + it('component canvas', async () => { + // child-canvas + await page.waitFor(100) + // const element = await page.$('.node-child-component') + const element = await page.$('child-canvas') + const data = await page.callMethod('getContext') + expect(data.ctx).toBe('object') + expect(data.hasFillRect).toBe(true) + }) +}) diff --git a/pages/API/create-canvas-context-async/create-canvas-context-async.uvue b/pages/API/create-canvas-context-async/create-canvas-context-async.uvue new file mode 100644 index 0000000000000000000000000000000000000000..9805decfae6ab2d7c7101fb65aebf786ba48b749 --- /dev/null +++ b/pages/API/create-canvas-context-async/create-canvas-context-async.uvue @@ -0,0 +1,55 @@ + + +