blob: d5c7234cad731dacdc1fc154aab79c77f5e4c57b [file] [log] [blame]
// Copyright 2017 The Fuchsia Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'dart:async';
import 'dart:io' as io;
import 'package:fidl_fuchsia_examples_hello/fidl.dart';
import '';
import 'package:fidl_fuchsia_sys/fidl.dart';
import 'package:test/test.dart';
void main(List<String> args) {
final StartupContext context = StartupContext.fromStartupInfo();
// TODO(rosswang): nested environments and determinism
test('schedule delayed futures',
() => Future<Null>.delayed(const Duration(seconds: 1)));
test('start hello_dart', () {
const LaunchInfo info = LaunchInfo(
context.launcher.createComponent(info, null);
test('communicate with a fidl service (hello_app_dart)', () async {
final Services services = Services();
final HelloProxy service = HelloProxy();
final ComponentControllerProxy actl = ComponentControllerProxy();
final LaunchInfo info = LaunchInfo(
directoryRequest: services.request());
context.launcher.createComponent(info, actl.ctrl.request());
// TODO(rosswang): let's see if we can generate a future-based fidl dart
final Completer<String> hello = Completer<String>();
service.say('hello', hello.complete);
expect(await hello.future, equals('hola from Dart!'));
expect(service.ctrl.error.timeout(const Duration(seconds: 2)),
test('dart:io exit() throws UnsupportedError', () {
expect(() => io.exit(-1), throwsUnsupportedError);