fix(android): fix failing test on Windows

On Windows the tests failed because the AppData directory doesn't yet
exist under an allowed app internal storage path. This change creates
the directory first when running tests.
This commit is contained in:
Eberhard Beilharz 2026-06-29 18:22:02 +02:00 • committed by Joshua Horton
parent aee5620dbf
commit 8f3ce341f8

View file

@ -1,5 +1,9 @@
/*
* Keyman is copyright (C) SIL Global. MIT License.
*/
package com.keyman.engine;
import android.content.Context;
import android.util.Log;
import androidx.test.core.app.ApplicationProvider;
@ -32,7 +36,11 @@ public class KMManagerTest {
// For some keyboard list tests, load an existing keyboard list.
// Can't use @Before because context is null before running tests.
public void loadOldKeyboardsList() {
KMManager.initialize(ApplicationProvider.getApplicationContext(), KMManager.KeyboardType.KEYBOARD_TYPE_INAPP);
Context context = ApplicationProvider.getApplicationContext();
// Create appData directory accessed in KMKeyboardWebViewClient
File dataDir = context.getDir("data", Context.MODE_PRIVATE);
dataDir.mkdirs();
KMManager.initialize(context, KMManager.KeyboardType.KEYBOARD_TYPE_INAPP);
File keyboards_dat = new File(TEST_RESOURCE_ROOT, OLD_KEYBOARDS_LIST);
if (keyboards_dat == null || !keyboards_dat.exists()) {