smoke_web_engine_test.dart 1.53 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 8
import 'package:flutter_driver/flutter_driver.dart';
import 'package:test/test.dart' hide TypeMatcher, isInstanceOf;
9
import 'package:webdriver/async_io.dart';
10

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

17
    late FlutterDriver driver;
18 19 20 21 22 23 24 25

    // 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 {
26
      driver.close();
27 28 29 30 31
    });

    test('title is correct', () async {
      expect(await driver.getText(titleFinder), 'Hello, world!');
    });
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46

    test('enable accessibility', () async {
      await driver.enableAccessibility();

      await Future<void>.delayed(const Duration(seconds: 2));

      // Elements with tag "flt-semantics" would show up after enabling
      // accessibility.
      //
      // The tag used here is based on
      // https://github.com/flutter/engine/blob/master/lib/web_ui/lib/src/engine/semantics/semantics.dart#L534
      final WebElement element = await driver.webDriver.findElement(const By.tagName('flt-semantics'));

      expect(element, isNotNull);
    });
47 48
  });
}