Skip to content

Commit

Permalink
Merge branch 'main' into chore/run-ios-test-on-ci
Browse files Browse the repository at this point in the history
  • Loading branch information
RyuNen344 authored Aug 22, 2023
2 parents 9f47a58 + 6beca62 commit 3229e99
Show file tree
Hide file tree
Showing 24 changed files with 871 additions and 461 deletions.
4 changes: 1 addition & 3 deletions build-logic/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@ group = "io.github.droidkaigi.confsched2023.buildlogic"
repositories {
google()
mavenCentral()
maven {
url = uri("https://plugins.gradle.org/m2/")
}
gradlePluginPortal()
}

// If we use jvmToolchain, we need to install JDK 11
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,32 @@ package io.github.droidkaigi.confsched2023.model
public data class TimetableCategory(
val id: Int,
val title: MultiLangText,
)
) {
public companion object
}

fun TimetableCategory.Companion.fakes(): List<TimetableCategory> {
return listOf(
TimetableCategory(
id = 1,
title = MultiLangText(
jaTitle = "Kotlin",
enTitle = "Kotlin",
),
),
TimetableCategory(
id = 2,
title = MultiLangText(
jaTitle = "Security / Identity / Privacy",
enTitle = "Security / Identity / Privacy",
),
),
TimetableCategory(
id = 3,
title = MultiLangText(
jaTitle = "UI・UX・デザイン",
enTitle = "UI・UX・Design",
),
),
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
package io.github.droidkaigi.confsched2023.testing.robot

import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.isRoot
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.onFirst
import androidx.compose.ui.test.onLast
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performTouchInput
import androidx.compose.ui.test.swipeLeft
import com.github.takahirom.roborazzi.captureRoboImage
import io.github.droidkaigi.confsched2023.designsystem.theme.KaigiTheme
import io.github.droidkaigi.confsched2023.sessions.SearchScreen
import io.github.droidkaigi.confsched2023.sessions.SearchScreenTestTag
import io.github.droidkaigi.confsched2023.sessions.component.DropdownFilterChipItemTestTag
import io.github.droidkaigi.confsched2023.sessions.section.SearchFilterTestTag
import io.github.droidkaigi.confsched2023.testing.RobotTestRule
import io.github.droidkaigi.confsched2023.testing.coroutines.runTestWithLogging
import kotlinx.coroutines.test.TestDispatcher
import javax.inject.Inject
import kotlin.time.Duration.Companion.seconds

class SearchScreenRobot @Inject constructor(
private val testDispatcher: TestDispatcher,
) {
@Inject lateinit var robotTestRule: RobotTestRule

private lateinit var composeTestRule: AndroidComposeTestRule<*, *>

operator fun invoke(
block: SearchScreenRobot.() -> Unit,
) {
runTestWithLogging(timeout = 30.seconds) {
this@SearchScreenRobot.composeTestRule = robotTestRule.composeTestRule
block()
}
}

fun setupSearchScreenContent() {
composeTestRule.setContent {
KaigiTheme {
SearchScreen(
onBackClick = {},
onTimetableItemClick = {},
)
}
}
waitUntilIdle()
}

fun clickFilterChip(filterChipTestTag: String) {
composeTestRule
.onNode(hasTestTag(filterChipTestTag))
.performClick()
waitUntilIdle()
}

fun scrollSearchFilterToLeft() {
composeTestRule
.onNode(hasTestTag(SearchFilterTestTag))
.performTouchInput {
swipeLeft(
startX = visibleSize.width.toFloat(),
endX = visibleSize.width / 2f,
)
}
}

fun clickFirstDropdownMenuItem() {
composeTestRule
.onAllNodes(hasTestTag(DropdownFilterChipItemTestTag))
.onFirst()
.performClick()
waitUntilIdle()
}

fun clickLastDropdownMenuItem() {
composeTestRule
.onAllNodes(hasTestTag(DropdownFilterChipItemTestTag))
.onLast()
.performClick()
waitUntilIdle()
}

fun checkScreenCapture() {
composeTestRule
.onNode(isRoot())
.captureRoboImage()
}

fun checkSearchScreenCapture() {
composeTestRule
.onNode(hasTestTag(SearchScreenTestTag))
.captureRoboImage()
}

fun waitUntilIdle() {
composeTestRule.waitForIdle()
testDispatcher.scheduler.advanceUntilIdle()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ sealed class AboutStrings : Strings<AboutStrings>(Bindings) {
object License : AboutStrings()
object PrivacyPolicy : AboutStrings()
object AppVersion : AboutStrings()
object LicenceDescription : AboutStrings()

private object Bindings : StringsBindings<AboutStrings>(
Lang.Japanese to { item, _ ->
Expand All @@ -43,6 +44,7 @@ sealed class AboutStrings : Strings<AboutStrings>(Bindings) {
License -> "ライセンス"
PrivacyPolicy -> "プライバシーポリシー"
AppVersion -> "アプリバージョン"
LicenceDescription -> "The Android robot is reproduced or modified from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License."
}
},
Lang.English to { item, bindings ->
Expand All @@ -63,6 +65,7 @@ sealed class AboutStrings : Strings<AboutStrings>(Bindings) {
License -> "License"
PrivacyPolicy -> "Privacy Policy"
AppVersion -> "App Version"
LicenceDescription -> bindings.defaultBinding(item, bindings)
}
},
default = Lang.Japanese,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.droidkaigi.confsched2023.about.component

import androidx.compose.foundation.isSystemInDarkTheme
import androidx.compose.foundation.layout.Arrangement
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Row
Expand All @@ -13,6 +14,8 @@ import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import io.github.droidkaigi.confsched2023.about.AboutStrings
import io.github.droidkaigi.confsched2023.designsystem.preview.MultiLanguagePreviews
Expand All @@ -24,6 +27,9 @@ const val AboutFooterLinksYouTubeItemTestTag = "AboutFooterLinksYouTubeItem"
const val AboutFooterLinksXItemTestTag = "AboutFooterLinksXItem"
const val AboutFooterLinksMediumItemTestTag = "AboutFooterLinksMediumItem"

private val licenseDescriptionLight = Color(0xFF6D7256)
private val licenseDescriptionDark = Color(0xFFFFFFFF)

@Composable
fun AboutFooterLinks(
versionName: String?,
Expand Down Expand Up @@ -71,6 +77,15 @@ fun AboutFooterLinks(
style = MaterialTheme.typography.labelLarge,
)
}
Spacer(modifier = Modifier.height(8.dp))
Text(
modifier = Modifier.padding(horizontal = 12.dp),
text = AboutStrings.LicenceDescription.asString(),
style = MaterialTheme.typography.labelSmall,
textAlign = TextAlign.Center,
color = if (isSystemInDarkTheme()) licenseDescriptionDark else licenseDescriptionLight,
)
Spacer(modifier = Modifier.height(8.dp))
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.compose.ui.platform.testTag
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.FontWeight
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.tooling.preview.PreviewParameter
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.sp
import io.github.droidkaigi.confsched2023.designsystem.preview.MultiThemePreviews
Expand Down Expand Up @@ -108,28 +109,15 @@ private fun FloorLevelSwitcherButton(
}
}

// TODO Use PreviewParameterProvider to display the Preview once the Linter issue is resolved.
// https://github.com/DroidKaigi/conference-app-2023/pull/557#discussion_r1295780974
@MultiThemePreviews
@Composable
fun FloorLevelSwitcherGroundPreview() {
KaigiTheme {
Surface {
FloorLevelSwitcher(
selectingFloorLevel = FloorLevel.Ground,
onClickFloorLevelSwitcher = {},
)
}
}
}

@MultiThemePreviews
@Composable
fun FloorLevelSwitcherBasementPreview() {
internal fun FloorLevelSwitcherPreview(
@PreviewParameter(PreviewFloorMapSwitcherFloorLevelProvider::class) floorLevel: FloorLevel,
) {
KaigiTheme {
Surface {
FloorLevelSwitcher(
selectingFloorLevel = FloorLevel.Basement,
selectingFloorLevel = floorLevel,
onClickFloorLevelSwitcher = {},
)
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.github.droidkaigi.confsched2023.floormap.component

import androidx.compose.ui.tooling.preview.PreviewParameterProvider
import io.github.droidkaigi.confsched2023.model.FloorLevel

class PreviewFloorMapSwitcherFloorLevelProvider : PreviewParameterProvider<FloorLevel> {
override val values: Sequence<FloorLevel>
get() = FloorLevel.values().asSequence()
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ import io.github.droidkaigi.confsched2023.model.TimetableSessionType
import io.github.droidkaigi.confsched2023.sessions.SearchScreenUiState.Empty
import io.github.droidkaigi.confsched2023.sessions.SearchScreenUiState.SearchList
import io.github.droidkaigi.confsched2023.sessions.component.EmptySearchResultBody
import io.github.droidkaigi.confsched2023.sessions.component.SearchFilter
import io.github.droidkaigi.confsched2023.sessions.component.SearchFilterUiState
import io.github.droidkaigi.confsched2023.sessions.component.SearchTextFieldAppBar
import io.github.droidkaigi.confsched2023.sessions.section.SearchFilter
import io.github.droidkaigi.confsched2023.sessions.section.SearchFilterUiState
import io.github.droidkaigi.confsched2023.sessions.section.SearchList
import io.github.droidkaigi.confsched2023.sessions.section.SearchListUiState

Expand All @@ -36,16 +36,25 @@ const val SearchScreenTestTag = "SearchScreen"

sealed interface SearchScreenUiState {
val searchQuery: String
val searchFilterUiState: SearchFilterUiState
val searchFilterDayUiState: SearchFilterUiState<DroidKaigi2023Day>
val searchFilterCategoryUiState: SearchFilterUiState<TimetableCategory>
val searchFilterSessionTypeUiState: SearchFilterUiState<TimetableSessionType>
val searchFilterLanguageUiState: SearchFilterUiState<Lang>

data class Empty(
override val searchQuery: String,
override val searchFilterUiState: SearchFilterUiState,
override val searchFilterDayUiState: SearchFilterUiState<DroidKaigi2023Day>,
override val searchFilterCategoryUiState: SearchFilterUiState<TimetableCategory>,
override val searchFilterSessionTypeUiState: SearchFilterUiState<TimetableSessionType>,
override val searchFilterLanguageUiState: SearchFilterUiState<Lang>,
) : SearchScreenUiState

data class SearchList(
override val searchQuery: String,
override val searchFilterUiState: SearchFilterUiState,
override val searchFilterDayUiState: SearchFilterUiState<DroidKaigi2023Day>,
override val searchFilterCategoryUiState: SearchFilterUiState<TimetableCategory>,
override val searchFilterSessionTypeUiState: SearchFilterUiState<TimetableSessionType>,
override val searchFilterLanguageUiState: SearchFilterUiState<Lang>,
val searchListUiState: SearchListUiState,
) : SearchScreenUiState
}
Expand Down Expand Up @@ -121,7 +130,10 @@ private fun SearchScreen(
color = MaterialTheme.colorScheme.outline,
)
SearchFilter(
searchFilterUiState = uiState.searchFilterUiState,
searchFilterDayUiState = uiState.searchFilterDayUiState,
searchFilterCategoryUiState = uiState.searchFilterCategoryUiState,
searchFilterSessionTypeUiState = uiState.searchFilterSessionTypeUiState,
searchFilterLanguageUiState = uiState.searchFilterLanguageUiState,
onDaySelected = onDaySelected,
onCategoriesSelected = onCategoriesSelected,
onSessionTypesSelected = onSessionTypesSelected,
Expand Down
Loading

0 comments on commit 3229e99

Please sign in to comment.