localizationRoleAppTest function
The test of the localization role that the CLI keeps in its
app_tests/localization_role, for the apps with the role, whichever
module provides it, that among accepts, or all of them: the root of
the app supports the languages of the app and no other, and has, for
each of them, a delegate of each kind of localizations that supports
it; once the user chose a language, the app is in it, and each text of
the app reads in it, or in English when it has no translation into it;
while the user chose none, the app and its texts are in the language
that the device prefers among those of the app; a choice is saved under
LocalizationRole.localeKey, and removed when the app follows the
device again; and the next start, initPreferences() again, restores
the language that was saved.
The test knows only the role. The matrix writes the languages and the
texts of each app for it, from the data of its localization role, into
languagesAndTextsFile, next to the probe of the test in
integration_test/localization_role/probe.dart, probeLanguages(). On
a device, for the start check, the probe checks the texts in the
language that it finds, goes through the first languages of the app, at
most languagesProbeLimit, and puts back the choice that it found. The
matrix of the fixtures runs the test only in its apps with every module,
which run other tests already.
Implementation
Future<MatrixAppTest> localizationRoleAppTest({
bool Function(MatrixApp app)? among,
}) async =>
MatrixAppTest(
'${await appTestsDirectoryOf('smf_flutter_cli')}/localization_role',
appliesTo: (app) =>
app.hook!.presentRoles.contains(localizationRole) &&
(among?.call(app) ?? true),
generatedFiles: _languagesAndTextsOf,
roles: {localizationRole},
startProbe: const MatrixStartProbe(
'integration_test/localization_role/probe.dart',
'probeLanguages',
),
);