ODK-X Services- UI-test doubt

In the DeviceSettingsFragment test whenDefaultLocalePreferenceScreenIsClicked_doChangeLanguage(), it
requires a list of locales as entries in the list preference dialog, however, the data isn’t static or provided by a datastore. It is a custom class that uses AsyncTask to fetch I/O data from odk internal file (path:app_name/assets/commonDefinitions.js) and parses it to return locales in the form of List<Map<String, Object>>.
To solve it, either:

  1. use power mock to mock this static LocalizationUtils.getCommonLocales method, however, power mock doesn’t currently run in android tests - java.lang.NoClassDefFoundError: Failed resolution of: Ljava/beans/Introspector; · Issue #1062 · powermock/powermock · GitHub
  2. create a file on my own with the dummy contents so locale can be set Since the fragment directly accesses the preferences screen and it, in turn, creates the CommonTranslationsLocaleScreen instance, there’s no other way around it

It would be of great help to me if I can get to know how should I proceed to solve this issue. @W_Brunette @Love @bengreen

1 Like

The details of how localization/internationalization works can be found in the documentation: Internationalization — ODK-X Docs

I think it’s fine to generate you own dummy contents. You can use the XLSX converter to create your files. My only concern is how to move the file to the correct location during the test. You should have the unit test copy the file into place and at the end of the test delete the file.

1 Like

Sure, will try to implement this solution.

1 Like