fix(home): 팔로잉 탭 후속 검증을 반영한다
This commit is contained in:
+42
@@ -0,0 +1,42 @@
|
||||
package kr.co.vividnext.sodalive.v2.main.home
|
||||
|
||||
import android.app.Application
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.widget.ImageView
|
||||
import coil.load
|
||||
import kr.co.vividnext.sodalive.common.ImageLoaderProvider
|
||||
import kr.co.vividnext.sodalive.v2.main.home.ui.loadHomeCreatorProfileImage
|
||||
import org.junit.Assert.assertFalse
|
||||
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.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], application = Application::class)
|
||||
class HomeCreatorProfileImageLoaderTest {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
if (!ImageLoaderProvider.isInitialized) {
|
||||
ImageLoaderProvider.init(RuntimeEnvironment.getApplication())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `blank 프로필 이미지는 이전 Coil 요청을 해제하고 drawable을 비운다`() {
|
||||
val imageView = ImageView(RuntimeEnvironment.getApplication())
|
||||
val disposable = imageView.load(ColorDrawable(Color.RED), ImageLoaderProvider.imageLoader)
|
||||
assertFalse(disposable.isDisposed)
|
||||
|
||||
imageView.loadHomeCreatorProfileImage(" ")
|
||||
|
||||
assertTrue(disposable.isDisposed)
|
||||
assertNull(imageView.drawable)
|
||||
}
|
||||
}
|
||||
+49
-47
@@ -8,7 +8,7 @@ import java.io.File
|
||||
class HomeFollowingFragmentSourceTest {
|
||||
|
||||
@Test
|
||||
fun `home layout exposes following content and section recycler ids`() {
|
||||
fun `홈 layout은 팔로잉 content와 section recycler id를 노출한다`() {
|
||||
val layout = homeMainLayoutSource()
|
||||
|
||||
assertTrue(layout.contains("@+id/nsv_home_following_content"))
|
||||
@@ -20,7 +20,7 @@ class HomeFollowingFragmentSourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `home main fragment injects following viewmodel and wires adapters`() {
|
||||
fun `홈 main fragment는 팔로잉 viewmodel과 adapter를 연결한다`() {
|
||||
val source = homeMainFragmentSource()
|
||||
|
||||
assertTrue(source.contains("HomeFollowingViewModel"))
|
||||
@@ -38,7 +38,7 @@ class HomeFollowingFragmentSourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `following tab branch shows following content and hides other home surfaces`() {
|
||||
fun `팔로잉 탭 분기는 팔로잉 content만 표시한다`() {
|
||||
val source = homeMainFragmentSource()
|
||||
val branch = source.substringAfter("private fun showHomeTab(index: Int)")
|
||||
.substringAfter("HOME_TAB_FOLLOWING ->")
|
||||
@@ -50,7 +50,7 @@ class HomeFollowingFragmentSourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `following tab loads following content only once`() {
|
||||
fun `팔로잉 탭은 팔로잉 content를 최초 한 번만 로드한다`() {
|
||||
val source = homeMainFragmentSource()
|
||||
|
||||
assertTrue(source.contains("private var hasLoadedFollowing = false"))
|
||||
@@ -60,7 +60,7 @@ class HomeFollowingFragmentSourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `following section chevrons call callback without starting activity`() {
|
||||
fun `팔로잉 section chevron은 이동 없이 callback만 호출한다`() {
|
||||
val source = homeMainFragmentSource()
|
||||
val callback = source.substringAfter("private fun onFollowingSectionMoreClick")
|
||||
.substringBefore("\n private fun")
|
||||
@@ -77,7 +77,7 @@ class HomeFollowingFragmentSourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `following state binding clears or binds each following section`() {
|
||||
fun `팔로잉 상태 binding은 section을 비우거나 바인딩한다`() {
|
||||
val source = homeMainFragmentSource()
|
||||
|
||||
assertTrue(source.contains("followingStateLiveData.observe(viewLifecycleOwner)"))
|
||||
@@ -85,7 +85,10 @@ class HomeFollowingFragmentSourceTest {
|
||||
assertTrue(source.contains("bindHomeFollowingContent(state)"))
|
||||
assertTrue(source.contains("HomeFollowingUiState.Empty ->"))
|
||||
assertTrue(source.contains("bindHomeFollowingEmpty(showEmptyMessage = true)"))
|
||||
assertTrue(source.contains("HomeFollowingUiState.LoginRequired -> bindHomeFollowingEmpty(showEmptyMessage = false)"))
|
||||
val loginRequiredSource = source.substringAfter("HomeFollowingUiState.LoginRequired ->")
|
||||
.substringBefore("is HomeFollowingUiState.Error ->")
|
||||
assertTrue(loginRequiredSource.contains("bindHomeFollowingEmpty(showEmptyMessage = false)"))
|
||||
assertTrue(loginRequiredSource.contains("finishHomePullRefresh(HOME_TAB_FOLLOWING)"))
|
||||
assertTrue(source.contains("is HomeFollowingUiState.Error ->"))
|
||||
assertTrue(source.contains("if (shouldPreserveHomeContentOnPullRefreshError(HOME_TAB_FOLLOWING)) return@observe"))
|
||||
assertTrue(source.contains("bindHomeFollowingEmpty(showEmptyMessage = false)"))
|
||||
@@ -102,7 +105,7 @@ class HomeFollowingFragmentSourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `following empty state shows centered reusable empty string only for all empty content`() {
|
||||
fun `팔로잉 empty 상태는 다국어 빈 문구와 상태 분기를 유지한다`() {
|
||||
val layout = homeMainLayoutSource()
|
||||
val emptyText = layout.substringAfter("@+id/tv_home_following_empty")
|
||||
.substringBefore("@+id/ll_home_following_creators_section")
|
||||
@@ -112,12 +115,7 @@ class HomeFollowingFragmentSourceTest {
|
||||
val stringsJa = projectFile("app/src/main/res/values-ja/strings.xml").readText()
|
||||
|
||||
assertTrue(layout.contains("@+id/tv_home_following_empty"))
|
||||
assertTrue(emptyText.contains("android:layout_width=\"match_parent\""))
|
||||
assertTrue(emptyText.contains("android:layout_height=\"match_parent\""))
|
||||
assertTrue(emptyText.contains("android:gravity=\"center\""))
|
||||
assertTrue(emptyText.contains("android:textAlignment=\"center\""))
|
||||
assertTrue(emptyText.contains("android:text=\"@string/screen_home_following_empty\""))
|
||||
assertTrue(emptyText.contains("android:visibility=\"gone\""))
|
||||
|
||||
assertTrue(
|
||||
strings.contains(
|
||||
@@ -138,8 +136,6 @@ class HomeFollowingFragmentSourceTest {
|
||||
)
|
||||
)
|
||||
|
||||
assertTrue(source.contains("binding.tvHomeFollowingEmpty.visibility = View.GONE"))
|
||||
assertTrue(source.contains("binding.tvHomeFollowingEmpty.visibility = if (showEmptyMessage) View.VISIBLE else View.GONE"))
|
||||
assertTrue(source.contains("HomeFollowingUiState.Empty ->"))
|
||||
assertTrue(source.contains("bindHomeFollowingEmpty(showEmptyMessage = true)"))
|
||||
assertTrue(source.contains("is HomeFollowingUiState.Error ->"))
|
||||
@@ -147,7 +143,7 @@ class HomeFollowingFragmentSourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `following adapters bind figma required item fields`() {
|
||||
fun `팔로잉 adapter는 필수 item field를 바인딩한다`() {
|
||||
val liveAdapter = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowingLiveAdapter.kt"
|
||||
).readText()
|
||||
@@ -183,7 +179,7 @@ class HomeFollowingFragmentSourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `following recent news hides chevron and reuses feed widgets by item type`() {
|
||||
fun `팔로잉 최근 소식은 chevron을 숨기고 feed widget을 재사용한다`() {
|
||||
val layout = homeMainLayoutSource()
|
||||
val recentNewsSection = layout.substringAfter("@+id/ll_home_following_recent_news_section")
|
||||
.substringBefore("</LinearLayout>")
|
||||
@@ -215,10 +211,13 @@ class HomeFollowingFragmentSourceTest {
|
||||
assertTrue(adapter.contains("FeedItem.Content"))
|
||||
assertFalse(adapter.contains("R.layout.item_home_following_news_content"))
|
||||
assertFalse(adapter.contains("R.layout.item_home_following_news_rank"))
|
||||
assertTrue(recentNewsSection.contains("tools:listitem=\"@layout/view_feed_content\""))
|
||||
assertTrue(projectFileOrNull("app/src/main/res/layout/item_home_following_news_content.xml") == null)
|
||||
assertTrue(projectFileOrNull("app/src/main/res/layout/item_home_following_news_rank.xml") == null)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `following ranking news builds sentence message and highlights rank text`() {
|
||||
fun `팔로잉 ranking 소식은 문장 message와 순위 강조를 만든다`() {
|
||||
val adapter = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowingNewsAdapter.kt"
|
||||
).readText()
|
||||
@@ -229,14 +228,15 @@ class HomeFollowingFragmentSourceTest {
|
||||
assertTrue(adapter.contains("context.getString("))
|
||||
assertTrue(adapter.contains("highlightRanges = listOf("))
|
||||
assertTrue(adapter.contains("FeedRankHighlight("))
|
||||
assertTrue(adapter.contains("start = message.indexOf(rankText)"))
|
||||
assertTrue(adapter.contains("endExclusive = message.indexOf(rankText) + rankText.length"))
|
||||
assertTrue(adapter.contains("start = message.lastIndexOf(rankText)"))
|
||||
assertTrue(adapter.contains("endExclusive = message.lastIndexOf(rankText) + rankText.length"))
|
||||
assertTrue(adapter.contains("R.string.screen_home_following_ranking_rank_format"))
|
||||
assertFalse(adapter.contains("message = ranking.body.ifBlank { ranking.title }"))
|
||||
assertFalse(adapter.contains("highlightRanges = emptyList()"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `following recent news models use nested payload response contract`() {
|
||||
fun `팔로잉 최근 소식 model은 nested payload 응답 계약을 사용한다`() {
|
||||
val models = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/data/HomeFollowingModels.kt"
|
||||
).readText()
|
||||
@@ -266,7 +266,7 @@ class HomeFollowingFragmentSourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `following recent news adapter binds nested payload ui variants`() {
|
||||
fun `팔로잉 최근 소식 adapter는 nested payload UI variant를 바인딩한다`() {
|
||||
val adapter = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowingNewsAdapter.kt"
|
||||
).readText()
|
||||
@@ -289,20 +289,34 @@ class HomeFollowingFragmentSourceTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `following creators section has no header and uses figma simple profile size`() {
|
||||
fun `팔로잉 최근 소식 feed model은 미제공 creator id를 합성하지 않는다`() {
|
||||
val adapter = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowingNewsAdapter.kt"
|
||||
).readText()
|
||||
|
||||
assertFalse(adapter.contains("creatorId = community.targetId.toString()"))
|
||||
assertFalse(adapter.contains("creatorId = content.targetId.toString()"))
|
||||
assertTrue(adapter.contains("creatorId = \"\""))
|
||||
assertTrue(adapter.contains("postId = community.postId.toString()"))
|
||||
assertTrue(adapter.contains("contentId = content.contentId.toString()"))
|
||||
assertTrue(adapter.contains("view.setOnFeedClick { onClickItem(community) }"))
|
||||
assertTrue(adapter.contains("view.setOnFeedClick { onClickItem(content) }"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `팔로잉 크리에이터 섹션은 header 없이 item layout을 사용한다`() {
|
||||
val layout = homeMainLayoutSource()
|
||||
val section = layout.substringAfter("@+id/ll_home_following_creators_section")
|
||||
.substringBefore("@+id/ll_home_following_on_air_section")
|
||||
val itemLayout = projectFile("app/src/main/res/layout/item_home_following_creator.xml").readText()
|
||||
|
||||
assertFalse(section.contains("view_home_following_creators_title"))
|
||||
assertTrue(itemLayout.contains("android:layout_width=\"75dp\""))
|
||||
assertTrue(itemLayout.contains("android:layout_height=\"75dp\""))
|
||||
assertTrue(itemLayout.contains("@style/Typography.Body5"))
|
||||
assertTrue(itemLayout.contains("@+id/iv_home_following_creator_profile"))
|
||||
assertTrue(itemLayout.contains("@+id/tv_home_following_creator_nickname"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `following creators list appends all button as last item`() {
|
||||
fun `팔로잉 크리에이터 목록은 전체 item을 마지막에 추가하고 이동을 연결한다`() {
|
||||
val adapter = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowingCreatorAdapter.kt"
|
||||
).readText()
|
||||
@@ -324,48 +338,36 @@ class HomeFollowingFragmentSourceTest {
|
||||
assertTrue(fragment.contains("onClickAll = { openFollowingCreatorAll() }"))
|
||||
assertTrue(fragment.contains("private fun openFollowingCreatorAll()"))
|
||||
assertTrue(fragment.contains("startActivity(Intent(requireContext(), FollowingCreatorActivity::class.java))"))
|
||||
assertTrue(allLayout.contains("android:layout_width=\"wrap_content\""))
|
||||
assertTrue(allLayout.contains("android:layout_height=\"wrap_content\""))
|
||||
assertTrue(allLayout.contains("android:layout_height=\"75dp\""))
|
||||
assertTrue(allLayout.contains("android:paddingHorizontal=\"16dp\""))
|
||||
assertTrue(allLayout.contains("android:textColor=\"@color/soda_400\""))
|
||||
assertTrue(allLayout.contains("android:visibility=\"invisible\""))
|
||||
assertTrue(allLayout.contains("@string/screen_home_theme_all"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `following recent chats section is horizontal box list`() {
|
||||
fun `팔로잉 최근 대화 섹션은 RecyclerView와 adapter를 연결한다`() {
|
||||
val layout = homeMainLayoutSource()
|
||||
val section = layout.substringAfter("@+id/rv_home_following_recent_chats")
|
||||
.substringBefore("@+id/ll_home_following_monthly_schedules_section")
|
||||
val fragment = homeMainFragmentSource()
|
||||
|
||||
assertTrue(section.contains("android:orientation=\"horizontal\""))
|
||||
assertTrue(layout.contains("@+id/rv_home_following_recent_chats"))
|
||||
assertTrue(fragment.contains("rvHomeFollowingRecentChats.apply"))
|
||||
assertTrue(fragment.contains("LinearLayoutManager.HORIZONTAL"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `following recent chat item matches figma box fields`() {
|
||||
fun `팔로잉 최근 대화 item은 필수 field와 클릭 계약을 바인딩한다`() {
|
||||
val adapter = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/ui/HomeFollowingChatAdapter.kt"
|
||||
).readText()
|
||||
val itemLayout = projectFile("app/src/main/res/layout/item_home_following_chat.xml").readText()
|
||||
|
||||
assertTrue(itemLayout.contains("android:layout_width=\"284dp\""))
|
||||
assertTrue(itemLayout.contains("android:layout_width=\"62dp\""))
|
||||
assertTrue(itemLayout.contains("android:layout_height=\"62dp\""))
|
||||
assertTrue(itemLayout.contains("@+id/iv_home_following_chat_creator_profile"))
|
||||
assertTrue(itemLayout.contains("@+id/tv_home_following_chat_creator_nickname"))
|
||||
assertTrue(itemLayout.contains("@+id/tv_home_following_chat_message"))
|
||||
assertTrue(itemLayout.contains("@+id/tv_home_following_chat_time"))
|
||||
assertTrue(itemLayout.contains("@+id/tv_home_following_chat_direct_badge"))
|
||||
assertTrue(itemLayout.contains("@drawable/bg_chat_direct_badge"))
|
||||
assertTrue(itemLayout.contains("@string/screen_chat_direct_badge"))
|
||||
val messageText = itemLayout.substringAfter("@+id/tv_home_following_chat_message")
|
||||
.substringBefore("@+id/tv_home_following_chat_creator_nickname")
|
||||
assertTrue(messageText.contains("android:maxLines=\"1\""))
|
||||
assertTrue(messageText.contains("android:ellipsize=\"end\""))
|
||||
assertFalse(adapter.contains("ViewGroup.LayoutParams.MATCH_PARENT"))
|
||||
assertTrue(adapter.contains("recyclerItemLayoutParams(parent)"))
|
||||
assertTrue(adapter.contains("directBadgeText.visibility = if (item.showDirectBadge)"))
|
||||
assertTrue(adapter.contains("formatChatRoomLastMessageTime(itemView.context, item.lastMessageAt)"))
|
||||
assertTrue(adapter.contains("itemView.setOnClickListener { onClickItem(item) }"))
|
||||
}
|
||||
|
||||
private fun homeMainFragmentSource(): String {
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package kr.co.vividnext.sodalive.v2.main.home
|
||||
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.common.UtcRelativeTimeTextFormatter
|
||||
import kr.co.vividnext.sodalive.v2.common.CreatorActivityType
|
||||
import kr.co.vividnext.sodalive.v2.main.chat.data.ChatRoomListItemResponse
|
||||
@@ -75,16 +74,6 @@ class HomeFollowingMapperTest {
|
||||
assertEquals(listOf("second", "first"), state.monthlySchedules.items.map { it.scheduleId })
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `PHOTO_CONTENT는 photo content label로 매핑된다`() {
|
||||
val state = response(
|
||||
recentNews = listOf(photoContentNews())
|
||||
).toUiState(formatter) as HomeFollowingUiState.Content
|
||||
val item = state.recentNews.items.single() as HomeFollowingNewsUiItem.Content
|
||||
|
||||
assertEquals(R.string.screen_home_following_photo_content, item.labelResId)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `recentNews nested payload는 type별 UI item으로 매핑된다`() {
|
||||
val state = response(
|
||||
@@ -121,7 +110,6 @@ class HomeFollowingMapperTest {
|
||||
val photoContent = state.recentNews.items[3] as HomeFollowingNewsUiItem.Content
|
||||
assertEquals(FollowingNewsType.PHOTO_CONTENT, photoContent.type)
|
||||
assertEquals(3002L, photoContent.contentId)
|
||||
assertEquals(R.string.screen_home_following_photo_content, photoContent.labelResId)
|
||||
|
||||
val community = state.recentNews.items[4] as HomeFollowingNewsUiItem.Community
|
||||
assertEquals(4001L, community.postId)
|
||||
|
||||
+138
@@ -0,0 +1,138 @@
|
||||
package kr.co.vividnext.sodalive.v2.main.home
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.res.Configuration
|
||||
import android.graphics.Color
|
||||
import android.graphics.drawable.ColorDrawable
|
||||
import android.view.ViewGroup
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import coil.load
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.common.ImageLoaderProvider
|
||||
import kr.co.vividnext.sodalive.v2.main.home.data.FollowingNewsType
|
||||
import kr.co.vividnext.sodalive.v2.main.home.model.HomeFollowingNewsUiItem
|
||||
import kr.co.vividnext.sodalive.v2.main.home.ui.HomeFollowingNewsAdapter
|
||||
import kr.co.vividnext.sodalive.v2.main.home.ui.buildHomeFollowingRankingFeedItem
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
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.RobolectricTestRunner
|
||||
import org.robolectric.RuntimeEnvironment
|
||||
import org.robolectric.annotation.Config
|
||||
import java.util.Locale
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], application = Application::class)
|
||||
class HomeFollowingNewsAdapterTest {
|
||||
|
||||
@Before
|
||||
fun setUp() {
|
||||
if (!ImageLoaderProvider.isInitialized) {
|
||||
ImageLoaderProvider.init(RuntimeEnvironment.getApplication())
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ranking 문장은 locale별 순위 단위를 사용하고 같은 문자열을 강조한다`() {
|
||||
assertRankingText(locale = Locale.KOREAN, expectedRankText = "7위")
|
||||
assertRankingText(locale = Locale.ENGLISH, expectedRankText = "No. 7")
|
||||
assertRankingText(locale = Locale.JAPANESE, expectedRankText = "7位")
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `ranking 제목에 같은 순위 문자열이 있어도 삽입된 순위 문자열을 강조한다`() {
|
||||
val feedItem = buildHomeFollowingRankingFeedItem(
|
||||
localizedContext(Locale.KOREAN),
|
||||
ranking(creatorNickname = "7위 크리에이터")
|
||||
)
|
||||
|
||||
val highlight = feedItem.highlightRanges.single()
|
||||
assertEquals(feedItem.message.lastIndexOf("7위"), highlight.start)
|
||||
assertEquals("7위", feedItem.message.substring(highlight.start, highlight.endExclusive))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `nullable content 이미지는 재사용된 ImageView의 이전 Coil 요청을 해제한다`() {
|
||||
val adapter = HomeFollowingNewsAdapter()
|
||||
adapter.submitItems(listOf(content(contentImageUrl = null)))
|
||||
val parent = FrameLayout(RuntimeEnvironment.getApplication()).apply {
|
||||
layoutParams = ViewGroup.LayoutParams(360, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
}
|
||||
val holder = adapter.onCreateViewHolder(parent, adapter.getItemViewType(0))
|
||||
val imageView = holder.itemView.findViewById<ImageView>(R.id.iv_feed_content_image)
|
||||
val disposable = imageView.load(ColorDrawable(Color.BLUE), ImageLoaderProvider.imageLoader)
|
||||
assertFalse(disposable.isDisposed)
|
||||
|
||||
adapter.onBindViewHolder(holder, 0)
|
||||
|
||||
assertTrue(disposable.isDisposed)
|
||||
assertNull(imageView.drawable)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `PHOTO_CONTENT는 Feed photo category label로 표시된다`() {
|
||||
val adapter = HomeFollowingNewsAdapter()
|
||||
adapter.submitItems(listOf(content(type = FollowingNewsType.PHOTO_CONTENT)))
|
||||
val parent = FrameLayout(RuntimeEnvironment.getApplication()).apply {
|
||||
layoutParams = ViewGroup.LayoutParams(360, ViewGroup.LayoutParams.WRAP_CONTENT)
|
||||
}
|
||||
val holder = adapter.onCreateViewHolder(parent, adapter.getItemViewType(0))
|
||||
|
||||
adapter.onBindViewHolder(holder, 0)
|
||||
|
||||
val categoryText = holder.itemView.findViewById<TextView>(R.id.tv_feed_content_category)
|
||||
assertEquals(parent.context.getString(R.string.screen_home_following_photo_content), categoryText.text.toString())
|
||||
}
|
||||
|
||||
private fun assertRankingText(locale: Locale, expectedRankText: String) {
|
||||
val feedItem = buildHomeFollowingRankingFeedItem(localizedContext(locale), ranking())
|
||||
|
||||
assertEquals("7", feedItem.rankText)
|
||||
assertFalse(feedItem.message.contains("7위") && expectedRankText != "7위")
|
||||
val highlight = feedItem.highlightRanges.single()
|
||||
assertEquals(expectedRankText, feedItem.message.substring(highlight.start, highlight.endExclusive))
|
||||
}
|
||||
|
||||
private fun localizedContext(locale: Locale): Context {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
val configuration = Configuration(context.resources.configuration)
|
||||
configuration.setLocale(locale)
|
||||
return context.createConfigurationContext(configuration)
|
||||
}
|
||||
|
||||
private fun ranking(creatorNickname: String = "creator") = HomeFollowingNewsUiItem.Ranking(
|
||||
newsId = "news-1",
|
||||
type = FollowingNewsType.CREATOR_RANKING,
|
||||
targetId = 1L,
|
||||
visibleFromAtUtc = "2026-07-30T00:00:00Z",
|
||||
visibleFromText = "1분 전",
|
||||
rank = 7,
|
||||
imageUrl = "https://example.com/rank.png",
|
||||
title = "ranking title",
|
||||
creatorNickname = creatorNickname
|
||||
)
|
||||
|
||||
private fun content(
|
||||
contentImageUrl: String? = "https://example.com/content.png",
|
||||
type: FollowingNewsType = FollowingNewsType.AUDIO_CONTENT
|
||||
) = HomeFollowingNewsUiItem.Content(
|
||||
newsId = "news-content",
|
||||
type = type,
|
||||
targetId = 10L,
|
||||
visibleFromAtUtc = "2026-07-30T00:00:00Z",
|
||||
visibleFromText = "1분 전",
|
||||
contentId = 10L,
|
||||
contentImageUrl = contentImageUrl,
|
||||
title = "content title",
|
||||
creatorProfileImageUrl = "https://example.com/profile.png",
|
||||
creatorNickname = "creator"
|
||||
)
|
||||
}
|
||||
@@ -56,10 +56,16 @@ class HomeFollowingViewModelTest {
|
||||
@Test
|
||||
fun `loadFollowing은 loading 후 content 상태를 발행한다`() {
|
||||
api.enqueueSuccess(response(followingCreators = listOf(creator())))
|
||||
val states = mutableListOf<HomeFollowingUiState>()
|
||||
val observer = Observer<HomeFollowingUiState> { states.add(it) }
|
||||
|
||||
viewModel.followingStateLiveData.observeForever(observer)
|
||||
viewModel.loadFollowing()
|
||||
viewModel.followingStateLiveData.removeObserver(observer)
|
||||
|
||||
val state = viewModel.followingStateLiveData.requireValue() as HomeFollowingUiState.Content
|
||||
assertTrue(states.first() is HomeFollowingUiState.Loading)
|
||||
assertTrue(states.last() is HomeFollowingUiState.Content)
|
||||
assertEquals(1L, state.followingCreators.items.single().creatorId)
|
||||
assertFalse(viewModel.isLoading.requireValue() ?: true)
|
||||
}
|
||||
|
||||
+59
-3
@@ -57,11 +57,11 @@ class HomeMainFragmentLoginGuardSourceTest {
|
||||
).readText()
|
||||
|
||||
val clickSource = source.substringFrom("private fun onFollowingNewsClick(item: HomeFollowingNewsUiItem)")
|
||||
assertTrue(clickSource.contains("val community = item as? HomeFollowingNewsUiItem.Community ?: return"))
|
||||
assertTrue(clickSource.contains("val postId = community.postId"))
|
||||
assertTrue(clickSource.contains("is HomeFollowingNewsUiItem.Community -> {"))
|
||||
assertTrue(clickSource.contains("val postId = item.postId"))
|
||||
assertBefore(
|
||||
clickSource,
|
||||
"val community = item as? HomeFollowingNewsUiItem.Community ?: return",
|
||||
"is HomeFollowingNewsUiItem.Community -> {",
|
||||
"handleCommunityAction"
|
||||
)
|
||||
assertBefore(
|
||||
@@ -75,6 +75,34 @@ class HomeMainFragmentLoginGuardSourceTest {
|
||||
assertFalse(clickSource.contains("EXTRA_COMMUNITY_POST_ID"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `HomeMainFragment 팔로잉 최근 소식 CREATOR_RANKING은 크리에이터 채널로 이동한다`() {
|
||||
val source = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragment.kt"
|
||||
).readText()
|
||||
|
||||
val clickSource = source.substringFrom("private fun onFollowingNewsClick(item: HomeFollowingNewsUiItem)")
|
||||
assertTrue(clickSource.contains("is HomeFollowingNewsUiItem.Ranking ->"))
|
||||
assertTrue(clickSource.contains("item.type == FollowingNewsType.CREATOR_RANKING"))
|
||||
assertTrue(clickSource.contains("handleCreatorAction(CreatorActionCommand.Profile(item.targetId))"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `HomeMainFragment 팔로잉 최근 소식 AUDIO_CONTENT는 오디오 상세로 이동한다`() {
|
||||
val source = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragment.kt"
|
||||
).readText()
|
||||
|
||||
val clickSource = source.substringFrom("private fun onFollowingNewsClick(item: HomeFollowingNewsUiItem)")
|
||||
assertTrue(clickSource.contains("is HomeFollowingNewsUiItem.Content ->"))
|
||||
assertTrue(clickSource.contains("item.type == FollowingNewsType.AUDIO_CONTENT"))
|
||||
assertTrue(
|
||||
clickSource.contains(
|
||||
"handleContentAction(ContentActionCommand.AudioDetail(audioContentId = item.contentId))"
|
||||
)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `HomeMainFragment 팔로잉 탭 선택은 로그인 가드 통과 후 탭을 전환한다`() {
|
||||
val source = projectFile(
|
||||
@@ -125,6 +153,34 @@ class HomeMainFragmentLoginGuardSourceTest {
|
||||
assertTrue(source.contains("private val liveActionCoordinator: LiveActionCoordinator by lazy"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `HomeMainFragment 팔로잉 On Air 아이템은 공통 Live Action으로 입장한다`() {
|
||||
val source = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragment.kt"
|
||||
).readText()
|
||||
|
||||
val clickSource = source.substringFrom("private fun onFollowingLiveClick(item: HomeFollowingLiveUiItem)")
|
||||
assertTrue(clickSource.contains("liveActionCoordinator.enterLiveRoom(item.liveId)"))
|
||||
assertFalse(clickSource.contains("= Unit"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `HomeMainFragment 팔로잉 스케줄은 type별 공통 Action으로 이동한다`() {
|
||||
val source = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragment.kt"
|
||||
).readText()
|
||||
|
||||
val clickSource = source.substringFrom("private fun onFollowingScheduleClick(item: HomeFollowingScheduleUiItem)")
|
||||
assertTrue(clickSource.contains("if (item.targetId <= 0L) return"))
|
||||
assertTrue(clickSource.contains("CreatorActivityType.Live -> liveActionCoordinator.enterLiveRoom(item.targetId)"))
|
||||
assertTrue(clickSource.contains("CreatorActivityType.LiveReplay"))
|
||||
assertTrue(clickSource.contains("CreatorActivityType.Audio -> handleContentAction("))
|
||||
assertTrue(clickSource.contains("ContentActionCommand.AudioDetail(audioContentId = item.targetId)"))
|
||||
assertTrue(clickSource.contains("CreatorActivityType.Community -> handleCommunityAction("))
|
||||
assertTrue(clickSource.contains("CommunityActionCommand.PostDetail(item.targetId)"))
|
||||
assertFalse(clickSource.contains("Intent("))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `HomeMainFragment 최근 활동 LIVE route는 공통 Live와 Creator Action을 사용한다`() {
|
||||
val source = projectFile(
|
||||
|
||||
@@ -42,27 +42,6 @@ class FeedViewTest {
|
||||
assertSame(category.parent, time.parent)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `content layout matches figma compact upload notice dimensions`() {
|
||||
val layout = projectFile("app/src/main/res/layout/view_feed_content.xml").readText()
|
||||
val source = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/widget/feed/FeedContentView.kt"
|
||||
).readText()
|
||||
val imageBlock = layout.substringAfter("@+id/iv_feed_content_image")
|
||||
.substringBefore("@+id/ll_feed_content_info")
|
||||
val infoBlock = layout.substringAfter("@+id/ll_feed_content_info")
|
||||
.substringBefore("</kr.co.vividnext.sodalive.v2.widget.feed.FeedContentView>")
|
||||
val titleBlock = layout.substringAfter("@+id/tv_feed_content_title")
|
||||
.substringBefore("@+id/ll_feed_content_meta")
|
||||
|
||||
assertTrue(layout.contains("android:padding=\"@dimen/spacing_14\""))
|
||||
assertTrue(imageBlock.contains("android:layout_width=\"88dp\""))
|
||||
assertTrue(imageBlock.contains("android:layout_height=\"88dp\""))
|
||||
assertTrue(infoBlock.contains("android:layout_marginStart=\"@dimen/spacing_14\""))
|
||||
assertTrue(titleBlock.contains("android:layout_marginTop=\"@dimen/spacing_6\""))
|
||||
assertTrue(source.contains("const val CONTENT_IMAGE_WIDTH_DP = 88"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `content root clipping is implemented in custom view code`() {
|
||||
val layout = projectFile("app/src/main/res/layout/view_feed_content.xml").readText()
|
||||
|
||||
Reference in New Issue
Block a user