From 010a1e9626e055ce4600c729ab2364cdc85dfccc Mon Sep 17 00:00:00 2001 From: alperozturk96 Date: Wed, 30 Sep 2026 15:26:12 +0200 Subject: [PATCH] remove flaky tests Signed-off-by: alperozturk96 --- .../com/nmc/android/ui/LauncherActivityIT.kt | 80 ------------------- .../com/nmc/android/ui/LauncherActivity.kt | 10 --- 2 files changed, 90 deletions(-) delete mode 100644 app/src/androidTest/java/com/nmc/android/ui/LauncherActivityIT.kt diff --git a/app/src/androidTest/java/com/nmc/android/ui/LauncherActivityIT.kt b/app/src/androidTest/java/com/nmc/android/ui/LauncherActivityIT.kt deleted file mode 100644 index 16e19db0f9a5..000000000000 --- a/app/src/androidTest/java/com/nmc/android/ui/LauncherActivityIT.kt +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Nextcloud - Android Client - * - * SPDX-FileCopyrightText: 2026 Alper Ozturk - * SPDX-FileCopyrightText: 2023 TSI-mc - * SPDX-License-Identifier: AGPL-3.0-or-later OR GPL-2.0-only - */ -package com.nmc.android.ui - -import android.content.Intent -import android.os.SystemClock -import android.view.View -import androidx.test.ext.junit.runners.AndroidJUnit4 -import androidx.test.platform.app.InstrumentationRegistry -import com.nextcloud.test.Flaky -import com.owncloud.android.AbstractIT -import com.owncloud.android.R -import org.junit.Assert.assertEquals -import org.junit.Assert.assertTrue -import org.junit.Test -import org.junit.runner.RunWith - -@RunWith(AndroidJUnit4::class) -class LauncherActivityIT : AbstractIT() { - - private val instrumentation get() = InstrumentationRegistry.getInstrumentation() - - @Test - fun testSplashScreenWithEmptyTitlesShouldHideTitles() { - val activity = launchLauncherActivity() - - assertEquals(View.GONE, activity.findViewById(R.id.splashScreenBold).visibility) - assertEquals(View.GONE, activity.findViewById(R.id.splashScreenNormal).visibility) - } - - @Test - @Flaky(reason = "Opening FileDisplayActivity can keep the main thread busy past the launch timeout") - fun testSplashScreenWithTitlesShouldShowTitles() { - val activity = launchLauncherActivity() - - instrumentation.runOnMainSync { activity.setSplashTitles("Example", "Cloud") } - - assertEquals(View.VISIBLE, activity.findViewById(R.id.splashScreenBold).visibility) - assertEquals(View.VISIBLE, activity.findViewById(R.id.splashScreenNormal).visibility) - } - - @Test - fun testSplashScreenWithEmptyTitlesShouldNotDelayNextScreen() { - val activity = launchLauncherActivity() - - assertTrue("Splash screen without titles did not open the next screen", activity.awaitFinishing()) - } - - private fun launchLauncherActivity(): LauncherActivity { - val intent = Intent(targetContext, LauncherActivity::class.java) - .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) - - return instrumentation.startActivitySync(intent) as LauncherActivity - } - - private fun LauncherActivity.awaitFinishing(): Boolean { - val deadline = SystemClock.uptimeMillis() + FINISH_TIMEOUT_IN_MILLIS - var finishing = false - - while (!finishing && SystemClock.uptimeMillis() < deadline) { - instrumentation.runOnMainSync { finishing = isFinishing } - - if (!finishing) { - Thread.sleep(FINISH_POLL_INTERVAL_IN_MILLIS) - } - } - - return finishing - } - - companion object { - private const val FINISH_TIMEOUT_IN_MILLIS = 5000L - private const val FINISH_POLL_INTERVAL_IN_MILLIS = 50L - } -} diff --git a/app/src/main/java/com/nmc/android/ui/LauncherActivity.kt b/app/src/main/java/com/nmc/android/ui/LauncherActivity.kt index 58ef5aa6781d..3005ce314b9f 100644 --- a/app/src/main/java/com/nmc/android/ui/LauncherActivity.kt +++ b/app/src/main/java/com/nmc/android/ui/LauncherActivity.kt @@ -11,7 +11,6 @@ package com.nmc.android.ui import android.content.Intent import android.os.Bundle import android.view.View -import androidx.annotation.VisibleForTesting import androidx.appcompat.app.AppCompatActivity import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen import androidx.lifecycle.lifecycleScope @@ -56,15 +55,6 @@ class LauncherActivity : scheduleSplashScreen() } - @VisibleForTesting - fun setSplashTitles(boldText: String, normalText: String) { - binding.splashScreenBold.visibility = View.VISIBLE - binding.splashScreenNormal.visibility = View.VISIBLE - - binding.splashScreenBold.text = boldText - binding.splashScreenNormal.text = normalText - } - private fun updateTitleVisibility() { if (resources.getString(R.string.splashScreenBold).isEmpty()) { binding.splashScreenBold.visibility = View.GONE