feat(creator): 오디오 탭 fragment 골격을 추가한다
This commit is contained in:
@@ -0,0 +1,161 @@
|
||||
package kr.co.vividnext.sodalive.v2.creator.channel.audio
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import android.widget.TextView
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.test.core.app.ApplicationProvider
|
||||
import kr.co.vividnext.sodalive.R
|
||||
import kr.co.vividnext.sodalive.v2.widget.CapsuleTabBarView
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertNotNull
|
||||
import org.junit.Assert.assertSame
|
||||
import org.junit.Assert.assertTrue
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
import org.robolectric.RobolectricTestRunner
|
||||
import org.robolectric.annotation.Config
|
||||
import java.io.File
|
||||
|
||||
@RunWith(RobolectricTestRunner::class)
|
||||
@Config(sdk = [28], application = Application::class)
|
||||
class CreatorChannelAudioFragmentLayoutTest {
|
||||
|
||||
@Test
|
||||
fun `오디오 fragment layout은 theme sort rate list empty error retry를 제공한다`() {
|
||||
val root = inflateView(R.layout.fragment_creator_channel_audio)
|
||||
val layout = projectFile("app/src/main/res/layout/fragment_creator_channel_audio.xml").readText()
|
||||
|
||||
val tabBar = requireNotNull(root.findViewById<CapsuleTabBarView>(R.id.view_creator_channel_audio_theme_tabs))
|
||||
val sortBar = requireNotNull(root.findViewById<View>(R.id.layout_creator_channel_audio_sort_bar))
|
||||
val rateCard = requireNotNull(root.findViewById<View>(R.id.layout_creator_channel_audio_rate_card))
|
||||
val audioList = requireNotNull(root.findViewById<RecyclerView>(R.id.rv_creator_channel_audio_contents))
|
||||
val emptyContainer = requireNotNull(root.findViewById<View>(R.id.layout_creator_channel_audio_empty))
|
||||
val emptyMessage = requireNotNull(root.findViewById<TextView>(R.id.tv_creator_channel_audio_empty_message))
|
||||
val errorMessage = requireNotNull(root.findViewById<TextView>(R.id.tv_creator_channel_audio_error_message))
|
||||
val retryButton = requireNotNull(root.findViewById<TextView>(R.id.btn_creator_channel_audio_retry))
|
||||
|
||||
assertSame(root, tabBar.parent)
|
||||
assertSame(root, sortBar.parent)
|
||||
assertSame(root, rateCard.parent)
|
||||
assertSame(root, audioList.parent)
|
||||
assertSame(root, emptyContainer.parent)
|
||||
assertSame(emptyContainer, emptyMessage.parent)
|
||||
assertSame(root, errorMessage.parent)
|
||||
assertSame(root, retryButton.parent)
|
||||
assertEquals(false, audioList.clipToPadding)
|
||||
assertTrue(layout.contains("android:background=\"@color/black\""))
|
||||
assertTrue(layout.contains("layout=\"@layout/view_capsule_tab_bar\""))
|
||||
assertTrue(layout.contains("android:layout_height=\"52dp\""))
|
||||
assertTrue(layout.contains("android:layout_marginHorizontal=\"@dimen/spacing_14\""))
|
||||
assertTrue(layout.contains("android:text=\"@string/creator_channel_audio_empty_message\""))
|
||||
assertTrue(layout.contains("android:text=\"@string/creator_channel_audio_error_message\""))
|
||||
assertTrue(layout.contains("tools:listitem=\"@layout/item_creator_channel_audio_content\""))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `오디오 sort bar는 전체 count 정렬 label sort icon을 제공한다`() {
|
||||
val root = inflateView(R.layout.fragment_creator_channel_audio)
|
||||
val sortBar = requireNotNull(root.findViewById<View>(R.id.layout_creator_channel_audio_sort_bar))
|
||||
|
||||
assertNotNull(sortBar.findViewById<TextView>(R.id.tv_creator_channel_audio_total_label))
|
||||
assertNotNull(sortBar.findViewById<TextView>(R.id.tv_creator_channel_audio_total_count))
|
||||
assertNotNull(sortBar.findViewById<View>(R.id.layout_creator_channel_audio_sort_button))
|
||||
assertNotNull(sortBar.findViewById<TextView>(R.id.tv_creator_channel_audio_sort_label))
|
||||
assertNotNull(sortBar.findViewById<ImageView>(R.id.iv_creator_channel_audio_sort))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `오디오 소장률 카드는 percent count track fill 영역을 제공한다`() {
|
||||
val root = inflateView(R.layout.fragment_creator_channel_audio)
|
||||
val rateCard = requireNotNull(root.findViewById<View>(R.id.layout_creator_channel_audio_rate_card))
|
||||
|
||||
assertNotNull(rateCard.findViewById<TextView>(R.id.tv_creator_channel_audio_rate_message))
|
||||
assertNotNull(rateCard.findViewById<TextView>(R.id.tv_creator_channel_audio_rate_count))
|
||||
assertNotNull(rateCard.findViewById<View>(R.id.view_creator_channel_audio_rate_track))
|
||||
assertNotNull(rateCard.findViewById<View>(R.id.view_creator_channel_audio_rate_fill))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `오디오 콘텐츠 item layout은 88dp thumbnail title secondary action 영역을 제공한다`() {
|
||||
val item = inflateView(R.layout.item_creator_channel_audio_content)
|
||||
val itemLayout = projectFile("app/src/main/res/layout/item_creator_channel_audio_content.xml").readText()
|
||||
val adapter = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/live/ui/CreatorChannelLiveReplayAdapter.kt"
|
||||
).readText()
|
||||
val thumbnail = requireNotNull(item.findViewById<View>(R.id.layout_creator_channel_audio_content_thumbnail))
|
||||
|
||||
assertNotNull(item.findViewById<ImageView>(R.id.iv_creator_channel_audio_content_thumbnail))
|
||||
assertNotNull(item.findViewById<ImageView>(R.id.iv_creator_channel_audio_content_adult_badge))
|
||||
assertNotNull(item.findViewById<ImageView>(R.id.iv_creator_channel_audio_content_original_tag))
|
||||
assertNotNull(item.findViewById<ImageView>(R.id.iv_creator_channel_audio_content_first_tag))
|
||||
assertNotNull(item.findViewById<ImageView>(R.id.iv_creator_channel_audio_content_point_tag))
|
||||
assertNotNull(item.findViewById<TextView>(R.id.tv_creator_channel_audio_content_free_tag))
|
||||
assertNotNull(item.findViewById<TextView>(R.id.tv_creator_channel_audio_content_title))
|
||||
assertNotNull(item.findViewById<TextView>(R.id.tv_creator_channel_audio_content_secondary_text))
|
||||
assertNotNull(item.findViewById<View>(R.id.layout_creator_channel_audio_content_action))
|
||||
assertNotNull(item.findViewById<ImageView>(R.id.iv_creator_channel_audio_content_play))
|
||||
assertNotNull(item.findViewById<ImageView>(R.id.iv_creator_channel_audio_content_can))
|
||||
assertNotNull(item.findViewById<View>(R.id.layout_creator_channel_audio_content_action_text))
|
||||
assertNotNull(item.findViewById<TextView>(R.id.tv_creator_channel_audio_content_action_text))
|
||||
assertEquals(dp(88), thumbnail.layoutParams.width)
|
||||
assertEquals(dp(88), thumbnail.layoutParams.height)
|
||||
assertTrue(itemLayout.contains("android:id=\"@+id/tv_creator_channel_audio_content_secondary_text\""))
|
||||
assertTrue(itemLayout.contains("@drawable/bg_audio_content_card_thumbnail"))
|
||||
assertTrue(adapter.contains("ItemCreatorChannelAudioContentBinding"))
|
||||
assertTrue(adapter.contains("layoutCreatorChannelAudioContentThumbnail.clipToOutline = true"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `오디오 fragment source는 skeleton observer retry visibility branches를 포함한다`() {
|
||||
val fragment = projectFile(
|
||||
"app/src/main/java/kr/co/vividnext/sodalive/v2/creator/channel/audio/CreatorChannelAudioFragment.kt"
|
||||
).readText()
|
||||
|
||||
assertTrue(fragment.contains("BaseFragment<FragmentCreatorChannelAudioBinding>"))
|
||||
assertTrue(fragment.contains("FragmentCreatorChannelAudioBinding::inflate"))
|
||||
assertTrue(fragment.contains("private val viewModel: CreatorChannelAudioViewModel by viewModel()"))
|
||||
assertTrue(fragment.contains("fun newInstance(creatorId: Long): CreatorChannelAudioFragment"))
|
||||
assertTrue(fragment.contains("arguments = Bundle().apply { putLong(ARG_CREATOR_ID, creatorId) }"))
|
||||
assertTrue(fragment.contains("viewModel.audioStateLiveData.observe(viewLifecycleOwner)"))
|
||||
assertTrue(fragment.contains("CreatorChannelAudioUiState.Loading -> bindLoading()"))
|
||||
assertTrue(fragment.contains("CreatorChannelAudioUiState.Empty -> bindEmpty()"))
|
||||
assertTrue(fragment.contains("is CreatorChannelAudioUiState.Error -> bindError(state)"))
|
||||
assertTrue(fragment.contains("is CreatorChannelAudioUiState.Content -> bindContent(state)"))
|
||||
assertTrue(fragment.contains("viewModel.retryAudio()"))
|
||||
assertTrue(fragment.contains("viewCreatorChannelAudioThemeTabs.root.isVisible = false"))
|
||||
assertTrue(fragment.contains("viewCreatorChannelAudioThemeTabs.root.setMenus"))
|
||||
assertTrue(fragment.contains("layoutCreatorChannelAudioSortBar.isVisible = false"))
|
||||
assertTrue(fragment.contains("layoutCreatorChannelAudioRateCard.isVisible = false"))
|
||||
assertTrue(fragment.contains("rvCreatorChannelAudioContents.isVisible = false"))
|
||||
assertTrue(fragment.contains("layoutCreatorChannelAudioEmpty.isVisible = true"))
|
||||
assertTrue(fragment.contains("tvCreatorChannelAudioErrorMessage.isVisible = true"))
|
||||
assertTrue(fragment.contains("btnCreatorChannelAudioRetry.isVisible = true"))
|
||||
assertTrue(fragment.contains("tvCreatorChannelAudioTotalCount.text = state.audioContentCount.moneyFormat()"))
|
||||
assertTrue(fragment.contains("tvCreatorChannelAudioSortLabel.setText(state.selectedSort.toLabelResId())"))
|
||||
assertTrue(fragment.contains("bindRate(state.rate)"))
|
||||
assertTrue(fragment.contains("tvCreatorChannelAudioRateMessage.text"))
|
||||
assertTrue(fragment.contains("ForegroundColorSpan"))
|
||||
assertTrue(fragment.contains("R.string.creator_channel_audio_owned_rate_count"))
|
||||
assertTrue(fragment.contains("viewCreatorChannelAudioRateFill.pivotX = 0f"))
|
||||
}
|
||||
|
||||
private fun inflateView(layoutResId: Int): View {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
return LayoutInflater.from(context).inflate(layoutResId, null, false)
|
||||
}
|
||||
|
||||
private fun dp(value: Int): Int {
|
||||
val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
return (value * context.resources.displayMetrics.density).toInt()
|
||||
}
|
||||
|
||||
private fun projectFile(relativePath: String): File {
|
||||
val candidates = listOf(File(relativePath), File("../$relativePath"))
|
||||
return candidates.firstOrNull { it.exists() }
|
||||
?: error("Project file not found: $relativePath")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user