debugger_stepping_web_test.dart 2 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
// @dart = 2.8

7 8 9 10
import 'dart:io';

import 'package:file/file.dart';

11 12 13
import '../integration.shard/test_data/stepping_project.dart';
import '../integration.shard/test_driver.dart';
import '../integration.shard/test_utils.dart';
14 15 16 17 18 19 20 21 22 23
import '../src/common.dart';

void main() {
  Directory tempDirectory;
  FlutterRunTestDriver flutter;

  setUp(() {
    tempDirectory = createResolvedTempDirectorySync('debugger_stepping_test.');
  });

24
  testWithoutContext('Web debugger can step over statements', () async {
25 26 27 28 29
    final WebSteppingProject _project = WebSteppingProject();
    await _project.setUpIn(tempDirectory);

    flutter = FlutterRunTestDriver(tempDirectory);

30 31 32
    await flutter.run(
      withDebugger: true, startPaused: true, chrome: true,
      additionalCommandArgs: <String>['--verbose']);
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
    await flutter.addBreakpoint(_project.breakpointUri, _project.breakpointLine);
    await flutter.resume();
    await flutter.waitForPause(); // Now we should be on the breakpoint.

    expect((await flutter.getSourceLocation()).line, equals(_project.breakpointLine));

    // Issue 5 steps, ensuring that we end up on the annotated lines each time.
    for (int i = 1; i <= _project.numberOfSteps; i += 1) {
      await flutter.stepOverOrOverAsyncSuspension();
      final SourcePosition location = await flutter.getSourceLocation();
      final int actualLine = location.line;

      // Get the line we're expected to stop at by searching for the comment
      // within the source code.
      final int expectedLine = _project.lineForStep(i);

      expect(actualLine, equals(expectedLine),
        reason: 'After $i steps, debugger should stop at $expectedLine but stopped at $actualLine'
      );
    }
53
  }, skip: platform.isWindows); // https://github.com/flutter/flutter/issues/70486
54 55 56 57 58 59

  tearDown(() async {
    await flutter.stop();
    tryToDelete(tempDirectory);
  });
}