package com.joe.camera.webcam.ui

import android.app.Application
import androidx.compose.ui.test.assertIsDisplayed
import androidx.compose.ui.test.junit4.createComposeRule
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performTouchInput
import androidx.compose.ui.test.doubleClick
import androidx.test.core.app.ApplicationProvider
import com.joe.camera.webcam.MainUiState
import com.joe.camera.webcam.MainViewModel
import org.junit.Rule
import org.junit.Test

class HomeScreenTest {
    @get:Rule val compose = createComposeRule()

    @Test fun doubleTapOpensControlMenu() {
        val viewModel = MainViewModel(ApplicationProvider.getApplicationContext<Application>())
        compose.setContent { WebCamTheme { HomeScreen(viewModel, MainUiState(remoteMode = true), onMedia = {}) } }
        compose.onNodeWithContentDescription("控制菜单").performTouchInput { doubleClick() }
        compose.onNodeWithText("录像").assertIsDisplayed()
        compose.onNodeWithText("媒体库").assertIsDisplayed()
    }
}
