mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-04-03 15:22:11 -04:00
Fix tests
This commit is contained in:
@@ -153,27 +153,19 @@ public class LoyaltyCardViewActivityTest
|
||||
final Button startButton = activity.findViewById(R.id.enterButton);
|
||||
startButton.performClick();
|
||||
|
||||
Dialog dialog = ShadowDialog.getLatestDialog();
|
||||
ShadowDialog shadowDialog = shadowOf(dialog);
|
||||
shadowDialog.clickOn(R.id.add_from_camera);
|
||||
|
||||
ShadowActivity.IntentForResult intentForResult = shadowOf(activity).peekNextStartedActivityForResult();
|
||||
assertNotNull(intentForResult);
|
||||
|
||||
Intent intent = intentForResult.intent;
|
||||
assertNotNull(intent);
|
||||
|
||||
String action = intent.getAction();
|
||||
assertNotNull(action);
|
||||
assertEquals(Intents.Scan.ACTION, action);
|
||||
|
||||
Bundle bundle = intent.getExtras();
|
||||
assertNotNull(bundle);
|
||||
|
||||
Intent resultIntent = new Intent(intent);
|
||||
Bundle resultBundle = new Bundle();
|
||||
resultBundle.putString(Intents.Scan.RESULT, BARCODE_DATA);
|
||||
resultBundle.putString(Intents.Scan.RESULT_FORMAT, BARCODE_TYPE);
|
||||
resultBundle.putString(BarcodeSelectorActivity.BARCODE_CONTENTS, BARCODE_DATA);
|
||||
resultBundle.putString(BarcodeSelectorActivity.BARCODE_FORMAT, BARCODE_TYPE);
|
||||
resultIntent.putExtras(resultBundle);
|
||||
|
||||
// Respond to image capture, success
|
||||
@@ -193,14 +185,20 @@ public class LoyaltyCardViewActivityTest
|
||||
final Button startButton = activity.findViewById(R.id.enterButton);
|
||||
startButton.performClick();
|
||||
|
||||
Dialog dialog = ShadowDialog.getLatestDialog();
|
||||
ShadowDialog shadowDialog = shadowOf(dialog);
|
||||
shadowDialog.clickOn(R.id.add_manually);
|
||||
|
||||
ShadowActivity.IntentForResult intentForResult = shadowOf(activity).peekNextStartedActivityForResult();
|
||||
Intent intent = intentForResult.intent;
|
||||
assertNotNull(intent);
|
||||
assertEquals(intent.getComponent().getClassName(), ScanActivity.class.getCanonicalName());
|
||||
|
||||
Activity newActivity = Robolectric.buildActivity(ScanActivity.class, intent).create().get();
|
||||
|
||||
final Button manualButton = newActivity.findViewById(R.id.add_manually);
|
||||
manualButton.performClick();
|
||||
|
||||
intentForResult = shadowOf(activity).peekNextStartedActivityForResult();
|
||||
assertNotNull(intentForResult);
|
||||
|
||||
Intent intent = intentForResult.intent;
|
||||
intent = intentForResult.intent;
|
||||
assertNotNull(intent);
|
||||
|
||||
Bundle bundle = intent.getExtras();
|
||||
|
||||
@@ -21,6 +21,7 @@ import org.robolectric.Robolectric;
|
||||
import org.robolectric.RobolectricTestRunner;
|
||||
import org.robolectric.annotation.Config;
|
||||
import org.robolectric.android.controller.ActivityController;
|
||||
import org.robolectric.shadows.ShadowActivity;
|
||||
import org.robolectric.shadows.ShadowAlertDialog;
|
||||
import org.robolectric.shadows.ShadowDialog;
|
||||
|
||||
@@ -73,16 +74,14 @@ public class MainActivityTest
|
||||
}
|
||||
|
||||
@Test
|
||||
public void clickAddLaunchesAddDialog()
|
||||
public void clickAddStartsScan()
|
||||
{
|
||||
final MainActivity activity = Robolectric.setupActivity(MainActivity.class);
|
||||
|
||||
activity.findViewById(R.id.fabAdd).performClick();
|
||||
|
||||
Dialog dialog = ShadowDialog.getLatestDialog();
|
||||
ShadowDialog shadowDialog = shadowOf(dialog);
|
||||
|
||||
assertEquals("Add Card", shadowDialog.getTitle());
|
||||
ShadowActivity shadowActivity = shadowOf(activity);
|
||||
assertEquals(shadowActivity.peekNextStartedActivityForResult().intent.getComponent(), new ComponentName(activity, ScanActivity.class));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user