diff options
author | Brandon Maxwell <maxwelb@google.com> | 2016-03-15 22:57:18 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2016-03-15 22:57:18 +0000 |
commit | 234f705cc0e0e3799939777e7cccf5d05dd44fb6 (patch) | |
tree | 2d6315a0fa98cb970b41951dc3b3a7c611292e0f /tests | |
parent | ff8f37c2bcc0e6976be10ea473a0a3e21bad95fd (diff) | |
parent | 724ee71dbb1e7b1fcb8cd332663772c215eb7e63 (diff) |
Merge "Keeping migration dialog up while migration in progress" into nyc-dev am: a98b35c260
am: 724ee71dbb
* commit '724ee71dbb1e7b1fcb8cd332663772c215eb7e63':
Keeping migration dialog up while migration in progress
Diffstat (limited to 'tests')
-rw-r--r-- | tests/src/com/android/dialer/filterednumber/MigrateBlockedNumbersDialogFragmentInstrumentationTest.java | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/tests/src/com/android/dialer/filterednumber/MigrateBlockedNumbersDialogFragmentInstrumentationTest.java b/tests/src/com/android/dialer/filterednumber/MigrateBlockedNumbersDialogFragmentInstrumentationTest.java index 16b6f3fac..0bfa6bcb2 100644 --- a/tests/src/com/android/dialer/filterednumber/MigrateBlockedNumbersDialogFragmentInstrumentationTest.java +++ b/tests/src/com/android/dialer/filterednumber/MigrateBlockedNumbersDialogFragmentInstrumentationTest.java @@ -16,12 +16,9 @@ package com.android.dialer.filterednumber; -import static org.mockito.Mockito.doNothing; -import static org.mockito.Mockito.verify; -import static org.mockito.Mockito.when; - import android.app.AlertDialog; import android.app.DialogFragment; +import android.content.ContentResolver; import android.content.DialogInterface; import android.test.ActivityInstrumentationTestCase2; @@ -40,9 +37,8 @@ public class MigrateBlockedNumbersDialogFragmentInstrumentationTest extends private static final String SHOW_TAG = "ShowTag"; - @Mock private BlockedNumbersMigrator mBlockedNumbersMigrator; + private BlockedNumbersMigrator mBlockedNumbersMigrator; @Mock private Listener mListener; - private DialtactsActivity mActivity; private DialogFragment mMigrateDialogFragment; public MigrateBlockedNumbersDialogFragmentInstrumentationTest() { @@ -53,13 +49,14 @@ public class MigrateBlockedNumbersDialogFragmentInstrumentationTest extends public void setUp() throws Exception { super.setUp(); MockitoAnnotations.initMocks(this); - mActivity = getActivity(); + mBlockedNumbersMigrator = new SynchronousBlockedNumbersMigrator( + getActivity().getContentResolver()); mMigrateDialogFragment = MigrateBlockedNumbersDialogFragment .newInstance(mBlockedNumbersMigrator, mListener); getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { - mMigrateDialogFragment.show(mActivity.getFragmentManager(), SHOW_TAG); + mMigrateDialogFragment.show(getActivity().getFragmentManager(), SHOW_TAG); } }); getInstrumentation().waitForIdleSync(); @@ -70,7 +67,6 @@ public class MigrateBlockedNumbersDialogFragmentInstrumentationTest extends } public void testDialogPositiveButtonPress() { - when(mBlockedNumbersMigrator.migrate(mListener)).thenReturn(true); getInstrumentation().runOnMainSync(new Runnable() { @Override public void run() { @@ -81,6 +77,17 @@ public class MigrateBlockedNumbersDialogFragmentInstrumentationTest extends getInstrumentation().waitForIdleSync(); // Dialog was dismissed assertNull(mMigrateDialogFragment.getDialog()); - verify(mBlockedNumbersMigrator).migrate(mListener); + } + + private static class SynchronousBlockedNumbersMigrator extends BlockedNumbersMigrator { + public SynchronousBlockedNumbersMigrator(ContentResolver contentResolver) { + super(contentResolver); + } + + @Override + public boolean migrate(BlockedNumbersMigrator.Listener listener) { + listener.onComplete(); + return true; + } } } |