mirror of
https://github.com/flutter/flutter.git
synced 2026-02-03 17:51:05 +08:00
git log 7e3b41dc7ba6..74e68ff8b108 --no-merges --oneline 74e68ff8b Roll src/third_party/skia 7b7805581733..66a973493468 (4 commits) (#6436) 58fbd1fd1 Roll src/third_party/skia 4442e3138927..7b7805581733 (1 commits) (#6435) 83151d9fc Roll src/third_party/skia 4dd17156c6e4..4442e3138927 (1 commits) (#6434) 5fe7e377d Roll src/third_party/skia 8841085abeb9..4dd17156c6e4 (1 commits) (#6432) 5340f4224 Revert "Use single_root_scheme when compiling platform (#6402)" (#6431) 37fd43d43 Add deadline_now_delta argument to Engine::NotifyIdle's trace (#6419) 4af077b29 Roll src/third_party/skia 4504a652c071..8841085abeb9 (1 commits) (#6429) 165f3dd1c Update //third_party/benchmark dependency to 21f1eb (ToT). (#6427) 34bd0ef87 Don’t build benchmarking binaries on Windows. (#6428) ae4db4469 Ensure setViewIdResourceName has the correct version guard (#6404) 2c5d0c407 [rapidjson] Fix import statements (#6418) c2128fc80 Create a benchmarking target for the shell. (#6420) 30f78af91 Raise errors on non-zero exits while creating artifacts on the bots. (#6424) 191168cec Disable line_height tests on Windows (#6423) 061cc6643 Fix ideographic baseline to match spec. (#6422) 74eac1f56 Roll src/third_party/skia bfa76f20bfcf..4504a652c071 (14 commits) (#6421) 10b45405b Implement ParagraphStyle.line_height and add tests for line_height and baselines. (#6417)
63 lines
2.4 KiB
Dart
63 lines
2.4 KiB
Dart
// Copyright 2018 The Chromium 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:ui';
|
|
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
|
|
void main() {
|
|
// Ahem font uses a constant ideographic/alphabetic baseline ratio.
|
|
const double kAhemBaselineRatio = 1.25;
|
|
|
|
test('predictably lays out a single-line paragraph', () {
|
|
for (double fontSize in <double>[10.0, 20.0, 30.0, 40.0]) {
|
|
final ParagraphBuilder builder = ParagraphBuilder(ParagraphStyle(
|
|
fontFamily: 'Ahem',
|
|
fontStyle: FontStyle.normal,
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: fontSize,
|
|
));
|
|
builder.addText('Test');
|
|
final Paragraph paragraph = builder.build();
|
|
paragraph.layout(ParagraphConstraints(width: 400.0));
|
|
|
|
expect(paragraph.height, closeTo(fontSize, 0.001));
|
|
expect(paragraph.width, closeTo(400.0, 0.001));
|
|
expect(paragraph.minIntrinsicWidth, closeTo(fontSize * 4.0, 0.001));
|
|
expect(paragraph.maxIntrinsicWidth, closeTo(fontSize * 4.0, 0.001));
|
|
expect(paragraph.alphabeticBaseline, closeTo(fontSize * .8, 0.001));
|
|
expect(
|
|
paragraph.ideographicBaseline,
|
|
closeTo(paragraph.alphabeticBaseline * kAhemBaselineRatio, 0.001),
|
|
);
|
|
}
|
|
});
|
|
|
|
test('predictably lays out a multi-line paragraph', () {
|
|
for (double fontSize in <double>[10.0, 20.0, 30.0, 40.0]) {
|
|
final ParagraphBuilder builder = ParagraphBuilder(ParagraphStyle(
|
|
fontFamily: 'Ahem',
|
|
fontStyle: FontStyle.normal,
|
|
fontWeight: FontWeight.normal,
|
|
fontSize: fontSize,
|
|
));
|
|
builder.addText('Test Ahem');
|
|
final Paragraph paragraph = builder.build();
|
|
paragraph.layout(ParagraphConstraints(width: fontSize * 5.0));
|
|
|
|
expect(paragraph.height, closeTo(fontSize * 2.0, 0.001)); // because it wraps
|
|
expect(paragraph.width, closeTo(fontSize * 5.0, 0.001));
|
|
expect(paragraph.minIntrinsicWidth, closeTo(fontSize * 4.0, 0.001));
|
|
|
|
// TODO(yjbanov): see https://github.com/flutter/flutter/issues/21965
|
|
expect(paragraph.maxIntrinsicWidth, closeTo(fontSize * 9.0, 0.001));
|
|
expect(paragraph.alphabeticBaseline, closeTo(fontSize * .8, 0.001));
|
|
expect(
|
|
paragraph.ideographicBaseline,
|
|
closeTo(paragraph.alphabeticBaseline * kAhemBaselineRatio, 0.001),
|
|
);
|
|
}
|
|
});
|
|
}
|