Move diagnostic_describe_all_properties tests

Change-Id: I541f7e9a39b3b0f3de60cf68117e643ba5b661b7
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/325966
Auto-Submit: Samuel Rawlins <srawlins@google.com>
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Phil Quitslund <pquitslund@google.com>
diff --git a/pkg/linter/test/rule_test_support.dart b/pkg/linter/test/rule_test_support.dart
index 4f1359a..c8ad67b 100644
--- a/pkg/linter/test/rule_test_support.dart
+++ b/pkg/linter/test/rule_test_support.dart
@@ -529,6 +529,18 @@
   bool get mounted;
 }
 
+mixin Diagnosticable {
+  void debugFillProperties(DiagnosticPropertiesBuilder properties) {}
+}
+
+class DiagnosticableTree with Diagnosticable {
+  List<DiagnosticsNode> debugDescribeChildren() => const [];
+}
+
+class DiagnosticPropertiesBuilder {}
+
+class DiagnosticsNode {}
+
 class Key {
   Key(String value);
 }
diff --git a/pkg/linter/test/rules/all.dart b/pkg/linter/test/rules/all.dart
index fed5ee1..529672a 100644
--- a/pkg/linter/test/rules/all.dart
+++ b/pkg/linter/test/rules/all.dart
@@ -60,6 +60,8 @@
 import 'deprecated_consistency_test.dart' as deprecated_consistency;
 import 'deprecated_member_use_from_same_package_test.dart'
     as deprecated_member_use_from_same_package;
+import 'diagnostic_describe_all_properties_test.dart'
+    as diagnostic_describe_all_properties;
 import 'directives_ordering_test.dart' as directives_ordering;
 import 'discarded_futures_test.dart' as discarded_futures;
 import 'do_not_use_environment_test.dart' as do_not_use_environment;
@@ -275,6 +277,7 @@
   depend_on_referenced_packages.main();
   deprecated_consistency.main();
   deprecated_member_use_from_same_package.main();
+  diagnostic_describe_all_properties.main();
   directives_ordering.main();
   discarded_futures.main();
   do_not_use_environment.main();
