diff options
author | Peter Li <pyli@google.com> | 2021-06-16 17:31:49 -0700 |
---|---|---|
committer | Peter Li <pyli@google.com> | 2021-06-24 08:22:41 +0000 |
commit | 8a4e799becd1e6c5b226335742bb3b5e60c3ae1f (patch) | |
tree | 233088b494742b9af74dae073cb03f621de7a677 | |
parent | 4545f187320eb1e4dee07e45e8cd27269eb7879c (diff) | |
download | Dialer-8a4e799becd1e6c5b226335742bb3b5e60c3ae1f.tar.gz |
Migrate CallStateLiveData tests
Bug: 187450541
Test: atest CarDialerUnitTests
Change-Id: I9e9241dcf60afae67d75dac6df1e3c1a4a577d1e
-rw-r--r-- | tests/unittests/src/com/android/car/dialer/livedata/CallStateLiveDataTest.java (renamed from tests/robotests/src/com/android/car/dialer/livedata/CallStateLiveDataTest.java) | 16 | ||||
-rw-r--r-- | tests/unittests/src/com/android/car/dialer/livedata/CallStateLiveDataUnitTest.java | 36 |
2 files changed, 10 insertions, 42 deletions
diff --git a/tests/robotests/src/com/android/car/dialer/livedata/CallStateLiveDataTest.java b/tests/unittests/src/com/android/car/dialer/livedata/CallStateLiveDataTest.java index b9e4c287..11cad651 100644 --- a/tests/robotests/src/com/android/car/dialer/livedata/CallStateLiveDataTest.java +++ b/tests/unittests/src/com/android/car/dialer/livedata/CallStateLiveDataTest.java @@ -1,5 +1,5 @@ /* - * Copyright (C) 2019 The Android Open Source Project + * Copyright (C) 2021 The Android Open Source Project * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,9 +29,9 @@ import android.telecom.Call; import androidx.lifecycle.Lifecycle; import androidx.lifecycle.LifecycleOwner; import androidx.lifecycle.LifecycleRegistry; - -import com.android.car.dialer.CarDialerRobolectricTestRunner; -import com.android.car.dialer.LiveDataObserver; +import androidx.lifecycle.Observer; +import androidx.test.annotation.UiThreadTest; +import androidx.test.ext.junit.runners.AndroidJUnit4; import org.junit.Before; import org.junit.Test; @@ -41,7 +41,7 @@ import org.mockito.Captor; import org.mockito.Mock; import org.mockito.MockitoAnnotations; -@RunWith(CarDialerRobolectricTestRunner.class) +@RunWith(AndroidJUnit4.class) public class CallStateLiveDataTest { private CallStateLiveData mCallStateLiveData; @@ -51,7 +51,7 @@ public class CallStateLiveDataTest { @Mock private LifecycleOwner mMockLifecycleOwner; @Mock - private LiveDataObserver<Integer> mMockObserver; + private Observer<Integer> mMockObserver; @Captor private ArgumentCaptor<Call.Callback> mCallbackCaptor; @@ -68,6 +68,7 @@ public class CallStateLiveDataTest { } @Test + @UiThreadTest public void testOnActiveRegistry() { mCallStateLiveData.onActive(); @@ -75,6 +76,7 @@ public class CallStateLiveDataTest { } @Test + @UiThreadTest public void testOnLifecycleStart() { mCallStateLiveData.observe(mMockLifecycleOwner, (value) -> mMockObserver.onChanged(value)); verify(mMockObserver, never()).onChanged(any()); @@ -88,6 +90,7 @@ public class CallStateLiveDataTest { } @Test + @UiThreadTest public void testOnStateChanged() { ArgumentCaptor<Integer> valueCaptor = ArgumentCaptor.forClass(Integer.class); doNothing().when(mMockObserver).onChanged(valueCaptor.capture()); @@ -101,6 +104,7 @@ public class CallStateLiveDataTest { } @Test + @UiThreadTest public void testOnInactiveUnregister() { mCallStateLiveData.observe(mMockLifecycleOwner, (value) -> mMockObserver.onChanged(value)); mLifecycleRegistry.handleLifecycleEvent(Lifecycle.Event.ON_START); diff --git a/tests/unittests/src/com/android/car/dialer/livedata/CallStateLiveDataUnitTest.java b/tests/unittests/src/com/android/car/dialer/livedata/CallStateLiveDataUnitTest.java deleted file mode 100644 index 9488040c..00000000 --- a/tests/unittests/src/com/android/car/dialer/livedata/CallStateLiveDataUnitTest.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (C) 2020 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.android.car.dialer.livedata; - -import androidx.test.ext.junit.runners.AndroidJUnit4; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; - -@RunWith(AndroidJUnit4.class) -public class CallStateLiveDataUnitTest { - - @Before - public void setup() { - } - - @Test - public void testOnActiveRegistry() { - } -} - |