From fda046441feddc181e178923e21d8a8b1f7e2e4f Mon Sep 17 00:00:00 2001 From: Jatin Date: Fri, 31 Oct 2025 23:37:29 +0530 Subject: [PATCH] refactor: update color value checks to use toARGB32() for consistency in tests --- test/cubit/canvas_cubit_test.dart | 1 - test/models/draw_model_test.dart | 35 ++++++++++++++++----------- test/models/text_item_model_test.dart | 4 +-- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/test/cubit/canvas_cubit_test.dart b/test/cubit/canvas_cubit_test.dart index 516cc584..2e7a138a 100644 --- a/test/cubit/canvas_cubit_test.dart +++ b/test/cubit/canvas_cubit_test.dart @@ -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'; diff --git a/test/models/draw_model_test.dart b/test/models/draw_model_test.dart index de986142..6dfb1747 100644 --- a/test/models/draw_model_test.dart +++ b/test/models/draw_model_test.dart @@ -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); @@ -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, @@ -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); @@ -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); @@ -152,7 +156,10 @@ void main() { expect(json['points'], isA()); 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); @@ -163,7 +170,7 @@ 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, @@ -171,7 +178,7 @@ void main() { { '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, @@ -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, @@ -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); @@ -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, @@ -210,7 +217,7 @@ void main() { final json = { 'points': pointsJson, - 'color': Colors.red.value, + 'color': Colors.red.toARGB32(), 'strokeWidth': 5.0, }; @@ -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); }); diff --git a/test/models/text_item_model_test.dart b/test/models/text_item_model_test.dart index 5b9c8795..baecf323 100644 --- a/test/models/text_item_model_test.dart +++ b/test/models/text_item_model_test.dart @@ -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); @@ -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);