diff --git a/pkg/linter/test/rules/diagnostic_describe_all_properties_test.dart b/pkg/linter/test/rules/diagnostic_describe_all_properties_test.dart
new file mode 100644
index 0000000..85ac49c
--- /dev/null
+++ b/pkg/linter/test/rules/diagnostic_describe_all_properties_test.dart
@@ -0,0 +1,145 @@
+// Copyright (c) 2023, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:test_reflective_loader/test_reflective_loader.dart';
+
+import '../rule_test_support.dart';
+
+main() {
+  defineReflectiveSuite(() {
+    defineReflectiveTests(DiagnosticDescribeAllPropertiesTest);
+  });
+}
+
+@reflectiveTest
+class DiagnosticDescribeAllPropertiesTest extends LintRuleTest {
+  @override
+  bool get addFlutterPackageDep => true;
+
+  @override
+  String get lintRule => 'diagnostic_describe_all_properties';
+
+  test_field() async {
+    await assertDiagnostics(r'''
+import 'package:flutter/widgets.dart';
+class MyWidget with Diagnosticable {
+  bool p = false;
+}
+''', [
+      lint(83, 1),
+    ]);
+  }
+
+  test_field_collectionOfWidgets() async {
+    await assertNoDiagnostics(r'''
+import 'package:flutter/widgets.dart';
+class MyWidget with Diagnosticable {
+  List<Widget> p = [];
+}
+''');
+  }
+
+  test_field_coveredByDebugField() async {
+    await assertNoDiagnostics(r'''
+import 'package:flutter/widgets.dart';
+class MyWidget with Diagnosticable {
+  String foo = '';
+  String debugFoo = '';
+
+  @override
+  void debugFillProperties(DiagnosticPropertiesBuilder properties) {
+    debugFoo;
+  }
+}
+''');
+  }
+
+  test_field_inDebugDescribeChildren() async {
+    await assertNoDiagnostics(r'''
+import 'package:flutter/widgets.dart';
+class MyWidget extends DiagnosticableTree {
+  String p = '';
+
+  @override
+  List<DiagnosticsNode> debugDescribeChildren() {
+    p;
+    return [];
+  }
+}
+''');
+  }
+
+  test_field_inDebugFillProperties() async {
+    await assertNoDiagnostics(r'''
+import 'package:flutter/widgets.dart';
+class MyWidget with Diagnosticable {
+  String p = '';
+
+  @override
+  void debugFillProperties(DiagnosticPropertiesBuilder properties) {
+    p;
+  }
+}
+''');
+  }
+
+  test_field_private() async {
+    await assertNoDiagnostics(r'''
+import 'package:flutter/widgets.dart';
+class MyWidget with Diagnosticable {
+  // ignore: unused_field
+  String _p = '';
+}
+''');
+  }
+
+  test_field_string() async {
+    await assertDiagnostics(r'''
+import 'package:flutter/widgets.dart';
+class MyWidget with Diagnosticable {
+  String p = '';
+}
+''', [
+      lint(85, 1),
+    ]);
+  }
+
+  test_field_widget() async {
+    await assertNoDiagnostics(r'''
+import 'package:flutter/widgets.dart';
+class MyWidget with Diagnosticable {
+  Widget? p;
+}
+''');
+  }
+
+  test_getter_string() async {
+    await assertDiagnostics(r'''
+import 'package:flutter/widgets.dart';
+class MyWidget with Diagnosticable {
+  String get p => '';
+}
+''', [
+      lint(89, 1),
+    ]);
+  }
+
+  test_getter_widget() async {
+    await assertNoDiagnostics(r'''
+import 'package:flutter/widgets.dart';
+class MyWidget with Diagnosticable {
+  Widget? get p => null;
+}
+''');
+  }
+
+  test_staticField_string() async {
+    await assertNoDiagnostics(r'''
+import 'package:flutter/widgets.dart';
+class MyWidget with Diagnosticable {
+  static String p = '';
+}
+''');
+  }
+}
diff --git a/pkg/linter/test_data/rules/diagnostic_describe_all_properties.dart b/pkg/linter/test_data/rules/diagnostic_describe_all_properties.dart
deleted file mode 100644
index 7adc568..0000000
--- a/pkg/linter/test_data/rules/diagnostic_describe_all_properties.dart
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
-// for details. All rights reserved. Use of this source code is governed by a
-// BSD-style license that can be found in the LICENSE file.
-
-// test w/ `dart test -N diagnostic_describe_all_properties`
-
-import 'package:flutter/foundation.dart';
-import 'package:flutter/widgets.dart';
-
-class MyWidget extends Diagnosticable {
-  Widget? p0; //Skipped
-  List<Widget> p00 = []; //Skipped
-  Widget? get p000 => null; //Skipped
-  String p1 = ''; //OK
-  String p2 = ''; //LINT
-  String get p3 => ''; //LINT
-  String _p3 = ''; //OK
-  String debugFoo = ''; //OK
-  String foo = ''; //OK (covered by debugFoo)
-  String debugBar = ''; //OK (covered by bar)
-  String bar = ''; //OK
-  static String p4 = ''; //OK
-  String p5 = ''; //OK (in debugDescribeChildren)
-
-  @override
-  void debugFillProperties(DiagnosticPropertiesBuilder properties) {
-    properties
-        .add(StringProperty('property', p1, defaultValue: '', quoted: false));
-    properties.add(StringProperty('debugFoo', debugFoo,
-        defaultValue: '', quoted: false));
-    properties
-        .add(StringProperty('bar', bar, defaultValue: '', quoted: false));
-  }
-
-  @override
-  List<DiagnosticsNode> debugDescribeChildren() {
-    // In real source this should be used to create a diagnostics node,
-    // but for us a reference suffices.
-    print(p5);
-    return [];
-  }
-}
-
-class MyWidget2 extends Diagnosticable {
-  bool property = false; //LINT
-}