expandDeviceMatrix static method
List<EnsembleTestDefinition>
expandDeviceMatrix(
- List<
EnsembleTestDefinition> definitions, - List<
TestDeviceTarget> devices
Expands each definition once per suite devices entry.
Implementation
@visibleForTesting
static List<EnsembleTestDefinition> expandDeviceMatrix(
List<EnsembleTestDefinition> definitions,
List<TestDeviceTarget> devices,
) {
if (devices.isEmpty) return definitions;
final expanded = <EnsembleTestDefinition>[];
for (final definition in definitions) {
final test = definition.testCase;
for (final device in devices) {
final multi = devices.length > 1;
expanded.add(
EnsembleTestDefinition(
assetPath: definition.assetPath,
testCase: _withRuntimeFields(
test,
id: multi ? '${test.id}[${device.id}]' : test.id,
startScreen: test.startScreen,
session: !multi || test.session == null
? test.session
: '${test.session}[${device.id}]',
mocks: test.mocks,
steps: test.steps,
initialState: _withDeviceLocale(test.initialState, device),
startScreenInputs: test.startScreenInputs,
deviceTarget: device,
scenarioId: test.scenarioId,
scenarioDescription: test.scenarioDescription,
// One screenshot sheet per device run (not a shared multi-device
// sheet). resolvedScreenshotSheetId falls back to the expanded id.
screenshotSheetId: test.screenshotSheetId,
),
),
);
}
}
return expanded;
}