fix(creator): 채널의 기본 프로필 이미지를 제거한다
This commit is contained in:
+2
-1
@@ -2192,7 +2192,8 @@ class CreatorChannelActivitySourceTest {
|
||||
assertTrue(adapter.contains("fanTalkContent?.text = fanTalk.content"))
|
||||
assertTrue(adapter.contains("fanTalkProfile?.loadUrl(fanTalk.profileImageUrl)"))
|
||||
assertTrue(adapter.contains("fanTalkContent?.text = \"\""))
|
||||
assertTrue(adapter.contains("fanTalkProfile?.setImageResource(R.drawable.ic_placeholder_profile)"))
|
||||
assertTrue(adapter.contains("fanTalkProfile?.dispose()"))
|
||||
assertTrue(adapter.contains("fanTalkProfile?.setImageDrawable(null)"))
|
||||
assertFalse(adapter.contains("private fun addCommentCard"))
|
||||
assertFalse(adapter.contains("addCommentCard("))
|
||||
}
|
||||
|
||||
+3
-1
@@ -156,7 +156,9 @@ class CreatorChannelFanTalkFragmentLayoutTest {
|
||||
assertTrue(adapter.contains("fun submitItems(items: List<CreatorChannelFanTalkUiModel>)"))
|
||||
assertTrue(adapter.contains("notifyDataSetChanged()"))
|
||||
assertTrue(adapter.contains("CircleCropTransformation()"))
|
||||
assertTrue(adapter.contains("R.drawable.ic_placeholder_profile"))
|
||||
assertTrue(adapter.contains("loadUrl(url)"))
|
||||
assertFalse(adapter.contains("placeholder("))
|
||||
assertFalse(adapter.contains("error(R.drawable"))
|
||||
assertTrue(adapter.contains("CreatorChannelFanTalkRightAction.Report"))
|
||||
assertTrue(adapter.contains("CreatorChannelFanTalkRightAction.OwnerMore"))
|
||||
assertTrue(adapter.contains("private val onItemClick: (CreatorChannelFanTalkUiModel) -> Unit"))
|
||||
|
||||
@@ -0,0 +1,164 @@
|
||||
package kr.co.vividnext.sodalive.v2.gift.ui
|
||||
|
||||
import android.app.Activity
|
||||
import android.app.Application
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.net.Uri
|
||||
import android.os.Looper
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import coil.Coil
|
||||
import coil.EventListener
|
||||
import coil.ImageLoader
|
||||
import coil.decode.DataSource
|
||||
import coil.fetch.DrawableResult
|
||||
import coil.fetch.Fetcher
|
||||
import coil.load
|
||||
import coil.request.ImageRequest
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.common.ToastMessage
|
||||
import kr.co.vividnext.sodalive.databinding.ItemGiftInboxReceivedBinding
|
||||
import kr.co.vividnext.sodalive.databinding.ItemGiftInboxSentBinding
|
||||
import kr.co.vividnext.sodalive.v2.gift.GiftInboxCardUiModel
|
||||
import kr.co.vividnext.sodalive.v2.gift.GiftInboxDirection
|
||||
import kr.co.vividnext.sodalive.v2.gift.GiftInboxRow
|
||||
import org.junit.After
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertNull
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Before
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.Robolectric
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.Shadows.shadowOf
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], application = Application::class)
|
||||
class GiftInboxAdapterTest {
|
||||
private lateinit var activity: Activity
|
||||
private lateinit var loader: ImageLoader
|
||||
private val requests = mutableListOf<ImageRequest>()
|
||||
private val delayedFetch = CompletableDeferred<Unit>()
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
activity = Robolectric.buildActivity(Activity::class.java).setup().visible().get()
|
||||
loader = ImageLoader.Builder(activity)
|
||||
.dispatcher(Dispatchers.Unconfined)
|
||||
.components {
|
||||
add(
|
||||
Fetcher.Factory<Uri> { data, _, _ ->
|
||||
if (data.scheme != "https") {
|
||||
null
|
||||
} else {
|
||||
Fetcher {
|
||||
if (data.lastPathSegment == "delayed") delayedFetch.await()
|
||||
DrawableResult(ColorDrawable(Color.GREEN), false, DataSource.NETWORK)
|
||||
}
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
.eventListenerFactory {
|
||||
object : EventListener {
|
||||
override fun onStart(request: ImageRequest) {
|
||||
requests += request
|
||||
}
|
||||
}
|
||||
}
|
||||
.build()
|
||||
Coil.setImageLoader(loader)
|
||||
}
|
||||
|
||||
@After
|
||||
fun tearDown() {
|
||||
activity.finish()
|
||||
Coil.reset()
|
||||
loader.shutdown()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `보낸 선물은 실제 URL 이미지만 요청하고 표시한다`() = verifyUrl(GiftInboxDirection.SENT)
|
||||
|
||||
@Test
|
||||
fun `받은 선물은 실제 URL 이미지만 요청하고 표시한다`() = verifyUrl(GiftInboxDirection.RECEIVED)
|
||||
|
||||
@Test
|
||||
fun `보낸 선물의 빈 source는 재사용 요청과 그림을 비운다`() = verifyEmptySource(GiftInboxDirection.SENT)
|
||||
|
||||
@Test
|
||||
fun `받은 선물의 빈 source는 재사용 요청과 그림을 비운다`() = verifyEmptySource(GiftInboxDirection.RECEIVED)
|
||||
|
||||
private fun verifyUrl(direction: GiftInboxDirection) {
|
||||
val (adapter, holder, image) = holder(direction)
|
||||
bind(adapter, holder, direction, "https://example.com/profile")
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
|
||||
val request = requests.single()
|
||||
assertEquals("https://example.com/profile", request.data)
|
||||
assertNull(request.placeholder)
|
||||
assertNull(request.error)
|
||||
assertNull(request.fallback)
|
||||
assertNotNull(image.drawable)
|
||||
}
|
||||
|
||||
private fun verifyEmptySource(direction: GiftInboxDirection) {
|
||||
val (adapter, holder, image) = holder(direction)
|
||||
listOf(null, "", " ").forEach { source ->
|
||||
val previous = image.load("https://example.com/delayed", loader)
|
||||
image.setImageDrawable(ColorDrawable(Color.RED))
|
||||
requests.clear()
|
||||
|
||||
bind(adapter, holder, direction, source)
|
||||
|
||||
assertTrue(previous.isDisposed)
|
||||
assertNull(image.drawable)
|
||||
assertTrue(requests.isEmpty())
|
||||
}
|
||||
delayedFetch.complete(Unit)
|
||||
shadowOf(Looper.getMainLooper()).idle()
|
||||
assertNull(image.drawable)
|
||||
}
|
||||
|
||||
private fun holder(direction: GiftInboxDirection): Triple<GiftInboxAdapter, GiftInboxAdapter.Holder, ImageView> {
|
||||
val adapter = GiftInboxAdapter({}, {}, {})
|
||||
adapter.submitList(listOf(GiftInboxRow.Card(card(direction, null))))
|
||||
val holder = adapter.onCreateViewHolder(FrameLayout(activity), adapter.getItemViewType(0))
|
||||
val image = when (val binding = holder.binding) {
|
||||
is ItemGiftInboxSentBinding -> binding.counterpartProfileImage
|
||||
is ItemGiftInboxReceivedBinding -> binding.counterpartProfileImage
|
||||
else -> error("선물 카드 바인딩 필요")
|
||||
}
|
||||
activity.setContentView(holder.itemView)
|
||||
image.layout(0, 0, 64, 64)
|
||||
return Triple(adapter, holder, image)
|
||||
}
|
||||
|
||||
private fun bind(adapter: GiftInboxAdapter, holder: GiftInboxAdapter.Holder, direction: GiftInboxDirection, source: String?) {
|
||||
adapter.submitList(null)
|
||||
adapter.submitList(listOf(GiftInboxRow.Card(card(direction, source))))
|
||||
adapter.onBindViewHolder(holder, 0)
|
||||
}
|
||||
|
||||
private fun card(direction: GiftInboxDirection, source: String?) = GiftInboxCardUiModel(
|
||||
applicationNo = "gift-1",
|
||||
direction = direction,
|
||||
status = ToastMessage(message = "신청"),
|
||||
subtitleRes = null,
|
||||
createdDate = "2026.10.28",
|
||||
dateLabelRes = R.string.gift_inbox_applied_date,
|
||||
sizeName = "small",
|
||||
categoryName = "gift",
|
||||
addressRequired = false,
|
||||
addressDeadlineDays = null,
|
||||
counterpartMemberId = 1L,
|
||||
counterpartNickname = "creator",
|
||||
counterpartProfileImageUrl = source
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user