|
|
|
|
@@ -155,11 +155,9 @@ void main() async {
|
|
|
|
|
expect(result.maxIntrinsicWidth, 60);
|
|
|
|
|
expect(result.minIntrinsicWidth, 30);
|
|
|
|
|
expect(result.height, 10);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line(' abc', hardBreak: true, width: 60.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line(' abc', hardBreak: true, width: 60.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// trailing whitespaces
|
|
|
|
|
text = build(ahemStyle, 'abc ');
|
|
|
|
|
@@ -167,10 +165,16 @@ void main() async {
|
|
|
|
|
expect(result.maxIntrinsicWidth, 60);
|
|
|
|
|
expect(result.minIntrinsicWidth, 30);
|
|
|
|
|
expect(result.height, 10);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abc ', hardBreak: true, width: 30.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement always includes trailing whitespace in the
|
|
|
|
|
// width, while Flutter and Canvas-based measurement don't.
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abc ', hardBreak: true, width: 60.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// mixed whitespaces
|
|
|
|
|
@@ -179,10 +183,16 @@ void main() async {
|
|
|
|
|
expect(result.maxIntrinsicWidth, 100);
|
|
|
|
|
expect(result.minIntrinsicWidth, 20);
|
|
|
|
|
expect(result.height, 10);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line(' ab c ', hardBreak: true, width: 80.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement always includes trailing whitespace in the
|
|
|
|
|
// width, while Flutter and Canvas-based measurement don't.
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line(' ab c ', hardBreak: true, width: 100.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// single whitespace
|
|
|
|
|
@@ -191,10 +201,16 @@ void main() async {
|
|
|
|
|
expect(result.maxIntrinsicWidth, 10);
|
|
|
|
|
expect(result.minIntrinsicWidth, 0);
|
|
|
|
|
expect(result.height, 10);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line(' ', hardBreak: true, width: 0.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement always includes trailing whitespace in the
|
|
|
|
|
// width, while Flutter and Canvas-based measurement don't.
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line(' ', hardBreak: true, width: 10.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// whitespace only
|
|
|
|
|
@@ -203,10 +219,16 @@ void main() async {
|
|
|
|
|
expect(result.maxIntrinsicWidth, 50);
|
|
|
|
|
expect(result.minIntrinsicWidth, 0);
|
|
|
|
|
expect(result.height, 10);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line(' ', hardBreak: true, width: 0.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement always includes trailing whitespace in the
|
|
|
|
|
// width, while Flutter and Canvas-based measurement don't.
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line(' ', hardBreak: true, width: 50.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
@@ -223,11 +245,9 @@ void main() async {
|
|
|
|
|
expect(result.minIntrinsicWidth, 50);
|
|
|
|
|
expect(result.width, 50);
|
|
|
|
|
expect(result.height, 10);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('12345', hardBreak: true, width: 50.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('12345', hardBreak: true, width: 50.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@@ -238,18 +258,22 @@ void main() async {
|
|
|
|
|
ui.ParagraphConstraints(width: 70);
|
|
|
|
|
MeasurementResult result;
|
|
|
|
|
|
|
|
|
|
// The long text doesn't fit in 50px of width, so it needs to wrap.
|
|
|
|
|
// The long text doesn't fit in 70px of width, so it needs to wrap.
|
|
|
|
|
result = instance.measure(build(ahemStyle, 'foo bar baz'), constraints);
|
|
|
|
|
expect(result.isSingleLine, false);
|
|
|
|
|
expect(result.maxIntrinsicWidth, 110);
|
|
|
|
|
expect(result.minIntrinsicWidth, 30);
|
|
|
|
|
expect(result.width, 70);
|
|
|
|
|
expect(result.height, 20);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('foo bar ', hardBreak: false, width: 70.0, lineNumber: 0),
|
|
|
|
|
line('baz', hardBreak: true, width: 30.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
@@ -266,11 +290,15 @@ void main() async {
|
|
|
|
|
expect(result.minIntrinsicWidth, 100);
|
|
|
|
|
expect(result.width, 50);
|
|
|
|
|
expect(result.height, 20);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('12345', hardBreak: false, width: 50.0, lineNumber: 0),
|
|
|
|
|
line('67890', hardBreak: true, width: 50.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The first word is force-broken twice.
|
|
|
|
|
@@ -281,12 +309,16 @@ void main() async {
|
|
|
|
|
expect(result.minIntrinsicWidth, 110);
|
|
|
|
|
expect(result.width, 50);
|
|
|
|
|
expect(result.height, 30);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abcde', hardBreak: false, width: 50.0, lineNumber: 0),
|
|
|
|
|
line('fghij', hardBreak: false, width: 50.0, lineNumber: 1),
|
|
|
|
|
line('k lm', hardBreak: true, width: 40.0, lineNumber: 2),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Constraints aren't enough even for a single character. In this case,
|
|
|
|
|
@@ -299,11 +331,15 @@ void main() async {
|
|
|
|
|
expect(result.minIntrinsicWidth, 20);
|
|
|
|
|
expect(result.width, 8);
|
|
|
|
|
expect(result.height, 20);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('A', hardBreak: false, width: 10.0, lineNumber: 0),
|
|
|
|
|
line('A', hardBreak: true, width: 10.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Extremely narrow constraints with new line in the middle.
|
|
|
|
|
@@ -312,15 +348,17 @@ void main() async {
|
|
|
|
|
expect(result.maxIntrinsicWidth, 20);
|
|
|
|
|
expect(result.minIntrinsicWidth, 20);
|
|
|
|
|
expect(result.width, 8);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
// This can only be done correctly by the canvas-based implementation.
|
|
|
|
|
expect(result.height, 30);
|
|
|
|
|
|
|
|
|
|
expect(result.height, 30);
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('A', hardBreak: false, width: 10.0, lineNumber: 0),
|
|
|
|
|
line('A', hardBreak: true, width: 10.0, lineNumber: 1),
|
|
|
|
|
line('A', hardBreak: true, width: 10.0, lineNumber: 2),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Extremely narrow constraints with new line in the end.
|
|
|
|
|
@@ -330,13 +368,17 @@ void main() async {
|
|
|
|
|
expect(result.minIntrinsicWidth, 30);
|
|
|
|
|
expect(result.width, 8);
|
|
|
|
|
expect(result.height, 40);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('A', hardBreak: false, width: 10.0, lineNumber: 0),
|
|
|
|
|
line('A', hardBreak: false, width: 10.0, lineNumber: 1),
|
|
|
|
|
line('A', hardBreak: true, width: 10.0, lineNumber: 2),
|
|
|
|
|
line('', hardBreak: true, width: 0.0, lineNumber: 3),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
@@ -353,11 +395,15 @@ void main() async {
|
|
|
|
|
expect(result.minIntrinsicWidth, 20);
|
|
|
|
|
expect(result.width, 50);
|
|
|
|
|
expect(result.height, 20);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('12', hardBreak: true, width: 20.0, lineNumber: 0),
|
|
|
|
|
line('34', hardBreak: true, width: 20.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
@@ -370,12 +416,16 @@ void main() async {
|
|
|
|
|
expect(result.maxIntrinsicWidth, 40);
|
|
|
|
|
expect(result.minIntrinsicWidth, 40);
|
|
|
|
|
expect(result.height, 30);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('', hardBreak: true, width: 0.0, lineNumber: 0),
|
|
|
|
|
line('', hardBreak: true, width: 0.0, lineNumber: 1),
|
|
|
|
|
line('1234', hardBreak: true, width: 40.0, lineNumber: 2),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Empty lines in the middle.
|
|
|
|
|
@@ -383,19 +433,23 @@ void main() async {
|
|
|
|
|
expect(result.maxIntrinsicWidth, 30);
|
|
|
|
|
expect(result.minIntrinsicWidth, 30);
|
|
|
|
|
expect(result.height, 30);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('12', hardBreak: true, width: 20.0, lineNumber: 0),
|
|
|
|
|
line('', hardBreak: true, width: 0.0, lineNumber: 1),
|
|
|
|
|
line('345', hardBreak: true, width: 30.0, lineNumber: 2),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Empty lines in the end.
|
|
|
|
|
result = instance.measure(build(ahemStyle, '1234\n\n'), constraints);
|
|
|
|
|
expect(result.maxIntrinsicWidth, 40);
|
|
|
|
|
expect(result.minIntrinsicWidth, 40);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
// This can only be done correctly in the canvas-based implementation.
|
|
|
|
|
expect(result.height, 30);
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
@@ -403,6 +457,10 @@ void main() async {
|
|
|
|
|
line('', hardBreak: true, width: 0.0, lineNumber: 1),
|
|
|
|
|
line('', hardBreak: true, width: 0.0, lineNumber: 2),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -419,11 +477,15 @@ void main() async {
|
|
|
|
|
expect(result.width, double.infinity);
|
|
|
|
|
expect(result.height, 20);
|
|
|
|
|
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('123', hardBreak: true, width: 30.0, lineNumber: 0),
|
|
|
|
|
line('456 789', hardBreak: true, width: 70.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
@@ -480,54 +542,74 @@ void main() async {
|
|
|
|
|
// Simple case.
|
|
|
|
|
result = instance.measure(build(ahemStyle, 'abc de fghi'), constraints);
|
|
|
|
|
expect(result.minIntrinsicWidth, 40);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abc ', hardBreak: false, width: 30.0, lineNumber: 0),
|
|
|
|
|
line('de ', hardBreak: false, width: 20.0, lineNumber: 1),
|
|
|
|
|
line('fghi', hardBreak: true, width: 40.0, lineNumber: 2),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// With new lines.
|
|
|
|
|
result = instance.measure(build(ahemStyle, 'abcd\nef\nghi'), constraints);
|
|
|
|
|
expect(result.minIntrinsicWidth, 40);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abcd', hardBreak: true, width: 40.0, lineNumber: 0),
|
|
|
|
|
line('ef', hardBreak: true, width: 20.0, lineNumber: 1),
|
|
|
|
|
line('ghi', hardBreak: true, width: 30.0, lineNumber: 2),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// With trailing whitespace.
|
|
|
|
|
result = instance.measure(build(ahemStyle, 'abcd efg'), constraints);
|
|
|
|
|
expect(result.minIntrinsicWidth, 40);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abcd ', hardBreak: false, width: 40.0, lineNumber: 0),
|
|
|
|
|
line('efg', hardBreak: true, width: 30.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// With trailing whitespace and new lines.
|
|
|
|
|
result = instance.measure(build(ahemStyle, 'abc \ndefg'), constraints);
|
|
|
|
|
expect(result.minIntrinsicWidth, 40);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abc ', hardBreak: true, width: 30.0, lineNumber: 0),
|
|
|
|
|
line('defg', hardBreak: true, width: 40.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Very long text.
|
|
|
|
|
result = instance.measure(build(ahemStyle, 'AAAAAAAAAAAA'), constraints);
|
|
|
|
|
expect(result.minIntrinsicWidth, 120);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('AAAAA', hardBreak: false, width: 50.0, lineNumber: 0),
|
|
|
|
|
line('AAAAA', hardBreak: false, width: 50.0, lineNumber: 1),
|
|
|
|
|
line('AA', hardBreak: true, width: 20.0, lineNumber: 2),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -537,64 +619,88 @@ void main() async {
|
|
|
|
|
// Simple case.
|
|
|
|
|
result = instance.measure(build(ahemStyle, 'abc de fghi'), constraints);
|
|
|
|
|
expect(result.maxIntrinsicWidth, 110);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abc ', hardBreak: false, width: 30.0, lineNumber: 0),
|
|
|
|
|
line('de ', hardBreak: false, width: 20.0, lineNumber: 1),
|
|
|
|
|
line('fghi', hardBreak: true, width: 40.0, lineNumber: 2),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// With new lines.
|
|
|
|
|
result = instance.measure(build(ahemStyle, 'abcd\nef\nghi'), constraints);
|
|
|
|
|
expect(result.maxIntrinsicWidth, 40);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abcd', hardBreak: true, width: 40.0, lineNumber: 0),
|
|
|
|
|
line('ef', hardBreak: true, width: 20.0, lineNumber: 1),
|
|
|
|
|
line('ghi', hardBreak: true, width: 30.0, lineNumber: 2),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// With long whitespace.
|
|
|
|
|
result = instance.measure(build(ahemStyle, 'abcd efg'), constraints);
|
|
|
|
|
expect(result.maxIntrinsicWidth, 100);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abcd ', hardBreak: false, width: 40.0, lineNumber: 0),
|
|
|
|
|
line('efg', hardBreak: true, width: 30.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// With trailing whitespace.
|
|
|
|
|
result = instance.measure(build(ahemStyle, 'abc def '), constraints);
|
|
|
|
|
expect(result.maxIntrinsicWidth, 100);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abc ', hardBreak: false, width: 30.0, lineNumber: 0),
|
|
|
|
|
line('def ', hardBreak: true, width: 30.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// With trailing whitespace and new lines.
|
|
|
|
|
result = instance.measure(build(ahemStyle, 'abc \ndef '), constraints);
|
|
|
|
|
expect(result.maxIntrinsicWidth, 60);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abc ', hardBreak: true, width: 30.0, lineNumber: 0),
|
|
|
|
|
line('def ', hardBreak: true, width: 30.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Very long text.
|
|
|
|
|
result = instance.measure(build(ahemStyle, 'AAAAAAAAAAAA'), constraints);
|
|
|
|
|
expect(result.maxIntrinsicWidth, 120);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('AAAAA', hardBreak: false, width: 50.0, lineNumber: 0),
|
|
|
|
|
line('AAAAA', hardBreak: false, width: 50.0, lineNumber: 1),
|
|
|
|
|
line('AA', hardBreak: true, width: 20.0, lineNumber: 2),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -619,10 +725,14 @@ void main() async {
|
|
|
|
|
expect(result.minIntrinsicWidth, 480);
|
|
|
|
|
expect(result.maxIntrinsicWidth, 480);
|
|
|
|
|
expect(result.height, 10);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('AA...', hardBreak: false, width: 50.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't handle the ellipsis case very well. The
|
|
|
|
|
// text wraps into multiple lines instead.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The short prefix should make the text break into two lines, but the
|
|
|
|
|
@@ -635,11 +745,15 @@ void main() async {
|
|
|
|
|
expect(result.minIntrinsicWidth, 450);
|
|
|
|
|
expect(result.maxIntrinsicWidth, 450);
|
|
|
|
|
expect(result.height, 20);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('AAA', hardBreak: true, width: 30.0, lineNumber: 0),
|
|
|
|
|
line('AA...', hardBreak: false, width: 50.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't handle the ellipsis case very well. The
|
|
|
|
|
// text wraps into multiple lines instead.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tiny constraints.
|
|
|
|
|
@@ -650,10 +764,14 @@ void main() async {
|
|
|
|
|
expect(result.minIntrinsicWidth, 40);
|
|
|
|
|
expect(result.maxIntrinsicWidth, 40);
|
|
|
|
|
expect(result.height, 10);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('...', hardBreak: false, width: 30.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't handle the ellipsis case very well. The
|
|
|
|
|
// text wraps into multiple lines instead.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tinier constraints (not enough for the ellipsis).
|
|
|
|
|
@@ -663,12 +781,19 @@ void main() async {
|
|
|
|
|
expect(result.minIntrinsicWidth, 40);
|
|
|
|
|
expect(result.maxIntrinsicWidth, 40);
|
|
|
|
|
expect(result.height, 10);
|
|
|
|
|
// TODO(flutter_web): https://github.com/flutter/flutter/issues/34346
|
|
|
|
|
// if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
// expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
// line('.', hardBreak: false, width: 10.0, lineNumber: 0),
|
|
|
|
|
// ]);
|
|
|
|
|
// }
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
// TODO(flutter_web): https://github.com/flutter/flutter/issues/34346
|
|
|
|
|
// expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
// line('.', hardBreak: false, width: 10.0, lineNumber: 0),
|
|
|
|
|
// ]);
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('...', hardBreak: false, width: 30.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't handle the ellipsis case very well. The
|
|
|
|
|
// text wraps into multiple lines instead.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
@@ -685,22 +810,24 @@ void main() async {
|
|
|
|
|
final ui.Paragraph oneline = build(maxlinesStyle, 'One line');
|
|
|
|
|
result = instance.measure(oneline, infiniteConstraints);
|
|
|
|
|
expect(result.height, 10);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('One line', hardBreak: true, width: 80.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('One line', hardBreak: true, width: 80.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// The height should respect max lines and be limited to two lines here.
|
|
|
|
|
final ui.Paragraph threelines =
|
|
|
|
|
build(maxlinesStyle, 'First\nSecond\nThird');
|
|
|
|
|
result = instance.measure(threelines, infiniteConstraints);
|
|
|
|
|
expect(result.height, 20);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('First', hardBreak: true, width: 50.0, lineNumber: 0),
|
|
|
|
|
line('Second', hardBreak: true, width: 60.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The height should respect max lines and be limited to two lines here.
|
|
|
|
|
@@ -710,11 +837,15 @@ void main() async {
|
|
|
|
|
);
|
|
|
|
|
result = instance.measure(veryLong, constraints);
|
|
|
|
|
expect(result.height, 20);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('Lorem ', hardBreak: false, width: 50.0, lineNumber: 0),
|
|
|
|
|
line('ipsum ', hardBreak: false, width: 50.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Case when last line is a long unbreakable word.
|
|
|
|
|
@@ -724,11 +855,15 @@ void main() async {
|
|
|
|
|
);
|
|
|
|
|
result = instance.measure(veryLongLastLine, constraints);
|
|
|
|
|
expect(result.height, 20);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('AAA ', hardBreak: false, width: 30.0, lineNumber: 0),
|
|
|
|
|
line('AAAAA', hardBreak: false, width: 50.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
@@ -757,30 +892,36 @@ void main() async {
|
|
|
|
|
p = build(onelineStyle, 'abcdef');
|
|
|
|
|
result = instance.measure(p, constraints);
|
|
|
|
|
expect(result.height, 10);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abcdef', hardBreak: true, width: 60.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
}
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abcdef', hardBreak: true, width: 60.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// Simple overflow case.
|
|
|
|
|
p = build(onelineStyle, 'abcd efg');
|
|
|
|
|
result = instance.measure(p, constraints);
|
|
|
|
|
expect(result.height, 10);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abc...', hardBreak: false, width: 60.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't handle the ellipsis case very well. The
|
|
|
|
|
// text wraps into multiple lines instead.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Another simple overflow case.
|
|
|
|
|
p = build(onelineStyle, 'a bcde fgh');
|
|
|
|
|
result = instance.measure(p, constraints);
|
|
|
|
|
expect(result.height, 10);
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('a b...', hardBreak: false, width: 60.0, lineNumber: 0),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't handle the ellipsis case very well. The
|
|
|
|
|
// text wraps into multiple lines instead.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// The ellipsis is supposed to go on the second line, but because the
|
|
|
|
|
@@ -788,26 +929,34 @@ void main() async {
|
|
|
|
|
p = build(multilineStyle, 'abcdef ghijkl');
|
|
|
|
|
result = instance.measure(p, constraints);
|
|
|
|
|
// This can only be done correctly in the canvas-based implementation.
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.height, 20);
|
|
|
|
|
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abcdef ', hardBreak: false, width: 60.0, lineNumber: 0),
|
|
|
|
|
line('ghijkl', hardBreak: true, width: 60.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// But when the 2nd line is long enough, the ellipsis is shown.
|
|
|
|
|
p = build(multilineStyle, 'abcd efghijkl');
|
|
|
|
|
result = instance.measure(p, constraints);
|
|
|
|
|
// This can only be done correctly in the canvas-based implementation.
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.height, 20);
|
|
|
|
|
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abcd ', hardBreak: false, width: 40.0, lineNumber: 0),
|
|
|
|
|
line('efg...', hardBreak: false, width: 60.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Even if the second line can be broken, we don't break it, we just
|
|
|
|
|
@@ -815,39 +964,51 @@ void main() async {
|
|
|
|
|
p = build(multilineStyle, 'abcde f gh ijk');
|
|
|
|
|
result = instance.measure(p, constraints);
|
|
|
|
|
// This can only be done correctly in the canvas-based implementation.
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.height, 20);
|
|
|
|
|
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abcde ', hardBreak: false, width: 50.0, lineNumber: 0),
|
|
|
|
|
line('f g...', hardBreak: false, width: 60.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// First line overflows but second line doesn't.
|
|
|
|
|
p = build(multilineStyle, 'abcdefg hijk');
|
|
|
|
|
result = instance.measure(p, constraints);
|
|
|
|
|
// This can only be done correctly in the canvas-based implementation.
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.height, 20);
|
|
|
|
|
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abcdef', hardBreak: false, width: 60.0, lineNumber: 0),
|
|
|
|
|
line('g hijk', hardBreak: true, width: 60.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Both first and second lines overflow.
|
|
|
|
|
p = build(multilineStyle, 'abcdefg hijklmnop');
|
|
|
|
|
result = instance.measure(p, constraints);
|
|
|
|
|
// This can only be done correctly in the canvas-based implementation.
|
|
|
|
|
if (instance is CanvasTextMeasurementService) {
|
|
|
|
|
if (instance.isCanvas) {
|
|
|
|
|
expect(result.height, 20);
|
|
|
|
|
|
|
|
|
|
expect(result.lines, <EngineLineMetrics>[
|
|
|
|
|
line('abcdef', hardBreak: false, width: 60.0, lineNumber: 0),
|
|
|
|
|
line('g h...', hardBreak: false, width: 60.0, lineNumber: 1),
|
|
|
|
|
]);
|
|
|
|
|
} else {
|
|
|
|
|
// DOM-based measurement can't produce line metrics for multi-line
|
|
|
|
|
// paragraphs.
|
|
|
|
|
expect(result.lines, isNull);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|