Skip to content
This repository has been archived by the owner on Mar 6, 2024. It is now read-only.

Screenshots for Localization

isabelrios edited this page Dec 21, 2021 · 2 revisions

All the l10n screenshots are generated through Xcode UI Tests. (XCTestCase subclasses). These tests are being run as part of the FocusSnapshotTests scheme. They should work on any device but recently we've only run them on iPhone device.

Running the tests locally

Make sure you have the following tools installed:

  • Xcode 13
  • Carthage - brew install carthage
  • Fastlane - brew install ruby; gem install fastlane

Update Fastlane:

gem install fastlane # Do not use sudo. Instead, install ruby via brew, do not use the system Ruby

Run screenshots from xcode:

The tests are under Blockzilla > SnapshotTests > SnapshotTests in the project navigator. There is a BaseTestCaseL10n that has some shared test methods and then the tests are in SnapshotTests. Select the test suite or test and run it by using the > button. This will run the test but the screenshot will not be saved.

Run screenshots from command line:

git clone git@github.com:mozilla-mobile/focus-ios.git
cd focus-ios
./checkout.sh
./l10n-screenshots.sh

If you want to run screenshots for just a specific locale, run the tool as follows:

./l10n-screenshots.sh nl,af,es

If no screenshots are generated, look at the log files in the screenshots directory:

sarentz@Risa ~/P/focus (master)> find screenshots -name \*.log
l10n-screenshots/locale/local/iPhone 11/snapshot.log

Sometimes the SnapshotHelper.swift file is outdated. This can be seen in the logs:

Your './ScreenshotTests/SnapshotHelper.swift' is outdated, please run `fastlane snapshot update`

You can fix this with:

fastlane snapshot update

You can then commit ScreenshotTests/SnapshotHelper.swift to the repository.

Running the tests on CI

Thanks a solution that was developed integrating Taskcluster with Bitrise. L10n tests run on CI and the screenshots for all locales are taken and stored automatically.

The only manual part is to trigger the hook so that the tests start, but once that happens the rest is all automated. As a quick summary, the Taskcluster trigger generates a firefox-iOS build and runs the test in a locale to check the status. If the build works, then it splits the locales (~75) in groups of 6 per job and schedules the different jobs needed so that they run on Bitrise. Each Bitrsie job just run the l10n tests without building and sends the artifacts, with the locales in zip files to Taskcluster where they are stored.

The trigger to get the latest screenshots is still manual since it happens on a demand way after talking with the l10n team and looking for the best time to get the release screenshot. If that specific time could set and known in advance in the future, that step could be automated too, but so far the communication is great and the screenshots are generated on time for each release.

This is the static link that is updated with the latest release's screenshots

Notes:

Currently screenshots are taken only for Focus, but that can be changed here: https://github.com/mozilla-mobile/focus-ios/blob/main/l10n-screenshots.sh#L39 by selecting KlarSnapshotTests schema.

The device used can be also modified in same script: https://github.com/mozilla-mobile/focus-ios/blob/main/l10n-screenshots.sh#L33

For more info contact Mobile Test Engineering team, slack : #mobile-testeng