watcher.dart 1.48 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
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import '../base/io.dart' show Process;

/// Callbacks for reporting progress while running tests.
8
abstract class TestWatcher {
9 10 11 12
  /// Called after a child process starts.
  ///
  /// If startPaused was true, the caller needs to resume in Observatory to
  /// start running the tests.
13
  void handleStartedProcess(ProcessEvent event) { }
14 15 16 17 18

  /// Called after the tests finish but before the process exits.
  ///
  /// The child process won't exit until this method completes.
  /// Not called if the process died.
19
  Future<void> handleFinishedTest(ProcessEvent event);
20 21

  /// Called when the test process crashed before connecting to test harness.
22
  Future<void> handleTestCrashed(ProcessEvent event);
23 24 25

  /// Called if we timed out waiting for the test process to connect to test
  /// harness.
26
  Future<void> handleTestTimedOut(ProcessEvent event);
27 28 29 30
}

/// Describes a child process started during testing.
class ProcessEvent {
31
  ProcessEvent(this.childIndex, this.process, [this.observatoryUri]);
32 33 34 35 36 37 38 39 40 41

  /// The index assigned when the child process was launched.
  ///
  /// Indexes are assigned consecutively starting from zero.
  /// When debugging, there should only be one child process so this will
  /// always be zero.
  final int childIndex;

  final Process process;

42
  /// The observatory URL or null if not debugging.
43 44
  final Uri observatoryUri;
}