smoke_web_engine_test.dart 1.55 KB
Newer Older
1 2 3 4
// Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

5 6
import 'dart:async';

7
import 'package:flutter_driver/flutter_driver.dart';
8
import 'package:test/test.dart';
9
import 'package:webdriver/async_io.dart';
10

11 12
// TODO(web): Migrate this test to a normal integration_test with a WidgetTester.

13
/// The following test is used as a simple smoke test for verifying Flutter
14 15 16 17 18
/// Framework and Flutter Web Engine integration.
void main() {
  group('Hello World App', () {
    final SerializableFinder titleFinder = find.byValueKey('title');

19
    late FlutterDriver driver;
20 21 22 23 24 25 26 27

    // Connect to the Flutter driver before running any tests.
    setUpAll(() async {
      driver = await FlutterDriver.connect();
    });

    // Close the connection to the driver after the tests have completed.
    tearDownAll(() async {
28
      driver.close();
29 30 31 32 33
    });

    test('title is correct', () async {
      expect(await driver.getText(titleFinder), 'Hello, world!');
    });
34 35

    test('enable accessibility', () async {
36
      await driver.setSemantics(true);
37

38
      // TODO(ianh): this delay violates our style guide. We should instead wait for a triggering event.
39 40
      await Future<void>.delayed(const Duration(seconds: 2));

41 42
      final WebElement? fltSemantics = await driver.webDriver.execute(
        'return document.querySelector("flt-glass-pane")?.shadowRoot.querySelector("flt-semantics")',
43
        <dynamic>[],
44 45
      ) as WebElement?;
      expect(fltSemantics, isNotNull);
46
    });
47 48
  });
}