rebelappstudio / accessibility_tools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

No accessibility issues found with some values of widget size or pixel ratio

aednlaxer opened this issue · comments

No issue found in this test when SizedBox's size is 99.3x99.3:

testWidgets(
    'Shows warning for a small tap area on desktop 2',
    (WidgetTester tester) async {
      final tapKey = UniqueKey();

      await tester.pumpWidget(
        TestApp(
          minimumTapAreas: const MinimumTapAreas(desktop: 0, mobile: 100),
          child: SizedBox(
            width: 99.3,
            height: 99.3,
            child: GestureDetector(
              key: tapKey,
              child: const Text('Tap area'),
              onTap: () {},
            ),
          ),
        ),
      );

      // Test fails here because no issues found so no icon is displayed
      await showAccessibilityIssues(tester);

      expectAccessibilityWarning(
        tester,
        erroredWidgetFinder: find.byKey(tapKey),
        tooltipMessage:
            'Tap area of 99.3x99.3 is too small:\nshould be at least 100x100',
      );
    },
  );

I believe it's happening here because size comparison fails and widget is considered off screen.

Another example is when pixel ratio is not an integer. Setting it to 1.3 (don't know if it's realistic though) and having a square 99x99 SizedBox:

testWidgets(
    'Shows warning for a small tap area on desktop 2',
    (WidgetTester tester) async {
      final tapKey = UniqueKey();

      tester.binding.window.devicePixelRatioTestValue = 1.3;

      await tester.pumpWidget(
        TestApp(
          minimumTapAreas: const MinimumTapAreas(desktop: 0, mobile: 100),
          child: SizedBox(
            width: 99,
            height: 99,
            child: GestureDetector(
              key: tapKey,
              child: const Text('Tap area'),
              onTap: () {},
            ),
          ),
        ),
      );

      // Test fails here because no issues found so no icon is displayed
      await showAccessibilityIssues(tester);

      expectAccessibilityWarning(
        tester,
        erroredWidgetFinder: find.byKey(tapKey),
        tooltipMessage:
            'Tap area of 99x99 is too small:\nshould be at least 100x100',
      );
    },
  );