Skip to content

Commit

Permalink
Remove WPLocaleTestRule and updateContextLocale (#21539)
Browse files Browse the repository at this point in the history
  • Loading branch information
nbradbury authored Dec 18, 2024
2 parents f10e29f + f68eb08 commit 92d71de
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ public class JPScreenshotTest extends BaseTest {
@ClassRule
public static final RuleChain LOCALE_TEST_RULES = RuleChain
// Run fastlane's official LocaleTestRule (which switches device language + sets up screengrab) first
.outerRule(new LocaleTestRule())
// Run our own rule (which handles our in-app locale switching logic) second
.around(new WPLocaleTestRule());
.outerRule(new LocaleTestRule());

// Note: running this as a static @ClassRule as part of the above RuleChain doesn't seem to work
// (apparently that would make those run too early?), but running it as @Rule does fix the issue.
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ public class WPScreenshotTest extends BaseTest {
@ClassRule
public static final RuleChain LOCALE_TEST_RULES = RuleChain
// Run fastlane's official LocaleTestRule (which switches device language + sets up screengrab) first
.outerRule(new LocaleTestRule())
// Run our own rule (which handles our in-app locale switching logic) second
.around(new WPLocaleTestRule());
.outerRule(new LocaleTestRule());

// Note: running this as a static @ClassRule as part of the above RuleChain doesn't seem to work
// (apparently that would make those run too early?), but running it as @Rule does fix the issue.
Expand Down
17 changes: 0 additions & 17 deletions WordPress/src/main/java/org/wordpress/android/AppInitializer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ import org.wordpress.android.util.BuildConfigWrapper
import org.wordpress.android.util.DateTimeUtils
import org.wordpress.android.util.EncryptedLogging
import org.wordpress.android.util.FluxCUtils
import org.wordpress.android.util.LocaleManager
import org.wordpress.android.util.NetworkUtils
import org.wordpress.android.util.PackageUtils
import org.wordpress.android.util.PerAppLocaleManager
Expand Down Expand Up @@ -1086,21 +1085,5 @@ class AppInitializer @Inject constructor(
}
return bitmapCache as BitmapLruCache
}

/**
* Update locale of the static context when language is changed.
*
* When calling this method the application context **must** be already initialized.
* This is already the case in `Activity`, `Fragment` or `View`.
*
* When called from other places (E.g. a `TestRule`) we should provide it in the [appContext] parameter.
*/
fun updateContextLocale(appContext: Context? = null) {
val context = appContext ?: run {
check(context != null) { "Context must be initialized before calling updateContextLocale" }
return@run context
}
this.context = LocaleManager.setLocale(context)
}
}
}
7 changes: 0 additions & 7 deletions WordPress/src/main/java/org/wordpress/android/WordPress.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.wordpress.android

import android.app.Application
import android.content.Context
import coil.decode.VideoFrameDecoder
import com.android.volley.RequestQueue
import dagger.hilt.EntryPoints
Expand Down Expand Up @@ -59,12 +58,6 @@ abstract class WordPress : Application(), coil.ImageLoaderFactory {
@JvmStatic
fun getContext() = AppInitializer.context!!

@JvmStatic
@JvmOverloads
fun updateContextLocale(appContext: Context? = null) {
AppInitializer.updateContextLocale(appContext)
}

@JvmStatic
fun getRestClientUtils() = AppInitializer.restClientUtils

Expand Down

0 comments on commit 92d71de

Please sign in to comment.