Loading src/com/android/settings/slices/SliceBackgroundWorker.java +4 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ import android.os.SystemClock; import android.util.ArrayMap; import android.util.Log; import androidx.annotation.VisibleForTesting; import java.io.Closeable; import java.io.IOException; import java.lang.reflect.InvocationTargetException; Loading Loading @@ -172,7 +174,8 @@ public abstract class SliceBackgroundWorker<E> implements Closeable { /** * Notify that data was updated and attempt to sync changes to the Slice. */ protected final void notifySliceChange() { @VisibleForTesting public final void notifySliceChange() { NotifySliceChangeHandler.getInstance().updateSlice(this); } Loading tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothUpdateWorkerTest.java +7 −15 Original line number Diff line number Diff line Loading @@ -16,12 +16,9 @@ package com.android.settings.homepage.contextualcards.slices; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import android.content.ContentResolver; import android.content.Context; import android.net.Uri; Loading @@ -29,7 +26,6 @@ import com.android.settings.slices.ShadowSliceBackgroundWorker; import com.android.settings.testutils.shadow.ShadowBluetoothAdapter; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; Loading @@ -43,50 +39,46 @@ public class BluetoothUpdateWorkerTest { private static final Uri URI = Uri.parse("content://com.android.settings.slices/test"); private BluetoothUpdateWorker mBluetoothUpdateWorker; private ContentResolver mResolver; private Context mContext; @Before public void setUp() { mContext = spy(RuntimeEnvironment.application); mBluetoothUpdateWorker = new BluetoothUpdateWorker(mContext, URI); mResolver = mock(ContentResolver.class); doReturn(mResolver).when(mContext).getContentResolver(); mContext = RuntimeEnvironment.getApplication(); mBluetoothUpdateWorker = spy(new BluetoothUpdateWorker(mContext, URI)); } @Test public void onAclConnectionStateChanged_shouldNotifyChange() { mBluetoothUpdateWorker.onAclConnectionStateChanged(null, 0); verify(mResolver).notifyChange(URI, null); verify(mBluetoothUpdateWorker).notifySliceChange(); } @Ignore("b/315399487") @Test public void onActiveDeviceChanged_shouldNotifyChange() { mBluetoothUpdateWorker.onActiveDeviceChanged(null, 0); verify(mResolver).notifyChange(URI, null); verify(mBluetoothUpdateWorker).notifySliceChange(); } @Test public void onBluetoothStateChanged_shouldNotifyChange() { mBluetoothUpdateWorker.onBluetoothStateChanged(0); verify(mResolver).notifyChange(URI, null); verify(mBluetoothUpdateWorker).notifySliceChange(); } @Test public void onConnectionStateChanged_shouldNotifyChange() { mBluetoothUpdateWorker.onConnectionStateChanged(null, 0); verify(mResolver).notifyChange(URI, null); verify(mBluetoothUpdateWorker).notifySliceChange(); } @Test public void onProfileConnectionStateChanged_shouldNotifyChange() { mBluetoothUpdateWorker.onProfileConnectionStateChanged(null, 0, 0); verify(mResolver).notifyChange(URI, null); verify(mBluetoothUpdateWorker).notifySliceChange(); } } No newline at end of file Loading
src/com/android/settings/slices/SliceBackgroundWorker.java +4 −1 Original line number Diff line number Diff line Loading @@ -29,6 +29,8 @@ import android.os.SystemClock; import android.util.ArrayMap; import android.util.Log; import androidx.annotation.VisibleForTesting; import java.io.Closeable; import java.io.IOException; import java.lang.reflect.InvocationTargetException; Loading Loading @@ -172,7 +174,8 @@ public abstract class SliceBackgroundWorker<E> implements Closeable { /** * Notify that data was updated and attempt to sync changes to the Slice. */ protected final void notifySliceChange() { @VisibleForTesting public final void notifySliceChange() { NotifySliceChangeHandler.getInstance().updateSlice(this); } Loading
tests/robotests/src/com/android/settings/homepage/contextualcards/slices/BluetoothUpdateWorkerTest.java +7 −15 Original line number Diff line number Diff line Loading @@ -16,12 +16,9 @@ package com.android.settings.homepage.contextualcards.slices; import static org.mockito.Mockito.doReturn; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.verify; import android.content.ContentResolver; import android.content.Context; import android.net.Uri; Loading @@ -29,7 +26,6 @@ import com.android.settings.slices.ShadowSliceBackgroundWorker; import com.android.settings.testutils.shadow.ShadowBluetoothAdapter; import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.robolectric.RobolectricTestRunner; Loading @@ -43,50 +39,46 @@ public class BluetoothUpdateWorkerTest { private static final Uri URI = Uri.parse("content://com.android.settings.slices/test"); private BluetoothUpdateWorker mBluetoothUpdateWorker; private ContentResolver mResolver; private Context mContext; @Before public void setUp() { mContext = spy(RuntimeEnvironment.application); mBluetoothUpdateWorker = new BluetoothUpdateWorker(mContext, URI); mResolver = mock(ContentResolver.class); doReturn(mResolver).when(mContext).getContentResolver(); mContext = RuntimeEnvironment.getApplication(); mBluetoothUpdateWorker = spy(new BluetoothUpdateWorker(mContext, URI)); } @Test public void onAclConnectionStateChanged_shouldNotifyChange() { mBluetoothUpdateWorker.onAclConnectionStateChanged(null, 0); verify(mResolver).notifyChange(URI, null); verify(mBluetoothUpdateWorker).notifySliceChange(); } @Ignore("b/315399487") @Test public void onActiveDeviceChanged_shouldNotifyChange() { mBluetoothUpdateWorker.onActiveDeviceChanged(null, 0); verify(mResolver).notifyChange(URI, null); verify(mBluetoothUpdateWorker).notifySliceChange(); } @Test public void onBluetoothStateChanged_shouldNotifyChange() { mBluetoothUpdateWorker.onBluetoothStateChanged(0); verify(mResolver).notifyChange(URI, null); verify(mBluetoothUpdateWorker).notifySliceChange(); } @Test public void onConnectionStateChanged_shouldNotifyChange() { mBluetoothUpdateWorker.onConnectionStateChanged(null, 0); verify(mResolver).notifyChange(URI, null); verify(mBluetoothUpdateWorker).notifySliceChange(); } @Test public void onProfileConnectionStateChanged_shouldNotifyChange() { mBluetoothUpdateWorker.onProfileConnectionStateChanged(null, 0, 0); verify(mResolver).notifyChange(URI, null); verify(mBluetoothUpdateWorker).notifySliceChange(); } } No newline at end of file