diff --git a/app/src/test/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragmentLayoutTest.kt b/app/src/test/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragmentLayoutTest.kt index 86548d9e..0c2c1fa0 100644 --- a/app/src/test/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragmentLayoutTest.kt +++ b/app/src/test/java/kr/co/vividnext/sodalive/v2/main/home/HomeMainFragmentLayoutTest.kt @@ -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(R.id.rv_home_banners)) assertNotNull(root.findViewById(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(R.id.iv_home_recent_activity_creator_profile)) + assertNotNull(recentActivity.findViewById(R.id.tv_home_recent_activity_type)) + assertNotNull(recentActivity.findViewById(R.id.tv_home_recent_activity_title)) + assertNotNull(recentActivity.findViewById(R.id.tv_home_recent_activity_nickname)) + assertNotNull(recentDebut.findViewById(R.id.iv_home_recent_debut_creator_profile)) + assertNotNull(recentDebut.findViewById(R.id.tv_home_recent_debut_creator_nickname)) + assertNotNull(creatorProfile.findViewById(R.id.iv_home_creator_profile)) + assertNotNull(creatorProfile.findViewById(R.id.tv_home_creator_profile_nickname)) + assertNotNull(followAllButton.findViewById(R.id.iv_home_follow_all_icon)) + assertNotNull(followAllButton.findViewById(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(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(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() + 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