Skip to content
Open
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
38 changes: 38 additions & 0 deletions test/unit/serialization/command/ellipse_shape_serializer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,42 @@ void main() {
expect(deserializedCommand.type, equals(type));
});
});

group('Version 2', () {
test('Test Ellipse deserialization for version 2', () {
const type = SerializerType.ELLIPSE_SHAPE_COMMAND;
final originalPaint = DummyPaintFactory.createPaint(version: Version.v1);
const center = Offset(100, 100);
const radius = 50.0;
const angle = 0.0;
final style = ShapeStyle.outline;

final command = DummyCommandFactory.createEllipseShapeCommand(
originalPaint,
radius,
radius,
center,
style,
angle,
);

final json = command.toJson();
json['version'] = Version.v2;
final deserializedCommand = EllipseShapeCommand.fromJson(json);

expect(
DummyPaintFactory.comparePaint(
originalPaint,
deserializedCommand.paint,
version: Version.v1,
),
isTrue);
expect(deserializedCommand.version, equals(Version.v2));
expect(deserializedCommand.center, equals(center));
expect(deserializedCommand.radiusX, equals(radius));
expect(deserializedCommand.radiusY, equals(radius));
expect(deserializedCommand.type, equals(type));
expect(deserializedCommand.angle, equals(angle));
});
});
}
39 changes: 39 additions & 0 deletions test/unit/serialization/command/heart_shape_serializer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,43 @@ void main() {
expect(deserializedCommand.style, equals(ShapeStyle.outline));
});
});

group('Version 2', () {
test('Test Heart deserialization for version 2', () {
const type = SerializerType.HEART_SHAPE_COMMAND;
final originalPaint = DummyPaintFactory.createPaint(version: Version.v1);
const center = Offset(100, 100);
const width = 50.0;
const height = 50.0;
const angle = 0.0;

final command = DummyCommandFactory.createHeartShapeCommand(
originalPaint,
width,
height,
angle,
center,
ShapeStyle.outline,
);

final json = command.toJson();
json['version'] = Version.v2;
final deserializedCommand = HeartShapeCommand.fromJson(json);

expect(
DummyPaintFactory.comparePaint(
originalPaint,
deserializedCommand.paint,
version: Version.v1,
),
isTrue);
expect(deserializedCommand.version, equals(Version.v2));
expect(deserializedCommand.center, equals(center));
expect(deserializedCommand.type, equals(type));
expect(deserializedCommand.angle, equals(angle));
expect(deserializedCommand.width, equals(width));
expect(deserializedCommand.height, equals(height));
expect(deserializedCommand.style, equals(ShapeStyle.outline));
});
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,44 @@ void main() {
expect(deserializedCommand.type, equals(type));
});
});

group('Version 2', () {
test('Test SquareShapeCommand deserialization for version 2', () {
const type = SerializerType.SQUARE_SHAPE_COMMAND;

final originalPaint = DummyPaintFactory.createPaint(version: Version.v1);
const originalTopLeft = Offset(0, 0);
const originalTopRight = Offset(1, 0);
const originalBottomLeft = Offset(0, 1);
const originalBottomRight = Offset(1, 1);

final command = DummyCommandFactory.createSquareShapeCommand(
originalPaint,
originalTopLeft,
originalTopRight,
originalBottomLeft,
originalBottomRight,
ShapeStyle.outline,
version: Version.v1,
);

final json = command.toJson();
json['version'] = Version.v2;
final deserializedCommand = SquareShapeCommand.fromJson(json);

expect(
DummyPaintFactory.comparePaint(
originalPaint,
deserializedCommand.paint,
version: Version.v1,
),
isTrue);
expect(deserializedCommand.version, equals(Version.v2));
expect(deserializedCommand.topLeft, equals(originalTopLeft));
expect(deserializedCommand.topRight, equals(originalTopRight));
expect(deserializedCommand.bottomLeft, equals(originalBottomLeft));
expect(deserializedCommand.bottomRight, equals(originalBottomRight));
expect(deserializedCommand.type, equals(type));
});
});
}
42 changes: 42 additions & 0 deletions test/unit/serialization/command/star_shape_serializer_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,46 @@ void main() {
expect(deserializedCommand.angle, equals(angle));
});
});

group('Version 2', () {
test('Test Star deserialization for version 2', () {
const type = SerializerType.STAR_SHAPE_COMMAND;
final originalPaint = DummyPaintFactory.createPaint(version: Version.v1);
const center = Offset(100, 100);
const radius = 50.0;
const numberOfPoints = 5;
const angle = 0.0;

final style = ShapeStyle.outline;

final command = DummyCommandFactory.createStarShapeCommand(
originalPaint,
numberOfPoints,
angle,
center,
style,
radius,
radius,
);

final json = command.toJson();
json['version'] = Version.v2;
final deserializedCommand = StarShapeCommand.fromJson(json);

expect(
DummyPaintFactory.comparePaint(
originalPaint,
deserializedCommand.paint,
version: Version.v1,
),
isTrue);
expect(deserializedCommand.version, equals(Version.v2));
expect(deserializedCommand.center, equals(center));
expect(deserializedCommand.radiusX, equals(radius));
expect(deserializedCommand.radiusY, equals(radius));
expect(deserializedCommand.type, equals(type));
expect(deserializedCommand.numberOfPoints, equals(numberOfPoints));
expect(deserializedCommand.angle, equals(angle));
});
});
}
Loading