
Other changes in this patch: - Make the 'flutter' tool say "Updating flutter tool..." when it calls pub get, to avoid confusion about what the pub get output is about. - Make the bash flutter tool call pub get when the revision has changed. (This was already happening on Windows.) - Fix a raft of bugs found by the analyzer. - Fix some style nits in various bits of code that happened to be near things the analyzer noticed. - Remove the logic in "flutter test" that would run "pub get", since upon further reflexion it was determined it didn't work anyway. We'll probably have to add better diagnostics here and say to run the updater script. - Remove the native velocity tracker script, since it was testing code that has since been removed. Notes on ignored warnings: - We ignore warnings in any packages that are not in the Flutter repo or in the author's current directory. - We ignore various irrelevant Strong Mode warnings. We still enable strong mode because even though it's not really relevant to our needs, it does (more or less accidentally) catch a few things that are helpful to us. - We allow CONSTANTS_LIKE_THIS, since we get some of those from other platforms that we are copying for sanity and consistency. - We allow one-member abstract classes since we have a number of them where it's perfectly reasonable. - We unfortunately still ignore warnings in mojom.dart autogenerated files. We should really fix those but that's a separate patch. - We verify the actual source file when we see the 'Name non-constant identifiers using lowerCamelCase.' lint, to allow one-letter variables that use capital letters (e.g. for physics expressions) and to allow multiple-underscore variable names. - We ignore all errors on lines that contain the following magic incantation and a "#" character: // analyzer doesn't like constructor tear-offs - For all remaining errors, if the line contains a comment of the form // analyzer says "..." ...then we ignore any errors that have that "..." string in them.
165 lines
4.7 KiB
Dart
165 lines
4.7 KiB
Dart
import 'dart:ui' as ui;
|
|
|
|
import 'package:flutter/rendering.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
import 'rendering_tester.dart';
|
|
|
|
class SquareImage implements ui.Image {
|
|
int get width => 10;
|
|
int get height => 10;
|
|
void dispose() { }
|
|
}
|
|
|
|
class WideImage implements ui.Image {
|
|
int get width => 20;
|
|
int get height => 10;
|
|
void dispose() { }
|
|
}
|
|
|
|
class TallImage implements ui.Image {
|
|
int get width => 10;
|
|
int get height => 20;
|
|
void dispose() { }
|
|
}
|
|
|
|
void main() {
|
|
test('Image sizing', () {
|
|
RenderImage image;
|
|
|
|
image = new RenderImage(image: new SquareImage());
|
|
layout(image,
|
|
constraints: new BoxConstraints(
|
|
minWidth: 25.0,
|
|
minHeight: 25.0,
|
|
maxWidth: 100.0,
|
|
maxHeight: 100.0));
|
|
expect(image.size.width, equals(25.0));
|
|
expect(image.size.height, equals(25.0));
|
|
|
|
image = new RenderImage(image: new WideImage());
|
|
layout(image,
|
|
constraints: new BoxConstraints(
|
|
minWidth: 5.0,
|
|
minHeight: 30.0,
|
|
maxWidth: 100.0,
|
|
maxHeight: 100.0));
|
|
expect(image.size.width, equals(60.0));
|
|
expect(image.size.height, equals(30.0));
|
|
|
|
image = new RenderImage(image: new TallImage());
|
|
layout(image,
|
|
constraints: new BoxConstraints(
|
|
minWidth: 50.0,
|
|
minHeight: 5.0,
|
|
maxWidth: 75.0,
|
|
maxHeight: 75.0));
|
|
expect(image.size.width, equals(50.0));
|
|
expect(image.size.height, equals(75.0));
|
|
|
|
image = new RenderImage(image: new WideImage());
|
|
layout(image,
|
|
constraints: new BoxConstraints(
|
|
minWidth: 5.0,
|
|
minHeight: 5.0,
|
|
maxWidth: 100.0,
|
|
maxHeight: 100.0));
|
|
expect(image.size.width, equals(20.0));
|
|
expect(image.size.height, equals(10.0));
|
|
|
|
image = new RenderImage(image: new WideImage());
|
|
layout(image,
|
|
constraints: new BoxConstraints(
|
|
minWidth: 5.0,
|
|
minHeight: 5.0,
|
|
maxWidth: 16.0,
|
|
maxHeight: 16.0));
|
|
expect(image.size.width, equals(16.0));
|
|
expect(image.size.height, equals(8.0));
|
|
|
|
image = new RenderImage(image: new TallImage());
|
|
layout(image,
|
|
constraints: new BoxConstraints(
|
|
minWidth: 5.0,
|
|
minHeight: 5.0,
|
|
maxWidth: 16.0,
|
|
maxHeight: 16.0));
|
|
expect(image.size.width, equals(8.0));
|
|
expect(image.size.height, equals(16.0));
|
|
|
|
image = new RenderImage(image: new SquareImage());
|
|
layout(image,
|
|
constraints: new BoxConstraints(
|
|
minWidth: 4.0,
|
|
minHeight: 4.0,
|
|
maxWidth: 8.0,
|
|
maxHeight: 8.0));
|
|
expect(image.size.width, equals(8.0));
|
|
expect(image.size.height, equals(8.0));
|
|
|
|
image = new RenderImage(image: new WideImage());
|
|
layout(image,
|
|
constraints: new BoxConstraints(
|
|
minWidth: 20.0,
|
|
minHeight: 20.0,
|
|
maxWidth: 30.0,
|
|
maxHeight: 30.0));
|
|
expect(image.size.width, equals(30.0));
|
|
expect(image.size.height, equals(20.0));
|
|
|
|
image = new RenderImage(image: new TallImage());
|
|
layout(image,
|
|
constraints: new BoxConstraints(
|
|
minWidth: 20.0,
|
|
minHeight: 20.0,
|
|
maxWidth: 30.0,
|
|
maxHeight: 30.0));
|
|
expect(image.size.width, equals(20.0));
|
|
expect(image.size.height, equals(30.0));
|
|
});
|
|
|
|
test('Null image sizing', () {
|
|
RenderImage image;
|
|
|
|
image = new RenderImage();
|
|
layout(image,
|
|
constraints: new BoxConstraints(
|
|
minWidth: 25.0,
|
|
minHeight: 25.0,
|
|
maxWidth: 100.0,
|
|
maxHeight: 100.0));
|
|
expect(image.size.width, equals(25.0));
|
|
expect(image.size.height, equals(25.0));
|
|
|
|
image = new RenderImage(width: 50.0);
|
|
layout(image,
|
|
constraints: new BoxConstraints(
|
|
minWidth: 25.0,
|
|
minHeight: 25.0,
|
|
maxWidth: 100.0,
|
|
maxHeight: 100.0));
|
|
expect(image.size.width, equals(50.0));
|
|
expect(image.size.height, equals(25.0));
|
|
|
|
image = new RenderImage(height: 50.0);
|
|
layout(image,
|
|
constraints: new BoxConstraints(
|
|
minWidth: 25.0,
|
|
minHeight: 25.0,
|
|
maxWidth: 100.0,
|
|
maxHeight: 100.0));
|
|
expect(image.size.width, equals(25.0));
|
|
expect(image.size.height, equals(50.0));
|
|
|
|
image = new RenderImage(width: 100.0, height: 100.0);
|
|
layout(image,
|
|
constraints: new BoxConstraints(
|
|
minWidth: 25.0,
|
|
minHeight: 25.0,
|
|
maxWidth: 75.0,
|
|
maxHeight: 75.0));
|
|
expect(image.size.width, equals(75.0));
|
|
expect(image.size.height, equals(75.0));
|
|
});
|
|
}
|