-
Notifications
You must be signed in to change notification settings - Fork 0
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 #269 from orcinusbr/add/autos-buttons-interaction
Add semantics matchers and interactions for αὐτός buttons
- Loading branch information
Showing
6 changed files
with
162 additions
and
2 deletions.
There are no files selected for viewing
44 changes: 44 additions & 0 deletions
44
...barrossilva/orca/platform/autos/test/kit/action/button/SemanticsMatcherExtensionsTests.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,44 @@ | ||
/* | ||
* Copyright © 2024 Orca | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If | ||
* not, see https://www.gnu.org/licenses. | ||
*/ | ||
|
||
package com.jeanbarrossilva.orca.platform.autos.test.kit.action.button | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import com.jeanbarrossilva.orca.platform.autos.kit.action.button.PrimaryButton | ||
import com.jeanbarrossilva.orca.platform.autos.kit.action.button.SecondaryButton | ||
import com.jeanbarrossilva.orca.platform.autos.theme.AutosTheme | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
internal class SemanticsMatcherExtensionsTests { | ||
@get:Rule val composeRule = createComposeRule() | ||
|
||
@Test | ||
fun matchesPrimaryButton() { | ||
composeRule | ||
.apply { setContent { AutosTheme { PrimaryButton(onClick = {}) {} } } } | ||
.onNode(isPrimaryButton()) | ||
.assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun matchesSecondaryButton() { | ||
composeRule | ||
.apply { setContent { AutosTheme { SecondaryButton(onClick = {}) {} } } } | ||
.onNode(isSecondaryButton()) | ||
.assertIsDisplayed() | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
...platform/autos/test/kit/action/button/SemanticsNodeInteractionsProviderExtensionsTests.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,44 @@ | ||
/* | ||
* Copyright © 2024 Orca | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If | ||
* not, see https://www.gnu.org/licenses. | ||
*/ | ||
|
||
package com.jeanbarrossilva.orca.platform.autos.test.kit.action.button | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import com.jeanbarrossilva.orca.platform.autos.kit.action.button.PrimaryButton | ||
import com.jeanbarrossilva.orca.platform.autos.kit.action.button.SecondaryButton | ||
import com.jeanbarrossilva.orca.platform.autos.theme.AutosTheme | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
internal class SemanticsNodeInteractionsProviderExtensionsTests { | ||
@get:Rule val composeRule = createComposeRule() | ||
|
||
@Test | ||
fun findsPrimaryButton() { | ||
composeRule | ||
.apply { setContent { AutosTheme { PrimaryButton(onClick = {}) {} } } } | ||
.onPrimaryButton() | ||
.assertIsDisplayed() | ||
} | ||
|
||
@Test | ||
fun findsSecondaryButton() { | ||
composeRule | ||
.apply { setContent { AutosTheme { SecondaryButton(onClick = {}) {} } } } | ||
.onSecondaryButton() | ||
.assertIsDisplayed() | ||
} | ||
} |
33 changes: 33 additions & 0 deletions
33
...jeanbarrossilva/orca/platform/autos/test/kit/action/button/SemanticsMatcher.extensions.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,33 @@ | ||
/* | ||
* Copyright © 2024 Orca | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If | ||
* not, see https://www.gnu.org/licenses. | ||
*/ | ||
|
||
package com.jeanbarrossilva.orca.platform.autos.test.kit.action.button | ||
|
||
import androidx.compose.ui.test.SemanticsMatcher | ||
import androidx.compose.ui.test.hasTestTag | ||
import com.jeanbarrossilva.orca.platform.autos.kit.action.button.PRIMARY_BUTTON_TAG | ||
import com.jeanbarrossilva.orca.platform.autos.kit.action.button.PrimaryButton | ||
import com.jeanbarrossilva.orca.platform.autos.kit.action.button.SECONDARY_BUTTON_TAG | ||
import com.jeanbarrossilva.orca.platform.autos.kit.action.button.SecondaryButton | ||
|
||
/** [SemanticsMatcher] that matches a [PrimaryButton]. */ | ||
fun isPrimaryButton(): SemanticsMatcher { | ||
return hasTestTag(PRIMARY_BUTTON_TAG) | ||
} | ||
|
||
/** [SemanticsMatcher] that matches a [SecondaryButton]. */ | ||
fun isSecondaryButton(): SemanticsMatcher { | ||
return hasTestTag(SECONDARY_BUTTON_TAG) | ||
} |
31 changes: 31 additions & 0 deletions
31
...rca/platform/autos/test/kit/action/button/SemanticsNodeInteractionsProvider.extensions.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,31 @@ | ||
/* | ||
* Copyright © 2024 Orca | ||
* | ||
* This program is free software: you can redistribute it and/or modify it under the terms of the | ||
* GNU General Public License as published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without | ||
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License along with this program. If | ||
* not, see https://www.gnu.org/licenses. | ||
*/ | ||
|
||
package com.jeanbarrossilva.orca.platform.autos.test.kit.action.button | ||
|
||
import androidx.compose.ui.test.SemanticsNodeInteraction | ||
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider | ||
import com.jeanbarrossilva.orca.platform.autos.kit.action.button.PrimaryButton | ||
import com.jeanbarrossilva.orca.platform.autos.kit.action.button.SecondaryButton | ||
|
||
/** [SemanticsNodeInteraction] of a [PrimaryButton]. */ | ||
fun SemanticsNodeInteractionsProvider.onPrimaryButton(): SemanticsNodeInteraction { | ||
return onNode(isPrimaryButton()) | ||
} | ||
|
||
/** [SemanticsNodeInteraction] of a [SecondaryButton]. */ | ||
fun SemanticsNodeInteractionsProvider.onSecondaryButton(): SemanticsNodeInteraction { | ||
return onNode(isSecondaryButton()) | ||
} |
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
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