1 /* 2 * Copyright (C) 2021 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.systemui.statusbar.phone.ongoingcall 18 19 import androidx.test.filters.SmallTest 20 import com.android.internal.logging.testing.UiEventLoggerFake 21 import com.android.systemui.SysuiTestCase 22 import com.google.common.truth.Truth.assertThat 23 import org.junit.Test 24 25 @SmallTest 26 class OngoingCallLoggerTest : SysuiTestCase() { 27 private val uiEventLoggerFake = UiEventLoggerFake() 28 private val ongoingCallLogger = OngoingCallLogger(uiEventLoggerFake) 29 30 @Test 31 fun logChipClicked_clickEventLogged() { 32 ongoingCallLogger.logChipClicked() 33 34 assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1) 35 assertThat(uiEventLoggerFake.eventId(0)) 36 .isEqualTo(OngoingCallLogger.OngoingCallEvents.ONGOING_CALL_CLICKED.id) 37 } 38 39 @Test 40 fun logChipVisibilityChanged_changeFromInvisibleToVisible_visibleEventLogged() { 41 ongoingCallLogger.logChipVisibilityChanged(false) 42 ongoingCallLogger.logChipVisibilityChanged(true) 43 44 assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1) 45 assertThat(uiEventLoggerFake.eventId(0)) 46 .isEqualTo(OngoingCallLogger.OngoingCallEvents.ONGOING_CALL_VISIBLE.id) 47 } 48 49 @Test 50 fun logChipVisibilityChanged_changeFromVisibleToInvisible_eventNotLogged() { 51 // Setting the chip to visible here will trigger a log 52 ongoingCallLogger.logChipVisibilityChanged(true) 53 assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1) 54 55 ongoingCallLogger.logChipVisibilityChanged(false) 56 57 // Expect that there were no new logs 58 assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1) 59 } 60 61 @Test 62 fun logChipVisibilityChanged_visibleThenVisibleAgain_eventNotLogged() { 63 // Setting the chip to visible here will trigger a log 64 ongoingCallLogger.logChipVisibilityChanged(true) 65 assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1) 66 67 ongoingCallLogger.logChipVisibilityChanged(true) 68 69 // Expect that there were no new logs 70 assertThat(uiEventLoggerFake.numLogs()).isEqualTo(1) 71 } 72 } 73