Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(873)

Unified Diff: mojo/public/dart/third_party/test/lib/src/runner/browser/iframe_test.dart

Issue 1346773002: Stop running pub get at gclient sync time and fix build bugs (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: mojo/public/dart/third_party/test/lib/src/runner/browser/iframe_test.dart
diff --git a/mojo/public/dart/third_party/test/lib/src/runner/browser/iframe_test.dart b/mojo/public/dart/third_party/test/lib/src/runner/browser/iframe_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..034164563d73d55a22146a6de6bb71cb9ab3e6ab
--- /dev/null
+++ b/mojo/public/dart/third_party/test/lib/src/runner/browser/iframe_test.dart
@@ -0,0 +1,80 @@
+// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library test.runner.browser.iframe_test;
+
+import '../../backend/live_test.dart';
+import '../../backend/live_test_controller.dart';
+import '../../backend/metadata.dart';
+import '../../backend/state.dart';
+import '../../backend/suite.dart';
+import '../../backend/test.dart';
+import '../../util/multi_channel.dart';
+import '../../util/remote_exception.dart';
+import '../../util/stack_trace_mapper.dart';
+
+/// A test in a running iframe.
+class IframeTest implements Test {
+ final String name;
+ final Metadata metadata;
+
+ /// The mapper used to map stack traces for errors coming from this test, or
+ /// `null`.
+ final StackTraceMapper _mapper;
+
+ /// The channel used to communicate with the test's [IframeListener].
+ final MultiChannel _channel;
+
+ IframeTest(this.name, this.metadata, this._channel, {StackTraceMapper mapper})
+ : _mapper = mapper;
+
+ LiveTest load(Suite suite) {
+ var controller;
+ var testChannel;
+ controller = new LiveTestController(suite, this, () {
+ controller.setState(const State(Status.running, Result.success));
+
+ testChannel = _channel.virtualChannel();
+ _channel.sink.add({
+ 'command': 'run',
+ 'channel': testChannel.id
+ });
+
+ testChannel.stream.listen((message) {
+ if (message['type'] == 'error') {
+ var asyncError = RemoteException.deserialize(message['error']);
+
+ var stackTrace = asyncError.stackTrace;
+ if (_mapper != null) stackTrace = _mapper.mapStackTrace(stackTrace);
+
+ controller.addError(asyncError.error, stackTrace);
+ } else if (message['type'] == 'state-change') {
+ controller.setState(
+ new State(
+ new Status.parse(message['status']),
+ new Result.parse(message['result'])));
+ } else if (message['type'] == 'print') {
+ controller.print(message['line']);
+ } else {
+ assert(message['type'] == 'complete');
+ controller.completer.complete();
+ }
+ });
+ }, () {
+ // Ignore all future messages from the test and complete it immediately.
+ // We don't need to tell it to run its tear-down because there's nothing a
+ // browser test needs to clean up on the file system anyway.
+ testChannel.sink.close();
+ if (!controller.completer.isCompleted) controller.completer.complete();
+ });
+ return controller.liveTest;
+ }
+
+ Test change({String name, Metadata metadata}) {
+ if (name == name && metadata == this.metadata) return this;
+ if (name == null) name = this.name;
+ if (metadata == null) metadata = this.metadata;
+ return new IframeTest(name, metadata, _channel);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698