Skip to content

Commit 9b32a7c

Browse files
committed
Add test cases
1 parent dac9859 commit 9b32a7c

2 files changed

Lines changed: 84 additions & 1 deletion

File tree

packages/devtools_app/lib/src/shared/ui/filter.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -441,7 +441,6 @@ class SettingFilter<T, V> {
441441
/// Whether a data element should be included based on the current state of the
442442
/// filter.
443443
bool includeData(T data) {
444-
print('should include $data ?');
445444
return !enabled || _includeCallback(data, setting.value);
446445
}
447446

packages/devtools_app/test/standalone_ui/ide_shared/property_editor/property_editor_test.dart

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,66 @@ void main() {
498498
expect(widthInput, findsNothing);
499499
expect(heightInput, findsNothing);
500500
});
501+
502+
testWidgets('can filter for only set values', (tester) async {
503+
// Load the property editor.
504+
await tester.pumpWidget(wrap(propertyEditor));
505+
506+
// Change the editable args.
507+
controller.initForTestsOnly(editableArgsResult: result1);
508+
await tester.pumpAndSettle();
509+
510+
final titleInput = _findTextFormField('String? title');
511+
final widthInput = _findTextFormField('double width');
512+
final heightInput = _findTextFormField('double? height');
513+
514+
// Verify all inputs are visible.
515+
expect(_findNoPropertiesMessage, findsNothing);
516+
expect(titleInput, findsOneWidget);
517+
expect(widthInput, findsOneWidget);
518+
expect(heightInput, findsOneWidget);
519+
520+
// Filter for only set vaues.
521+
await _setFilter(
522+
'Only include properties that are set in the code.',
523+
tester: tester,
524+
);
525+
526+
// Verify only the "title" and "width" properties are visible.
527+
expect(heightInput, findsNothing);
528+
expect(titleInput, findsOneWidget);
529+
expect(widthInput, findsOneWidget);
530+
});
531+
532+
testWidgets('can filter for only default values', (tester) async {
533+
// Load the property editor.
534+
await tester.pumpWidget(wrap(propertyEditor));
535+
536+
// Change the editable args.
537+
controller.initForTestsOnly(editableArgsResult: result1);
538+
await tester.pumpAndSettle();
539+
540+
final titleInput = _findTextFormField('String? title');
541+
final widthInput = _findTextFormField('double width');
542+
final heightInput = _findTextFormField('double? height');
543+
544+
// Verify all inputs are visible.
545+
expect(_findNoPropertiesMessage, findsNothing);
546+
expect(titleInput, findsOneWidget);
547+
expect(widthInput, findsOneWidget);
548+
expect(heightInput, findsOneWidget);
549+
550+
// Filter for only default vaues.
551+
await _setFilter(
552+
'Only include properties that match the default value.',
553+
tester: tester,
554+
);
555+
556+
// Verify only the "height" property is visible.
557+
expect(heightInput, findsOneWidget);
558+
expect(titleInput, findsNothing);
559+
expect(widthInput, findsNothing);
560+
});
501561
});
502562

503563
group('editing arguments', () {
@@ -925,6 +985,30 @@ final _findNoPropertiesMessage = find.text(
925985
'No widget properties at current cursor location.',
926986
);
927987

988+
Future<void> _setFilter(
989+
String filterSettingText, {
990+
required WidgetTester tester,
991+
}) async {
992+
final filterButtonFinder = find.byType(DevToolsFilterButton);
993+
await tester.tap(filterButtonFinder);
994+
await tester.pumpAndSettle();
995+
996+
final rowFinder = find.ancestor(
997+
of: find.textContaining(filterSettingText),
998+
matching: find.byType(Row),
999+
);
1000+
final checkboxFinder = find.descendant(
1001+
of: rowFinder,
1002+
matching: find.byType(NotifierCheckbox),
1003+
);
1004+
await tester.tap(checkboxFinder);
1005+
await tester.pumpAndSettle();
1006+
1007+
final applyFilterButtonFinder = find.byType(DialogApplyButton);
1008+
await tester.tap(applyFilterButtonFinder);
1009+
await tester.pumpAndSettle();
1010+
}
1011+
9281012
Finder _findFilterField() => find.descendant(
9291013
of: find.byType(StandaloneFilterField<EditableProperty>),
9301014
matching: find.byType(TextField),

0 commit comments

Comments
 (0)