| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 library mojo_apptest; | 5 library mojo_apptest; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:mojo/application.dart'; | 9 import 'package:mojo/application.dart'; |
| 10 import 'package:mojo/bindings.dart'; | 10 import 'package:mojo/bindings.dart'; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 // call from the shell. We need to first have a valid connection to the shell | 29 // call from the shell. We need to first have a valid connection to the shell |
| 30 // so that apptests can connect to other applications. | 30 // so that apptests can connect to other applications. |
| 31 void initialize(List<String> args, String url) { | 31 void initialize(List<String> args, String url) { |
| 32 group('dart_apptests', () { | 32 group('dart_apptests', () { |
| 33 setUp(testSetUp); | 33 setUp(testSetUp); |
| 34 tearDown(testTearDown); | 34 tearDown(testTearDown); |
| 35 for (var testFunction in _testFunctions) { | 35 for (var testFunction in _testFunctions) { |
| 36 testFunction(this, url); | 36 testFunction(this, url); |
| 37 } | 37 } |
| 38 }); | 38 }); |
| 39 // Append a final test to terminate shell connection. | 39 |
| 40 // TODO(johnmccutchan): Remove this once package 'test' supports a global | 40 tearDownAll(() async { |
| 41 // tearDown callback. | |
| 42 test('TERMINATE SHELL CONNECTION', () async { | |
| 43 await close(); | 41 await close(); |
| 44 MojoHandle.reportLeakedHandles(); | 42 MojoHandle.reportLeakedHandles(); |
| 45 }); | 43 }); |
| 46 } | 44 } |
| 47 | 45 |
| 48 void testSetUp() {} | 46 void testSetUp() {} |
| 49 | 47 |
| 50 Future testTearDown() async { | 48 Future testTearDown() async { |
| 51 // Reset any connections between tests. | 49 // Reset any connections between tests. |
| 52 await resetConnections(); | 50 await resetConnections(); |
| 53 } | 51 } |
| 54 } | 52 } |
| 55 | 53 |
| 56 /// The public interface to apptests. | 54 /// The public interface to apptests. |
| 57 /// | 55 /// |
| 58 /// In a dart mojo application, [incomingHandle] is `args[0]`. [testFunctions] | 56 /// In a dart mojo application, [incomingHandle] is `args[0]`. [testFunctions] |
| 59 /// is list of [AppTestFunction]. Each function will be passed the application | 57 /// is list of [AppTestFunction]. Each function will be passed the application |
| 60 /// and url. | 58 /// and url. |
| 61 runAppTests(var incomingHandle, List<AppTestFunction> testFunctions) { | 59 runAppTests(var incomingHandle, List<AppTestFunction> testFunctions) { |
| 62 var appHandle = new MojoHandle(incomingHandle); | 60 var appHandle = new MojoHandle(incomingHandle); |
| 63 var application = | 61 var application = |
| 64 new _ConnectionToShellApplication.fromHandle(appHandle, testFunctions); | 62 new _ConnectionToShellApplication.fromHandle(appHandle, testFunctions); |
| 65 | 63 |
| 66 /// [Application]'s [initialize] will be called. | 64 /// [Application]'s [initialize] will be called. |
| 67 } | 65 } |
| OLD | NEW |