Remove the data-client app adapter implementation (#5499)

* logErrorsInsteadOfCrashing only ever returned false, so remove it and simplify logger

* Removed unused getMediaWikiBaseUrl()

* Removed getDesiredLeadImageDp() from commons app adapter, since it's unused

* Inlined the isLoggedIn() method of the app adapter

* Inline the app adapter username/password

* Removed the unused getRestbaseUriFormat() from the commons app adapter

* Remove references to the data-client SharedPreferenceCookieManager

* Manage our own OkHttpClient and remove the AppAdapter implementation
This commit is contained in:
Paul Hawke 2024-01-30 19:21:43 -06:00 committed by GitHub
parent ab9e57f5be
commit 8db0b54929
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
57 changed files with 422 additions and 518 deletions

View file

@ -10,9 +10,10 @@ import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.test.core.app.ApplicationProvider
import fr.free.nrw.commons.OkHttpConnectionFactory
import fr.free.nrw.commons.R
import fr.free.nrw.commons.TestAppAdapter
import fr.free.nrw.commons.TestCommonsApplication
import fr.free.nrw.commons.createTestClient
import fr.free.nrw.commons.auth.login.LoginResult
import fr.free.nrw.commons.kvstore.JsonKvStore
import org.junit.Assert
@ -27,7 +28,6 @@ import org.robolectric.Robolectric
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import org.robolectric.fakes.RoboMenuItem
import org.wikipedia.AppAdapter
import java.lang.reflect.Method
@ -74,7 +74,7 @@ class LoginActivityUnitTests {
@Before
fun setUp() {
MockitoAnnotations.openMocks(this)
AppAdapter.set(TestAppAdapter())
OkHttpConnectionFactory.CLIENT = createTestClient()
activity = Robolectric.buildActivity(LoginActivity::class.java).create().get()
context = ApplicationProvider.getApplicationContext()
menuItem = RoboMenuItem(null)

View file

@ -19,7 +19,8 @@ class CsrfTokenClientTest : MockWebServerTest() {
private val sessionManager = mock(SessionManager::class.java)
private val tokenInterface = mock(CsrfTokenInterface::class.java)
private val loginClient = mock(LoginClient::class.java)
private val subject = CsrfTokenClient(sessionManager, tokenInterface, loginClient)
private val logoutClient = mock(LogoutClient::class.java)
private val subject = CsrfTokenClient(sessionManager, tokenInterface, loginClient, logoutClient)
@Test
@Throws(Throwable::class)