-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #176 from tarkalabs/sheshu/feature/tui_menu_item
TUI Menu item component created
- Loading branch information
Showing
24 changed files
with
374 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+5.41 KB
...enShotTest_Custom_LeadingIconStyle_Failure_isSelected_false_darkTheme_false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+5.75 KB
...eenShotTest_Custom_LeadingIconStyle_Failure_isSelected_false_darkTheme_true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.41 KB
...ItemScreenShotTest_LeadingIconStyle_NORMAL_isSelected_false_darkTheme_false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.36 KB
...uItemScreenShotTest_LeadingIconStyle_NORMAL_isSelected_false_darkTheme_true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.25 KB
...uItemScreenShotTest_LeadingIconStyle_NORMAL_isSelected_true_darkTheme_false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.01 KB
...nuItemScreenShotTest_LeadingIconStyle_NORMAL_isSelected_true_darkTheme_true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.83 KB
...temScreenShotTest_LeadingIconStyle_SUCCESS_isSelected_false_darkTheme_false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.73 KB
...ItemScreenShotTest_LeadingIconStyle_SUCCESS_isSelected_false_darkTheme_true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.72 KB
...ItemScreenShotTest_LeadingIconStyle_SUCCESS_isSelected_true_darkTheme_false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4.4 KB
...uItemScreenShotTest_LeadingIconStyle_SUCCESS_isSelected_true_darkTheme_true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.24 KB
...ItemScreenShotTest_LeadingIconStyle_NORMAL_isSelected_false_darkTheme_false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.17 KB
...uItemScreenShotTest_LeadingIconStyle_NORMAL_isSelected_false_darkTheme_true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4 KB
...uItemScreenShotTest_LeadingIconStyle_NORMAL_isSelected_true_darkTheme_false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.87 KB
...nuItemScreenShotTest_LeadingIconStyle_NORMAL_isSelected_true_darkTheme_true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.24 KB
...temScreenShotTest_LeadingIconStyle_SUCCESS_isSelected_false_darkTheme_false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.17 KB
...ItemScreenShotTest_LeadingIconStyle_SUCCESS_isSelected_false_darkTheme_true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+4 KB
...ItemScreenShotTest_LeadingIconStyle_SUCCESS_isSelected_true_darkTheme_false.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+3.87 KB
...uItemScreenShotTest_LeadingIconStyle_SUCCESS_isSelected_true_darkTheme_true.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 61 additions & 0 deletions
61
tarkaui/src/androidTest/java/com/tarkalabs/uicomponents/TUIMenuItemTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
package com.tarkalabs.uicomponents | ||
|
||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.ui.Modifier | ||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithTag | ||
import androidx.compose.ui.test.onNodeWithText | ||
import androidx.compose.ui.test.performClick | ||
import com.tarkalabs.tarkaicons.AddCircle24 | ||
import com.tarkalabs.tarkaicons.TarkaIcons.Regular | ||
import com.tarkalabs.uicomponents.components.TUIMenuItem | ||
import com.tarkalabs.uicomponents.components.TUIMenuItemTags | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.mockito.kotlin.mock | ||
import org.mockito.kotlin.verify | ||
|
||
class TUIMenuItemTest { | ||
|
||
@get:Rule val composeTestRule = createComposeRule() | ||
val tags = TUIMenuItemTags() | ||
|
||
@Test fun menu_Item_Displayed() { | ||
composeTestRule.setContent { | ||
TUIMenuItem( | ||
label = "Label", | ||
onMenuItemClick = {}, | ||
isSelected = true, | ||
modifier = Modifier.fillMaxWidth(), | ||
leadingIcon = Regular.AddCircle24, | ||
trailingIcon = Regular.AddCircle24, | ||
tags = tags | ||
) | ||
} | ||
composeTestRule.onNodeWithTag(tags.parentTag,useUnmergedTree = true).assertIsDisplayed() | ||
composeTestRule.onNodeWithTag(tags.leadingContentTag,useUnmergedTree = true).assertIsDisplayed() | ||
composeTestRule.onNodeWithTag(tags.trailingContentTag,useUnmergedTree = true).assertIsDisplayed() | ||
composeTestRule.onNodeWithText("Label",useUnmergedTree = true).assertIsDisplayed() | ||
} | ||
|
||
@Test fun button_Click_Triggered() { | ||
val onMenuItemClick: () -> Unit = mock() | ||
|
||
composeTestRule.setContent { | ||
TUIMenuItem( | ||
label = "Label", | ||
onMenuItemClick = onMenuItemClick, | ||
isSelected = true, | ||
modifier = Modifier.fillMaxWidth(), | ||
leadingIcon = Regular.AddCircle24, | ||
trailingIcon = Regular.AddCircle24, | ||
tags = tags | ||
) | ||
} | ||
composeTestRule.onNodeWithTag(tags.parentTag,useUnmergedTree = true).performClick() | ||
|
||
verify(onMenuItemClick).invoke() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
83 changes: 83 additions & 0 deletions
83
.../src/androidTest/java/com/tarkalabs/uicomponents/screenshots/TUIMenuItemScreenShotTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
package com.tarkalabs.uicomponents.screenshots | ||
|
||
import androidx.compose.foundation.layout.fillMaxWidth | ||
import androidx.compose.ui.Modifier | ||
import com.tarkalabs.tarkaicons.Checkmark24 | ||
import com.tarkalabs.tarkaicons.Circle24 | ||
import com.tarkalabs.tarkaicons.TarkaIcons.Regular | ||
import com.tarkalabs.uicomponents.components.TUIMenuItem | ||
import com.tarkalabs.uicomponents.components.TUIMenuItemIconStyle | ||
import com.tarkalabs.uicomponents.components.TUIMenuItemIconStyle.SUCCESS | ||
import com.tarkalabs.uicomponents.components.TUIMenuItemTags | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.junit.runners.Parameterized | ||
|
||
@RunWith(Parameterized::class) | ||
class TUIMenuItemScreenShotTest( | ||
private val leadingIconStyle: TUIMenuItemIconStyle, | ||
private val isSelected: Boolean, | ||
private val darkTheme: Boolean, | ||
private val testName: String, | ||
) : ComposeScreenshotComparator() { | ||
|
||
companion object { | ||
|
||
@JvmStatic | ||
@Parameterized.Parameters | ||
fun data(): Collection<Array<Any?>> { | ||
val leadingIconStyleValues = listOf(TUIMenuItemIconStyle.NORMAL, SUCCESS) | ||
val isSelectedValues = listOf(true, false) | ||
val darkThemeValues = listOf(true, false) | ||
|
||
val testData = ArrayList<Array<Any?>>() | ||
|
||
for (style in leadingIconStyleValues) { | ||
for (selectedValue in isSelectedValues) { | ||
for (darkThemeValue in darkThemeValues) { | ||
val testName = | ||
"LeadingIconStyle_${style}_isSelected_${selectedValue}_darkTheme_${darkThemeValue}" | ||
testData.add( | ||
arrayOf( | ||
style, selectedValue, darkThemeValue, testName | ||
) | ||
) | ||
} | ||
} | ||
} | ||
return testData | ||
} | ||
} | ||
|
||
@Test | ||
fun testTuiMenuItem() { | ||
compareScreenshotFor(darkTheme, testName) { | ||
TUIMenuItem( | ||
modifier = Modifier, | ||
label = "Label", | ||
isSelected = isSelected, | ||
onMenuItemClick = { /*TODO*/ }, | ||
leadingIconStyle = leadingIconStyle, | ||
leadingIcon = if (leadingIconStyle == SUCCESS) Regular.Checkmark24 else null | ||
) | ||
} | ||
} | ||
|
||
@Test | ||
fun testTuiMenuItem_Failure_With_Leading_Icon_Cirlce() { | ||
compareScreenshotFor( | ||
darkTheme, | ||
"Custom_LeadingIconStyle_Failure_isSelected_false_darkTheme_${darkTheme}" | ||
) { | ||
TUIMenuItem( | ||
modifier = Modifier.fillMaxWidth(), | ||
label = "Label", | ||
isSelected = false, | ||
leadingIcon = Regular.Circle24, | ||
trailingIcon = Regular.Circle24, | ||
onMenuItemClick = {}, | ||
tags = TUIMenuItemTags(parentTag = "hello") | ||
) | ||
} | ||
} | ||
} |
Oops, something went wrong.