test(home): 홈 추천 섹션 레이아웃 검증을 추가한다
This commit is contained in:
@@ -12,6 +12,7 @@ import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.v2.widget.TextTabBarView
|
||||
import kr.co.vividnext.sodalive.v2.widget.banner.BannerView
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
import org.junit.Assert.assertNotNull
|
||||
@@ -60,7 +61,6 @@ class HomeMainFragmentLayoutTest {
|
||||
)
|
||||
val listIds = listOf(
|
||||
R.id.rv_home_lives,
|
||||
R.id.rv_home_banners,
|
||||
R.id.rv_home_recent_activity_creators,
|
||||
R.id.rv_home_recent_debut_creators,
|
||||
R.id.rv_home_first_audio_contents,
|
||||
@@ -77,9 +77,48 @@ class HomeMainFragmentLayoutTest {
|
||||
assertNotNull(recyclerView)
|
||||
assertEquals(RecyclerView.HORIZONTAL, recyclerView.layoutManager?.canScrollHorizontally()?.toOrientation())
|
||||
}
|
||||
assertNotNull(root.findViewById<BannerView>(R.id.rv_home_banners))
|
||||
assertNotNull(root.findViewById<View>(R.id.ll_home_business_info))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `home phase6 item layouts expose required binding views`() {
|
||||
val recentActivity = inflateView(R.layout.item_home_recent_activity_creator)
|
||||
val recentDebut = inflateView(R.layout.item_home_recent_debut_creator)
|
||||
val creatorProfile = inflateView(R.layout.item_home_creator_profile)
|
||||
val followAllButton = inflateView(R.layout.view_home_follow_all_button)
|
||||
|
||||
assertNotNull(recentActivity.findViewById<ImageView>(R.id.iv_home_recent_activity_creator_profile))
|
||||
assertNotNull(recentActivity.findViewById<TextView>(R.id.tv_home_recent_activity_type))
|
||||
assertNotNull(recentActivity.findViewById<TextView>(R.id.tv_home_recent_activity_title))
|
||||
assertNotNull(recentActivity.findViewById<TextView>(R.id.tv_home_recent_activity_nickname))
|
||||
assertNotNull(recentDebut.findViewById<ImageView>(R.id.iv_home_recent_debut_creator_profile))
|
||||
assertNotNull(recentDebut.findViewById<TextView>(R.id.tv_home_recent_debut_creator_nickname))
|
||||
assertNotNull(creatorProfile.findViewById<ImageView>(R.id.iv_home_creator_profile))
|
||||
assertNotNull(creatorProfile.findViewById<TextView>(R.id.tv_home_creator_profile_nickname))
|
||||
assertNotNull(followAllButton.findViewById<ImageView>(R.id.iv_home_follow_all_icon))
|
||||
assertNotNull(followAllButton.findViewById<TextView>(R.id.tv_home_follow_all))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `recent activity creator item matches figma capsule dimensions`() {
|
||||
val recentActivity = inflateViewWithParent(R.layout.item_home_recent_activity_creator)
|
||||
val profileImage = recentActivity.findViewById<ImageView>(R.id.iv_home_recent_activity_creator_profile)
|
||||
|
||||
assertEquals(244.dpToPx(), recentActivity.layoutParams.width)
|
||||
assertEquals(76.dpToPx(), recentActivity.layoutParams.height)
|
||||
assertEquals(52.dpToPx(), profileImage.layoutParams.width)
|
||||
assertEquals(52.dpToPx(), profileImage.layoutParams.height)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `popular community section is hidden until phase7 binding is implemented`() {
|
||||
val root = inflateView(R.layout.fragment_v2_main_home)
|
||||
val popularCommunitySection = root.findViewById<LinearLayout>(R.id.ll_home_popular_community_section)
|
||||
|
||||
assertEquals(View.GONE, popularCommunitySection.visibility)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `home layout uses section title components and custom genre title row`() {
|
||||
val root = inflateView(R.layout.fragment_v2_main_home)
|
||||
@@ -136,6 +175,12 @@ class HomeMainFragmentLayoutTest {
|
||||
return LayoutInflater.from(context).inflate(layoutResId, null, false)
|
||||
}
|
||||
|
||||
private fun inflateViewWithParent(layoutResId: Int): View {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
val parent = android.widget.FrameLayout(context)
|
||||
return LayoutInflater.from(context).inflate(layoutResId, parent, false)
|
||||
}
|
||||
|
||||
private fun View.containsClassName(className: String): Boolean {
|
||||
if (javaClass.name == className) return true
|
||||
if (this !is android.view.ViewGroup) return false
|
||||
|
||||
Reference in New Issue
Block a user