-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathToFileTest.kt
More file actions
46 lines (37 loc) · 1.58 KB
/
ToFileTest.kt
File metadata and controls
46 lines (37 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package info.hannes.logcat
import android.graphics.Bitmap
import androidx.test.core.graphics.writeToTestStorage
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.captureToBitmap
import androidx.test.espresso.assertion.ViewAssertions
import androidx.test.espresso.matcher.ViewMatchers.*
import androidx.test.ext.junit.rules.activityScenarioRule
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.moka.lib.assertions.MatchOperator
import com.moka.lib.assertions.RecyclerViewItemCountAssertion
import info.hannes.logcat.ui.LogfileActivity
import org.hamcrest.CoreMatchers.allOf
import org.junit.Rule
import org.junit.Test
import org.junit.rules.TestName
import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class ToFileTest {
@get:Rule
val activityScenarioRule = activityScenarioRule<LogfileActivity>()
@get:Rule
var nameRule = TestName()
@Test
fun logFileBasicTest() {
onView(allOf(withContentDescription("Timber Logfile"),
withParent(withId(info.hannes.logcat.ui.R.id.action_bar)),
isDisplayed()))
val recycler = onView(withId(info.hannes.logcat.ui.R.id.log_recycler))
recycler.check(ViewAssertions.matches(isDisplayed()))
recycler.check(RecyclerViewItemCountAssertion(2, MatchOperator.GREATER_EQUAL))
// Screenshot is too fast. It generates black screens
Thread.sleep(300)
onView(isRoot())
.perform(captureToBitmap { bitmap: Bitmap -> bitmap.writeToTestStorage("${javaClass.simpleName}_${nameRule.methodName}") })
}
}