Run tests with FFI.

This commit is contained in:
Luigi Rosso
2022-10-25 15:47:42 -07:00
parent 5d94a3b89c
commit f6ffb0b980
2 changed files with 42 additions and 3 deletions

View File

@ -5,7 +5,7 @@ on:
jobs:
build:
runs-on: ubuntu-latest
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
@ -24,5 +24,15 @@ jobs:
flutter channel stable
flutter doctor
- name: Build WASM
run: |
cd wasm
./build_wasm.sh release
- name: Build Shared Lib
run: |
cd shared_lib
./build_shared.sh
- name: Run tests
run: flutter test
run: flutter test

View File

@ -5,7 +5,7 @@ import 'package:rive/src/rive_text.dart';
import 'src/utils.dart';
void main() {
test('simple shaping', () {
test('text shaping works', () {
final bytes = loadFile('assets/RobotoFlex.ttf');
expect(bytes.lengthInBytes, 1654412);
@ -13,5 +13,34 @@ void main() {
var roboto = Font.decode(bytes.buffer.asUint8List());
expect(roboto, isNotNull);
var text = 'ffi test';
var runs = [
TextRun(
font: roboto!,
fontSize: 32.0,
unicharCount: text.length,
styleId: 0,
)
];
var result = runs.first.font.shape(text, runs);
expect(result.paragraphs.length, 1);
expect(result.paragraphs.first.runs.length, 1);
var glyphRun = result.paragraphs.first.runs.first;
// ffi gets ligated as a single glyph
expect(glyphRun.glyphCount, 6);
expect(glyphRun.textIndexAt(0), 0); // ffi
expect(glyphRun.textIndexAt(1), 3); // space after ffi
var breakLinesResult = result.breakLines(60, TextAlign.left);
expect(breakLinesResult.length, 1); // 1 paragraph
expect(breakLinesResult.first.length, 2); // 2 lines in the paragraph
// first line shows first glyph on the left
expect(breakLinesResult.first.first.startIndex, 0);
// second line shows third glyph on the left, which is the start of 'test'
expect(breakLinesResult.first[1].startIndex, 2);
});
}