| // Copyright 2013 The Flutter 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:io' as io; |
| import 'dart:ui' as ui; |
| |
| // Signals a waiting latch in the native test. |
| void signal() native 'Signal'; |
| |
| // Signals a waiting latch in the native test, passing a boolean value. |
| void signalBoolValue(bool value) native 'SignalBoolValue'; |
| |
| // Signals a waiting latch in the native test, passing a string value. |
| void signalStringValue(String value) native 'SignalStringValue'; |
| |
| // Signals a waiting latch in the native test, which returns a value to the fixture. |
| bool signalBoolReturn() native 'SignalBoolReturn'; |
| |
| // Notify the native test that the first frame has been scheduled. |
| void notifyFirstFrameScheduled() native 'NotifyFirstFrameScheduled'; |
| |
| void main() { |
| } |
| |
| @pragma('vm:entry-point') |
| void customEntrypoint() { |
| } |
| |
| @pragma('vm:entry-point') |
| void verifyNativeFunction() { |
| signal(); |
| } |
| |
| @pragma('vm:entry-point') |
| void verifyNativeFunctionWithParameters() { |
| signalBoolValue(true); |
| } |
| |
| @pragma('vm:entry-point') |
| void verifyNativeFunctionWithReturn() { |
| bool value = signalBoolReturn(); |
| signalBoolValue(value); |
| } |
| |
| @pragma('vm:entry-point') |
| void readPlatformExecutable() { |
| signalStringValue(io.Platform.executable); |
| } |
| |
| @pragma('vm:entry-point') |
| void drawHelloWorld() { |
| ui.PlatformDispatcher.instance.onBeginFrame = (Duration duration) { |
| final ui.ParagraphBuilder paragraphBuilder = ui.ParagraphBuilder(ui.ParagraphStyle()) |
| ..addText('Hello world'); |
| final ui.Paragraph paragraph = paragraphBuilder.build(); |
| |
| paragraph.layout(const ui.ParagraphConstraints(width: 800.0)); |
| |
| final ui.PictureRecorder recorder = ui.PictureRecorder(); |
| final ui.Canvas canvas = ui.Canvas(recorder); |
| |
| canvas.drawParagraph(paragraph, ui.Offset.zero); |
| |
| final ui.Picture picture = recorder.endRecording(); |
| final ui.SceneBuilder sceneBuilder = ui.SceneBuilder() |
| ..addPicture(ui.Offset.zero, picture) |
| ..pop(); |
| |
| ui.window.render(sceneBuilder.build()); |
| }; |
| |
| ui.PlatformDispatcher.instance.scheduleFrame(); |
| notifyFirstFrameScheduled(); |
| } |