package com.ponzischeme89.memby.ui.player

import android.app.Activity
import android.graphics.Color
import android.graphics.drawable.GradientDrawable
import android.view.LayoutInflater
import android.view.View
import android.widget.FrameLayout
import android.widget.TextView
import com.github.takahirom.roborazzi.captureRoboImage
import com.ponzischeme89.memby.R
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.Robolectric
import org.robolectric.RobolectricTestRunner
import org.robolectric.annotation.Config
import org.robolectric.annotation.GraphicsMode

@RunWith(RobolectricTestRunner::class)
@GraphicsMode(GraphicsMode.Mode.NATIVE)
@Config(sdk = [34], qualifiers = "w960dp-h540dp-television-xhdpi")
class SeasonFinaleLowerThirdScreenshotTest {
    @Test
    fun `season finale stacks above playback start cue`() {
        val activity = Robolectric.buildActivity(Activity::class.java).setup().get()
        val root = FrameLayout(activity).apply {
            background = GradientDrawable(
                GradientDrawable.Orientation.TL_BR,
                intArrayOf(
                    Color.rgb(17, 37, 48),
                    Color.rgb(12, 20, 27),
                    Color.rgb(3, 7, 10),
                ),
            )
        }
        val inflater = LayoutInflater.from(activity)
        val timing = inflater.inflate(R.layout.player_time_remaining, root, false).apply {
            visibility = View.VISIBLE
            findViewById<TextView>(R.id.player_time_remaining_label).text = "FINISHES IN"
            findViewById<TextView>(R.id.player_time_remaining_value).text = "52 mins (9:54 PM)"
        }
        val finale = inflater.inflate(R.layout.player_season_finale, root, false).apply {
            visibility = View.VISIBLE
            findViewById<TextView>(R.id.player_season_finale_value).text =
                "Signal Hill · Season 2 finale"
        }
        root.addView(timing)
        root.addView(finale)
        activity.setContentView(root)

        root.captureRoboImage(
            "build/screenshots/season-finale/player-season-finale-lower-third.png",
        )
    }
}
