Use external/robolectric-shadows/run_robotests.mk
This allows Settings to test against the latest framework changes. Also replaced TestConfig with traditional robolectric.properties. Bug: 73173204 Bug: 73892008 Test: make -j56 RunSettingsRoboTests Change-Id: I3135b4fa5f095ba79b282a76f45dd9baa2584bc7
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
package com.android.settings.bluetooth;
|
||||
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.fail;
|
||||
import static org.mockito.Matchers.any;
|
||||
import static org.mockito.Mockito.doNothing;
|
||||
@@ -38,23 +37,18 @@ import android.widget.CheckBox;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.TestConfig;
|
||||
import com.android.settings.testutils.SettingsRobolectricTestRunner;
|
||||
import com.android.settings.testutils.shadow.ShadowEventLogWriter;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.RuntimeEnvironment;
|
||||
import org.robolectric.shadows.ShadowAlertDialog;
|
||||
import org.robolectric.shadows.ShadowApplication;
|
||||
import org.robolectric.util.FragmentTestUtil;
|
||||
|
||||
@RunWith(SettingsRobolectricTestRunner.class)
|
||||
@Config(manifest = TestConfig.MANIFEST_PATH, sdk = TestConfig.SDK_VERSION,
|
||||
shadows=ShadowEventLogWriter.class)
|
||||
public class BluetoothPairingDialogTest {
|
||||
|
||||
private static final String FILLER = "text that goes in a view";
|
||||
@@ -139,7 +133,7 @@ public class BluetoothPairingDialogTest {
|
||||
when(controller.getDeviceVariantMessageHintId())
|
||||
.thenReturn(BluetoothPairingController.INVALID_DIALOG_TYPE);
|
||||
|
||||
Context context = spy(ShadowApplication.getInstance().getApplicationContext());
|
||||
Context context = spy(RuntimeEnvironment.application);
|
||||
InputMethodManager imm = mock(InputMethodManager.class);
|
||||
doReturn(imm).when(context).getSystemService(Context.INPUT_METHOD_SERVICE);
|
||||
|
||||
@@ -176,8 +170,7 @@ public class BluetoothPairingDialogTest {
|
||||
|
||||
// get the relevant views
|
||||
View messagePairing = frag.getmDialog().findViewById(R.id.pairing_code_message);
|
||||
TextView pairingViewContent =
|
||||
(TextView) frag.getmDialog().findViewById(R.id.pairing_subhead);
|
||||
TextView pairingViewContent = frag.getmDialog().findViewById(R.id.pairing_subhead);
|
||||
View pairingViewCaption = frag.getmDialog().findViewById(R.id.pairing_caption);
|
||||
|
||||
// check that the relevant views are visible and that the passkey is shown
|
||||
@@ -288,8 +281,8 @@ public class BluetoothPairingDialogTest {
|
||||
BluetoothPairingDialogFragment frag = makeFragment();
|
||||
|
||||
// verify that the checkbox is visible and that the device name is correct
|
||||
CheckBox sharingCheckbox = (CheckBox) frag.getmDialog()
|
||||
.findViewById(R.id.phonebook_sharing_message_confirm_pin);
|
||||
CheckBox sharingCheckbox =
|
||||
frag.getmDialog().findViewById(R.id.phonebook_sharing_message_confirm_pin);
|
||||
assertThat(sharingCheckbox.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
}
|
||||
|
||||
@@ -306,8 +299,8 @@ public class BluetoothPairingDialogTest {
|
||||
BluetoothPairingDialogFragment frag = makeFragment();
|
||||
|
||||
// verify that the checkbox is gone
|
||||
CheckBox sharingCheckbox = (CheckBox) frag.getmDialog()
|
||||
.findViewById(R.id.phonebook_sharing_message_confirm_pin);
|
||||
CheckBox sharingCheckbox =
|
||||
frag.getmDialog().findViewById(R.id.phonebook_sharing_message_confirm_pin);
|
||||
assertThat(sharingCheckbox.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@@ -325,7 +318,7 @@ public class BluetoothPairingDialogTest {
|
||||
BluetoothPairingDialogFragment frag = makeFragment();
|
||||
|
||||
// verify message is what we expect it to be and is visible
|
||||
TextView message = (TextView) frag.getmDialog().findViewById(R.id.message_below_pin);
|
||||
TextView message = frag.getmDialog().findViewById(R.id.message_below_pin);
|
||||
assertThat(message.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(TextUtils.equals(frag.getString(R.string.cancel), message.getText())).isTrue();
|
||||
}
|
||||
@@ -344,7 +337,7 @@ public class BluetoothPairingDialogTest {
|
||||
BluetoothPairingDialogFragment frag = makeFragment();
|
||||
|
||||
// verify message is what we expect it to be and is visible
|
||||
TextView hint = (TextView) frag.getmDialog().findViewById(R.id.pin_values_hint);
|
||||
TextView hint = frag.getmDialog().findViewById(R.id.pin_values_hint);
|
||||
assertThat(hint.getVisibility()).isEqualTo(View.VISIBLE);
|
||||
assertThat(TextUtils.equals(frag.getString(R.string.cancel), hint.getText())).isTrue();
|
||||
}
|
||||
@@ -364,16 +357,16 @@ public class BluetoothPairingDialogTest {
|
||||
BluetoothPairingDialogFragment frag = makeFragment();
|
||||
|
||||
// verify message is what we expect it to be and is visible
|
||||
TextView hint = (TextView) frag.getmDialog().findViewById(R.id.pin_values_hint);
|
||||
TextView hint = frag.getmDialog().findViewById(R.id.pin_values_hint);
|
||||
assertThat(hint.getVisibility()).isEqualTo(View.GONE);
|
||||
TextView message = (TextView) frag.getmDialog().findViewById(R.id.message_below_pin);
|
||||
TextView message = frag.getmDialog().findViewById(R.id.message_below_pin);
|
||||
assertThat(message.getVisibility()).isEqualTo(View.GONE);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void pairingStringIsFormattedCorrectly() {
|
||||
final String device = "test_device";
|
||||
final Context context = ShadowApplication.getInstance().getApplicationContext();
|
||||
final Context context = RuntimeEnvironment.application;
|
||||
assertThat(context.getString(R.string.bluetooth_pb_acceptance_dialog_text, device, device))
|
||||
.contains(device);
|
||||
}
|
||||
@@ -443,6 +436,7 @@ public class BluetoothPairingDialogTest {
|
||||
when(fragment.getPairingViewText()).thenReturn(existingText);
|
||||
setupFragment(fragment);
|
||||
AlertDialog dialog = ShadowAlertDialog.getLatestAlertDialog();
|
||||
assertThat(dialog).isNotNull();
|
||||
boolean expected = !TextUtils.isEmpty(existingText);
|
||||
assertThat(dialog.getButton(Dialog.BUTTON_POSITIVE).isEnabled()).isEqualTo(expected);
|
||||
}
|
||||
|
Reference in New Issue
Block a user