mirror of
https://github.com/rive-app/rive-flutter.git
synced 2025-08-24 08:34:44 +08:00
Run tests with FFI.
This commit is contained in:
14
.github/workflows/tests.yaml
vendored
14
.github/workflows/tests.yaml
vendored
@ -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
|
||||
|
@ -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);
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user