1/**
2 * Copyright 2018 Google Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *     http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17import expect from 'expect';
18import {
19  getTestState,
20  setupTestBrowserHooks,
21  setupTestPageAndContextHooks,
22  describeFailsFirefox,
23} from './mocha-utils'; // eslint-disable-line import/extensions
24
25describe('Touchscreen', function () {
26  setupTestBrowserHooks();
27  setupTestPageAndContextHooks();
28
29  it('should tap the button', async () => {
30    const { puppeteer, page, server } = getTestState();
31    const iPhone = puppeteer.devices['iPhone 6'];
32    await page.emulate(iPhone);
33    await page.goto(server.PREFIX + '/input/button.html');
34    await page.tap('button');
35    expect(await page.evaluate(() => globalThis.result)).toBe('Clicked');
36  });
37  it('should report touches', async () => {
38    const { puppeteer, page, server } = getTestState();
39    const iPhone = puppeteer.devices['iPhone 6'];
40    await page.emulate(iPhone);
41    await page.goto(server.PREFIX + '/input/touches.html');
42    const button = await page.$('button');
43    await button.tap();
44    expect(await page.evaluate(() => globalThis.getResult())).toEqual([
45      'Touchstart: 0',
46      'Touchend: 0',
47    ]);
48  });
49});
50