-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Restore preview in CMP * Fix todos in detekt config * Add issue to todo * Resolve Koin todos * Resolve wear todos * Fix bug with first month * Update Compose UI tests with Kakao
- Loading branch information
Showing
63 changed files
with
481 additions
and
384 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,3 +20,4 @@ cmp-iosApp/iosApp.xcodeproj/* | |
*.jks | ||
*.jks.* | ||
app/src/main/play | ||
/gcm-diagnose.log |
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
19 changes: 19 additions & 0 deletions
19
app-wear-common/src/main/kotlin/ru/beryukhov/coffeegram/data/Const.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,19 @@ | ||
package ru.beryukhov.coffeegram.data | ||
|
||
import androidx.annotation.VisibleForTesting | ||
|
||
const val START_ACTIVITY_PATH = "/start-activity" | ||
const val DAY_COFFEE_PATH = "/coffee" | ||
|
||
@VisibleForTesting | ||
fun Map<CoffeeType, Int>.withEmpty(): List<Pair<CoffeeType, Int>> { | ||
@Suppress("DataClassShouldBeImmutable") | ||
data class MutablePair(val ct: CoffeeType, var count: Int) | ||
|
||
val emptyList: MutableList<MutablePair> = | ||
CoffeeType.entries.map { MutablePair(it, 0) }.toMutableList() | ||
this.forEach { entry: Map.Entry<CoffeeType, Int> -> | ||
emptyList.filter { it.ct == entry.key }.forEach { it.count = entry.value } | ||
} | ||
return emptyList.map { it.ct to it.count } | ||
} |
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
40 changes: 40 additions & 0 deletions
40
app/src/androidTest/java/ru/beryukhov/coffeegram/CoffeeListScreen.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,40 @@ | ||
package ru.beryukhov.coffeegram | ||
|
||
import androidx.compose.ui.semantics.SemanticsNode | ||
import androidx.compose.ui.test.SemanticsMatcher | ||
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider | ||
import io.github.kakaocup.compose.node.element.ComposeScreen | ||
import io.github.kakaocup.compose.node.element.KNode | ||
import io.github.kakaocup.compose.node.element.lazylist.KLazyListItemNode | ||
import io.github.kakaocup.compose.node.element.lazylist.KLazyListNode | ||
import ru.beryukhov.coffeegram.pages.LazyListItemPosition | ||
import ru.beryukhov.coffeegram.pages.LazyListLengthSemantics | ||
|
||
class CoffeeListScreen(semanticsProvider: SemanticsNodeInteractionsProvider) : | ||
ComposeScreen<CoffeeListScreen>( | ||
semanticsProvider = semanticsProvider, | ||
viewBuilderAction = { | ||
hasTestTag("CoffeeListScreen") | ||
} | ||
) { | ||
val coffeeList = KLazyListNode( | ||
semanticsProvider = semanticsProvider, | ||
viewBuilderAction = { | ||
hasTestTag("CoffeeList") | ||
}, | ||
itemTypeBuilder = { | ||
itemType(::CoffeeItemNode) | ||
}, | ||
positionMatcher = { position -> SemanticsMatcher.expectValue(LazyListItemPosition, position) }, | ||
lengthSemanticsPropertyKey = LazyListLengthSemantics | ||
) | ||
} | ||
|
||
class CoffeeItemNode( | ||
semanticsNode: SemanticsNode, | ||
semanticsProvider: SemanticsNodeInteractionsProvider, | ||
) : KLazyListItemNode<CoffeeItemNode>(semanticsNode, semanticsProvider) { | ||
val title: KNode = child { | ||
hasTestTag("CoffeeName") | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
app/src/androidTest/java/ru/beryukhov/coffeegram/ComposeAppTest.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,27 @@ | ||
package ru.beryukhov.coffeegram | ||
|
||
import androidx.compose.ui.test.junit4.createAndroidComposeRule | ||
import io.github.kakaocup.compose.node.element.ComposeScreen | ||
import org.junit.Rule | ||
import org.junit.Test | ||
|
||
class ComposeAppTest { | ||
@get:Rule | ||
val composeTestRule = createAndroidComposeRule<MainActivity>() | ||
@Test | ||
fun testDayOpen() { | ||
ComposeScreen.onComposeScreen<TableScreen>(composeTestRule) { | ||
assertIsDisplayed() | ||
day("1").apply { | ||
assertIsDisplayed() | ||
performClick() | ||
} | ||
} | ||
ComposeScreen.onComposeScreen<CoffeeListScreen>(composeTestRule) { | ||
assertIsDisplayed() | ||
coffeeList.assertLengthEquals(42) | ||
// CappuccinoItem.assertIsDisplayed() | ||
// LatteItem.assertIsDisplayed() | ||
} | ||
} | ||
} |
65 changes: 65 additions & 0 deletions
65
app/src/androidTest/java/ru/beryukhov/coffeegram/ComposeScreenTest.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,65 @@ | ||
package ru.beryukhov.coffeegram | ||
|
||
import androidx.compose.ui.test.assertIsDisplayed | ||
import androidx.compose.ui.test.junit4.ComposeTestRule | ||
import androidx.compose.ui.test.junit4.createComposeRule | ||
import androidx.compose.ui.test.onNodeWithText | ||
import io.github.kakaocup.compose.node.element.ComposeScreen.Companion.onComposeScreen | ||
import kotlinx.datetime.Month | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import ru.beryukhov.coffeegram.model.NavigationStore | ||
import ru.beryukhov.date_time_utils.YearMonth | ||
import ru.beryukhov.date_time_utils.nowYM | ||
|
||
class ComposeScreenTest { | ||
@get:Rule | ||
val composeTestRule = createComposeRule() | ||
|
||
@Test | ||
fun testYear() { | ||
withRule(yearMonth = YearMonth(2020, Month(1))) { | ||
onNodeWithText("2020").assertIsDisplayed() | ||
onComposeScreen<TableScreen>(composeTestRule) { | ||
yearName.assertIsDisplayed() | ||
monthName.assertIsDisplayed() | ||
yearName.assertTextEquals("2020") | ||
monthName.assertTextEquals("January") | ||
} | ||
} | ||
} | ||
|
||
@Test | ||
fun testMonthChange() { | ||
withRule(yearMonth = YearMonth(2020, Month(9))) { | ||
onComposeScreen<TableScreen>(composeTestRule) { | ||
monthName.assertTextEquals("September") | ||
leftArrowButton { | ||
assertIsDisplayed() | ||
performClick() | ||
} | ||
monthName.assertTextEquals("August") | ||
rightArrowButton { | ||
assertIsDisplayed() | ||
performClick() | ||
} | ||
monthName.assertTextEquals("September") | ||
rightArrowButton { | ||
assertIsDisplayed() | ||
performClick() | ||
} | ||
monthName.assertTextEquals("October") | ||
} | ||
} | ||
} | ||
|
||
private inline fun <R> withRule(yearMonth: YearMonth = nowYM(), block: ComposeTestRule.() -> R): R = | ||
with(composeTestRule) { | ||
setContent { | ||
PagesContent( | ||
navigationStore = NavigationStore(yearMonth = yearMonth), | ||
) | ||
} | ||
block() | ||
} | ||
} |
70 changes: 0 additions & 70 deletions
70
app/src/androidTest/java/ru/beryukhov/coffeegram/ExampleComposeTest.kt
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
app/src/androidTest/java/ru/beryukhov/coffeegram/PageObject.kt
This file was deleted.
Oops, something went wrong.
30 changes: 30 additions & 0 deletions
30
app/src/androidTest/java/ru/beryukhov/coffeegram/TableScreen.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,30 @@ | ||
package ru.beryukhov.coffeegram | ||
|
||
import androidx.compose.ui.test.SemanticsNodeInteractionsProvider | ||
import io.github.kakaocup.compose.node.element.ComposeScreen | ||
import io.github.kakaocup.compose.node.element.KNode | ||
|
||
class TableScreen(semanticsProvider: SemanticsNodeInteractionsProvider) : | ||
ComposeScreen<TableScreen>( | ||
semanticsProvider = semanticsProvider, | ||
viewBuilderAction = { | ||
hasTestTag("TableScreen") | ||
} | ||
) { | ||
val leftArrowButton = KNode(semanticsProvider) { | ||
hasContentDescription("LeftArrow") | ||
} | ||
val rightArrowButton = KNode(semanticsProvider) { | ||
hasTestTag("RightArrow") | ||
} | ||
val monthName = KNode(semanticsProvider) { | ||
hasTestTag("Month") | ||
} | ||
val yearName = KNode(semanticsProvider) { | ||
hasTestTag("Year") | ||
} | ||
fun day(number: String) = onNode { | ||
hasTestTag("Day") | ||
hasText(number) | ||
} | ||
} |
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
Oops, something went wrong.