Merge "VideoCalling UI adds the init value" into main
This commit is contained in:
committed by
Android (Google) Code Review
commit
7c6b213c73
@@ -44,12 +44,12 @@ constructor(
|
||||
context: Context,
|
||||
key: String,
|
||||
private val callStateRepository: CallStateRepository = CallStateRepository(context),
|
||||
private val videoCallingRepository: VideoCallingRepository = VideoCallingRepository(context),
|
||||
) : TogglePreferenceController(context, key), On4gLteUpdateListener {
|
||||
|
||||
private var subId = SubscriptionManager.INVALID_SUBSCRIPTION_ID
|
||||
private var preference: TwoStatePreference? = null
|
||||
private var callingPreferenceCategoryController: CallingPreferenceCategoryController? = null
|
||||
private val repository = VideoCallingRepository(context)
|
||||
|
||||
private var videoCallEditable = false
|
||||
private var isInCall = false
|
||||
@@ -71,14 +71,18 @@ constructor(
|
||||
override fun displayPreference(screen: PreferenceScreen) {
|
||||
super.displayPreference(screen)
|
||||
preference = screen.findPreference(preferenceKey)
|
||||
Log.d(TAG, "init ui")
|
||||
preference?.isVisible = false
|
||||
callingPreferenceCategoryController?.updateChildVisible(preferenceKey, false)
|
||||
}
|
||||
|
||||
override fun onViewCreated(viewLifecycleOwner: LifecycleOwner) {
|
||||
repository.isVideoCallReadyFlow(subId).collectLatestWithLifecycle(viewLifecycleOwner) {
|
||||
isReady ->
|
||||
preference?.isVisible = isReady
|
||||
callingPreferenceCategoryController?.updateChildVisible(preferenceKey, isReady)
|
||||
}
|
||||
videoCallingRepository.isVideoCallReadyFlow(subId)
|
||||
.collectLatestWithLifecycle(viewLifecycleOwner) { isReady ->
|
||||
Log.d(TAG, "isVideoCallReadyFlow: update visible")
|
||||
preference?.isVisible = isReady
|
||||
callingPreferenceCategoryController?.updateChildVisible(preferenceKey, isReady)
|
||||
}
|
||||
callStateRepository.callStateFlow(subId).collectLatestWithLifecycle(viewLifecycleOwner) {
|
||||
callState ->
|
||||
isInCall = callState != TelephonyManager.CALL_STATE_IDLE
|
||||
@@ -129,10 +133,10 @@ constructor(
|
||||
|
||||
class VideoCallingSearchItem(private val context: Context) :
|
||||
MobileNetworkSettingsSearchItem {
|
||||
private val repository = VideoCallingRepository(context)
|
||||
private val videoCallingRepository = VideoCallingRepository(context)
|
||||
|
||||
private fun isAvailable(subId: Int): Boolean = runBlocking {
|
||||
repository.isVideoCallReadyFlow(subId).first()
|
||||
videoCallingRepository.isVideoCallReadyFlow(subId).first()
|
||||
}
|
||||
|
||||
override fun getSearchResult(subId: Int): MobileNetworkSettingsSearchResult? {
|
||||
|
@@ -47,6 +47,8 @@ class VideoCallingPreferenceControllerTest {
|
||||
private val context: Context = ApplicationProvider.getApplicationContext()
|
||||
|
||||
private val mockCallStateRepository = mock<CallStateRepository> {}
|
||||
private val mockVideoCallingRepository = mock<VideoCallingRepository> {}
|
||||
|
||||
|
||||
private var controller =
|
||||
spy(
|
||||
@@ -54,6 +56,7 @@ class VideoCallingPreferenceControllerTest {
|
||||
context = context,
|
||||
key = TEST_KEY,
|
||||
callStateRepository = mockCallStateRepository,
|
||||
videoCallingRepository = mockVideoCallingRepository
|
||||
)
|
||||
) {
|
||||
on { queryImsState(SUB_ID) } doReturn mockVtQueryImsState
|
||||
@@ -70,6 +73,42 @@ class VideoCallingPreferenceControllerTest {
|
||||
controller.displayPreference(preferenceScreen)
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun displayPreference_uiInitState_isHidden() {
|
||||
assertThat(preference.isVisible).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onViewCreated_videoCallIsNotReady_isHidden() = runBlocking {
|
||||
mockVideoCallingRepository.stub {
|
||||
on { isVideoCallReadyFlow(SUB_ID) } doReturn flowOf(false)
|
||||
}
|
||||
mockCallStateRepository.stub {
|
||||
on { callStateFlow(SUB_ID) } doReturn flowOf(TelephonyManager.CALL_STATE_IDLE)
|
||||
}
|
||||
|
||||
controller.onViewCreated(TestLifecycleOwner())
|
||||
delay(100)
|
||||
|
||||
assertThat(preference.isVisible).isFalse()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun onViewCreated_videoCallIsNotReady_isShown() = runBlocking {
|
||||
mockVideoCallingRepository.stub {
|
||||
on { isVideoCallReadyFlow(SUB_ID) } doReturn flowOf(true)
|
||||
}
|
||||
mockCallStateRepository.stub {
|
||||
on { callStateFlow(SUB_ID) } doReturn flowOf(TelephonyManager.CALL_STATE_IDLE)
|
||||
}
|
||||
|
||||
controller.onViewCreated(TestLifecycleOwner())
|
||||
delay(100)
|
||||
|
||||
assertThat(preference.isVisible).isTrue()
|
||||
}
|
||||
|
||||
@Test
|
||||
fun updateState_4gLteOff_disabledAndUnchecked() {
|
||||
mockQueryVoLteState.stub { on { isEnabledByUser } doReturn false }
|
||||
@@ -82,6 +121,9 @@ class VideoCallingPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
fun updateState_4gLteOnWithoutCall_enabledAndChecked() = runBlocking {
|
||||
mockVideoCallingRepository.stub {
|
||||
on { isVideoCallReadyFlow(SUB_ID) } doReturn flowOf(true)
|
||||
}
|
||||
mockVtQueryImsState.stub {
|
||||
on { isEnabledByUser } doReturn true
|
||||
on { isAllowUserControl } doReturn true
|
||||
@@ -101,6 +143,9 @@ class VideoCallingPreferenceControllerTest {
|
||||
|
||||
@Test
|
||||
fun updateState_4gLteOnWithCall_disabledAndChecked() = runBlocking {
|
||||
mockVideoCallingRepository.stub {
|
||||
on { isVideoCallReadyFlow(SUB_ID) } doReturn flowOf(true)
|
||||
}
|
||||
mockVtQueryImsState.stub {
|
||||
on { isEnabledByUser } doReturn true
|
||||
on { isAllowUserControl } doReturn true
|
||||
|
Reference in New Issue
Block a user