-
Notifications
You must be signed in to change notification settings - Fork 200
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 #158 from DroidKaigi/yamada-ika/add-staff-screen
Add Staff Screen
- Loading branch information
Showing
18 changed files
with
519 additions
and
10 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
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
29 changes: 20 additions & 9 deletions
29
...src/androidMain/kotlin/io/github/droidkaigi/confsched/data/staff/StaffRepositoryModule.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 |
---|---|---|
@@ -1,23 +1,34 @@ | ||
package io.github.droidkaigi.confsched.data.staff | ||
|
||
import dagger.Binds | ||
import dagger.Module | ||
import dagger.Provides | ||
import dagger.hilt.InstallIn | ||
import dagger.hilt.components.SingletonComponent | ||
import dagger.multibindings.ClassKey | ||
import dagger.multibindings.IntoMap | ||
import io.github.droidkaigi.confsched.data.di.RepositoryQualifier | ||
import io.github.droidkaigi.confsched.model.StaffRepository | ||
import javax.inject.Singleton | ||
|
||
@Module | ||
@InstallIn(SingletonComponent::class) | ||
public class StaffRepositoryModule { | ||
public abstract class StaffRepositoryModule { | ||
@Binds | ||
@RepositoryQualifier | ||
@IntoMap | ||
@ClassKey(StaffRepository::class) | ||
public abstract fun bind(repository: StaffRepository): Any | ||
|
||
@Provides | ||
@Singleton | ||
public fun provideStaffRepository( | ||
staffApi: StaffApiClient, | ||
): StaffRepository { | ||
return DefaultStaffRepository( | ||
staffApi = staffApi, | ||
) | ||
public companion object { | ||
@Provides | ||
@Singleton | ||
public fun provideStaffRepository( | ||
staffApi: StaffApiClient, | ||
): StaffRepository { | ||
return DefaultStaffRepository( | ||
staffApi = staffApi, | ||
) | ||
} | ||
} | ||
} |
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
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
27 changes: 27 additions & 0 deletions
27
core/testing/src/main/java/io/github/droidkaigi/confsched/testing/robot/StaffScreenRobot.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 io.github.droidkaigi.confsched.testing.robot | ||
|
||
import io.github.droidkaigi.confsched.designsystem.theme.KaigiTheme | ||
import io.github.droidkaigi.confsched.staff.StaffScreen | ||
import io.github.droidkaigi.confsched.testing.DefaultScreenRobot | ||
import io.github.droidkaigi.confsched.testing.DefaultStaffServerRobot | ||
import io.github.droidkaigi.confsched.testing.ScreenRobot | ||
import io.github.droidkaigi.confsched.testing.StaffServerRobot | ||
import javax.inject.Inject | ||
|
||
class StaffScreenRobot @Inject constructor( | ||
private val screenRobot: DefaultScreenRobot, | ||
private val staffServerRobot: DefaultStaffServerRobot, | ||
) : ScreenRobot by screenRobot, | ||
StaffServerRobot by staffServerRobot { | ||
suspend fun setupScreenContent() { | ||
robotTestRule.setContent { | ||
KaigiTheme { | ||
StaffScreen( | ||
onNavigationIconClick = { }, | ||
onStaffItemClick = { }, | ||
) | ||
} | ||
} | ||
waitUntilIdle() | ||
} | ||
} |
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 @@ | ||
/build |
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,24 @@ | ||
plugins { | ||
id("droidkaigi.convention.kmpfeature") | ||
} | ||
|
||
android.namespace = "io.github.droidkaigi.confsched.feature.staff" | ||
roborazzi.generateComposePreviewRobolectricTests.packages = listOf("io.github.droidkaigi.confsched.staff") | ||
kotlin { | ||
sourceSets { | ||
commonMain { | ||
dependencies { | ||
implementation(projects.core.model) | ||
implementation(projects.core.ui) | ||
implementation(libs.kotlinxCoroutinesCore) | ||
implementation(projects.core.designsystem) | ||
implementation(libs.moleculeRuntime) | ||
} | ||
} | ||
androidUnitTest { | ||
dependencies { | ||
implementation(projects.core.testing) | ||
} | ||
} | ||
} | ||
} |
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,21 @@ | ||
# Add project specific ProGuard rules here. | ||
# You can control the set of applied configuration files using the | ||
# proguardFiles setting in build.gradle.kts. | ||
# | ||
# For more details, see | ||
# http://developer.android.com/guide/developing/tools/proguard.html | ||
|
||
# If your project uses WebView with JS, uncomment the following | ||
# and specify the fully qualified class name to the JavaScript interface | ||
# class: | ||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview { | ||
# public *; | ||
#} | ||
|
||
# Uncomment this to preserve the line number information for | ||
# debugging stack traces. | ||
#-keepattributes SourceFile,LineNumberTable | ||
|
||
# If you keep the line number information, uncomment this to | ||
# hide the original source file name. | ||
#-renamesourcefileattribute SourceFile |
77 changes: 77 additions & 0 deletions
77
.../staff/src/androidUnitTest/kotlin/io/github/droidkaigi/confsched/staff/StaffScreenTest.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,77 @@ | ||
package io.github.droidkaigi.confsched.staff | ||
|
||
import dagger.hilt.android.testing.BindValue | ||
import dagger.hilt.android.testing.HiltAndroidTest | ||
import io.github.droidkaigi.confsched.testing.DescribedBehavior | ||
import io.github.droidkaigi.confsched.testing.RobotTestRule | ||
import io.github.droidkaigi.confsched.testing.StaffServerRobot.ServerStatus.Error | ||
import io.github.droidkaigi.confsched.testing.StaffServerRobot.ServerStatus.Operational | ||
import io.github.droidkaigi.confsched.testing.describeBehaviors | ||
import io.github.droidkaigi.confsched.testing.execute | ||
import io.github.droidkaigi.confsched.testing.robot.StaffScreenRobot | ||
import io.github.droidkaigi.confsched.testing.runRobot | ||
import io.github.droidkaigi.confsched.testing.todoChecks | ||
import org.junit.Rule | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.robolectric.ParameterizedRobolectricTestRunner | ||
import javax.inject.Inject | ||
|
||
@RunWith(ParameterizedRobolectricTestRunner::class) | ||
@HiltAndroidTest | ||
class StaffScreenTest( | ||
private val testCase: DescribedBehavior<StaffScreenRobot>, | ||
) { | ||
@get:Rule | ||
@BindValue val robotTestRule: RobotTestRule = RobotTestRule(testInstance = this) | ||
|
||
@Inject | ||
lateinit var staffScreenRobot: StaffScreenRobot | ||
|
||
@Test | ||
fun runTest() { | ||
runRobot(staffScreenRobot) { | ||
testCase.execute(staffScreenRobot) | ||
} | ||
} | ||
|
||
companion object { | ||
@JvmStatic | ||
@ParameterizedRobolectricTestRunner.Parameters(name = "{0}") | ||
fun behaviors(): List<DescribedBehavior<StaffScreenRobot>> { | ||
return describeBehaviors<StaffScreenRobot>(name = "StaffScreen") { | ||
describe("when server is operational") { | ||
run { | ||
setupStaffServer(Operational) | ||
} | ||
describe("when launch") { | ||
run { | ||
setupScreenContent() | ||
} | ||
itShould("show staff screen") { | ||
captureScreenWithChecks( | ||
checks = todoChecks("This screen is still empty now. Please add some checks."), | ||
) | ||
} | ||
} | ||
} | ||
|
||
describe("when server is down") { | ||
run { | ||
setupStaffServer(Error) | ||
} | ||
describe("when launch") { | ||
run { | ||
setupScreenContent() | ||
} | ||
itShould("show snackbar") { | ||
captureScreenWithChecks( | ||
checks = todoChecks("This screen is still empty now. Please add some checks."), | ||
) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
feature/staff/src/androidUnitTest/resources/robolectric.properties
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,7 @@ | ||
sdk=34 | ||
# RobolectricDeviceQualifiers.NexusOne | ||
qualifiers=w320dp-h533dp-normal-long-notround-any-hdpi-keyshidden-trackball | ||
|
||
application=dagger.hilt.android.testing.HiltTestApplication | ||
# https://github.com/robolectric/robolectric/issues/6593 | ||
instrumentedPackages=androidx.loader.content |
Oops, something went wrong.