mirror of https://github.com/iSoron/uhabits.git
Add otus directory with OtusIntroTest, OtusSettingTest, AboutScreen, IntroScreen, SettingScreen. Add androidTestImplementations for Kaspresso. Update testInstrumentationRunner for Kaspresso.
parent
fc9cc423d0
commit
48a4b9ffa1
@ -0,0 +1,20 @@
|
|||||||
|
package org.isoron.uhabits.otus
|
||||||
|
|
||||||
|
import com.kaspersky.kaspresso.screens.KScreen
|
||||||
|
import org.isoron.uhabits.R
|
||||||
|
import io.github.kakaocup.kakao.text.KTextView
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
object AboutScreen : KScreen<AboutScreen>() {
|
||||||
|
override val layoutId: Int? = null
|
||||||
|
override val viewClass: Class<*>? = null
|
||||||
|
val tvVersion = KTextView { withId(R.id.tvVersion) }
|
||||||
|
val tvRate = KTextView { withId(R.id.tvRate) }
|
||||||
|
val tvFeedback = KTextView { withId(R.id.tvFeedback) }
|
||||||
|
val tvTranslate = KTextView { withId(R.id.tvTranslate) }
|
||||||
|
val tvSource = KTextView { withId(R.id.tvSource) }
|
||||||
|
val tvPrivacy = KTextView { withId(R.id.tvPrivacy) }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
|||||||
|
package org.isoron.uhabits.otus
|
||||||
|
|
||||||
|
import com.kaspersky.kaspresso.screens.KScreen
|
||||||
|
import org.isoron.uhabits.R
|
||||||
|
import io.github.kakaocup.kakao.text.KTextView
|
||||||
|
import io.github.kakaocup.kakao.bottomnav.KBottomNavigationView
|
||||||
|
import io.github.kakaocup.kakao.image.KImageView
|
||||||
|
import io.github.kakaocup.kakao.text.KButton
|
||||||
|
|
||||||
|
|
||||||
|
object IntroScreen : KScreen<IntroScreen>() {
|
||||||
|
override val layoutId: Int? = null
|
||||||
|
override val viewClass: Class<*>? = null
|
||||||
|
val bottom = KBottomNavigationView { withId(R.id.bottom) }
|
||||||
|
val back = KButton { withId(R.id.back) }
|
||||||
|
val done = KButton { withId(R.id.done) }
|
||||||
|
val next = KButton { withId(R.id.next) }
|
||||||
|
val skip = KButton { withId(R.id.skip) }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -0,0 +1,111 @@
|
|||||||
|
package org.isoron.uhabits.otus
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import androidx.test.uiautomator.UiDevice
|
||||||
|
import com.kaspersky.components.alluresupport.interceptors.step.AllureMapperStepInterceptor
|
||||||
|
import com.kaspersky.components.alluresupport.interceptors.testrun.DumpLogcatTestInterceptor
|
||||||
|
import com.kaspersky.kaspresso.kaspresso.Kaspresso
|
||||||
|
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase
|
||||||
|
import org.isoron.uhabits.activities.intro.IntroActivity
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
class OtusIntroTest: TestCase(kaspressoBuilder = Kaspresso.Builder.simple(
|
||||||
|
customize = {
|
||||||
|
if (isAndroidRuntime) {
|
||||||
|
UiDevice
|
||||||
|
.getInstance(instrumentation)
|
||||||
|
.executeShellCommand("appops set --uid ${InstrumentationRegistry.getInstrumentation().targetContext.packageName} MANAGE_EXTERNAL_STORAGE allow")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).apply {
|
||||||
|
stepWatcherInterceptors.addAll(
|
||||||
|
listOf(
|
||||||
|
AllureMapperStepInterceptor()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
testRunWatcherInterceptors.addAll (
|
||||||
|
listOf(
|
||||||
|
DumpLogcatTestInterceptor(logcatDumper)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val activityScenarioRule = ActivityScenarioRule(IntroActivity::class.java)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun test_checkElementsOnAllIntroScreens() = run {
|
||||||
|
step("Проверка 1 интро и переход на 2") {
|
||||||
|
IntroScreen {
|
||||||
|
bottom.isVisible()
|
||||||
|
skip.isVisible()
|
||||||
|
back.isInvisible()
|
||||||
|
done.isInvisible()
|
||||||
|
next.isVisible()
|
||||||
|
next.click()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
step("Проверка 2 интро и переход на 3") {
|
||||||
|
IntroScreen {
|
||||||
|
bottom.isVisible()
|
||||||
|
skip.isVisible()
|
||||||
|
back.isInvisible()
|
||||||
|
done.isInvisible()
|
||||||
|
next.isVisible()
|
||||||
|
next.click()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
step("Проверка 3 интро") {
|
||||||
|
IntroScreen {
|
||||||
|
bottom.isVisible()
|
||||||
|
skip.isInvisible()
|
||||||
|
back.isInvisible()
|
||||||
|
next.isInvisible()
|
||||||
|
done.isVisible()
|
||||||
|
done.click()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
fun test_skipFromFirstIntro() = run {
|
||||||
|
step("Проверка отображения элементов на 1 интро и скип") {
|
||||||
|
IntroScreen {
|
||||||
|
bottom.isVisible()
|
||||||
|
skip.isVisible()
|
||||||
|
back.isInvisible()
|
||||||
|
done.isInvisible()
|
||||||
|
next.isVisible()
|
||||||
|
skip.click()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@Test
|
||||||
|
fun test_skipFromSecondIntro() = run {
|
||||||
|
step("Проверка отображения элеметов на 1 интро и переход ко 2") {
|
||||||
|
IntroScreen {
|
||||||
|
bottom.isVisible()
|
||||||
|
skip.isVisible()
|
||||||
|
back.isInvisible()
|
||||||
|
done.isInvisible()
|
||||||
|
next.isVisible()
|
||||||
|
next.click()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
step("Проверка отображения элементов на 2 интро и скип") {
|
||||||
|
IntroScreen {
|
||||||
|
bottom.isVisible()
|
||||||
|
skip.isVisible()
|
||||||
|
back.isInvisible()
|
||||||
|
done.isInvisible()
|
||||||
|
next.isVisible()
|
||||||
|
skip.click()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package org.isoron.uhabits.otus
|
||||||
|
|
||||||
|
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
||||||
|
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||||
|
import androidx.test.platform.app.InstrumentationRegistry
|
||||||
|
import androidx.test.rule.GrantPermissionRule
|
||||||
|
import androidx.test.uiautomator.UiDevice
|
||||||
|
import com.kaspersky.components.alluresupport.interceptors.step.AllureMapperStepInterceptor
|
||||||
|
import com.kaspersky.components.alluresupport.interceptors.testrun.DumpLogcatTestInterceptor
|
||||||
|
import com.kaspersky.kaspresso.kaspresso.Kaspresso
|
||||||
|
import com.kaspersky.kaspresso.testcases.api.testcase.TestCase
|
||||||
|
import org.isoron.uhabits.activities.settings.SettingsActivity
|
||||||
|
import org.junit.Assert
|
||||||
|
import org.junit.Rule
|
||||||
|
import org.junit.Test
|
||||||
|
import org.junit.runner.RunWith
|
||||||
|
|
||||||
|
@RunWith(AndroidJUnit4::class)
|
||||||
|
|
||||||
|
class OtusSettingTest: TestCase(kaspressoBuilder = Kaspresso.Builder.simple(
|
||||||
|
customize = {
|
||||||
|
if (isAndroidRuntime) {
|
||||||
|
UiDevice
|
||||||
|
.getInstance(instrumentation)
|
||||||
|
.executeShellCommand("appops set --uid ${InstrumentationRegistry.getInstrumentation().targetContext.packageName} MANAGE_EXTERNAL_STORAGE allow")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
).apply {
|
||||||
|
stepWatcherInterceptors.addAll(
|
||||||
|
listOf(
|
||||||
|
AllureMapperStepInterceptor()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
testRunWatcherInterceptors.addAll (
|
||||||
|
listOf(
|
||||||
|
DumpLogcatTestInterceptor(logcatDumper)
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
) {
|
||||||
|
|
||||||
|
@get:Rule
|
||||||
|
val activityScenarioRule = ActivityScenarioRule(SettingsActivity::class.java)
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun test_checkToolbarAndCountElements() = run {
|
||||||
|
step("1") {
|
||||||
|
SettingScreen {
|
||||||
|
Assert.assertEquals(23, recyclerView.getSize())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
step("2") {
|
||||||
|
SettingScreen {
|
||||||
|
toolbarSettings.isVisible()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,26 @@
|
|||||||
|
package org.isoron.uhabits.otus
|
||||||
|
|
||||||
|
import org.isoron.uhabits.R
|
||||||
|
import io.github.kakaocup.kakao.toolbar.KToolbar
|
||||||
|
import org.hamcrest.Matcher
|
||||||
|
import android.view.View
|
||||||
|
import com.kaspersky.kaspresso.screens.KScreen
|
||||||
|
import io.github.kakaocup.kakao.recycler.KRecyclerItem
|
||||||
|
import io.github.kakaocup.kakao.recycler.KRecyclerView
|
||||||
|
|
||||||
|
object SettingScreen: KScreen<SettingScreen>() {
|
||||||
|
override val layoutId: Int? = null
|
||||||
|
override val viewClass: Class<*>? = null
|
||||||
|
val toolbarSettings = KToolbar { withId(R.id.toolbar) }
|
||||||
|
val recyclerView = KRecyclerView(
|
||||||
|
builder = { withId(R.id.recycler_view) },
|
||||||
|
itemTypeBuilder = { itemType(::NoteSettingScreen) }
|
||||||
|
)
|
||||||
|
class NoteSettingScreen(matcher: Matcher<View>) : KRecyclerItem<NoteSettingScreen>(matcher) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in new issue