diff --git a/packages/flutter/test/painting/text_span_test.dart b/packages/flutter/test/painting/text_span_test.dart index 08b30122f18..81133b225f1 100644 --- a/packages/flutter/test/painting/text_span_test.dart +++ b/packages/flutter/test/painting/text_span_test.dart @@ -8,12 +8,14 @@ import 'package:test/test.dart'; void main() { test('TextSpan equals', () { - TextSpan a1 = new TextSpan(text: 'a'); // ignore: prefer_const_constructors - TextSpan a2 = new TextSpan(text: 'a'); // ignore: prefer_const_constructors + String text = 'a'; // we want these instances to be separate instances so that we're not just checking with a single object + TextSpan a1 = new TextSpan(text: text); + TextSpan a2 = new TextSpan(text: text); TextSpan b1 = new TextSpan(children: [ a1 ]); TextSpan b2 = new TextSpan(children: [ a2 ]); - TextSpan c1 = new TextSpan(); // ignore: prefer_const_constructors - TextSpan c2 = new TextSpan(); // ignore: prefer_const_constructors + String nullText; // we want these instances to be separate instances so that we're not just checking with a single object + TextSpan c1 = new TextSpan(text: nullText); + TextSpan c2 = new TextSpan(text: nullText); expect(a1 == a2, isTrue); expect(b1 == b2, isTrue); diff --git a/packages/flutter/test/widgets/key_test.dart b/packages/flutter/test/widgets/key_test.dart index 199aa1df43c..b640dd67d61 100644 --- a/packages/flutter/test/widgets/key_test.dart +++ b/packages/flutter/test/widgets/key_test.dart @@ -19,32 +19,37 @@ class NotEquals { void main() { testWidgets('Keys', (WidgetTester tester) async { - expect(new ValueKey(3) == new ValueKey(3), isTrue); // ignore: prefer_const_constructors - expect(new ValueKey(3) == new ValueKey(3), isFalse); // ignore: prefer_const_constructors - expect(new ValueKey(3) == new ValueKey(2), isFalse); // ignore: prefer_const_constructors + int int3 = 3; // we want these instances to be separate instances so that we're not just checking with a single object + expect(new ValueKey(int3) == new ValueKey(int3), isTrue); + expect(new ValueKey(int3) == new ValueKey(int3), isFalse); + int int2 = 2; // we want these instances to be separate instances so that we're not just checking with a single object + expect(new ValueKey(int3) == new ValueKey(int2), isFalse); expect(const ValueKey(double.NAN) == const ValueKey(double.NAN), isFalse); - - expect(new Key('') == new ValueKey(''), isTrue); // ignore: prefer_const_constructors - expect(new ValueKey('') == new ValueKey(''), isTrue); // ignore: prefer_const_constructors - expect(new TestValueKey('') == new ValueKey(''), isFalse); // ignore: prefer_const_constructors - expect(new TestValueKey('') == new TestValueKey(''), isTrue); // ignore: prefer_const_constructors - expect(new ValueKey('') == new ValueKey(''), isFalse); // ignore: prefer_const_constructors - expect(new TestValueKey('') == new TestValueKey(''), isFalse); // ignore: prefer_const_constructors - + String empty = ''; // we want these instances to be separate instances so that we're not just checking with a single object + expect(new Key(empty) == new ValueKey(empty), isTrue); + expect(new ValueKey(empty) == new ValueKey(empty), isTrue); + expect(new TestValueKey(empty) == new ValueKey(empty), isFalse); + expect(new TestValueKey(empty) == new TestValueKey(empty), isTrue); + + expect(new ValueKey(empty) == new ValueKey(empty), isFalse); + expect(new TestValueKey(empty) == new TestValueKey(empty), isFalse); + expect(new UniqueKey() == new UniqueKey(), isFalse); LocalKey k = new UniqueKey(); expect(new UniqueKey() == new UniqueKey(), isFalse); expect(k == k, isTrue); - + expect(new ValueKey(k) == new ValueKey(k), isTrue); expect(new ValueKey(k) == new ValueKey(k), isFalse); expect(new ObjectKey(k) == new ObjectKey(k), isTrue); - expect(new ValueKey(const NotEquals()) == new ValueKey(const NotEquals()), isFalse); // ignore: prefer_const_constructors - expect(new ObjectKey(const NotEquals()) == new ObjectKey(const NotEquals()), isTrue); // ignore: prefer_const_constructors - - expect(new ObjectKey(const Object()) == new ObjectKey(const Object()), isTrue); // ignore: prefer_const_constructors + NotEquals constNotEquals = const NotEquals(); // we want these instances to be separate instances so that we're not just checking with a single object + expect(new ValueKey(constNotEquals) == new ValueKey(constNotEquals), isFalse); + expect(new ObjectKey(constNotEquals) == new ObjectKey(constNotEquals), isTrue); + + Object constObject = const Object(); // we want these instances to be separate instances so that we're not just checking with a single object + expect(new ObjectKey(constObject) == new ObjectKey(constObject), isTrue); expect(new ObjectKey(new Object()) == new ObjectKey(new Object()), isFalse); expect(const ValueKey(true), hasOneLineDescription); diff --git a/packages/flutter/test/widgets/render_object_widget_test.dart b/packages/flutter/test/widgets/render_object_widget_test.dart index dd47645c25a..3df11f4bbc3 100644 --- a/packages/flutter/test/widgets/render_object_widget_test.dart +++ b/packages/flutter/test/widgets/render_object_widget_test.dart @@ -6,9 +6,10 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; -final BoxDecoration kBoxDecorationA = new BoxDecoration(); // ignore: prefer_const_constructors -final BoxDecoration kBoxDecorationB = new BoxDecoration(); // ignore: prefer_const_constructors -final BoxDecoration kBoxDecorationC = new BoxDecoration(); // ignore: prefer_const_constructors +final Border nullBorder = null; // we want these instances to be separate instances so that we're not just checking with a single object +final BoxDecoration kBoxDecorationA = new BoxDecoration(border: nullBorder); +final BoxDecoration kBoxDecorationB = new BoxDecoration(border: nullBorder); +final BoxDecoration kBoxDecorationC = new BoxDecoration(border: nullBorder); class TestWidget extends StatelessWidget { const TestWidget({ this.child });