Skip to content

Commit

Permalink
test cases (#476)
Browse files Browse the repository at this point in the history
Co-authored-by: Anubhav Agrawal <[email protected]>
  • Loading branch information
Anubhvv and Anubhav Agrawal authored Aug 14, 2023
1 parent f3ed2bf commit 96074ee
Showing 1 changed file with 29 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.microsoft.fluentuidemo.demos
import androidx.compose.ui.test.*
import com.microsoft.fluentui.tokenized.controls.*
import com.microsoft.fluentuidemo.BaseTest
import junit.framework.TestCase.fail
import org.junit.Before
import org.junit.Test

Expand Down Expand Up @@ -87,4 +88,32 @@ class V2TextFieldActivityUITest : BaseTest() {
component.performTextInput("Test")
component.assertExists("Password mode did not render properly")
}
@Test
fun testReadOnlyMode() {
val control = composeTestRule.onNodeWithTag(TEXT_FIELD_READONLY_PARAM)
val component = composeTestRule.onNodeWithTag(TEXT_FIELD, true)
component.assertExists("Text field did not render properly")
modifiableParametersButton.performClick()
modifiableParametersButton.performTouchInput { swipeUp(durationMillis = 1000) }
toggleControlToValue(control, true)
component.performClick()
component.assertIsFocused()
try {
component.performTextInput("Test")
fail("Text field should not be editable")
} catch (e: Exception) {
//Test passed as exception was thrown
}
}

@Test
fun testEnabledMode(){
val control = composeTestRule.onNodeWithTag(TEXT_FIELD_ENABLED_PARAM)
val component = composeTestRule.onNodeWithTag(TEXT_FIELD, true)
component.assertExists("Text field did not render properly")
modifiableParametersButton.performClick()
modifiableParametersButton.performTouchInput { swipeUp(durationMillis = 1000) }
toggleControlToValue(control, false)
component.assertIsNotEnabled()
}
}

0 comments on commit 96074ee

Please sign in to comment.