VmServiceProxyGoldenFileComparator class final

Compares image pixels against a golden image file on the host system.

This comparator will send a request, using the VM service protocol, to a host script (i.e. the driver script, running in a Dart VM on the host desktop OS), which will then forward the comparison to a concrete GoldenFileComparator.

To use, run useIfRunningOnDevice in the main() of a test file or similar:

import 'package:integration_test/integration_test.dart';

void main() {
  VmServiceProxyGoldenFileComparator.useIfRunningOnDevice();

  // Actual tests and such below.
}

When either compare or update is called, the following event is sent with dev.postEvent:

dev.postEvent('compare' /* or 'update' */, <String, Object?>{
  'id':    1001,                 // a valid unique integer, often incrementing;
  'path':  'path/to/image.png',  // golden key created by matchesGoldenFile;
  'bytes': '...base64encoded',   // base64 encoded bytes representing the current image.
}, stream: 'integration_test.VmServiceProxyGoldenFileComparator');

The comparator expects a response at the service extension ext.integration_test.VmServiceProxyGoldenFileComparator that is either of the following formats:

<String, Object?>{
  'error': 'Description of why the operation failed'
}

or:

<String, Object?>{
  'result': true /* or possibly false, in the case of 'compare' calls */
}

See also:

Inheritance
Annotations

Properties

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

compare(Uint8List imageBytes, Uri golden) Future<bool>
Compares the pixels of decoded png imageBytes against the golden file identified by golden.
override
getTestUri(Uri key, int? version) Uri
Returns a new golden file Uri to incorporate any version number with the key.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
update(Uri golden, Uint8List imageBytes) Future<void>
Updates the golden file identified by golden with imageBytes.
override

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

useIfRunningOnDevice() → void
Conditionally sets goldenFileComparator to VmServiceProxyGoldenFileComparator.