Android Open Source - Timetable Event Add Activity Test Case






From Project

Back to project page Timetable.

License

The source code is released under:

GNU General Public License

If you think the Android project Timetable listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.timetable.android.uitests;
// w  w  w .  ja  v  a 2 s.  c o  m
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.TimeZone;

import org.holoeverywhere.widget.EditText;

import android.content.Context;
import android.content.Intent;
import android.test.ActivityInstrumentationTestCase2;
import android.test.RenamingDelegatingContext;
import android.test.UiThreadTest;
import android.view.View;

import com.timetable.android.R;
import com.timetable.android.activities.EventAddActivity;

public class EventAddActivityTestCase extends ActivityInstrumentationTestCase2<EventAddActivity> {
  
  private SimpleDateFormat dateTimeFormat = new SimpleDateFormat("dd.MM.yyyy HH:mm");
  
  private Calendar initDate;
  
  private Context mContext;
  
  private EventAddActivity mActivity;
  
  
  
  public EventAddActivityTestCase() {
    super(EventAddActivity.class);
  }

  @Override
  public void setUp() {
    initDate = Calendar.getInstance();
    try {
      initDate.setTime(dateTimeFormat.parse("14.02.2014 23:27"));
    } catch (ParseException e) {
      fail(e.getMessage());
    }
    
    Intent i = new Intent();
    i.putExtra(EventAddActivity.EXTRA_DATE, EventAddActivity.INIT_DATE_FORMAT.format(initDate.getTime()));
    setActivityIntent(i);
    
    mContext = new RenamingDelegatingContext(getActivity(), "test_");
    mActivity = getActivity();
    
    
    
  }
  
  private String getFieldText(int fieldId) {
    return ((EditText) mActivity.findViewById(fieldId)).getText().toString();
  }
  
  public void testInitValues() {
    assertNotNull(mActivity);
    assertNotNull(mActivity.getIntent().getExtras());
    assertEquals("14.02.2014", getFieldText(R.id.event_add_date_val));
    assertEquals("00:00", getFieldText(R.id.event_add_start_time_val));
    assertEquals("01:00", getFieldText(R.id.event_add_end_time_val));
    assertEquals("", getFieldText(R.id.event_add_name_val));
    assertEquals("", getFieldText(R.id.event_add_place_val));
    assertEquals("", getFieldText(R.id.event_add_note_val));
    assertEquals(mContext.getResources().getString(R.string.event_add_interval_init_value), getFieldText(R.id.event_period_interval_val));
    boolean [] initWeekOccurances = mActivity.getEventPeriodWeekOccurrences(); 
    assertEquals(true, initWeekOccurances[initDate.get(Calendar.DAY_OF_WEEK) - 1]);
  
    
  }
  
  @UiThreadTest
  public void testViewVisibility() {
    assertEquals(View.GONE, mActivity.findViewById(R.id.event_period_interval_text_left).getVisibility());
    assertEquals(View.GONE, mActivity.findViewById(R.id.event_period_interval_text_right).getVisibility());
    assertEquals(View.GONE, mActivity.findViewById(R.id.event_period_interval_val).getVisibility());
    assertEquals(View.GONE, mActivity.findViewById(R.id.event_period_end_date_spinner).getVisibility());
    assertEquals(View.GONE, mActivity.findViewById(R.id.event_period_end_date_val).getVisibility());
    
  }
  
}




Java Source Code List

com.timetable.android.AlarmSoundPreference.java
com.timetable.android.BroadcastActions.java
com.timetable.android.DeviceMuteService.java
com.timetable.android.EventBroadcastSender.java
com.timetable.android.EventChecker.java
com.timetable.android.EventController.java
com.timetable.android.EventPager.java
com.timetable.android.EventPeriod.java
com.timetable.android.EventService.java
com.timetable.android.EventViewProvider.java
com.timetable.android.EventView.java
com.timetable.android.Event.java
com.timetable.android.IllegalEventDataException.java
com.timetable.android.Logger.java
com.timetable.android.ServiceStarter.java
com.timetable.android.TimetableApp.java
com.timetable.android.TimetableDatabase.java
com.timetable.android.activities.EventAddActivity.java
com.timetable.android.activities.EventCopyActivity.java
com.timetable.android.activities.EventDayViewActivity.java
com.timetable.android.activities.EventEditActivity.java
com.timetable.android.activities.SettingsActivity.java
com.timetable.android.alarm.AlarmDialogActivity.java
com.timetable.android.alarm.AlarmService.java
com.timetable.android.alarm.EventAlarm.java
com.timetable.android.uitests.AlarmDialogActivityTestCase.java
com.timetable.android.uitests.EventAddActivityTestCase.java
com.timetable.android.uitests.TimetableUiTestCase.java
com.timetable.android.utils.DateFormatFactory.java
com.timetable.android.utils.DateUtils.java
com.timetable.android.utils.FakeTimeProvider.java
com.timetable.android.utils.SimpleTimeProvider.java
com.timetable.android.utils.TestAlarmStarter.java
com.timetable.android.utils.TimeProvider.java
com.timetable.android.utils.Utils.java