Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Add checks to constructors and add missing constructor members #9106

Merged
merged 4 commits into from
May 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/stub_ui/lib/src/ui/compositing.dart
Original file line number Diff line number Diff line change
Expand Up @@ -875,6 +875,12 @@ class SceneHost {
/// The scene host takes ownership of the provided export token handle.
SceneHost(dynamic exportTokenHandle);

SceneHost.fromViewHolderToken(
dynamic viewHolderTokenHandle,
void Function() viewConnectedCallback,
void Function() viewDisconnectedCallback,
void Function(bool) viewStateChangedCallback);

/// Releases the resources associated with the child scene host.
///
/// After calling this function, the child scene host cannot be used further.
Expand Down
34 changes: 31 additions & 3 deletions lib/stub_ui/lib/src/ui/painting.dart
Original file line number Diff line number Diff line change
Expand Up @@ -962,8 +962,8 @@ class Paint {
double get strokeMiterLimit {
return null;
}
set strokeMiterLimit(double value) {
}

set strokeMiterLimit(double value) {}

/// Whether to paint inside shapes, the edges of shapes, or both.
///
Expand Down Expand Up @@ -1213,7 +1213,8 @@ abstract class Gradient extends Shader {
List<Color> colors, [
List<double> colorStops,
TileMode tileMode = TileMode.clamp,
Float64List matrix4, // TODO(yjbanov): Implement this https://github.com/flutter/flutter/issues/32819
Float64List
matrix4, // TODO(yjbanov): Implement this https://github.com/flutter/flutter/issues/32819
]) =>
_GradientLinear(from, to, colors, colorStops, tileMode);

Expand Down Expand Up @@ -1490,6 +1491,25 @@ class ColorFilter {
: _color = color,
_blendMode = blendMode;

/// Construct a color filter that transforms a color by a 4x5 matrix. The
/// matrix is in row-major order and the translation column is specified in
/// unnormalized, 0...255, space.
const ColorFilter.matrix(List<double> matrix)
: _color = null,
_blendMode = null;

/// Construct a color filter that applies the sRGB gamma curve to the RGB
/// channels.
const ColorFilter.linearToSrgbGamma()
: _color = null,
_blendMode = null;

/// Creates a color filter that applies the inverse of the sRGB gamma curve
/// to the RGB channels.
const ColorFilter.srgbToLinearGamma()
: _color = null,
_blendMode = null;

final Color _color;
final BlendMode _blendMode;

Expand Down Expand Up @@ -1632,6 +1652,14 @@ class ImageFilter {
ImageFilter.blur({double sigmaX = 0.0, double sigmaY = 0.0}) {
_initBlur(sigmaX, sigmaY);
}

/// Creates an image filter that applies a matrix transformation.
///
/// For example, applying a positive scale matrix (see [Matrix4.diagonal3])
/// when used with [BackdropFilter] would magnify the background image.
ImageFilter.matrix(Float64List matrix4,
{FilterQuality filterQuality = FilterQuality.low}) {}

void _initBlur(double sigmaX, double sigmaY) {
// TODO(b/128318717): Implement me.
}
Expand Down
1 change: 1 addition & 0 deletions lib/stub_ui/lib/src/ui/text.dart
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ class TextStyle {
Paint background,
Paint foreground,
List<Shadow> shadows,
List<FontFeature> fontFeatures,
}) : assert(
color == null || foreground == null,
'Cannot provide both a color and a foreground\n'
Expand Down
4 changes: 3 additions & 1 deletion lib/stub_ui/lib/src/ui/window.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,9 @@ class PluginUtilities {
}
}

class ImageShader {}
class ImageShader {
ImageShader(Image image, TileMode tmx, TileMode tmy, Float64List matrix4);
}

class IsolateNameServer {
static SendPort lookupPortByName(String name) {
Expand Down
96 changes: 90 additions & 6 deletions web_sdk/test/api_conform_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,70 @@ void main() {
}
// Next will check that the public methods exposed in each library are
// identical.
final Map<String, MethodDeclaration> uiMethods = <String, MethodDeclaration>{};
final Map<String, MethodDeclaration> webMethods = <String, MethodDeclaration>{};
final Map<String, MethodDeclaration> uiMethods =
<String, MethodDeclaration>{};
final Map<String, MethodDeclaration> webMethods =
<String, MethodDeclaration>{};
final Map<String, ConstructorDeclaration> uiConstructors =
<String, ConstructorDeclaration>{};
final Map<String, ConstructorDeclaration> webConstructors =
<String, ConstructorDeclaration>{};
_collectPublicMethods(uiClass, uiMethods);
_collectPublicMethods(webClass, webMethods);
_collectPublicConstructors(uiClass, uiConstructors);
_collectPublicConstructors(webClass, webConstructors);

for (String name in uiConstructors.keys) {
final ConstructorDeclaration uiConstructor = uiConstructors[name];
final ConstructorDeclaration webConstructor = webConstructors[name];
if (webConstructor == null) {
failed = true;
print(
'Warning: lib/ui/ui.dart $className.$name is missing from lib/stub_ui/ui.dart.',
);
continue;
}

if (uiConstructor.parameters.parameters.length !=
webConstructor.parameters.parameters.length) {
failed = true;
print(
'Warning: lib/ui/ui.dart $className.$name has a different parameter '
'length than in lib/stub_ui/ui.dart.');
}

for (int i = 0;
i < uiConstructor.parameters.parameters.length &&
i < uiConstructor.parameters.parameters.length;
i++) {
// Technically you could re-order named parameters and still be valid,
// but we enforce that they are identical.
for (int i = 0;
i < uiConstructor.parameters.parameters.length &&
i < webConstructor.parameters.parameters.length;
i++) {
final FormalParameter uiParam =
uiConstructor.parameters.parameters[i];
final FormalParameter webParam =
webConstructor.parameters.parameters[i];
if (webParam.identifier.name != uiParam.identifier.name) {
failed = true;
print('Warning: lib/ui/ui.dart $className.$name parameter $i'
' ${uiParam.identifier.name} has a different name in lib/stub_ui/ui.dart.');
}
if (uiParam.isPositional != webParam.isPositional) {
failed = true;
print('Warning: lib/ui/ui.dart $className.$name parameter $i'
'${uiParam.identifier.name} is positional, but not in lib/stub_ui/ui.dart.');
}
if (uiParam.isNamed != webParam.isNamed) {
failed = true;
print('Warning: lib/ui/ui.dart $className.$name parameter $i'
'${uiParam.identifier.name} is named, but not in lib/stub_ui/ui.dart.');
}
}
}
}

for (String methodName in uiMethods.keys) {
final MethodDeclaration uiMethod = uiMethods[methodName];
Expand All @@ -57,28 +117,32 @@ void main() {
if (uiMethod.parameters == null || webMethod.parameters == null) {
continue;
}
if (uiMethod.parameters.parameters.length != webMethod.parameters.parameters.length) {
if (uiMethod.parameters.parameters.length !=
webMethod.parameters.parameters.length) {
failed = true;
print(
'Warning: lib/ui/ui.dart $className.$methodName has a different parameter '
'length than in lib/stub_ui/ui.dart.');
}
// Technically you could re-order named parameters and still be valid,
// but we enforce that they are identical.
for (int i = 0; i < uiMethod.parameters.parameters.length && i < webMethod.parameters.parameters.length; i++) {
for (int i = 0;
i < uiMethod.parameters.parameters.length &&
i < webMethod.parameters.parameters.length;
i++) {
final FormalParameter uiParam = uiMethod.parameters.parameters[i];
final FormalParameter webParam = webMethod.parameters.parameters[i];
if (webParam.identifier.name != uiParam.identifier.name) {
failed = true;
print('Warning: lib/ui/ui.dart $className.$methodName parameter $i'
' ${uiParam.identifier.name} has a different name in lib/stub_ui/ui.dart.');
}
if (uiParam.isPositional && !webParam.isPositional) {
if (uiParam.isPositional != webParam.isPositional) {
failed = true;
print('Warning: lib/ui/ui.dart $className.$methodName parameter $i'
'${uiParam.identifier.name} is positional, but not in lib/stub_ui/ui.dart.');
}
if (uiParam.isNamed && !webParam.isNamed) {
if (uiParam.isNamed != webParam.isNamed) {
failed = true;
print('Warning: lib/ui/ui.dart $className.$methodName parameter $i'
'${uiParam.identifier.name} is named, but not in lib/stub_ui/ui.dart.');
Expand All @@ -94,6 +158,8 @@ void main() {
exit(0);
}

void _checkParameters() {}

// Collects all public classes defined by the part files of [unit].
void _collectPublicClasses(CompilationUnit unit,
Map<String, ClassDeclaration> destination, String root) {
Expand Down Expand Up @@ -121,6 +187,24 @@ void _collectPublicClasses(CompilationUnit unit,
}
}

void _collectPublicConstructors(ClassDeclaration classDeclaration,
Map<String, ConstructorDeclaration> destination) {
for (ClassMember member in classDeclaration.members) {
if (member is! ConstructorDeclaration) {
continue;
}
final ConstructorDeclaration method = member;
if (method?.name?.name == null) {
destination['Unnamed Constructor'] = method;
continue;
}
if (method.name.name.startsWith('_')) {
continue;
}
destination[method.name.name] = method;
}
}

void _collectPublicMethods(ClassDeclaration classDeclaration,
Map<String, MethodDeclaration> destination) {
for (ClassMember member in classDeclaration.members) {
Expand Down