instance property access fix

Signed-off-by: parneet-guraya <gurayaparneet@gmail.com>
This commit is contained in:
parneet-guraya 2024-10-20 21:01:44 +05:30
parent 8d629b4305
commit f26b651f54
No known key found for this signature in database
GPG key ID: 63B807C4B2A9064B
5 changed files with 8 additions and 7 deletions

View file

@ -105,7 +105,7 @@ class AboutActivityTest {
fun testLaunchTranslate() { fun testLaunchTranslate() {
Espresso.onView(ViewMatchers.withId(R.id.about_translate)).perform(ViewActions.click()) Espresso.onView(ViewMatchers.withId(R.id.about_translate)).perform(ViewActions.click())
Espresso.onView(ViewMatchers.withId(android.R.id.button1)).perform(ViewActions.click()) Espresso.onView(ViewMatchers.withId(android.R.id.button1)).perform(ViewActions.click())
val langCode = CommonsApplication.getInstance().languageLookUpTable.codes[0] val langCode = CommonsApplication.instance.languageLookUpTable!!.codes[0]
Intents.intended( Intents.intended(
CoreMatchers.allOf( CoreMatchers.allOf(
IntentMatchers.hasAction(Intent.ACTION_VIEW), IntentMatchers.hasAction(Intent.ACTION_VIEW),

View file

@ -85,7 +85,6 @@ class CommonsApplication : MultiDexApplication() {
@Inject @Inject
lateinit var customOkHttpNetworkFetcher: CustomOkHttpNetworkFetcher lateinit var customOkHttpNetworkFetcher: CustomOkHttpNetworkFetcher
//TODO [parry] not being used anywhere, remove after checking
var languageLookUpTable: AppLanguageLookUpTable? = null var languageLookUpTable: AppLanguageLookUpTable? = null
private set private set
@ -385,7 +384,9 @@ class CommonsApplication : MultiDexApplication() {
/** /**
* Constants End * Constants End
*/ */
var instance: CommonsApplication? = null
@JvmStatic
lateinit var instance: CommonsApplication
private set private set
@JvmField @JvmField

View file

@ -32,7 +32,7 @@ class ThanksClient
revisionId.toString(), // Rev revisionId.toString(), // Rev
null, // Log null, // Log
csrfTokenClient.getTokenBlocking(), // Token csrfTokenClient.getTokenBlocking(), // Token
CommonsApplication.getInstance().userAgent, // Source CommonsApplication.instance.userAgent, // Source
).map { mwThankPostResponse -> ).map { mwThankPostResponse ->
mwThankPostResponse.result?.success == 1 mwThankPostResponse.result?.success == 1
} }

View file

@ -258,7 +258,7 @@ class DescriptionEditActivity :
username, username,
) )
val commonsApplication = CommonsApplication.getInstance() val commonsApplication = CommonsApplication.instance
if (commonsApplication != null) { if (commonsApplication != null) {
commonsApplication.clearApplicationData(this, logoutListener) commonsApplication.clearApplicationData(this, logoutListener)
} }
@ -291,7 +291,7 @@ class DescriptionEditActivity :
username, username,
) )
val commonsApplication = CommonsApplication.getInstance() val commonsApplication = CommonsApplication.instance
if (commonsApplication != null) { if (commonsApplication != null) {
commonsApplication.clearApplicationData(this, logoutListener) commonsApplication.clearApplicationData(this, logoutListener)
} }

View file

@ -39,7 +39,7 @@ class ThanksClientTest {
fun setUp() { fun setUp() {
MockitoAnnotations.openMocks(this) MockitoAnnotations.openMocks(this)
mockedApplication = Mockito.mockStatic(CommonsApplication::class.java) mockedApplication = Mockito.mockStatic(CommonsApplication::class.java)
`when`(CommonsApplication.getInstance()).thenReturn(commonsApplication) `when`(CommonsApplication.instance).thenReturn(commonsApplication)
thanksClient = ThanksClient(csrfTokenClient, service) thanksClient = ThanksClient(csrfTokenClient, service)
} }