mirror of
https://github.com/nextcloud/android.git
synced 2024-11-23 21:55:48 +03:00
Fix SplashScreen title tests
Signed-off-by: alperozturk <alper_ozturk@proton.me>
This commit is contained in:
parent
ff6919124a
commit
887c197287
2 changed files with 40 additions and 17 deletions
|
@ -23,7 +23,10 @@ package com.nmc.android.ui
|
||||||
|
|
||||||
import androidx.test.espresso.Espresso.onView
|
import androidx.test.espresso.Espresso.onView
|
||||||
import androidx.test.espresso.assertion.ViewAssertions.matches
|
import androidx.test.espresso.assertion.ViewAssertions.matches
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
|
import androidx.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
|
||||||
|
import androidx.test.espresso.matcher.ViewMatchers.withEffectiveVisibility
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withId
|
import androidx.test.espresso.matcher.ViewMatchers.withId
|
||||||
import androidx.test.espresso.matcher.ViewMatchers.withText
|
import androidx.test.espresso.matcher.ViewMatchers.withText
|
||||||
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
||||||
|
@ -33,6 +36,7 @@ import com.owncloud.android.R
|
||||||
import org.junit.Rule
|
import org.junit.Rule
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import org.junit.runner.RunWith
|
import org.junit.runner.RunWith
|
||||||
|
import org.mockito.AdditionalMatchers.not
|
||||||
|
|
||||||
@RunWith(AndroidJUnit4::class)
|
@RunWith(AndroidJUnit4::class)
|
||||||
class LauncherActivityIT : AbstractIT() {
|
class LauncherActivityIT : AbstractIT() {
|
||||||
|
@ -41,14 +45,26 @@ class LauncherActivityIT : AbstractIT() {
|
||||||
val activityRule = ActivityScenarioRule(LauncherActivity::class.java)
|
val activityRule = ActivityScenarioRule(LauncherActivity::class.java)
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun verifyUIElements() {
|
fun testSplashScreenWithEmptyTitlesShouldHideTitles() {
|
||||||
waitForIdleSync()
|
waitForIdleSync()
|
||||||
|
|
||||||
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
|
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
|
||||||
onView(withId(R.id.splashScreenBold)).check(matches(isCompletelyDisplayed()))
|
|
||||||
onView(withId(R.id.splashScreenNormal)).check(matches(isCompletelyDisplayed()))
|
|
||||||
|
|
||||||
onView(withId(R.id.splashScreenBold)).check(matches(withText("Magenta")))
|
onView(withId(R.id.splashScreenBold)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
|
||||||
onView(withId(R.id.splashScreenNormal)).check(matches(withText("CLOUD")))
|
onView(withId(R.id.splashScreenNormal)).check(matches(withEffectiveVisibility(ViewMatchers.Visibility.GONE)))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testSplashScreenWithTitlesShouldShowTitles() {
|
||||||
|
waitForIdleSync()
|
||||||
|
onView(withId(R.id.ivSplash)).check(matches(isCompletelyDisplayed()))
|
||||||
|
|
||||||
|
activityRule.scenario.onActivity {
|
||||||
|
it.setSplashTitles("Example", "Cloud")
|
||||||
|
}
|
||||||
|
|
||||||
|
val onePercentArea = ViewMatchers.isDisplayingAtLeast(1)
|
||||||
|
onView(withId(R.id.splashScreenBold)).check(matches(onePercentArea))
|
||||||
|
onView(withId(R.id.splashScreenNormal)).check(matches(onePercentArea))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,8 +23,10 @@ package com.nmc.android.ui
|
||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.os.Bundle
|
import android.os.Bundle
|
||||||
import android.os.Handler
|
import android.os.Handler
|
||||||
|
import android.os.Looper
|
||||||
import android.text.TextUtils
|
import android.text.TextUtils
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import androidx.annotation.VisibleForTesting
|
||||||
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
import androidx.core.splashscreen.SplashScreen.Companion.installSplashScreen
|
||||||
import com.nextcloud.client.preferences.AppPreferences
|
import com.nextcloud.client.preferences.AppPreferences
|
||||||
import com.owncloud.android.R
|
import com.owncloud.android.R
|
||||||
|
@ -54,6 +56,15 @@ class LauncherActivity : BaseActivity() {
|
||||||
scheduleSplashScreen()
|
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() {
|
private fun updateTitleVisibility() {
|
||||||
if (TextUtils.isEmpty(resources.getString(R.string.splashScreenBold))) {
|
if (TextUtils.isEmpty(resources.getString(R.string.splashScreenBold))) {
|
||||||
binding.splashScreenBold.visibility = View.GONE
|
binding.splashScreenBold.visibility = View.GONE
|
||||||
|
@ -64,18 +75,14 @@ class LauncherActivity : BaseActivity() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun scheduleSplashScreen() {
|
private fun scheduleSplashScreen() {
|
||||||
Handler().postDelayed(
|
Handler(Looper.getMainLooper()).postDelayed({
|
||||||
{
|
if (!user.isPresent) {
|
||||||
// if user is null then go to authenticator activity
|
startActivity(Intent(this, AuthenticatorActivity::class.java))
|
||||||
if (!user.isPresent) {
|
} else {
|
||||||
startActivity(Intent(this, AuthenticatorActivity::class.java))
|
startActivity(Intent(this, FileDisplayActivity::class.java))
|
||||||
} else {
|
}
|
||||||
startActivity(Intent(this, FileDisplayActivity::class.java))
|
finish()
|
||||||
}
|
}, SPLASH_DURATION)
|
||||||
finish()
|
|
||||||
},
|
|
||||||
SPLASH_DURATION
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
|
Loading…
Reference in a new issue