コード例 #1
0
  @Override
  protected void setUp() throws Exception {
    super.setUp();

    if (!GenymotionManager.isGenymotionDevice()) {
      // Avoid test on non Genymotion devices.
      return;
    }

    // Change IMEI before creating activity as the imei is read inside onStart()
    GenymotionManager genymotion;
    genymotion = GenymotionManager.getGenymotionManager(getInstrumentation().getTargetContext());
    // Faking a Google Nexus 4
    genymotion.getRadio().setDeviceId("353918050000000");

    // Add parameter to allow activity to start and create fragment RadioSampleFragment.
    Intent radioIntent;
    radioIntent = new Intent(getInstrumentation().getTargetContext(), SampleActivity.class);
    radioIntent.putExtra(SampleActivity.ARG_ITEM_ID, RadioSampleFragment.TAG);
    setActivityIntent(radioIntent);

    // Create activity and get fragment back
    FragmentManager fragmentManager = getActivity().getSupportFragmentManager();
    fragmentRadio =
        (RadioSampleFragment) fragmentManager.findFragmentByTag(RadioSampleFragment.TAG);
  }
コード例 #2
0
  public void testDeviceId() {

    if (!GenymotionManager.isGenymotionDevice()) {
      // Avoid test on non Genymotion devices.
      return;
    }

    TextView tvDeviceType =
        (TextView) fragmentRadio.getView().findViewById(R.id.tv_radioDeviceType);
    String text = tvDeviceType.getText().toString();
    Assert.assertTrue(text.endsWith("Nexus 4"));
  }