|
6 | 6 | */ |
7 | 7 | package com.nmc.android.ui |
8 | 8 |
|
| 9 | +import android.content.Intent |
9 | 10 | import android.view.View |
10 | | -import androidx.test.core.app.launchActivity |
11 | 11 | import androidx.test.ext.junit.runners.AndroidJUnit4 |
| 12 | +import androidx.test.platform.app.InstrumentationRegistry |
12 | 13 | import com.owncloud.android.AbstractIT |
13 | 14 | import com.owncloud.android.R |
14 | 15 | import org.junit.Assert.assertEquals |
| 16 | +import org.junit.Assert.assertTrue |
15 | 17 | import org.junit.Test |
16 | 18 | import org.junit.runner.RunWith |
17 | 19 |
|
18 | 20 | @RunWith(AndroidJUnit4::class) |
19 | 21 | class LauncherActivityIT : AbstractIT() { |
20 | 22 |
|
| 23 | + private val instrumentation get() = InstrumentationRegistry.getInstrumentation() |
| 24 | + |
21 | 25 | @Test |
22 | 26 | fun testSplashScreenWithEmptyTitlesShouldHideTitles() { |
23 | | - launchActivity<LauncherActivity>().onActivity { activity -> |
24 | | - assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.ivSplash).visibility) |
25 | | - assertEquals(View.GONE, activity.findViewById<View>(R.id.splashScreenBold).visibility) |
26 | | - assertEquals(View.GONE, activity.findViewById<View>(R.id.splashScreenNormal).visibility) |
27 | | - } |
| 27 | + val activity = launchLauncherActivity() |
| 28 | + |
| 29 | + assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.ivSplash).visibility) |
| 30 | + assertEquals(View.GONE, activity.findViewById<View>(R.id.splashScreenBold).visibility) |
| 31 | + assertEquals(View.GONE, activity.findViewById<View>(R.id.splashScreenNormal).visibility) |
28 | 32 | } |
29 | 33 |
|
30 | 34 | @Test |
31 | 35 | fun testSplashScreenWithTitlesShouldShowTitles() { |
32 | | - launchActivity<LauncherActivity>().onActivity { activity -> |
33 | | - activity.setSplashTitles("Example", "Cloud") |
| 36 | + val activity = launchLauncherActivity() |
| 37 | + |
| 38 | + instrumentation.runOnMainSync { activity.setSplashTitles("Example", "Cloud") } |
| 39 | + |
| 40 | + assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.ivSplash).visibility) |
| 41 | + assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.splashScreenBold).visibility) |
| 42 | + assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.splashScreenNormal).visibility) |
| 43 | + } |
| 44 | + |
| 45 | + @Test |
| 46 | + fun testSplashScreenWithEmptyTitlesShouldNotDelayNextScreen() { |
| 47 | + val activity = launchLauncherActivity() |
| 48 | + |
| 49 | + instrumentation.waitForIdleSync() |
| 50 | + |
| 51 | + assertTrue(activity.isFinishing) |
| 52 | + } |
| 53 | + |
| 54 | + private fun launchLauncherActivity(): LauncherActivity { |
| 55 | + val intent = Intent(targetContext, LauncherActivity::class.java) |
| 56 | + .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK) |
34 | 57 |
|
35 | | - assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.ivSplash).visibility) |
36 | | - assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.splashScreenBold).visibility) |
37 | | - assertEquals(View.VISIBLE, activity.findViewById<View>(R.id.splashScreenNormal).visibility) |
38 | | - } |
| 58 | + return instrumentation.startActivitySync(intent) as LauncherActivity |
39 | 59 | } |
40 | 60 | } |
0 commit comments