personalist UI Tests (#381)
Co-authored-by: PraveenKumar <pyeruva@microsoft.com>
This commit is contained in:
Родитель
487aec1d8b
Коммит
f7193d61b0
|
@ -11,6 +11,7 @@ import org.junit.runners.Suite
|
|||
V2AvatarActivityUITest::class,
|
||||
V2AvatarGroupActivityUITest::class,
|
||||
V2DrawerActivityUITest::class,
|
||||
V2ProgressIndicatorUITest::class
|
||||
V2ProgressIndicatorUITest::class,
|
||||
V2PersonaListActivityUITest::class
|
||||
)
|
||||
class UiTestSuite
|
|
@ -0,0 +1,57 @@
|
|||
package com.microsoft.fluentuidemo.demos
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.compose.ui.test.*
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.espresso.intent.Intents
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.microsoft.fluentuidemo.DemoActivity
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
|
||||
class V2PersonaListActivityUITest {
|
||||
private fun launchActivity() {
|
||||
ActivityScenario.launch<V2PersonaListActivity>(setUpIntentForActivity())
|
||||
}
|
||||
|
||||
private fun setUpIntentForActivity(): Intent {
|
||||
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
val intent = Intent(targetContext, V2PersonaListActivity::class.java)
|
||||
intent.putExtra(DemoActivity.DEMO_ID, UUID.randomUUID())
|
||||
return intent
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
|
||||
@Before
|
||||
fun initialize() {
|
||||
Intents.init()
|
||||
launchActivity()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPersonaListBounds(){
|
||||
val personaList = composeTestRule.onNodeWithTag("list")
|
||||
personaList.onChildAt(0).assertHeightIsAtLeast(48.dp)
|
||||
}
|
||||
@Test
|
||||
fun testPersonaList(){
|
||||
composeTestRule.onRoot(true).printToLog("tree")
|
||||
val personaList = composeTestRule.onNodeWithTag("list")
|
||||
personaList.assertExists()
|
||||
personaList.assertIsDisplayed()
|
||||
personaList.assert(hasScrollAction())
|
||||
personaList.onChildAt(0).assertHasClickAction()
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Intents.release()
|
||||
}
|
||||
}
|
|
@ -5,8 +5,10 @@ import android.os.Bundle
|
|||
import androidx.compose.material.*
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.rememberCoroutineScope
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.vector.rememberVectorPainter
|
||||
import androidx.compose.ui.platform.ComposeView
|
||||
import androidx.compose.ui.platform.testTag
|
||||
import com.microsoft.fluentui.theme.FluentTheme
|
||||
import com.microsoft.fluentui.theme.token.AliasTokens
|
||||
import com.microsoft.fluentui.theme.token.controlTokens.AvatarStatus.Available
|
||||
|
@ -236,6 +238,7 @@ class V2PersonaListActivity : DemoActivity() {
|
|||
val coroutineScope: CoroutineScope = rememberCoroutineScope()
|
||||
Scaffold(scaffoldState = scaffoldState) {
|
||||
PersonaList(
|
||||
modifier = Modifier.testTag("list"),
|
||||
personas = createPersonasList(scaffoldState, coroutineScope),
|
||||
border = BorderType.Bottom,
|
||||
borderInset = BorderInset.XXLarge
|
||||
|
|
|
@ -48,7 +48,7 @@ fun PersonaList(
|
|||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val lazyListState = rememberLazyListState()
|
||||
LazyColumn(state = lazyListState, modifier = Modifier.draggable(
|
||||
LazyColumn(state = lazyListState, modifier = modifier.draggable(
|
||||
orientation = Orientation.Vertical,
|
||||
state = rememberDraggableState { delta ->
|
||||
scope.launch {
|
||||
|
@ -61,7 +61,6 @@ fun PersonaList(
|
|||
text = item.title,
|
||||
subText = item.subTitle,
|
||||
secondarySubText = item.footer,
|
||||
modifier = modifier,
|
||||
onClick = item.onClick,
|
||||
border = border,
|
||||
borderInset = borderInset,
|
||||
|
|
Загрузка…
Ссылка в новой задаче