1// Copyright 2013 The Flutter Authors. All rights reserved. 2// Use of this source code is governed by a BSD-style license that can be 3// found in the LICENSE file. 4 5import 'dart:async'; 6import 'dart:io' as io; 7 8import 'package:fidl_fuchsia_examples_hello/fidl_async.dart'; 9import 'package:fidl_fuchsia_io/fidl_async.dart'; 10import 'package:fidl_fuchsia_sys/fidl_async.dart'; 11import 'package:fuchsia_services/services.dart'; 12import 'package:test/test.dart'; 13 14void main(List<String> args) { 15 final StartupContext context = StartupContext.fromStartupInfo(); 16 LauncherProxy launcher; 17 18 setUp(() { 19 launcher = LauncherProxy(); 20 context.incoming.connectToService(launcher); 21 }); 22 23 tearDown(() { 24 launcher.ctrl.close(); 25 launcher = null; 26 }); 27 28 // TODO(rosswang): nested environments and determinism 29 30 test('schedule delayed futures', 31 () => Future<Null>.delayed(const Duration(seconds: 1))); 32 33 test('start hello_dart', () async { 34 const LaunchInfo info = LaunchInfo( 35 url: 36 'fuchsia-pkg://fuchsia.com/hello_dart_jit#meta/hello_dart_jit.cmx'); 37 await launcher.createComponent( 38 info, ComponentControllerProxy().ctrl.request()); 39 }); 40 41 test('communicate with a fidl service (hello_app_dart)', () async { 42 final HelloProxy service = HelloProxy(); 43 final dirProxy = DirectoryProxy(); 44 45 final ComponentControllerProxy actl = ComponentControllerProxy(); 46 47 final LaunchInfo info = LaunchInfo( 48 url: 49 'fuchsia-pkg://fuchsia.com/hello_app_dart_jit#meta/hello_app_dart_jit.cmx', 50 directoryRequest: dirProxy.ctrl.request().passChannel()); 51 await launcher.createComponent(info, actl.ctrl.request()); 52 Incoming(dirProxy).connectToService(service); 53 54 expect(await service.say('hello'), equals('hola from Dart!')); 55 56 actl.ctrl.close(); 57 }); 58 59 test('dart:io exit() throws UnsupportedError', () { 60 expect(() => io.exit(-1), throwsUnsupportedError); 61 }); 62} 63