Package org.robolectric.shadows
Class ShadowLocaleManager
java.lang.Object
org.robolectric.shadows.ShadowLocaleManager
@Implements(value=android.app.LocaleManager.class, minSdk=33, isInAndroidSdk=false) public class ShadowLocaleManager extends Object
Shadow of
LocaleManager
-
Constructor Summary
Constructors Constructor Description ShadowLocaleManager()
-
Method Summary
Modifier and Type Method Description void
enforceInstallerCheck(boolean value)
Sets the value ofenforceInstallerCheck
.protected LocaleList
getApplicationLocales(String packageName)
Returns the stored locales from in-memory map for the given package whenLocaleManager.getApplicationLocales()
is invoked in source code via tests.protected LocaleList
getSystemLocales()
protected void
setApplicationLocales(String packageName, LocaleList locales)
Stores the passed locales for the given package in-memory.void
setCallerAsInstallerForPackage(String packageName)
Sets the caller as the installer of the given package.
-
Constructor Details
-
ShadowLocaleManager
public ShadowLocaleManager()
-
-
Method Details
-
getApplicationLocales
Returns the stored locales from in-memory map for the given package whenLocaleManager.getApplicationLocales()
is invoked in source code via tests.If
enforceInstallerCheck
is set as true, this method will return locales only if the package is installed by caller. Else it will throw aSecurityException
.Adds the package name in a set to record that this method was invoked for given package.
- See Also:
enforceInstallerCheck
,setCallerAsInstallerForPackage(java.lang.String)
-
setApplicationLocales
Stores the passed locales for the given package in-memory.Use this method in tests to substitute call for
LocaleManager.setApplicationLocales(android.os.LocaleList)
. -
getSystemLocales
-
enforceInstallerCheck
public void enforceInstallerCheck(boolean value)Sets the value ofenforceInstallerCheck
.Set this to true if the intention to invoke
getApplicationLocales(java.lang.String)
is as an installer of the app.In order to mark apps as installed by the caller(installer), use
setCallerAsInstallerForPackage(java.lang.String)
. -
setCallerAsInstallerForPackage
Sets the caller as the installer of the given package.We are explicitly not storing the package name of the installer. It's implied that the test app is the installer if using this method.
-