feat(event): ID 기반 상세 화면과 기존 진입을 연결한다

This commit is contained in:
2026-10-29 11:47:56 +09:00
parent b5c49c22c5
commit 8879b38e1f
5 changed files with 487 additions and 45 deletions
+3
View File
@@ -201,6 +201,9 @@
<activity android:name=".settings.notice.NoticeDetailActivity" /> <activity android:name=".settings.notice.NoticeDetailActivity" />
<activity android:name=".settings.event.EventActivity" /> <activity android:name=".settings.event.EventActivity" />
<activity android:name=".settings.event.EventDetailActivity" /> <activity android:name=".settings.event.EventDetailActivity" />
<activity
android:name=".v2.event.EventDetailActivity"
android:exported="false" />
<activity android:name=".settings.notification.NotificationSettingsActivity" /> <activity android:name=".settings.notification.NotificationSettingsActivity" />
<activity android:name=".settings.notification.NotificationReceiveSettingsActivity" /> <activity android:name=".settings.notification.NotificationReceiveSettingsActivity" />
<activity android:name=".settings.ContentSettingsActivity" /> <activity android:name=".settings.ContentSettingsActivity" />
@@ -91,6 +91,9 @@ import kr.co.vividnext.sodalive.home.HomeApi
import kr.co.vividnext.sodalive.home.HomeRepository import kr.co.vividnext.sodalive.home.HomeRepository
import kr.co.vividnext.sodalive.home.HomeViewModel import kr.co.vividnext.sodalive.home.HomeViewModel
import kr.co.vividnext.sodalive.home.pushnotification.PushNotificationListViewModel import kr.co.vividnext.sodalive.home.pushnotification.PushNotificationListViewModel
import kr.co.vividnext.sodalive.v2.event.EventDetailViewModel
import kr.co.vividnext.sodalive.v2.event.data.EventDetailApi
import kr.co.vividnext.sodalive.v2.event.data.EventDetailRepository
import kr.co.vividnext.sodalive.v2.gift.GiftSendRequestViewModel import kr.co.vividnext.sodalive.v2.gift.GiftSendRequestViewModel
import kr.co.vividnext.sodalive.v2.gift.GiftInboxViewModel import kr.co.vividnext.sodalive.v2.gift.GiftInboxViewModel
import kr.co.vividnext.sodalive.v2.gift.GiftDetailViewModel import kr.co.vividnext.sodalive.v2.gift.GiftDetailViewModel
@@ -333,6 +336,7 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
single { ApiBuilder().build(get(), LiveApi::class.java) } single { ApiBuilder().build(get(), LiveApi::class.java) }
single { ApiBuilder().build(get(), TermsApi::class.java) } single { ApiBuilder().build(get(), TermsApi::class.java) }
single { ApiBuilder().build(get(), EventApi::class.java) } single { ApiBuilder().build(get(), EventApi::class.java) }
single { ApiBuilder().build(get(), EventDetailApi::class.java) }
single { ApiBuilder().build(get(), SeriesApi::class.java) } single { ApiBuilder().build(get(), SeriesApi::class.java) }
single { ApiBuilder().build(get(), SeriesMainApi::class.java) } single { ApiBuilder().build(get(), SeriesMainApi::class.java) }
single { ApiBuilder().build(get(), ReportApi::class.java) } single { ApiBuilder().build(get(), ReportApi::class.java) }
@@ -480,6 +484,7 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
viewModel { GiftSendRequestViewModel(get()) } viewModel { GiftSendRequestViewModel(get()) }
viewModel { GiftInboxViewModel(get()) } viewModel { GiftInboxViewModel(get()) }
viewModel { GiftDetailViewModel(get()) } viewModel { GiftDetailViewModel(get()) }
viewModel { EventDetailViewModel(get()) }
viewModel { GiftRecipientAddressViewModel(get()) } viewModel { GiftRecipientAddressViewModel(get()) }
viewModel { GiftTrackingViewModel(get()) } viewModel { GiftTrackingViewModel(get()) }
viewModel { GiftCancelViewModel(get()) } viewModel { GiftCancelViewModel(get()) }
@@ -517,6 +522,7 @@ class AppDI(private val context: Context, isDebugMode: Boolean) {
factory { LiveRepository(get(), get(), get()) } factory { LiveRepository(get(), get(), get()) }
factory { V2vRepository(get()) } factory { V2vRepository(get()) }
factory { EventRepository(get()) } factory { EventRepository(get()) }
factory { EventDetailRepository(get()) }
factory { LiveRecommendRepository(get()) } factory { LiveRecommendRepository(get()) }
factory { CanRepository(get()) } factory { CanRepository(get()) }
factory { CanPaymentTempRepository(get()) } factory { CanPaymentTempRepository(get()) }
@@ -1,56 +1,21 @@
package kr.co.vividnext.sodalive.settings.event package kr.co.vividnext.sodalive.settings.event
import android.content.Intent import android.os.Bundle
import android.net.Uri import androidx.appcompat.app.AppCompatActivity
import android.view.View
import android.widget.FrameLayout
import android.widget.RelativeLayout
import androidx.core.content.IntentCompat import androidx.core.content.IntentCompat
import coil.load
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.base.BaseActivity
import kr.co.vividnext.sodalive.common.Constants import kr.co.vividnext.sodalive.common.Constants
import kr.co.vividnext.sodalive.databinding.ActivityEventDetailBinding
class EventDetailActivity : BaseActivity<ActivityEventDetailBinding>( class EventDetailActivity : AppCompatActivity() {
ActivityEventDetailBinding::inflate override fun onCreate(savedInstanceState: Bundle?) {
) { super.onCreate(savedInstanceState)
private lateinit var event: EventItem val event = IntentCompat.getParcelableExtra(
override fun setupView() {
event = IntentCompat.getParcelableExtra(
intent, intent,
Constants.EXTRA_EVENT, Constants.EXTRA_EVENT,
EventItem::class.java EventItem::class.java
)!!
binding.toolbar.tvBack.text = getString(R.string.screen_event_detail_title)
binding.toolbar.tvBack.setOnClickListener { finish() }
if (!event.link.isNullOrBlank()) {
binding.flParticipate.visibility = View.VISIBLE
val flParticipateLp =
binding.flParticipate.layoutParams as RelativeLayout.LayoutParams
val ivEventLp = binding.ivEvent.layoutParams as FrameLayout.LayoutParams
ivEventLp.bottomMargin = flParticipateLp.height
binding.ivEvent.layoutParams = ivEventLp
} else {
binding.flParticipate.visibility = View.GONE
}
binding.tvParticipate.setOnClickListener {
if (!event.link.isNullOrBlank()) {
startActivity(
Intent(
Intent.ACTION_VIEW,
Uri.parse(event.link)
)
) )
if (event != null && event.id > 0L) {
startActivity(kr.co.vividnext.sodalive.v2.event.EventDetailActivity.newIntent(this, event.id))
} }
} finish()
binding.ivEvent.load(event.detailImageUrl)
} }
} }
@@ -0,0 +1,88 @@
package kr.co.vividnext.sodalive.v2.event
import android.content.Context
import android.content.Intent
import android.view.View
import android.widget.RelativeLayout
import androidx.core.view.isVisible
import coil.load
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.base.BaseActivity
import kr.co.vividnext.sodalive.common.LoadingDialog
import kr.co.vividnext.sodalive.databinding.ActivityEventDetailBinding
import kr.co.vividnext.sodalive.v2.components.modal.V2ModalDialog
import org.koin.androidx.viewmodel.ext.android.viewModel
class EventDetailActivity : BaseActivity<ActivityEventDetailBinding>(ActivityEventDetailBinding::inflate) {
private val viewModel: EventDetailViewModel by viewModel()
private var loadingDialog: LoadingDialog? = null
private var errorDialog: V2ModalDialog? = null
override fun setupView() {
binding.toolbar.tvBack.setText(R.string.screen_event_detail_title)
binding.toolbar.tvBack.setOnClickListener { finish() }
binding.flParticipate.isVisible = false
binding.tvParticipate.setOnClickListener {
val link = (viewModel.state.value as? EventDetailUiState.Content)?.detail?.link
if (!link.isNullOrBlank() && !EventDetailLinkPolicy.launch(this, link)) {
showToast(getString(R.string.common_error_unknown))
}
}
viewModel.state.observe(this, ::render)
viewModel.loadInitial(intent.getLongExtra(EXTRA_EVENT_ID, 0L))
}
private fun render(state: EventDetailUiState) {
dismissDialogs()
when (state) {
EventDetailUiState.Loading -> {
loadingDialog = LoadingDialog(this, layoutInflater).also { it.show(screenWidth) }
}
is EventDetailUiState.Content -> {
val participates = !state.detail.link.isNullOrBlank()
binding.flParticipate.isVisible = participates
val scroll = binding.ivEvent.parent as View
val params = scroll.layoutParams as RelativeLayout.LayoutParams
if (participates) {
params.addRule(RelativeLayout.ABOVE, R.id.fl_participate)
} else {
params.removeRule(RelativeLayout.ABOVE)
}
scroll.layoutParams = params
binding.ivEvent.load(state.detail.detailImageUrl)
}
is EventDetailUiState.Unavailable -> finish()
EventDetailUiState.Error -> {
errorDialog = V2ModalDialog(
activity = this,
layoutInflater = layoutInflater,
title = getString(R.string.screen_event_detail_title),
desc = getString(R.string.common_error_unknown),
confirmButtonTitle = getString(R.string.gift_inbox_retry),
confirmButtonClick = { viewModel.retry() },
cancelButtonTitle = getString(R.string.dialog_close),
cancelButtonClick = { finish() }
).also { it.show(screenWidth) }
}
}
}
private fun dismissDialogs() {
loadingDialog?.dismiss()
loadingDialog = null
errorDialog?.dismiss()
errorDialog = null
}
override fun onDestroy() {
dismissDialogs()
super.onDestroy()
}
companion object {
const val EXTRA_EVENT_ID = "EXTRA_EVENT_ID"
fun newIntent(context: Context, eventId: Long): Intent =
Intent(context, EventDetailActivity::class.java).putExtra(EXTRA_EVENT_ID, eventId)
}
}
@@ -0,0 +1,380 @@
package kr.co.vividnext.sodalive.v2.event
import android.app.Application
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.graphics.drawable.ColorDrawable
import android.os.Looper
import android.view.View
import androidx.lifecycle.ViewModelProvider
import androidx.test.core.app.ApplicationProvider
import coil.Coil
import coil.EventListener
import coil.ImageLoader
import coil.decode.DataSource
import coil.intercept.Interceptor
import coil.request.ImageRequest
import coil.request.SuccessResult
import io.reactivex.rxjava3.android.plugins.RxAndroidPlugins
import io.reactivex.rxjava3.core.Single
import io.reactivex.rxjava3.plugins.RxJavaPlugins
import io.reactivex.rxjava3.schedulers.Schedulers
import io.reactivex.rxjava3.subjects.SingleSubject
import kr.co.vividnext.sodalive.R
import kr.co.vividnext.sodalive.common.ApiResponse
import kr.co.vividnext.sodalive.common.Constants
import kr.co.vividnext.sodalive.common.SharedPreferenceManager
import kr.co.vividnext.sodalive.settings.event.EventItem
import kr.co.vividnext.sodalive.v2.event.data.EventDetailApi
import kr.co.vividnext.sodalive.v2.event.data.EventDetailRepository
import kr.co.vividnext.sodalive.v2.event.data.EventDetailResponse
import kotlinx.coroutines.Dispatchers
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertNotNull
import org.junit.Assert.assertNull
import org.junit.Assert.assertSame
import org.junit.Assert.assertTrue
import org.junit.Before
import org.junit.Test
import org.junit.runner.RunWith
import org.koin.androidx.viewmodel.dsl.viewModel
import org.koin.core.context.startKoin
import org.koin.core.context.stopKoin
import org.koin.dsl.module
import org.robolectric.Robolectric
import org.robolectric.RobolectricTestRunner
import org.robolectric.Shadows.shadowOf
import org.robolectric.annotation.Config
import org.robolectric.android.controller.ActivityController
import org.robolectric.shadows.ShadowDialog
import org.robolectric.shadows.ShadowToast
import java.io.IOException
import kr.co.vividnext.sodalive.settings.event.EventDetailActivity as LegacyEventDetailActivity
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [28], application = Application::class)
class EventDetailNavigationTest {
private val context: Context get() = ApplicationProvider.getApplicationContext()
private lateinit var api: NavigationFakeApi
private lateinit var loader: ImageLoader
private val imageRequests = mutableListOf<ImageRequest>()
@Before
fun setUp() {
RxJavaPlugins.setIoSchedulerHandler { Schedulers.trampoline() }
RxAndroidPlugins.setInitMainThreadSchedulerHandler { Schedulers.trampoline() }
RxAndroidPlugins.setMainThreadSchedulerHandler { Schedulers.trampoline() }
SharedPreferenceManager.resetForTest()
SharedPreferenceManager.init(context)
api = NavigationFakeApi()
startKoin { modules(module { viewModel { EventDetailViewModel(EventDetailRepository(api)) } }) }
loader = ImageLoader.Builder(context)
.dispatcher(Dispatchers.Unconfined)
.components {
add(
Interceptor { chain ->
SuccessResult(ColorDrawable(Color.TRANSPARENT), chain.request, DataSource.MEMORY)
}
)
}
.eventListenerFactory {
object : EventListener {
override fun onStart(request: ImageRequest) {
imageRequests += request
}
}
}
.build()
Coil.setImageLoader(loader)
}
@After
fun tearDown() {
Coil.reset()
loader.shutdown()
stopKoin()
RxJavaPlugins.reset()
RxAndroidPlugins.reset()
SharedPreferenceManager.resetForTest()
}
@Test
fun `ID 전용 진입은 Int 초과와 Long 최대 ID를 그대로 조회한다`() {
listOf(Int.MAX_VALUE.toLong() + 1L, Long.MAX_VALUE).forEach { id ->
val intent = EventDetailActivity.newIntent(context, id)
assertEquals(EventDetailActivity::class.java.name, intent.component?.className)
assertEquals(setOf(EventDetailActivity.EXTRA_EVENT_ID), intent.extras?.keySet())
assertEquals(id, intent.getLongExtra(EventDetailActivity.EXTRA_EVENT_ID, 0L))
val controller = open(intent)
assertFalse(controller.get().isFinishing)
assertEquals(id, api.requests.last())
close(controller)
}
assertEquals(listOf(2147483648L, Long.MAX_VALUE), api.requests)
}
@Test
fun `누락과 잘못된 타입 및 양수가 아닌 ID는 요청 없이 종료한다`() {
listOf(
Intent(context, EventDetailActivity::class.java),
EventDetailActivity.newIntent(context, 0L),
EventDetailActivity.newIntent(context, -1L),
Intent(context, EventDetailActivity::class.java).putExtra(EventDetailActivity.EXTRA_EVENT_ID, "7"),
Intent(context, EventDetailActivity::class.java).putExtra(EventDetailActivity.EXTRA_EVENT_ID, 7)
).forEach { intent ->
val controller = open(intent)
assertTrue(controller.get().isFinishing)
assertNull(shadowOf(controller.get()).nextStartedActivity)
close(controller)
}
assertTrue(api.requests.isEmpty())
}
@Test
fun `레거시 bridge는 Parcelable ID만 전달하고 즉시 종료한다`() {
listOf(2147483648L, Long.MAX_VALUE).forEach { id ->
val item = EventItem(id, "stale-thumbnail", "stale-detail", "stale-popup", "https://stale.example")
val bridge = Robolectric.buildActivity(
LegacyEventDetailActivity::class.java,
Intent(context, LegacyEventDetailActivity::class.java).putExtra(Constants.EXTRA_EVENT, item)
).setup()
val forwarded = shadowOf(bridge.get()).nextStartedActivity
assertTrue(bridge.get().isFinishing)
assertEquals(EventDetailActivity::class.java.name, forwarded.component?.className)
assertEquals(setOf(EventDetailActivity.EXTRA_EVENT_ID), forwarded.extras?.keySet())
assertEquals(id, forwarded.getLongExtra(EventDetailActivity.EXTRA_EVENT_ID, 0L))
assertNull(shadowOf(bridge.get()).nextStartedActivity)
val detail = open(forwarded)
assertEquals(id, api.requests.last())
detail.get().binding.tvParticipate.performClick()
assertEquals("https://server.example/join", shadowOf(detail.get()).nextStartedActivity.dataString)
close(detail)
bridge.pause().stop().destroy()
}
}
@Test
fun `레거시 extra 누락과 잘못된 값은 전달 없이 종료한다`() {
listOf(
Intent(context, LegacyEventDetailActivity::class.java),
Intent(context, LegacyEventDetailActivity::class.java).putExtra(Constants.EXTRA_EVENT, "invalid"),
Intent(context, LegacyEventDetailActivity::class.java).putExtra(Constants.EXTRA_EVENT, EventItem(0L, "old")),
Intent(context, LegacyEventDetailActivity::class.java).putExtra(Constants.EXTRA_EVENT, EventItem(-1L, "old"))
).forEach { intent ->
val bridge = Robolectric.buildActivity(LegacyEventDetailActivity::class.java, intent).setup()
assertTrue(bridge.get().isFinishing)
assertNull(shadowOf(bridge.get()).nextStartedActivity)
bridge.pause().stop().destroy()
}
assertTrue(api.requests.isEmpty())
}
@Test
fun `서버 success false는 신규 화면을 실제 종료한다`() {
api.next = Single.just(ApiResponse(false, null, "잘못된 요청입니다."))
val controller = open()
assertTrue(controller.get().isFinishing)
assertNull(shadowOf(controller.get()).nextStartedActivity)
assertEquals(listOf(7L), api.requests)
close(controller)
}
@Test
fun `이미지와 링크는 서버 값만 사용하고 참여 클릭 전에는 이동하지 않는다`() {
val detail = api.detail(7L).copy(detailImageUrl = "https://server.example/detail.png")
api.next = Single.just(ApiResponse(true, detail, null))
val controller = open(
EventDetailActivity.newIntent(context, 7L).putExtra(Constants.EXTRA_EVENT, EventItem(99L, "old", "old-detail"))
)
controller.visible()
shadowOf(Looper.getMainLooper()).idle()
assertTrue(imageRequests.any { it.data == "https://server.example/detail.png" })
assertFalse(imageRequests.any { it.data == "old-detail" || it.data == "old" })
assertNull(shadowOf(controller.get()).nextStartedActivity)
controller.get().binding.tvParticipate.performClick()
assertEquals("https://server.example/join", shadowOf(controller.get()).nextStartedActivity.dataString)
close(controller)
}
@Test
fun `링크만 있는 성공은 화면을 유지하고 클릭으로만 참여한다`() {
val controller = open()
val activity = controller.get()
assertTrue(ViewModelProvider(activity)[EventDetailViewModel::class.java].state.value is EventDetailUiState.Content)
assertFalse(activity.isFinishing)
assertNull(shadowOf(activity).nextStartedActivity)
activity.binding.tvParticipate.performClick()
assertEquals(Intent.ACTION_VIEW, shadowOf(activity).nextStartedActivity.action)
close(controller)
}
@Test
fun `nullable 이미지와 누락 또는 blank 링크도 정상 상세이며 이동하지 않는다`() {
listOf(null, "", " ").forEach { link ->
api.next = Single.just(ApiResponse(true, api.detail(7L).copy(link = link), null))
val controller = open()
val activity = controller.get()
assertFalse(activity.isFinishing)
assertTrue(ViewModelProvider(activity)[EventDetailViewModel::class.java].state.value is EventDetailUiState.Content)
activity.binding.tvParticipate.performClick()
assertNull(shadowOf(activity).nextStartedActivity)
assertNull(ShadowToast.getTextOfLatestToast())
close(controller)
}
}
@Test
fun `지원하지 않는 서버 링크는 정상 상세를 유지하고 클릭 시 공통 오류만 알린다`() {
api.next = Single.just(ApiResponse(true, api.detail(7L).copy(link = "javascript:alert(1)"), null))
val controller = open()
val activity = controller.get()
activity.binding.tvParticipate.performClick()
assertFalse(activity.isFinishing)
assertNull(shadowOf(activity).nextStartedActivity)
assertEquals(activity.getString(R.string.common_error_unknown), ShadowToast.getTextOfLatestToast())
close(controller)
}
@Test
fun `참여 링크를 처리할 앱이 없어도 충돌 없이 공통 오류를 알린다`() {
shadowOf(ApplicationProvider.getApplicationContext<Application>()).checkActivities(true)
val controller = open()
val activity = controller.get()
activity.binding.tvParticipate.performClick()
assertFalse(activity.isFinishing)
assertEquals(activity.getString(R.string.common_error_unknown), ShadowToast.getTextOfLatestToast())
close(controller)
}
@Test
fun `오류 modal은 공통 문구만 표시하고 같은 ID 재시도로 성공한다`() {
api.next = Single.error(IOException("비공개 원문"))
val controller = open()
val activity = controller.get()
val dialog = ShadowDialog.getLatestDialog()
assertNotNull(dialog)
assertTrue(dialog.isShowing)
assertEquals(
activity.getString(R.string.common_error_unknown),
dialog.findViewById<android.widget.TextView>(R.id.tv_desc).text
)
dialog.findViewById<View>(R.id.tv_confirm).performClick()
assertFalse(dialog.isShowing)
assertEquals(listOf(7L, 7L), api.requests)
assertTrue(ViewModelProvider(activity)[EventDetailViewModel::class.java].state.value is EventDetailUiState.Content)
assertFalse(activity.isFinishing)
close(controller)
}
@Test
fun `오류 modal 닫기는 추가 조회 없이 종료한다`() {
api.next = Single.error(IOException())
val controller = open()
val dialog = ShadowDialog.getLatestDialog()
dialog.findViewById<View>(R.id.tv_cancel).performClick()
assertFalse(dialog.isShowing)
assertTrue(controller.get().isFinishing)
assertEquals(listOf(7L), api.requests)
close(controller)
}
@Test
fun `로딩 중 재생성은 이전 dialog를 닫고 같은 ViewModel 요청을 유지한다`() {
val pending = SingleSubject.create<ApiResponse<EventDetailResponse>>()
api.next = pending
val controller = open()
val previous = controller.get()
val viewModel = ViewModelProvider(previous)[EventDetailViewModel::class.java]
val oldDialog = ShadowDialog.getLatestDialog()
assertTrue(oldDialog.isShowing)
val recreated = controller.recreate().get()
assertFalse(oldDialog.isShowing)
assertSame(viewModel, ViewModelProvider(recreated)[EventDetailViewModel::class.java])
assertEquals(listOf(7L), api.requests)
val newDialog = ShadowDialog.getLatestDialog()
assertTrue(newDialog.isShowing)
pending.onSuccess(ApiResponse(true, api.detail(7L), null))
assertFalse(newDialog.isShowing)
assertFalse(recreated.isFinishing)
assertNull(shadowOf(recreated).nextStartedActivity)
close(controller)
}
@Test
fun `성공 후 재생성은 재조회나 자동 이동 없이 뒤로가기를 연결한다`() {
val controller = open()
val activity = controller.recreate().get()
assertEquals(listOf(7L), api.requests)
assertNull(shadowOf(activity).nextStartedActivity)
activity.binding.toolbar.tvBack.performClick()
assertTrue(activity.isFinishing)
close(controller)
}
@Test
fun `오류 재생성은 이전 modal을 닫고 재조회 없이 새 modal의 재시도를 연결한다`() {
api.next = Single.error(IOException())
val controller = open()
val oldDialog = ShadowDialog.getLatestDialog()
controller.recreate()
assertFalse(oldDialog.isShowing)
assertEquals(listOf(7L), api.requests)
val newDialog = ShadowDialog.getLatestDialog()
assertTrue(newDialog.isShowing)
newDialog.findViewById<View>(R.id.tv_confirm).performClick()
assertEquals(listOf(7L, 7L), api.requests)
assertFalse(newDialog.isShowing)
close(controller)
}
@Test
fun `종료 시 로딩과 오류 dialog를 정리하고 늦은 응답은 실행하지 않는다`() {
val pending = SingleSubject.create<ApiResponse<EventDetailResponse>>()
api.next = pending
val loading = open()
val activity = loading.get()
val dialog = ShadowDialog.getLatestDialog()
assertTrue(pending.hasObservers())
close(loading)
assertFalse(dialog.isShowing)
assertFalse(pending.hasObservers())
pending.onSuccess(ApiResponse(true, api.detail(7L), null))
assertNull(shadowOf(activity).nextStartedActivity)
api.next = Single.error(IOException())
val error = open()
val errorDialog = ShadowDialog.getLatestDialog()
assertTrue(errorDialog.isShowing)
close(error)
assertFalse(errorDialog.isShowing)
}
@Test
fun `신규 상세는 외부 공개와 딥링크 등록 없이 manifest에 연결된다`() {
val intent = EventDetailActivity.newIntent(context, 7L)
val info = context.packageManager.getActivityInfo(intent.component!!, 0)
assertFalse(info.exported)
assertEquals(EventDetailActivity::class.java.name, info.name)
}
private fun open(intent: Intent = EventDetailActivity.newIntent(context, 7L)) =
Robolectric.buildActivity(EventDetailActivity::class.java, intent).setup()
private fun close(controller: ActivityController<EventDetailActivity>) {
controller.pause().stop().destroy()
}
private class NavigationFakeApi : EventDetailApi {
val requests = mutableListOf<Long>()
var next: Single<ApiResponse<EventDetailResponse>>? = null
override fun getEventDetail(id: Long, authHeader: String?): Single<ApiResponse<EventDetailResponse>> {
requests += id
return next.also { next = null } ?: Single.just(ApiResponse(true, detail(id), null))
}
fun detail(id: Long) = EventDetailResponse(id, "server-thumbnail", null, null, "https://server.example/join")
}
}