From c75eb050dfed69ffda7950ca4a88330e7f4f39a1 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Wed, 20 Jan 2021 16:32:41 +0100 Subject: [PATCH] Cleanup and fix test compilation --- .../java/org/matrix/android/sdk/common/CommonTestHelper.kt | 4 +++- .../session/room/timeline/TimelineForwardPaginationTest.kt | 4 ++-- .../org/matrix/android/sdk/internal/session/DefaultSession.kt | 1 - vector/src/main/java/im/vector/app/features/MainActivity.kt | 2 -- .../java/im/vector/app/features/link/LinkHandlerActivity.kt | 2 +- 5 files changed, 6 insertions(+), 7 deletions(-) diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CommonTestHelper.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CommonTestHelper.kt index cb49ee8818..a4dbd70b11 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CommonTestHelper.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/common/CommonTestHelper.kt @@ -378,7 +378,9 @@ class CommonTestHelper(context: Context) { fun Iterable.signOutAndClose() = forEach { signOutAndClose(it) } fun signOutAndClose(session: Session) { - doSync(60_000) { session.signOut(true, it) } + runBlockingTest(timeout = 60_000) { + session.signOut(true) + } // no need signout will close // session.close() } diff --git a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineForwardPaginationTest.kt b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineForwardPaginationTest.kt index 34edf37733..f156a5eb64 100644 --- a/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineForwardPaginationTest.kt +++ b/matrix-sdk-android/src/androidTest/java/org/matrix/android/sdk/session/room/timeline/TimelineForwardPaginationTest.kt @@ -66,8 +66,8 @@ class TimelineForwardPaginationTest : InstrumentedTest { numberOfMessagesToSend) // Alice clear the cache - commonTestHelper.doSync { - aliceSession.clearCache(it) + commonTestHelper.runBlockingTest { + aliceSession.clearCache() } // And restarts the sync diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt index def865328c..fc5941bc61 100644 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/session/DefaultSession.kt @@ -20,7 +20,6 @@ import androidx.annotation.MainThread import dagger.Lazy import io.realm.RealmConfiguration import okhttp3.OkHttpClient -import org.matrix.android.sdk.api.MatrixCallback import org.matrix.android.sdk.api.auth.data.SessionParams import org.matrix.android.sdk.api.failure.GlobalError import org.matrix.android.sdk.api.pushrules.PushRuleService diff --git a/vector/src/main/java/im/vector/app/features/MainActivity.kt b/vector/src/main/java/im/vector/app/features/MainActivity.kt index beb9be8b9d..f8b8229e70 100644 --- a/vector/src/main/java/im/vector/app/features/MainActivity.kt +++ b/vector/src/main/java/im/vector/app/features/MainActivity.kt @@ -175,12 +175,10 @@ class MainActivity : VectorBaseActivity(), UnlockedActiv emptyViewModel.viewModelScope.launch { try { session.clearCache() - Timber.e("CACHE success") doLocalCleanup(clearPreferences = false) session.startSyncing(applicationContext) startNextActivityAndFinish() } catch (failure: Throwable) { - Timber.e("CACHE failure") displayError(failure) } } diff --git a/vector/src/main/java/im/vector/app/features/link/LinkHandlerActivity.kt b/vector/src/main/java/im/vector/app/features/link/LinkHandlerActivity.kt index b71d0a429e..7183f27980 100644 --- a/vector/src/main/java/im/vector/app/features/link/LinkHandlerActivity.kt +++ b/vector/src/main/java/im/vector/app/features/link/LinkHandlerActivity.kt @@ -151,7 +151,7 @@ class LinkHandlerActivity : VectorBaseActivity() { private fun safeSignout(uri: Uri) { val session = sessionHolder.getSafeActiveSession() - if(session == null) { + if (session == null) { // Should not happen startLoginActivity(uri) } else {