• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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:isolate';
6import 'dart:ui';
7
8void main() {
9}
10
11@pragma('vm:entry-point')
12void sayHi() {
13  print('Hi');
14}
15
16@pragma('vm:entry-point')
17void throwExceptionNow() {
18  throw 'Hello';
19}
20
21@pragma('vm:entry-point')
22void canRegisterNativeCallback() async {
23  print('In function canRegisterNativeCallback');
24  notifyNative();
25  print('Called native method from canRegisterNativeCallback');
26}
27
28void notifyNative() native 'NotifyNative';
29
30@pragma('vm:entry-point')
31void testIsolateShutdown() {  }
32
33@pragma('vm:entry-point')
34void testCanSaveCompilationTrace() {
35  List<int> trace;
36  try {
37    trace = saveCompilationTrace();
38  } catch (exception) {
39    print('Could not save compilation trace: ' + exception);
40  }
41  notifyResult(trace != null && trace.isNotEmpty);
42}
43
44void notifyResult(bool success) native 'NotifyNative';
45void passMessage(String message) native 'PassMessage';
46
47void secondaryIsolateMain(String message) {
48  print('Secondary isolate got message: ' + message);
49  passMessage('Hello from code is secondary isolate.');
50  notifyNative();
51}
52
53@pragma('vm:entry-point')
54void testCanLaunchSecondaryIsolate() {
55  Isolate.spawn(secondaryIsolateMain, 'Hello from root isolate.');
56  notifyNative();
57}
58
59@pragma('vm:entry-point')
60void testCanRecieveArguments(List<String> args) {
61  notifyResult(args != null && args.length == 1 && args[0] == 'arg1');
62}
63