debugger_stepping_test.dart 1.7 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5 6 7 8 9 10 11 12
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'package:file/file.dart';

import '../src/common.dart';
import 'test_data/stepping_project.dart';
import 'test_driver.dart';
import 'test_utils.dart';

void main() {
13
  late Directory tempDir;
14 15 16 17 18 19 20 21

  setUp(() async {
    tempDir = createResolvedTempDirectorySync('debugger_stepping_test.');
  });

  tearDown(() async {
    tryToDelete(tempDir);
  });
22

23
  testWithoutContext('can step over statements', () async {
24 25
    final SteppingProject project = SteppingProject();
    await project.setUpIn(tempDir);
26

27
    final FlutterRunTestDriver flutter = FlutterRunTestDriver(tempDir);
28

29 30 31
    await flutter.run(withDebugger: true, startPaused: true);
    await flutter.addBreakpoint(project.breakpointUri, project.breakpointLine);
    await flutter.resume(waitForNextPause: true); // Now we should be on the breakpoint.
32

33
    expect((await flutter.getSourceLocation())?.line, equals(project.breakpointLine));
34 35

    // Issue 5 steps, ensuring that we end up on the annotated lines each time.
36 37 38
    for (int i = 1; i <= project.numberOfSteps; i += 1) {
      await flutter.stepOverOrOverAsyncSuspension();
      final SourcePosition? location = await flutter.getSourceLocation();
39
      final int? actualLine = location?.line;
40 41 42

      // Get the line we're expected to stop at by searching for the comment
      // within the source code.
43
      final int expectedLine = project.lineForStep(i);
44 45 46 47 48 49

      expect(actualLine, equals(expectedLine),
        reason: 'After $i steps, debugger should stop at $expectedLine but stopped at $actualLine'
      );
    }

50
    await flutter.stop();
51
  });
52
}