testGoldenSceneOnLinux function

  1. @isGoldenScene
  2. @isTest
void testGoldenSceneOnLinux(
  1. String description,
  2. WidgetTesterCallback test, {
  3. bool? skip,
  4. Timeout? timeout,
  5. bool semanticsEnabled = true,
  6. TestVariant<Object?> variant = const DefaultTestVariant(),
  7. dynamic tags,
  8. int? retry,
})

Run a golden scene test, which pretends to run on a Linux platform.

A golden scene refers to a single golden file, which might contain many individual golden images within itself.

Loads app fonts so that text descriptions and instructions can be rendered within the final golden scene.

Configures the test to use a 1:1 logical to physical pixel ratio so that anti-aliasing is reduced.

Runs the test with a text scale factor to 1.0.

All test view configurations are reset after the test completes.

This test runner pretends to run on a Mac by setting debugDefaultTargetPlatformOverride to TargetPlatform.linux.

Implementation

@isGoldenScene
@isTest
void testGoldenSceneOnLinux(
  String description,
  WidgetTesterCallback test, {
  bool? skip,
  Timeout? timeout,
  bool semanticsEnabled = true,
  TestVariant<Object?> variant = const DefaultTestVariant(),
  dynamic tags,
  int? retry,
}) {
  testGoldenScene(
    description,
    (tester) async {
      debugDefaultTargetPlatformOverride = TargetPlatform.linux;

      tester.view
        ..devicePixelRatio = 1.0
        ..platformDispatcher.textScaleFactorTestValue = 1.0;

      try {
        await test(tester);
      } finally {
        debugDefaultTargetPlatformOverride = null;
      }
    },
    skip: skip,
    variant: variant,
    timeout: timeout,
    semanticsEnabled: semanticsEnabled,
    tags: tags,
    retry: retry,
  );
}