Skip to content
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
1 change: 0 additions & 1 deletion test/cubit/canvas_cubit_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import 'package:flutter_test/flutter_test.dart';
import 'package:bloc_test/bloc_test.dart';
import 'package:texterra/cubit/canvas_cubit.dart';
import 'package:texterra/cubit/canvas_state.dart';
import 'package:texterra/models/text_item_model.dart';
import 'package:texterra/models/draw_model.dart';
import 'package:texterra/constants/color_constants.dart';

Expand Down
35 changes: 21 additions & 14 deletions test/models/draw_model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ void main() {

expect(json['offsetX'], 15.5);
expect(json['offsetY'], 25.5);
expect(json['color'], Colors.red.value);
expect(
json['color'],
Colors.red.toARGB32(),
);
expect(json['strokeWidth'], 3.0);
expect(json['strokeCap'], StrokeCap.round.index);
expect(json['strokeJoin'], StrokeJoin.round.index);
Expand All @@ -45,7 +48,7 @@ void main() {
final json = {
'offsetX': 30.5,
'offsetY': 40.5,
'color': Colors.blue.value,
'color': Colors.blue.toARGB32(),
'strokeWidth': 7.0,
'strokeCap': StrokeCap.square.index,
'strokeJoin': StrokeJoin.miter.index,
Expand All @@ -55,7 +58,7 @@ void main() {

expect(point.offset.dx, 30.5);
expect(point.offset.dy, 40.5);
expect(point.paint.color.value, Colors.blue.value);
expect(point.paint.color.toARGB32(), Colors.blue.toARGB32());
expect(point.paint.strokeWidth, 7.0);
expect(point.paint.strokeCap, StrokeCap.square);
expect(point.paint.strokeJoin, StrokeJoin.miter);
Expand All @@ -77,7 +80,8 @@ void main() {
final deserialized = DrawingPoint.fromJson(json);

expect(deserialized.offset, original.offset);
expect(deserialized.paint.color.value, original.paint.color.value);
expect(
deserialized.paint.color.toARGB32(), original.paint.color.toARGB32());
expect(deserialized.paint.strokeWidth, original.paint.strokeWidth);
expect(deserialized.paint.strokeCap, original.paint.strokeCap);
expect(deserialized.paint.strokeJoin, original.paint.strokeJoin);
Expand Down Expand Up @@ -152,7 +156,10 @@ void main() {

expect(json['points'], isA<List>());
expect(json['points'].length, 3);
expect(json['color'], Colors.green.value);
expect(
json['color'],
Colors.green.toARGB32(),
);
expect(json['strokeWidth'], 4.0);
expect(json['brushType'], BrushType.marker.index);
expect(json['isFill'], false);
Expand All @@ -163,15 +170,15 @@ void main() {
{
'offsetX': 10.0,
'offsetY': 10.0,
'color': Colors.blue.value,
'color': Colors.blue.toARGB32(),
'strokeWidth': 6.0,
'strokeCap': StrokeCap.round.index,
'strokeJoin': StrokeJoin.round.index,
},
{
'offsetX': 20.0,
'offsetY': 20.0,
'color': Colors.blue.value,
'color': Colors.blue.toARGB32(),
'strokeWidth': 6.0,
'strokeCap': StrokeCap.round.index,
'strokeJoin': StrokeJoin.round.index,
Expand All @@ -180,7 +187,7 @@ void main() {

final json = {
'points': pointsJson,
'color': Colors.blue.value,
'color': Colors.blue.toARGB32(),
'strokeWidth': 6.0,
'strokeCap': StrokeCap.round.index,
'brushType': BrushType.brush.index,
Expand All @@ -190,7 +197,7 @@ void main() {
final path = DrawPath.fromJson(json);

expect(path.points.length, 2);
expect(path.color.value, Colors.blue.value);
expect(path.color.toARGB32(), Colors.blue.toARGB32());
expect(path.strokeWidth, 6.0);
expect(path.brushType, BrushType.brush);
expect(path.isFill, false);
Expand All @@ -201,7 +208,7 @@ void main() {
{
'offsetX': 10.0,
'offsetY': 10.0,
'color': Colors.red.value,
'color': Colors.red.toARGB32(),
'strokeWidth': 5.0,
'strokeCap': StrokeCap.round.index,
'strokeJoin': StrokeJoin.round.index,
Expand All @@ -210,7 +217,7 @@ void main() {

final json = {
'points': pointsJson,
'color': Colors.red.value,
'color': Colors.red.toARGB32(),
'strokeWidth': 5.0,
};

Expand Down Expand Up @@ -244,15 +251,15 @@ void main() {
final deserialized = DrawPath.fromJson(json);

expect(deserialized.points.length, original.points.length);
expect(deserialized.color.value, original.color.value);
expect(deserialized.color.toARGB32(), original.color.toARGB32());
expect(deserialized.strokeWidth, original.strokeWidth);
expect(deserialized.brushType, original.brushType);
expect(deserialized.isFill, original.isFill);

// Check first point
expect(deserialized.points[0].offset, original.points[0].offset);
expect(deserialized.points[0].paint.color.value,
original.points[0].paint.color.value);
expect(deserialized.points[0].paint.color.toARGB32(),
original.points[0].paint.color.toARGB32());
expect(deserialized.points[0].paint.strokeWidth,
original.points[0].paint.strokeWidth);
});
Expand Down
4 changes: 2 additions & 2 deletions test/models/text_item_model_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void main() {
expect(json['highlightColor'], 0xFFFFEB3B);
expect(json['textAlign'], TextAlign.center.index);
expect(json['hasShadow'], true);
expect(json['shadowColor'], Colors.black.value);
expect(json['shadowColor'], Colors.black.toARGB32());
expect(json['shadowBlurRadius'], 5.0);
expect(json['shadowOffsetDx'], 3.0);
expect(json['shadowOffsetDy'], 3.0);
Expand Down Expand Up @@ -273,7 +273,7 @@ void main() {
'fontStyle': FontStyle.normal.index,
'fontWeight': FontWeight.normal.index,
'fontFamily': 'Roboto',
'color': Colors.black.value,
'color': Colors.black.toARGB32(),
};

final textItem = TextItem.fromJson(json);
Expand Down