@Test
  public void testAddItem() {

    ArrayList<GroceryItem> items = _activity.getItemsDisplayed();
    int count = items.size();

    _btnAdd.performClick();

    try {

      _btnAdd.performClick();
      Intent data =
          super.targetActivityIsStarted(
              shadowOf(this._activity), EditMasterItemActivity.class.getName());
      assert (data != null);

      GroceryItem item = saveGroceryItemValues(data);
      _activity.processActivityResult(BaseListActivity.ACTIVITY_ADD, Activity.RESULT_OK, data);
      ArrayList<GroceryItem> itemsDisplayed = _activity.getItemsDisplayed();

      assertTrue(itemsDisplayed.contains(item));
      _activity.saveList();
      items = _activity.loadGroceryItems(FileNameConstants.MasterFileName);
      assertEquals(count + 1, items.size());

    } catch (Exception e) {
      fail("Exception testing adding of an empty category");
      // TODO Auto-generated catch block
      // e.printStackTrace();
    }
  }
Ejemplo n.º 2
0
 @Override
 protected void onActivityResult(int requestCode, int resultCode, Intent data) {
   super.onActivityResult(requestCode, resultCode, data);
   if (requestCode == SETTINGS_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
     loadSettings();
     if (locationName.equals(getText(R.string.text_current_location))) {
       locationButton.performClick();
     } else if (data.getBooleanExtra(SettingsActivity.EXTRA_NEED_UPDATE, false)
         || forecastScrollView.getChildCount() == 0) {
       weatherUpdated = false;
       satelliteUpdated = false;
       updateButton.performClick();
     }
   }
 }
Ejemplo n.º 3
0
 @Override
 public boolean onOptionsItemSelected(MenuItem item) {
   switch (item.getItemId()) {
     case MENU_ABOUT_ID:
       Dialog dialog =
           new AlertDialog.Builder(this)
               .setIcon(R.drawable.icon)
               .setTitle(R.string.app_name)
               .setMessage(R.string.app_about)
               .setPositiveButton(
                   R.string.btn_ok,
                   new OnClickListener() {
                     public void onClick(DialogInterface arg0, int arg1) {}
                   })
               .create();
       dialog.show();
       break;
     case MENU_PREFERENCE_ID:
       settingsButton.performClick();
       break;
     default:
       break;
   }
   return false;
 }
Ejemplo n.º 4
0
 @Test
 public void start_shouldStartRouting() throws Exception {
   fragment.createRouteToDestination();
   Route testRoute = new Route(getFixture("around_the_block"));
   fragment.success(testRoute);
   ImageButton startBtn = (ImageButton) fragment.getView().findViewById(R.id.routing_circle);
   startBtn.performClick();
   assertThat(activity.getSupportFragmentManager()).hasFragmentWithTag(RouteFragment.TAG);
 }
Ejemplo n.º 5
0
 @Override
 public void onLocationUpdate(LocationInfo location, long costTime, int locator) {
   if (location == null) {
     return;
   }
   latitude = location.getLatitude();
   longitude = location.getLongitude();
   locationName = location.toString();
   userPrefs.setCurrentLocation(longitude, latitude, locationName);
   locationTextView.setText(String.format("%s (%.3f, %.3f)", locationName, longitude, latitude));
   weatherUpdated = false;
   satelliteUpdated = false;
   StatManager.getInstance().sendLocationStat(location, costTime, locator);
   updateButton.performClick();
 }