Revamp all tests and reuse strings
This commit is contained in:
Родитель
e5d20845c3
Коммит
3b50a4dc54
|
@ -26,7 +26,6 @@ open class BaseTest {
|
|||
Intents.release()
|
||||
}
|
||||
|
||||
// TODO: Replace this everywhere else
|
||||
fun launchActivity(activity: Class<*>) {
|
||||
ActivityScenario.launch<DemoActivity>(setUpIntentForActivity(activity))
|
||||
}
|
||||
|
|
|
@ -1,18 +1,9 @@
|
|||
package com.microsoft.fluentuidemo
|
||||
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.test.espresso.Espresso.onView
|
||||
import androidx.test.espresso.Espresso.pressBack
|
||||
import androidx.test.espresso.action.ViewActions
|
||||
import androidx.test.espresso.contrib.RecyclerViewActions
|
||||
import androidx.test.espresso.intent.Intents
|
||||
import androidx.test.espresso.intent.Intents.intended
|
||||
import androidx.test.espresso.intent.matcher.IntentMatchers.hasComponent
|
||||
import androidx.test.espresso.matcher.ViewMatchers
|
||||
import androidx.test.ext.junit.rules.ActivityScenarioRule
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import org.junit.*
|
||||
import org.junit.runner.*
|
||||
import org.junit.Rule
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class DemoListActivityUITest {
|
||||
|
|
|
@ -16,10 +16,10 @@ import org.junit.runners.Suite
|
|||
V2CardNudgeActivityUITest::class,
|
||||
V2CardUITest::class,
|
||||
V2CitationUITest::class,
|
||||
V2DialogUITest::class,
|
||||
V2DialogActivityUITest::class,
|
||||
V2DrawerActivityUITest::class,
|
||||
V2LabelUITest::class,
|
||||
V2ListItemActivityUITest::class,
|
||||
V2ListItemUITest::class,
|
||||
V2PeoplePickerUITest::class,
|
||||
V2PersonaChipActivityUITest::class,
|
||||
V2PersonaListActivityUITest::class,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package com.microsoft.fluentuidemo.demos
|
||||
|
||||
import androidx.compose.ui.test.*
|
||||
import com.microsoft.fluentui.tokenized.persona.ANONYMOUS
|
||||
import com.microsoft.fluentui.tokenized.persona.AVATAR_ICON
|
||||
import com.microsoft.fluentui.tokenized.persona.AVATAR_IMAGE
|
||||
import com.microsoft.fluentuidemo.BaseTest
|
||||
|
@ -41,7 +42,7 @@ class V2AvatarActivityUITest : BaseTest() {
|
|||
//Check
|
||||
amandaAvatar.assertContentDescriptionContains("Active", substring = true)
|
||||
|
||||
composeTestRule.onAllNodesWithContentDescription("Anonymous")
|
||||
composeTestRule.onAllNodesWithContentDescription(ANONYMOUS)
|
||||
.assertAll(hasAnyChild(hasTestTag(AVATAR_ICON)))
|
||||
}
|
||||
|
||||
|
|
|
@ -1,43 +1,21 @@
|
|||
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 com.microsoft.fluentuidemo.BaseTest
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
|
||||
private const val ITEM_1_TAG = "item 1"
|
||||
private const val ITEM_2_TAG = "item 2"
|
||||
private const val LARGE_AVATAR_SIZE = 72
|
||||
private const val SMALL_AVATAR_SIZE = 56
|
||||
|
||||
class V2AvatarCarouselActivityUITest {
|
||||
private fun launchActivity() {
|
||||
ActivityScenario.launch<V2AvatarCarouselActivity>(setUpIntentForActivity())
|
||||
}
|
||||
|
||||
private fun setUpIntentForActivity(): Intent {
|
||||
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
val intent = Intent(targetContext, V2AvatarCarouselActivity::class.java)
|
||||
intent.putExtra(DemoActivity.DEMO_ID, UUID.randomUUID())
|
||||
return intent
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
class V2AvatarCarouselActivityUITest : BaseTest() {
|
||||
|
||||
@Before
|
||||
fun initialize() {
|
||||
Intents.init()
|
||||
launchActivity()
|
||||
launchActivity(V2AvatarCarouselActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -90,8 +68,4 @@ class V2AvatarCarouselActivityUITest {
|
|||
composeTestRule.onNodeWithTag(AVATAR_CAROUSEL_SMALL_CAROUSEL).assert(hasScrollAction())
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Intents.release()
|
||||
}
|
||||
}
|
|
@ -1,40 +1,17 @@
|
|||
package com.microsoft.fluentuidemo.demos
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.compose.ui.test.*
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
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 com.microsoft.fluentuidemo.BaseTest
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
|
||||
class V2AvatarGroupActivityUITest {
|
||||
|
||||
private fun launchActivity() {
|
||||
ActivityScenario.launch<V2AvatarGroupActivity>(setUpIntentForActivity())
|
||||
}
|
||||
|
||||
private fun setUpIntentForActivity(): Intent {
|
||||
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
val intent = Intent(targetContext, V2AvatarGroupActivity::class.java)
|
||||
intent.putExtra(DemoActivity.DEMO_ID, UUID.randomUUID())
|
||||
return intent
|
||||
}
|
||||
class V2AvatarGroupActivityUITest : BaseTest() {
|
||||
|
||||
@Before
|
||||
fun initialize() {
|
||||
Intents.init()
|
||||
launchActivity()
|
||||
launchActivity(V2AvatarGroupActivity::class.java)
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
|
||||
@Test
|
||||
fun testIncreaseDecreaseMaxAvatar() {
|
||||
val plusButton = composeTestRule.onNodeWithText("+")
|
||||
|
@ -104,9 +81,5 @@ class V2AvatarGroupActivityUITest {
|
|||
)
|
||||
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Intents.release()
|
||||
}
|
||||
|
||||
}
|
|
@ -1,37 +1,15 @@
|
|||
package com.microsoft.fluentuidemo.demos
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.compose.ui.test.*
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
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 androidx.compose.ui.test.onNodeWithTag
|
||||
import com.microsoft.fluentuidemo.BaseTest
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
|
||||
class V2BadgeActivityUITest {
|
||||
private fun launchActivity() {
|
||||
ActivityScenario.launch<V2BadgeActivity>(setUpIntentForActivity())
|
||||
}
|
||||
|
||||
private fun setUpIntentForActivity(): Intent {
|
||||
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
val intent = Intent(targetContext, V2BadgeActivity::class.java)
|
||||
intent.putExtra(DemoActivity.DEMO_ID, UUID.randomUUID())
|
||||
return intent
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
class V2BadgeActivityUITest : BaseTest() {
|
||||
|
||||
@Before
|
||||
fun initialize() {
|
||||
Intents.init()
|
||||
launchActivity()
|
||||
launchActivity(V2BadgeActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -46,8 +24,4 @@ class V2BadgeActivityUITest {
|
|||
listBadge.assertExists("Badge did not load")
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Intents.release()
|
||||
}
|
||||
}
|
|
@ -10,6 +10,10 @@ 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.fluentui.tokenized.drawer.DRAWER_CONTENT_TAG
|
||||
import com.microsoft.fluentui.tokenized.drawer.DRAWER_HANDLE_TAG
|
||||
import com.microsoft.fluentui.tokenized.drawer.DRAWER_SCRIM_TAG
|
||||
import com.microsoft.fluentuidemo.BaseTest
|
||||
import com.microsoft.fluentuidemo.DemoActivity
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
|
@ -17,26 +21,11 @@ import org.junit.Rule
|
|||
import org.junit.Test
|
||||
import java.util.*
|
||||
|
||||
class V2BottomDrawerUITest {
|
||||
|
||||
private fun launchActivity() {
|
||||
ActivityScenario.launch<V2BottomDrawerActivity>(setUpIntentForActivity())
|
||||
}
|
||||
|
||||
private fun setUpIntentForActivity(): Intent {
|
||||
val context = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
val intent = Intent(context, V2BottomDrawerActivity::class.java)
|
||||
intent.putExtra(DemoActivity.DEMO_ID, UUID.randomUUID())
|
||||
return intent
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
class V2BottomDrawerUITest : BaseTest() {
|
||||
|
||||
@Before
|
||||
fun initialize() {
|
||||
Intents.init()
|
||||
launchActivity()
|
||||
launchActivity(V2BottomDrawerActivity::class.java)
|
||||
}
|
||||
|
||||
private val drawerHandle = composeTestRule.onNodeWithTag(DRAWER_HANDLE_TAG)
|
||||
|
@ -212,9 +201,4 @@ class V2BottomDrawerUITest {
|
|||
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Intents.release()
|
||||
}
|
||||
|
||||
}
|
|
@ -6,6 +6,7 @@ import androidx.compose.ui.test.junit4.createComposeRule
|
|||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.espresso.intent.Intents
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.microsoft.fluentuidemo.BaseTest
|
||||
import com.microsoft.fluentuidemo.DemoActivity
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
|
@ -13,25 +14,11 @@ import org.junit.Rule
|
|||
import org.junit.Test
|
||||
import java.util.*
|
||||
|
||||
class V2ButtonsActivityUITest {
|
||||
private fun launchActivity() {
|
||||
ActivityScenario.launch<V2ButtonsActivity>(setUpIntentForActivity())
|
||||
}
|
||||
|
||||
private fun setUpIntentForActivity(): Intent {
|
||||
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
val intent = Intent(targetContext, V2ButtonsActivity::class.java)
|
||||
intent.putExtra(DemoActivity.DEMO_ID, UUID.randomUUID())
|
||||
return intent
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
class V2ButtonsActivityUITest : BaseTest() {
|
||||
|
||||
@Before
|
||||
fun initialize() {
|
||||
Intents.init()
|
||||
launchActivity()
|
||||
launchActivity(V2ButtonsActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -63,8 +50,4 @@ class V2ButtonsActivityUITest {
|
|||
theme2Button.assertExists("Theme change crashing")
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Intents.release()
|
||||
}
|
||||
}
|
|
@ -1,171 +1,93 @@
|
|||
package com.microsoft.fluentuidemo.demos
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.compose.ui.test.*
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import androidx.test.core.app.ActivityScenario
|
||||
import androidx.test.espresso.intent.Intents
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.SmallTest
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.microsoft.fluentuidemo.DemoActivity
|
||||
import org.junit.After
|
||||
import com.microsoft.fluentui.tokenized.notification.*
|
||||
import com.microsoft.fluentuidemo.BaseTest
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import java.util.*
|
||||
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
@SmallTest
|
||||
class V2CardNudgeActivityUITest {
|
||||
|
||||
// TAGS FOR TESTING
|
||||
private val MODIFIABLE_PARAMETER_SECTION = "Modifiable Parameters"
|
||||
private val ICON_PARAM = "Icon Param"
|
||||
private val SUBTITLE_PARAM = "Subtitle Param"
|
||||
private val ACCENT_ICON_PARAM = "Accent Icon Param"
|
||||
private val ACCENT_TEXT_PARAM = "Accent Text Param"
|
||||
private val ACTION_BUTTON_PARAM = "Action Button Param"
|
||||
private val DISMISS_BUTTON_PARAM = "Dismiss Button Param"
|
||||
private val CARD_NUDGE = "Card Nudge"
|
||||
private val ICON = "Icon"
|
||||
private val ACCENT_ICON = "Accent Icon"
|
||||
private val ACCENT_TEXT = "Accent Text"
|
||||
private val SUBTITLE = "Subtitle"
|
||||
private val ACTION_BUTTON = "Action Button"
|
||||
private val DISMISS_BUTTON = "Dismiss Button"
|
||||
|
||||
private fun launchActivity() {
|
||||
ActivityScenario.launch<V2CardNudgeActivity>(setUpIntentForActivity())
|
||||
}
|
||||
|
||||
private fun setUpIntentForActivity(): Intent {
|
||||
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
val intent = Intent(targetContext, V2CardNudgeActivity::class.java)
|
||||
intent.putExtra(DemoActivity.DEMO_ID, UUID.randomUUID())
|
||||
return intent
|
||||
}
|
||||
class V2CardNudgeActivityUITest : BaseTest() {
|
||||
|
||||
@Before
|
||||
fun initialize() {
|
||||
Intents.init()
|
||||
launchActivity()
|
||||
launchActivity(V2CardNudgeActivity::class.java)
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
private val modifiableParametersButton = composeTestRule.onAllNodesWithTag(MODIFIABLE_PARAMETER_SECTION)[0]
|
||||
private val modifiableParametersButton =
|
||||
composeTestRule.onAllNodesWithTag(CARD_NUDGE_MODIFIABLE_PARAMETER_SECTION)[0]
|
||||
|
||||
@Test
|
||||
fun testCardNudgeDisplay() {
|
||||
composeTestRule.onNodeWithTag(CARD_NUDGE).assertExists()
|
||||
composeTestRule.onNodeWithTag(CARD_NUDGE_CARD_NUDGE).assertExists()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCardNudgeIconDisplay() {
|
||||
modifiableParametersButton.performClick()
|
||||
val control = composeTestRule.onNodeWithTag(ICON_PARAM)
|
||||
control.assertExists()
|
||||
for ((key, value) in control.fetchSemanticsNode().config) {
|
||||
if (key.name == "ToggleableState" && value.toString() == "Off") {
|
||||
control.performClick()
|
||||
break
|
||||
}
|
||||
}
|
||||
composeTestRule.onNodeWithTag(ICON).assertExists()
|
||||
val control = composeTestRule.onNodeWithTag(CARD_NUDGE_ICON_PARAM)
|
||||
val component = composeTestRule.onNodeWithTag(CARD_NUDGE_ICON)
|
||||
assertExistsAfterToggleOnly(control, component, "Icon did not render properly")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCardNudgeSubtitleDisplay() {
|
||||
modifiableParametersButton.performClick()
|
||||
val control = composeTestRule.onNodeWithTag(SUBTITLE_PARAM)
|
||||
control.assertExists()
|
||||
for ((key, value) in control.fetchSemanticsNode().config) {
|
||||
if (key.name == "ToggleableState" && value.toString() == "Off") {
|
||||
control.performClick()
|
||||
break
|
||||
}
|
||||
}
|
||||
composeTestRule.onNodeWithTag(SUBTITLE).assertExists()
|
||||
val control = composeTestRule.onNodeWithTag(CARD_NUDGE_SUBTITLE_PARAM)
|
||||
val component = composeTestRule.onNodeWithTag(CARD_NUDGE_SUBTITLE)
|
||||
assertExistsAfterToggleOnly(control, component, "Subtitle did not render properly")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCardNudgeAccentIconDisplay() {
|
||||
modifiableParametersButton.performClick()
|
||||
val control = composeTestRule.onNodeWithTag(ACCENT_ICON_PARAM)
|
||||
control.assertExists()
|
||||
for ((key, value) in control.fetchSemanticsNode().config) {
|
||||
if (key.name == "ToggleableState" && value.toString() == "Off") {
|
||||
control.performClick()
|
||||
break
|
||||
}
|
||||
}
|
||||
composeTestRule.onNodeWithTag(ACCENT_ICON).assertExists()
|
||||
val control = composeTestRule.onNodeWithTag(CARD_NUDGE_ACCENT_ICON_PARAM)
|
||||
val component = composeTestRule.onNodeWithTag(CARD_NUDGE_ACCENT_ICON)
|
||||
assertExistsAfterToggleOnly(control, component, "Accent icon did not render properly")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCardNudgeAccentTextDisplay() {
|
||||
modifiableParametersButton.performClick()
|
||||
val control = composeTestRule.onNodeWithTag(ACCENT_TEXT_PARAM)
|
||||
control.assertExists()
|
||||
for ((key, value) in control.fetchSemanticsNode().config) {
|
||||
if (key.name == "ToggleableState" && value.toString() == "Off") {
|
||||
control.performClick()
|
||||
break
|
||||
}
|
||||
}
|
||||
composeTestRule.onNodeWithTag(ACCENT_TEXT).assertExists()
|
||||
val control = composeTestRule.onNodeWithTag(CARD_NUDGE_ACCENT_TEXT_PARAM)
|
||||
val component = composeTestRule.onNodeWithTag(CARD_NUDGE_ACCENT_TEXT)
|
||||
assertExistsAfterToggleOnly(control, component, "Accent text did not render properly")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCardNudgeActionDisplay() {
|
||||
modifiableParametersButton.performClick()
|
||||
composeTestRule.onNodeWithTag(ICON_PARAM)
|
||||
.performTouchInput { swipeUp(durationMillis = 1000) }
|
||||
val control = composeTestRule.onNodeWithTag(ACTION_BUTTON_PARAM)
|
||||
control.assertExists()
|
||||
for ((key, value) in control.fetchSemanticsNode().config) {
|
||||
if (key.name == "ToggleableState" && value.toString() == "Off") {
|
||||
control.performClick()
|
||||
break
|
||||
}
|
||||
}
|
||||
composeTestRule.onNodeWithTag(ACTION_BUTTON).assertExists()
|
||||
modifiableParametersButton.performTouchInput { swipeUp(durationMillis = 1000) }
|
||||
val control = composeTestRule.onNodeWithTag(CARD_NUDGE_ACTION_BUTTON_PARAM)
|
||||
val component = composeTestRule.onNodeWithTag(CARD_NUDGE_ACTION_BUTTON)
|
||||
assertExistsAfterToggleOnly(control, component, "Action button did not render properly")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testCardNudgeDismissDisplay() {
|
||||
modifiableParametersButton.performClick()
|
||||
composeTestRule.onNodeWithTag(ICON_PARAM)
|
||||
.performTouchInput { swipeUp(durationMillis = 1000) }
|
||||
val control = composeTestRule.onNodeWithTag(DISMISS_BUTTON_PARAM)
|
||||
control.assertExists()
|
||||
for ((key, value) in control.fetchSemanticsNode().config) {
|
||||
if (key.name == "ToggleableState" && value.toString() == "Off") {
|
||||
control.performClick()
|
||||
break
|
||||
}
|
||||
}
|
||||
composeTestRule.onNodeWithTag(DISMISS_BUTTON).assertExists()
|
||||
modifiableParametersButton.performTouchInput { swipeUp(durationMillis = 1000) }
|
||||
val control = composeTestRule.onNodeWithTag(CARD_NUDGE_DISMISS_BUTTON_PARAM)
|
||||
val component = composeTestRule.onNodeWithTag(CARD_NUDGE_DISMISS_BUTTON)
|
||||
assertExistsAfterToggleOnly(control, component, "Dismiss button did not render properly")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testLeftSwipe() {
|
||||
composeTestRule.onNodeWithTag(CARD_NUDGE).performTouchInput { swipeLeft() }
|
||||
composeTestRule.onNodeWithTag(CARD_NUDGE).performClick()
|
||||
composeTestRule.onNodeWithTag(CARD_NUDGE_CARD_NUDGE).performTouchInput { swipeLeft() }
|
||||
composeTestRule.onNodeWithTag(CARD_NUDGE_CARD_NUDGE).performClick()
|
||||
composeTestRule.onNodeWithText("Left Swiped", substring = true).assertExists()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testRightSwipe() {
|
||||
composeTestRule.onNodeWithTag(CARD_NUDGE).performTouchInput { swipeRight() }
|
||||
composeTestRule.onNodeWithTag(CARD_NUDGE).performClick()
|
||||
composeTestRule.onNodeWithTag(CARD_NUDGE_CARD_NUDGE).performTouchInput { swipeRight() }
|
||||
composeTestRule.onNodeWithTag(CARD_NUDGE_CARD_NUDGE).performClick()
|
||||
composeTestRule.onNodeWithText("Right Swiped", substring = true).assertExists()
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Intents.release()
|
||||
}
|
||||
}
|
|
@ -10,6 +10,7 @@ import androidx.test.core.app.ActivityScenario
|
|||
import androidx.test.espresso.Espresso
|
||||
import androidx.test.espresso.intent.Intents
|
||||
import androidx.test.platform.app.InstrumentationRegistry
|
||||
import com.microsoft.fluentuidemo.BaseTest
|
||||
import com.microsoft.fluentuidemo.DemoActivity
|
||||
import org.junit.After
|
||||
import org.junit.Before
|
||||
|
@ -17,33 +18,13 @@ import org.junit.Rule
|
|||
import org.junit.Test
|
||||
import java.util.*
|
||||
|
||||
class V2DialogUITest {
|
||||
|
||||
private fun launchActivity() {
|
||||
ActivityScenario.launch<V2DialogActivity>(setUpIntentForActivity())
|
||||
}
|
||||
|
||||
private fun setUpIntentForActivity(): Intent {
|
||||
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
val intent = Intent(targetContext, V2DialogActivity::class.java)
|
||||
intent.putExtra(DemoActivity.DEMO_ID, UUID.randomUUID())
|
||||
return intent
|
||||
}
|
||||
class V2DialogActivityUITest: BaseTest() {
|
||||
|
||||
@Before
|
||||
fun initialize() {
|
||||
Intents.init()
|
||||
launchActivity()
|
||||
launchActivity(V2DialogActivity::class.java)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Intents.release()
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
|
||||
@Test
|
||||
fun testDialog() {
|
||||
composeTestRule.onNodeWithText("Show Dialog").performClick()
|
|
@ -1,47 +1,22 @@
|
|||
package com.microsoft.fluentuidemo.demos
|
||||
|
||||
import android.content.Intent
|
||||
import android.content.res.Resources
|
||||
import androidx.compose.ui.geometry.Offset
|
||||
import androidx.compose.ui.test.*
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import androidx.compose.ui.unit.Dp
|
||||
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 com.microsoft.fluentui.tokenized.drawer.DRAWER_CONTENT_TAG
|
||||
import com.microsoft.fluentui.tokenized.drawer.DRAWER_HANDLE_TAG
|
||||
import com.microsoft.fluentui.tokenized.drawer.DRAWER_SCRIM_TAG
|
||||
import com.microsoft.fluentuidemo.BaseTest
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
|
||||
//Below tag name used in Drawer component
|
||||
const val DRAWER_HANDLE_TAG = "Drawer Handle"
|
||||
const val DRAWER_CONTENT_TAG = "Drawer Content"
|
||||
const val DRAWER_SCRIM_TAG = "Drawer Scrim"
|
||||
|
||||
|
||||
class V2DrawerActivityUITest {
|
||||
private fun launchActivity() {
|
||||
ActivityScenario.launch<V2DrawerActivity>(setUpIntentForActivity())
|
||||
}
|
||||
|
||||
private fun setUpIntentForActivity(): Intent {
|
||||
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
val intent = Intent(targetContext, V2DrawerActivity::class.java)
|
||||
intent.putExtra(DemoActivity.DEMO_ID, UUID.randomUUID())
|
||||
return intent
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
class V2DrawerActivityUITest : BaseTest() {
|
||||
|
||||
@Before
|
||||
fun initialize() {
|
||||
Intents.init()
|
||||
launchActivity()
|
||||
launchActivity(V2DrawerActivity::class.java)
|
||||
}
|
||||
|
||||
private val drawerHandle = composeTestRule.onNodeWithTag(DRAWER_HANDLE_TAG)
|
||||
|
@ -284,8 +259,4 @@ class V2DrawerActivityUITest {
|
|||
closeCheckForVerticalDrawer()
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Intents.release()
|
||||
}
|
||||
}
|
|
@ -35,7 +35,7 @@ private const val BOLD_TAG = "Bold"
|
|||
private const val SUBTLE_TAG = "Subtle"
|
||||
private const val CHEVRON_TAG = "Chevron"
|
||||
|
||||
class V2ListItemActivityUITest {
|
||||
class V2ListItemUITest {
|
||||
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
|
@ -1,80 +1,42 @@
|
|||
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 com.microsoft.fluentui.tokenized.persona.ANONYMOUS
|
||||
import com.microsoft.fluentui.tokenized.persona.AVATAR_IMAGE
|
||||
import com.microsoft.fluentuidemo.BaseTest
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
|
||||
private const val MEDIUM_PERSONA_CHIP_TAG = "medium persona chip"
|
||||
private const val SMALL_PERSONA_CHIP_TAG = "small persona chip"
|
||||
private const val ANONYMOUS_PERSONA_CHIP_TAG = "ann persona chip"
|
||||
private const val DISABLED_PERSONA_CHIP_TAG = "disabled persona chip"
|
||||
private const val ANONYMOUS = "Anonymous"
|
||||
private const val AVATAR_TAG = "Image"
|
||||
private const val SWITCH_TAG = "switch"
|
||||
private const val CLOSE_ICON_CONTENT_DESCRIPTION = "Close"
|
||||
private const val PERSONA_CHIP_HEIGHT = 22
|
||||
private const val AVATAR_ICON_SIZE = 16
|
||||
|
||||
class V2PersonaChipActivityUITest {
|
||||
|
||||
private fun launchActivity() {
|
||||
ActivityScenario.launch<V2PersonaChipActivity>(setUpIntentForActivity())
|
||||
}
|
||||
|
||||
private fun setUpIntentForActivity(): Intent {
|
||||
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
val intent = Intent(targetContext, V2PersonaChipActivity::class.java)
|
||||
intent.putExtra(DemoActivity.DEMO_ID, UUID.randomUUID())
|
||||
return intent
|
||||
}
|
||||
class V2PersonaChipActivityUITest : BaseTest() {
|
||||
|
||||
@Before
|
||||
fun initialize() {
|
||||
Intents.init()
|
||||
launchActivity()
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
|
||||
@Test
|
||||
fun testPersonaChipBounds() {
|
||||
composeTestRule.onNodeWithTag(MEDIUM_PERSONA_CHIP_TAG).assertHeightIsAtLeast(
|
||||
PERSONA_CHIP_HEIGHT.dp
|
||||
)
|
||||
composeTestRule.onNodeWithTag(SMALL_PERSONA_CHIP_TAG).assertHeightIsAtLeast(
|
||||
PERSONA_CHIP_HEIGHT.dp
|
||||
)
|
||||
launchActivity(V2PersonaChipActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPersonaChipAvatarAndIconSize() {
|
||||
composeTestRule.onNode(
|
||||
hasTestTag(AVATAR_TAG).and(
|
||||
hasTestTag(AVATAR_IMAGE).and(
|
||||
hasAnyAncestor(
|
||||
hasTestTag(
|
||||
MEDIUM_PERSONA_CHIP_TAG
|
||||
PERSONA_CHIP_MEDIUM_CHIP
|
||||
)
|
||||
)
|
||||
), true
|
||||
).assertHeightIsEqualTo(AVATAR_ICON_SIZE.dp)
|
||||
composeTestRule.onNodeWithTag(SWITCH_TAG).performClick()
|
||||
composeTestRule.onNodeWithTag(MEDIUM_PERSONA_CHIP_TAG).performClick()
|
||||
composeTestRule.onNodeWithTag(PERSONA_CHIP_SWITCH).performClick()
|
||||
composeTestRule.onNodeWithTag(PERSONA_CHIP_MEDIUM_CHIP).performClick()
|
||||
composeTestRule.onNode(
|
||||
hasContentDescription(CLOSE_ICON_CONTENT_DESCRIPTION).and(
|
||||
hasAnyAncestor(
|
||||
hasTestTag(
|
||||
MEDIUM_PERSONA_CHIP_TAG
|
||||
PERSONA_CHIP_MEDIUM_CHIP
|
||||
)
|
||||
)
|
||||
), true
|
||||
|
@ -84,21 +46,21 @@ class V2PersonaChipActivityUITest {
|
|||
@Test
|
||||
fun testMediumPersonaChip() {
|
||||
composeTestRule.onNode(
|
||||
hasTestTag(AVATAR_TAG).and(
|
||||
hasTestTag(AVATAR_IMAGE).and(
|
||||
hasAnyAncestor(
|
||||
hasTestTag(
|
||||
MEDIUM_PERSONA_CHIP_TAG
|
||||
PERSONA_CHIP_MEDIUM_CHIP
|
||||
)
|
||||
)
|
||||
), true
|
||||
).assertExists()
|
||||
composeTestRule.onNodeWithTag(SWITCH_TAG).performClick()
|
||||
composeTestRule.onNodeWithTag(MEDIUM_PERSONA_CHIP_TAG).performClick()
|
||||
composeTestRule.onNodeWithTag(PERSONA_CHIP_SWITCH).performClick()
|
||||
composeTestRule.onNodeWithTag(PERSONA_CHIP_MEDIUM_CHIP).performClick()
|
||||
composeTestRule.onNode(
|
||||
hasTestTag(AVATAR_TAG).and(
|
||||
hasTestTag(AVATAR_IMAGE).and(
|
||||
hasAnyAncestor(
|
||||
hasTestTag(
|
||||
MEDIUM_PERSONA_CHIP_TAG
|
||||
PERSONA_CHIP_MEDIUM_CHIP
|
||||
)
|
||||
)
|
||||
), true
|
||||
|
@ -107,7 +69,7 @@ class V2PersonaChipActivityUITest {
|
|||
hasContentDescription(CLOSE_ICON_CONTENT_DESCRIPTION).and(
|
||||
hasAnyAncestor(
|
||||
hasTestTag(
|
||||
MEDIUM_PERSONA_CHIP_TAG
|
||||
PERSONA_CHIP_MEDIUM_CHIP
|
||||
)
|
||||
)
|
||||
), true
|
||||
|
@ -117,21 +79,21 @@ class V2PersonaChipActivityUITest {
|
|||
@Test
|
||||
fun testSmallPersonaChip() {
|
||||
composeTestRule.onNode(
|
||||
hasTestTag(AVATAR_TAG).and(
|
||||
hasTestTag(AVATAR_IMAGE).and(
|
||||
hasAnyAncestor(
|
||||
hasTestTag(
|
||||
SMALL_PERSONA_CHIP_TAG
|
||||
PERSONA_CHIP_SMALL_CHIP
|
||||
)
|
||||
)
|
||||
), true
|
||||
).assertDoesNotExist()
|
||||
composeTestRule.onNodeWithTag(SWITCH_TAG).performClick()
|
||||
composeTestRule.onNodeWithTag(SMALL_PERSONA_CHIP_TAG).performClick()
|
||||
composeTestRule.onNodeWithTag(PERSONA_CHIP_SWITCH).performClick()
|
||||
composeTestRule.onNodeWithTag(PERSONA_CHIP_SMALL_CHIP).performClick()
|
||||
composeTestRule.onNode(
|
||||
hasTestTag(AVATAR_TAG).and(
|
||||
hasTestTag(AVATAR_IMAGE).and(
|
||||
hasAnyAncestor(
|
||||
hasTestTag(
|
||||
SMALL_PERSONA_CHIP_TAG
|
||||
PERSONA_CHIP_SMALL_CHIP
|
||||
)
|
||||
)
|
||||
), true
|
||||
|
@ -140,7 +102,7 @@ class V2PersonaChipActivityUITest {
|
|||
hasContentDescription(CLOSE_ICON_CONTENT_DESCRIPTION).and(
|
||||
hasAnyAncestor(
|
||||
hasTestTag(
|
||||
MEDIUM_PERSONA_CHIP_TAG
|
||||
PERSONA_CHIP_MEDIUM_CHIP
|
||||
)
|
||||
)
|
||||
), true
|
||||
|
@ -149,7 +111,7 @@ class V2PersonaChipActivityUITest {
|
|||
|
||||
@Test
|
||||
fun testAnonymousPersonaChip() {
|
||||
composeTestRule.onNode(hasParent(hasTestTag(ANONYMOUS_PERSONA_CHIP_TAG)), true)
|
||||
composeTestRule.onNode(hasParent(hasTestTag(PERSONA_CHIP_ANONYMOUS)), true)
|
||||
.assertTextContains(
|
||||
ANONYMOUS
|
||||
)
|
||||
|
@ -157,11 +119,7 @@ class V2PersonaChipActivityUITest {
|
|||
|
||||
@Test
|
||||
fun testDisabledPersonaChip() {
|
||||
composeTestRule.onNodeWithTag(DISABLED_PERSONA_CHIP_TAG).assertIsNotEnabled()
|
||||
composeTestRule.onNodeWithTag(PERSONA_CHIP_DISABLED).assertIsNotEnabled()
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Intents.release()
|
||||
}
|
||||
}
|
|
@ -1,58 +1,31 @@
|
|||
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 com.microsoft.fluentuidemo.BaseTest
|
||||
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()
|
||||
class V2PersonaListActivityUITest : BaseTest() {
|
||||
|
||||
@Before
|
||||
fun initialize() {
|
||||
Intents.init()
|
||||
launchActivity()
|
||||
launchActivity(V2PersonaListActivity::class.java)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPersonaListBounds() {
|
||||
val personaList = composeTestRule.onNodeWithTag("list")
|
||||
val personaList = composeTestRule.onNodeWithTag(PERSONA_LIST)
|
||||
personaList.onChildAt(0).assertHeightIsAtLeast(48.dp)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testPersonaList() {
|
||||
composeTestRule.onRoot(true).printToLog("tree")
|
||||
val personaList = composeTestRule.onNodeWithTag("list")
|
||||
val personaList = composeTestRule.onNodeWithTag(PERSONA_LIST)
|
||||
personaList.assertExists()
|
||||
personaList.assertIsDisplayed()
|
||||
personaList.assert(hasScrollAction())
|
||||
personaList.onChildAt(0).assertHasClickAction()
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Intents.release()
|
||||
}
|
||||
}
|
|
@ -1,40 +1,17 @@
|
|||
package com.microsoft.fluentuidemo.demos
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
import androidx.compose.ui.test.onAllNodesWithTag
|
||||
import androidx.compose.ui.test.onNodeWithTag
|
||||
import androidx.compose.ui.test.performClick
|
||||
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 com.microsoft.fluentuidemo.BaseTest
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
|
||||
class V2ScaffoldActivityUITest {
|
||||
|
||||
private fun launchActivity() {
|
||||
ActivityScenario.launch<V2ScaffoldActivity>(setUpIntentForActivity())
|
||||
}
|
||||
|
||||
private fun setUpIntentForActivity(): Intent {
|
||||
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
val intent = Intent(targetContext, V2ScaffoldActivity::class.java)
|
||||
intent.putExtra(DemoActivity.DEMO_ID, UUID.randomUUID())
|
||||
return intent
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
class V2ScaffoldActivityUITest : BaseTest() {
|
||||
|
||||
@Before
|
||||
fun initialize() {
|
||||
Intents.init()
|
||||
launchActivity()
|
||||
launchActivity(V2ScaffoldActivity::class.java)
|
||||
}
|
||||
|
||||
//Tag for Test
|
||||
|
@ -73,8 +50,4 @@ class V2ScaffoldActivityUITest {
|
|||
}
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Intents.release()
|
||||
}
|
||||
}
|
|
@ -16,6 +16,10 @@ import com.microsoft.fluentui.tokenized.shimmer.Shimmer
|
|||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
|
||||
// Tags used for testing
|
||||
const val SHIMMER = "shimmer"
|
||||
const val SHIMMER_CIRCLE = "circleShimmer"
|
||||
|
||||
class V2ShimmerUITest {
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
|
@ -28,19 +32,19 @@ class V2ShimmerUITest {
|
|||
shape = ShimmerShape.Box, modifier = Modifier
|
||||
.height(50.dp)
|
||||
.width(50.dp)
|
||||
.testTag("shimmer")
|
||||
.testTag(SHIMMER)
|
||||
)
|
||||
Shimmer(
|
||||
shape = ShimmerShape.Circle,
|
||||
modifier = Modifier
|
||||
.size(50.dp)
|
||||
.testTag("circleShimmer")
|
||||
.testTag(SHIMMER_CIRCLE)
|
||||
)
|
||||
}
|
||||
}
|
||||
composeTestRule.onNodeWithTag("shimmer").assertHeightIsEqualTo(50.dp)
|
||||
composeTestRule.onNodeWithTag(SHIMMER).assertHeightIsEqualTo(50.dp)
|
||||
.assertWidthIsEqualTo(50.dp)
|
||||
composeTestRule.onNodeWithTag("circleShimmer").assertHeightIsEqualTo(50.dp)
|
||||
composeTestRule.onNodeWithTag(SHIMMER_CIRCLE).assertHeightIsEqualTo(50.dp)
|
||||
.assertWidthIsEqualTo(50.dp)
|
||||
}
|
||||
}
|
|
@ -1,77 +1,45 @@
|
|||
package com.microsoft.fluentuidemo.demos
|
||||
|
||||
import android.content.Intent
|
||||
import androidx.compose.ui.test.*
|
||||
import androidx.compose.ui.test.junit4.createComposeRule
|
||||
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 com.microsoft.fluentui.tokenized.notification.*
|
||||
import com.microsoft.fluentuidemo.BaseTest
|
||||
import org.junit.Before
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
import java.util.*
|
||||
|
||||
class V2SnackbarActivityUITest {
|
||||
|
||||
// TAGS FOR TESTING
|
||||
private val MODIFIABLE_PARAMETER_SECTION = "Modifiable Parameters"
|
||||
private val ICON_PARAM = "Icon Param"
|
||||
private val SUBTITLE_PARAM = "Subtitle Param"
|
||||
private val ACTION_BUTTON_PARAM = "Action Button Param"
|
||||
private val DISMISS_BUTTON_PARAM = "Dismiss Button Param"
|
||||
private val SHOW_SNACKBAR = "Show Snackbar"
|
||||
private val DISMISS_SNACKBAR = "Dismiss Snackbar"
|
||||
private val SNACKBAR = "Snackbar"
|
||||
private val ICON = "Icon"
|
||||
private val SUBTITLE = "Subtitle"
|
||||
private val ACTION_BUTTON = "Action Button"
|
||||
private val DISMISS_BUTTON = "Dismiss Button"
|
||||
|
||||
private fun launchActivity() {
|
||||
ActivityScenario.launch<V2SnackbarActivity>(setUpIntentForActivity())
|
||||
}
|
||||
|
||||
private fun setUpIntentForActivity(): Intent {
|
||||
val targetContext = InstrumentationRegistry.getInstrumentation().targetContext
|
||||
val intent = Intent(targetContext, V2SnackbarActivity::class.java)
|
||||
intent.putExtra(DemoActivity.DEMO_ID, UUID.randomUUID())
|
||||
return intent
|
||||
}
|
||||
class V2SnackbarActivityUITest : BaseTest() {
|
||||
|
||||
@Before
|
||||
fun initialize() {
|
||||
Intents.init()
|
||||
launchActivity()
|
||||
launchActivity(V2SnackbarActivity::class.java)
|
||||
}
|
||||
|
||||
@get:Rule
|
||||
val composeTestRule = createComposeRule()
|
||||
val showSnackBarButton = composeTestRule.onNodeWithTag(SHOW_SNACKBAR)
|
||||
val dismissSnackbarButton = composeTestRule.onNodeWithTag(DISMISS_SNACKBAR)
|
||||
val modifiableParametersButton = composeTestRule.onAllNodesWithTag(MODIFIABLE_PARAMETER_SECTION)[0]
|
||||
|
||||
private val showSnackBarButton = composeTestRule.onNodeWithTag(SNACK_BAR_SHOW_SNACKBAR)
|
||||
private val dismissSnackbarButton = composeTestRule.onNodeWithTag(SNACK_BAR_DISMISS_SNACKBAR)
|
||||
private val modifiableParametersButton = composeTestRule.onAllNodesWithTag(
|
||||
SNACK_BAR_MODIFIABLE_PARAMETER_SECTION
|
||||
)[0]
|
||||
|
||||
@Test
|
||||
fun testSnackbarDisplay() {
|
||||
showSnackBarButton.assertExists().performClick()
|
||||
composeTestRule.waitUntil(1000L) {
|
||||
composeTestRule.onAllNodesWithTag(SNACKBAR).fetchSemanticsNodes()
|
||||
composeTestRule.onAllNodesWithTag(SNACK_BAR).fetchSemanticsNodes()
|
||||
.isNotEmpty()
|
||||
}
|
||||
dismissSnackbarButton.assertExists().performClick()
|
||||
composeTestRule.waitUntil(1000L) {
|
||||
composeTestRule.onAllNodesWithTag(SNACKBAR).fetchSemanticsNodes().isEmpty()
|
||||
composeTestRule.onAllNodesWithTag(SNACK_BAR).fetchSemanticsNodes().isEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testSnackbarIconDisplay() {
|
||||
modifiableParametersButton.performClick()
|
||||
composeTestRule.onNodeWithTag(ICON_PARAM).performClick()
|
||||
composeTestRule.onNodeWithTag(SNACK_BAR_ICON_PARAM).performClick()
|
||||
showSnackBarButton.performClick()
|
||||
composeTestRule.waitUntil(1000L) {
|
||||
composeTestRule.onAllNodesWithTag(ICON).fetchSemanticsNodes()
|
||||
composeTestRule.onAllNodesWithTag(SNACK_BAR_ICON).fetchSemanticsNodes()
|
||||
.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
@ -79,10 +47,10 @@ class V2SnackbarActivityUITest {
|
|||
@Test
|
||||
fun testSnackbarSubtitleDisplay() {
|
||||
modifiableParametersButton.performClick()
|
||||
composeTestRule.onNodeWithTag(SUBTITLE_PARAM).performClick()
|
||||
composeTestRule.onNodeWithTag(SNACK_BAR_SUBTITLE_PARAM).performClick()
|
||||
showSnackBarButton.performClick()
|
||||
composeTestRule.waitUntil(1000L) {
|
||||
composeTestRule.onAllNodesWithTag(SUBTITLE).fetchSemanticsNodes()
|
||||
composeTestRule.onAllNodesWithTag(SNACK_BAR_SUBTITLE).fetchSemanticsNodes()
|
||||
.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
@ -90,10 +58,10 @@ class V2SnackbarActivityUITest {
|
|||
@Test
|
||||
fun testSnackbarActionDisplay() {
|
||||
modifiableParametersButton.performClick()
|
||||
composeTestRule.onNodeWithTag(ACTION_BUTTON_PARAM).performClick()
|
||||
composeTestRule.onNodeWithTag(SNACK_BAR_ACTION_BUTTON_PARAM).performClick()
|
||||
showSnackBarButton.performClick()
|
||||
composeTestRule.waitUntil(1000L) {
|
||||
composeTestRule.onAllNodesWithTag(ACTION_BUTTON).fetchSemanticsNodes()
|
||||
composeTestRule.onAllNodesWithTag(SNACK_BAR_ACTION_BUTTON).fetchSemanticsNodes()
|
||||
.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
@ -101,18 +69,13 @@ class V2SnackbarActivityUITest {
|
|||
@Test
|
||||
fun testSnackbarDismissDisplay() {
|
||||
modifiableParametersButton.performClick()
|
||||
composeTestRule.onNodeWithTag(ICON_PARAM)
|
||||
.performTouchInput { swipeUp(durationMillis = 1000L) }
|
||||
composeTestRule.onNodeWithTag(DISMISS_BUTTON_PARAM).performClick()
|
||||
modifiableParametersButton.performTouchInput { swipeUp(durationMillis = 1000L) }
|
||||
composeTestRule.onNodeWithTag(SNACK_BAR_DISMISS_BUTTON_PARAM).performClick()
|
||||
showSnackBarButton.performClick()
|
||||
composeTestRule.waitUntil(1000L) {
|
||||
composeTestRule.onAllNodesWithTag(DISMISS_BUTTON).fetchSemanticsNodes()
|
||||
composeTestRule.onAllNodesWithTag(SNACK_BAR_DISMISS_BUTTON).fetchSemanticsNodes()
|
||||
.isNotEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
Intents.release()
|
||||
}
|
||||
}
|
|
@ -4,14 +4,7 @@ import android.os.Bundle
|
|||
import android.view.LayoutInflater
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxHeight
|
||||
import androidx.compose.foundation.layout.fillMaxSize
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.layout.wrapContentHeight
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.text.BasicText
|
||||
import androidx.compose.material.icons.Icons
|
||||
|
@ -44,19 +37,19 @@ import com.microsoft.fluentuidemo.R
|
|||
import com.microsoft.fluentuidemo.databinding.V2ActivityComposeBinding
|
||||
import kotlin.math.abs
|
||||
|
||||
// Tags used for testing
|
||||
const val CARD_NUDGE_MODIFIABLE_PARAMETER_SECTION = "Modifiable Parameters"
|
||||
const val CARD_NUDGE_ICON_PARAM = "Icon Param"
|
||||
const val CARD_NUDGE_SUBTITLE_PARAM = "Subtitle Param"
|
||||
const val CARD_NUDGE_ACCENT_ICON_PARAM = "Accent Icon Param"
|
||||
const val CARD_NUDGE_ACCENT_TEXT_PARAM = "Accent Text Param"
|
||||
const val CARD_NUDGE_ACTION_BUTTON_PARAM = "Action Button Param"
|
||||
const val CARD_NUDGE_DISMISS_BUTTON_PARAM = "Dismiss Button Param"
|
||||
|
||||
class V2CardNudgeActivity : DemoActivity() {
|
||||
override val contentNeedsScrollableContainer: Boolean
|
||||
get() = false
|
||||
|
||||
// Tags used for testing
|
||||
private val MODIFIABLE_PARAMETER_SECTION = "Modifiable Parameters"
|
||||
private val ICON_PARAM = "Icon Param"
|
||||
private val SUBTITLE_PARAM = "Subtitle Param"
|
||||
private val ACCENT_ICON_PARAM = "Accent Icon Param"
|
||||
private val ACCENT_TEXT_PARAM = "Accent Text Param"
|
||||
private val ACTION_BUTTON_PARAM = "Action Button Param"
|
||||
private val DISMISS_BUTTON_PARAM = "Dismiss Button Param"
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
val context = this
|
||||
|
@ -85,7 +78,7 @@ class V2CardNudgeActivity : DemoActivity() {
|
|||
|
||||
ListItem.SectionHeader(
|
||||
title = LocalContext.current.resources.getString(R.string.app_modifiable_parameters),
|
||||
modifier = Modifier.testTag(MODIFIABLE_PARAMETER_SECTION),
|
||||
modifier = Modifier.testTag(CARD_NUDGE_MODIFIABLE_PARAMETER_SECTION),
|
||||
enableChevron = true,
|
||||
enableContentOpenCloseTransition = true,
|
||||
chevronOrientation = ChevronOrientation(90f, 0f),
|
||||
|
@ -103,7 +96,7 @@ class V2CardNudgeActivity : DemoActivity() {
|
|||
onValueChange = {
|
||||
icon = it
|
||||
},
|
||||
modifier = Modifier.testTag(ICON_PARAM),
|
||||
modifier = Modifier.testTag(CARD_NUDGE_ICON_PARAM),
|
||||
checkedState = icon
|
||||
)
|
||||
}
|
||||
|
@ -128,7 +121,7 @@ class V2CardNudgeActivity : DemoActivity() {
|
|||
subtitle = null
|
||||
}
|
||||
},
|
||||
modifier = Modifier.testTag(SUBTITLE_PARAM),
|
||||
modifier = Modifier.testTag(CARD_NUDGE_SUBTITLE_PARAM),
|
||||
checkedState = !subtitle.isNullOrBlank()
|
||||
)
|
||||
}
|
||||
|
@ -153,7 +146,7 @@ class V2CardNudgeActivity : DemoActivity() {
|
|||
accentText = null
|
||||
}
|
||||
},
|
||||
modifier = Modifier.testTag(ACCENT_TEXT_PARAM),
|
||||
modifier = Modifier.testTag(CARD_NUDGE_ACCENT_TEXT_PARAM),
|
||||
checkedState = !accentText.isNullOrBlank()
|
||||
)
|
||||
}
|
||||
|
@ -172,7 +165,7 @@ class V2CardNudgeActivity : DemoActivity() {
|
|||
onValueChange = {
|
||||
accentImage = it
|
||||
},
|
||||
modifier = Modifier.testTag(ACCENT_ICON_PARAM),
|
||||
modifier = Modifier.testTag(CARD_NUDGE_ACCENT_ICON_PARAM),
|
||||
checkedState = accentImage
|
||||
)
|
||||
}
|
||||
|
@ -191,7 +184,9 @@ class V2CardNudgeActivity : DemoActivity() {
|
|||
onValueChange = {
|
||||
actionButton = it
|
||||
},
|
||||
modifier = Modifier.testTag(ACTION_BUTTON_PARAM),
|
||||
modifier = Modifier.testTag(
|
||||
CARD_NUDGE_ACTION_BUTTON_PARAM
|
||||
),
|
||||
checkedState = actionButton
|
||||
)
|
||||
}
|
||||
|
@ -207,10 +202,12 @@ class V2CardNudgeActivity : DemoActivity() {
|
|||
LocalContext.current.resources.getString(R.string.fluentui_enabled),
|
||||
trailingAccessoryContent = {
|
||||
ToggleSwitch(
|
||||
modifier = Modifier.testTag(
|
||||
CARD_NUDGE_DISMISS_BUTTON_PARAM
|
||||
),
|
||||
onValueChange = {
|
||||
dismissEnabled = it
|
||||
},
|
||||
modifier = Modifier.testTag(DISMISS_BUTTON_PARAM),
|
||||
checkedState = dismissEnabled
|
||||
)
|
||||
}
|
||||
|
|
|
@ -30,6 +30,14 @@ import com.microsoft.fluentuidemo.DemoActivity
|
|||
import com.microsoft.fluentuidemo.R.drawable
|
||||
import com.microsoft.fluentuidemo.databinding.V2ActivityComposeBinding
|
||||
|
||||
// Tags used for testing
|
||||
const val PERSONA_CHIP_SMALL_CHIP = "small persona chip"
|
||||
const val PERSONA_CHIP_MEDIUM_CHIP = "medium persona chip"
|
||||
const val PERSONA_CHIP_ANONYMOUS = "ann persona chip"
|
||||
const val PERSONA_CHIP_DISABLED = "disabled persona chip"
|
||||
const val PERSONA_CHIP_SWITCH = "switch persona chip"
|
||||
|
||||
|
||||
class V2PersonaChipActivity : DemoActivity() {
|
||||
override val contentNeedsScrollableContainer: Boolean
|
||||
get() = false
|
||||
|
@ -145,7 +153,7 @@ class V2PersonaChipActivity : DemoActivity() {
|
|||
)
|
||||
)
|
||||
ToggleSwitch(
|
||||
modifier = Modifier.testTag("switch"),
|
||||
modifier = Modifier.testTag(PERSONA_CHIP_SWITCH),
|
||||
onValueChange = { showCloseButton = !showCloseButton },
|
||||
checkedState = showCloseButton
|
||||
)
|
||||
|
@ -183,14 +191,14 @@ class V2PersonaChipActivity : DemoActivity() {
|
|||
BasicText(text = "Person Chip Brand", style = TextStyle(color = textColor))
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||
PersonaChip(
|
||||
modifier = Modifier.testTag("small persona chip"),
|
||||
modifier = Modifier.testTag(PERSONA_CHIP_SMALL_CHIP),
|
||||
person = createPersonWithName(),
|
||||
size = PersonaChipSize.Small,
|
||||
style = Brand,
|
||||
selected = selectedList[2],
|
||||
onClick = { selectedList[2] = !selectedList[2] })
|
||||
PersonaChip(
|
||||
modifier = Modifier.testTag("medium persona chip"),
|
||||
modifier = Modifier.testTag(PERSONA_CHIP_MEDIUM_CHIP),
|
||||
person = createPersonWithName(),
|
||||
style = Brand,
|
||||
selected = selectedList[3],
|
||||
|
@ -253,7 +261,7 @@ class V2PersonaChipActivity : DemoActivity() {
|
|||
)
|
||||
Row(horizontalArrangement = Arrangement.spacedBy(16.dp)) {
|
||||
PersonaChip(
|
||||
modifier = Modifier.testTag("ann persona chip"),
|
||||
modifier = Modifier.testTag(PERSONA_CHIP_ANONYMOUS),
|
||||
person = createPersonWithNothing(),
|
||||
size = PersonaChipSize.Small,
|
||||
style = Warning,
|
||||
|
@ -307,7 +315,7 @@ class V2PersonaChipActivity : DemoActivity() {
|
|||
} else null
|
||||
)
|
||||
PersonaChip(
|
||||
modifier = Modifier.testTag("disabled persona chip"),
|
||||
modifier = Modifier.testTag(PERSONA_CHIP_DISABLED),
|
||||
person = createPersonWithName(),
|
||||
style = Neutral,
|
||||
enabled = false,
|
||||
|
|
|
@ -23,6 +23,9 @@ import com.microsoft.fluentuidemo.icons.ListItemIcons
|
|||
import com.microsoft.fluentuidemo.icons.listitemicons.Chevron
|
||||
import com.microsoft.fluentuidemo.util.invokeToast
|
||||
|
||||
// Tags used for testing
|
||||
const val PERSONA_LIST = "persona_list"
|
||||
|
||||
class V2PersonaListActivity : DemoActivity() {
|
||||
override val contentNeedsScrollableContainer: Boolean
|
||||
get() = false
|
||||
|
@ -229,7 +232,7 @@ class V2PersonaListActivity : DemoActivity() {
|
|||
@Composable
|
||||
private fun CreatePersonaListActivityUI(context: Context) {
|
||||
PersonaList(
|
||||
modifier = Modifier.testTag("list"),
|
||||
modifier = Modifier.testTag(PERSONA_LIST),
|
||||
personas = createPersonasList(context),
|
||||
border = BorderType.Bottom,
|
||||
borderInset = BorderInset.XXLarge
|
||||
|
|
|
@ -38,6 +38,15 @@ import com.microsoft.fluentuidemo.R
|
|||
import com.microsoft.fluentuidemo.databinding.V2ActivityComposeBinding
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
// Tags used for testing
|
||||
const val SNACK_BAR_MODIFIABLE_PARAMETER_SECTION = "Modifiable Parameters"
|
||||
const val SNACK_BAR_ICON_PARAM = "Icon Param"
|
||||
const val SNACK_BAR_SUBTITLE_PARAM = "Subtitle Param"
|
||||
const val SNACK_BAR_ACTION_BUTTON_PARAM = "Action Button Param"
|
||||
const val SNACK_BAR_DISMISS_BUTTON_PARAM = "Dismiss Button Param"
|
||||
const val SNACK_BAR_SHOW_SNACKBAR = "Show Snackbar"
|
||||
const val SNACK_BAR_DISMISS_SNACKBAR = "Dismiss Snackbar"
|
||||
|
||||
class V2SnackbarActivity : DemoActivity() {
|
||||
override val contentNeedsScrollableContainer: Boolean
|
||||
get() = false
|
||||
|
@ -46,14 +55,6 @@ class V2SnackbarActivity : DemoActivity() {
|
|||
super.onCreate(savedInstanceState)
|
||||
val context = this
|
||||
|
||||
// Tags used for testing
|
||||
val MODIFIABLE_PARAMETER_SECTION = "Modifiable Parameters"
|
||||
val ICON_PARAM = "Icon Param"
|
||||
val SUBTITLE_PARAM = "Subtitle Param"
|
||||
val ACTION_BUTTON_PARAM = "Action Button Param"
|
||||
val DISMISS_BUTTON_PARAM = "Dismiss Button Param"
|
||||
val SHOW_SNACKBAR = "Show Snackbar"
|
||||
val DISMISS_SNACKBAR = "Dismiss Snackbar"
|
||||
val v2ActivityComposeBinding = V2ActivityComposeBinding.inflate(
|
||||
LayoutInflater.from(container.context),
|
||||
container,
|
||||
|
@ -84,7 +85,7 @@ class V2SnackbarActivity : DemoActivity() {
|
|||
enableChevron = true,
|
||||
enableContentOpenCloseTransition = true,
|
||||
chevronOrientation = ChevronOrientation(90f, 0f),
|
||||
modifier = Modifier.testTag(MODIFIABLE_PARAMETER_SECTION)
|
||||
modifier = Modifier.testTag(SNACK_BAR_MODIFIABLE_PARAMETER_SECTION)
|
||||
) {
|
||||
LazyColumn(Modifier.fillMaxHeight(0.5F)) {
|
||||
item {
|
||||
|
@ -181,7 +182,7 @@ class V2SnackbarActivity : DemoActivity() {
|
|||
icon = it
|
||||
},
|
||||
checkedState = icon,
|
||||
modifier = Modifier.testTag(ICON_PARAM)
|
||||
modifier = Modifier.testTag(SNACK_BAR_ICON_PARAM)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
@ -206,7 +207,7 @@ class V2SnackbarActivity : DemoActivity() {
|
|||
}
|
||||
},
|
||||
checkedState = !subtitle.isNullOrBlank(),
|
||||
modifier = Modifier.testTag(SUBTITLE_PARAM)
|
||||
modifier = Modifier.testTag(SNACK_BAR_SUBTITLE_PARAM)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
@ -225,7 +226,7 @@ class V2SnackbarActivity : DemoActivity() {
|
|||
actionLabel = it
|
||||
},
|
||||
checkedState = actionLabel,
|
||||
modifier = Modifier.testTag(ACTION_BUTTON_PARAM)
|
||||
modifier = Modifier.testTag(SNACK_BAR_ACTION_BUTTON_PARAM)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
@ -244,7 +245,7 @@ class V2SnackbarActivity : DemoActivity() {
|
|||
dismissEnabled = it
|
||||
},
|
||||
checkedState = dismissEnabled,
|
||||
modifier = Modifier.testTag(DISMISS_BUTTON_PARAM)
|
||||
modifier = Modifier.testTag(SNACK_BAR_DISMISS_BUTTON_PARAM)
|
||||
)
|
||||
}
|
||||
)
|
||||
|
@ -302,7 +303,7 @@ class V2SnackbarActivity : DemoActivity() {
|
|||
text = LocalContext.current.resources.getString(R.string.fluentui_show_snackbar),
|
||||
size = ButtonSize.Small,
|
||||
style = ButtonStyle.OutlinedButton,
|
||||
modifier = Modifier.testTag(SHOW_SNACKBAR)
|
||||
modifier = Modifier.testTag(SNACK_BAR_SHOW_SNACKBAR)
|
||||
)
|
||||
|
||||
Button(
|
||||
|
@ -312,7 +313,7 @@ class V2SnackbarActivity : DemoActivity() {
|
|||
text = LocalContext.current.resources.getString(R.string.fluentui_dismiss_snackbar),
|
||||
size = ButtonSize.Small,
|
||||
style = ButtonStyle.OutlinedButton,
|
||||
modifier = Modifier.testTag(DISMISS_SNACKBAR)
|
||||
modifier = Modifier.testTag(SNACK_BAR_DISMISS_SNACKBAR)
|
||||
)
|
||||
}
|
||||
Box(Modifier.fillMaxHeight(), contentAlignment = Alignment.Center) {
|
||||
|
|
|
@ -243,9 +243,9 @@ private val AnimationSpec = TweenSpec<Float>(durationMillis = 256)
|
|||
private const val DrawerOpenFraction = 0.5f
|
||||
|
||||
//Tag use for testing
|
||||
private const val DRAWER_HANDLE_TAG = "Drawer Handle"
|
||||
private const val DRAWER_CONTENT_TAG = "Drawer Content"
|
||||
private const val DRAWER_SCRIM_TAG = "Drawer Scrim"
|
||||
const val DRAWER_HANDLE_TAG = "Drawer Handle"
|
||||
const val DRAWER_CONTENT_TAG = "Drawer Content"
|
||||
const val DRAWER_SCRIM_TAG = "Drawer Scrim"
|
||||
|
||||
//Drawer Handle height + padding
|
||||
private val DrawerHandleHeightOffset = 20.dp
|
||||
|
@ -725,7 +725,7 @@ private fun BottomDrawer(
|
|||
.focusable(false),
|
||||
) {
|
||||
Column {
|
||||
if(showHandle) {
|
||||
if (showHandle) {
|
||||
Column(
|
||||
horizontalAlignment = Alignment.CenterHorizontally,
|
||||
modifier = Modifier
|
||||
|
@ -923,10 +923,10 @@ fun BottomDrawer(
|
|||
slideOver: Boolean = true,
|
||||
expandable: Boolean = true,
|
||||
scrimVisible: Boolean = true,
|
||||
showHandle:Boolean = true,
|
||||
showHandle: Boolean = true,
|
||||
drawerTokens: DrawerTokens? = null,
|
||||
drawerContent: @Composable () -> Unit
|
||||
) {
|
||||
) {
|
||||
if (drawerState.enable) {
|
||||
val themeID =
|
||||
FluentTheme.themeID //Adding This only for recomposition in case of Token Updates. Unused otherwise.
|
||||
|
|
|
@ -39,13 +39,13 @@ import com.microsoft.fluentui.tokenized.segmentedcontrols.PillMetaData
|
|||
import kotlin.math.roundToInt
|
||||
|
||||
// TAGS FOR TESTING
|
||||
private const val CARD_NUDGE = "Card Nudge"
|
||||
private const val ICON = "Icon"
|
||||
private const val ACCENT_ICON = "Accent Icon"
|
||||
private const val ACCENT_TEXT = "Accent Text"
|
||||
private const val SUBTITLE = "Subtitle"
|
||||
private const val ACTION_BUTTON = "Action Button"
|
||||
private const val DISMISS_BUTTON = "Dismiss Button"
|
||||
const val CARD_NUDGE_CARD_NUDGE = "Card Nudge"
|
||||
const val CARD_NUDGE_ICON = "Icon"
|
||||
const val CARD_NUDGE_ACCENT_ICON = "Accent Icon"
|
||||
const val CARD_NUDGE_ACCENT_TEXT = "Accent Text"
|
||||
const val CARD_NUDGE_SUBTITLE = "Subtitle"
|
||||
const val CARD_NUDGE_ACTION_BUTTON = "Action Button"
|
||||
const val CARD_NUDGE_DISMISS_BUTTON = "Dismiss Button"
|
||||
|
||||
class CardNudgeMetaData(
|
||||
val message: String,
|
||||
|
@ -125,7 +125,7 @@ fun CardNudge(
|
|||
thresholds = { _, _ -> FractionalThreshold(0.3F) },
|
||||
orientation = Orientation.Horizontal,
|
||||
)
|
||||
.testTag(CARD_NUDGE),
|
||||
.testTag(CARD_NUDGE_CARD_NUDGE),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
LaunchedEffect(state.offset.value) {
|
||||
|
@ -160,7 +160,7 @@ fun CardNudge(
|
|||
)
|
||||
} else Modifier
|
||||
)
|
||||
.testTag(ICON),
|
||||
.testTag(CARD_NUDGE_ICON),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Icon(
|
||||
|
@ -190,7 +190,7 @@ fun CardNudge(
|
|||
Box(
|
||||
modifier = Modifier
|
||||
.size(12.dp)
|
||||
.testTag(ACCENT_ICON),
|
||||
.testTag(CARD_NUDGE_ACCENT_ICON),
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Icon(
|
||||
|
@ -204,7 +204,7 @@ fun CardNudge(
|
|||
BasicText(
|
||||
metadata.accentText,
|
||||
style = token.accentTypography(cardNudgeInfo),
|
||||
modifier = Modifier.testTag(ACCENT_TEXT)
|
||||
modifier = Modifier.testTag(CARD_NUDGE_ACCENT_TEXT)
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ fun CardNudge(
|
|||
BasicText(
|
||||
metadata.subTitle,
|
||||
style = token.subtitleTypography(cardNudgeInfo),
|
||||
modifier = Modifier.testTag(SUBTITLE)
|
||||
modifier = Modifier.testTag(CARD_NUDGE_SUBTITLE)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -223,7 +223,7 @@ fun CardNudge(
|
|||
if (metadata.actionMetaData != null) {
|
||||
PillButton(
|
||||
metadata.actionMetaData,
|
||||
modifier = Modifier.testTag(ACTION_BUTTON),
|
||||
modifier = Modifier.testTag(CARD_NUDGE_ACTION_BUTTON),
|
||||
pillButtonTokens = object : PillButtonTokens() {
|
||||
@Composable
|
||||
override fun backgroundBrush(pillButtonInfo: PillButtonInfo): StateBrush {
|
||||
|
@ -260,7 +260,7 @@ fun CardNudge(
|
|||
modifier = Modifier
|
||||
.padding(10.dp)
|
||||
.size(token.dismissIconSize(cardNudgeInfo))
|
||||
.testTag(DISMISS_BUTTON),
|
||||
.testTag(CARD_NUDGE_DISMISS_BUTTON),
|
||||
tint = token.iconColor(cardNudgeInfo),
|
||||
onClick = metadata.dismissOnClick
|
||||
)
|
||||
|
|
|
@ -35,11 +35,11 @@ import kotlinx.coroutines.sync.withLock
|
|||
import kotlin.coroutines.resume
|
||||
|
||||
// TAGS FOR TESTING
|
||||
private const val SNACKBAR = "Snackbar"
|
||||
private const val ICON = "Icon"
|
||||
private const val SUBTITLE = "Subtitle"
|
||||
private const val ACTION_BUTTON = "Action Button"
|
||||
private const val DISMISS_BUTTON = "Dismiss Button"
|
||||
const val SNACK_BAR = "Snack bar"
|
||||
const val SNACK_BAR_ICON = "Icon"
|
||||
const val SNACK_BAR_SUBTITLE = "Subtitle"
|
||||
const val SNACK_BAR_ACTION_BUTTON = "Action Button"
|
||||
const val SNACK_BAR_DISMISS_BUTTON = "Dismiss Button"
|
||||
|
||||
class SnackbarMetadata(
|
||||
val message: String,
|
||||
|
@ -142,13 +142,13 @@ fun Snackbar(
|
|||
.semantics {
|
||||
liveRegion = LiveRegionMode.Polite
|
||||
}
|
||||
.testTag(SNACKBAR),
|
||||
.testTag(SNACK_BAR),
|
||||
verticalAlignment = Alignment.CenterVertically
|
||||
) {
|
||||
if (metadata.icon != null && metadata.icon.isIconAvailable()) {
|
||||
Box(
|
||||
modifier = Modifier
|
||||
.testTag(ICON)
|
||||
.testTag(SNACK_BAR_ICON)
|
||||
.then(
|
||||
if (metadata.icon.onClick != null) {
|
||||
Modifier.clickable(
|
||||
|
@ -192,7 +192,7 @@ fun Snackbar(
|
|||
BasicText(
|
||||
text = metadata.subTitle,
|
||||
style = token.subtitleTypography(snackBarInfo),
|
||||
modifier = Modifier.testTag(SUBTITLE)
|
||||
modifier = Modifier.testTag(SNACK_BAR_SUBTITLE)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -201,7 +201,7 @@ fun Snackbar(
|
|||
Button(
|
||||
onClick = { metadata.clicked() },
|
||||
modifier = Modifier
|
||||
.testTag(ACTION_BUTTON)
|
||||
.testTag(SNACK_BAR_ACTION_BUTTON)
|
||||
.then(
|
||||
if (!metadata.enableDismiss)
|
||||
Modifier.padding(horizontal = 16.dp, vertical = 12.dp)
|
||||
|
@ -235,7 +235,7 @@ fun Snackbar(
|
|||
onClickLabel = "Dismiss",
|
||||
onClick = { metadata.dismiss() }
|
||||
)
|
||||
.testTag(DISMISS_BUTTON)
|
||||
.testTag(SNACK_BAR_DISMISS_BUTTON)
|
||||
) {
|
||||
Icon(
|
||||
Icons.Filled.Close,
|
||||
|
|
|
@ -29,6 +29,7 @@ import com.microsoft.fluentui.theme.token.FluentIcon
|
|||
import com.microsoft.fluentui.theme.token.Icon
|
||||
import com.microsoft.fluentui.theme.token.controlTokens.*
|
||||
|
||||
// Tags used for testing
|
||||
const val AVATAR_IMAGE = "Image"
|
||||
const val AVATAR_ICON = "Icon"
|
||||
|
||||
|
|
|
@ -21,6 +21,9 @@ import kotlinx.parcelize.RawValue
|
|||
* @property status Current Status of the person
|
||||
* @property isOOO Enable/Disable Out-Of-Office flag for person
|
||||
*/
|
||||
|
||||
const val ANONYMOUS = "Anonymous"
|
||||
|
||||
@Parcelize
|
||||
class Person(
|
||||
val firstName: String = "",
|
||||
|
@ -36,7 +39,7 @@ class Person(
|
|||
fun getName(): String {
|
||||
val name = "$firstName $lastName"
|
||||
if (name.trim().isBlank())
|
||||
return "Anonymous"
|
||||
return ANONYMOUS
|
||||
return name
|
||||
}
|
||||
|
||||
|
@ -46,7 +49,7 @@ class Person(
|
|||
return label
|
||||
if (!email.isNullOrBlank())
|
||||
return email
|
||||
return "Anonymous"
|
||||
return ANONYMOUS
|
||||
}
|
||||
|
||||
fun isImageAvailable(): Boolean {
|
||||
|
@ -101,7 +104,7 @@ class Group(
|
|||
|
||||
fun getName(): String {
|
||||
if (groupName.trim().isBlank())
|
||||
return "Anonymous"
|
||||
return ANONYMOUS
|
||||
return groupName
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче