コード例 #1
0
        @Override
        protected void afterActivityLaunched() {
          super.afterActivityLaunched();
          SelectTasksActivity sa = getActivity();

          // Setting up an adapter with test data
          Calendar cal = Calendar.getInstance();
          Task t = new Task("01", "Clean up", 60, cal, cal.getTimeInMillis(), cal, 30);
          ArrayList<Task> arrayList = new ArrayList<Task>();
          arrayList.add(t);
          SelectTasksAdapter adapter = new SelectTasksAdapter(getActivity(), arrayList);
          adapter.notifyDataSetChanged();

          // Setting the activity to use the adapter with test data
          sa.setAdapter(adapter);
        }
コード例 #2
0
  @Test
  public void testSelectMultipleActivities() {
    String activityName1 = "Test Activity 1";
    String activityName2 = "Test Activity 2";
    Calendar cal = Calendar.getInstance();
    Task t1 = new Task("01", activityName1, 60, cal, cal.getTimeInMillis(), cal, 30);
    Task t2 = new Task("01", activityName2, 60, cal, cal.getTimeInMillis(), cal, 30);
    ArrayList<Task> arrayList = new ArrayList<Task>();
    arrayList.add(t1);
    arrayList.add(t2);
    SelectTasksAdapter adapter = new SelectTasksAdapter(ctx, arrayList);
    adapter.notifyDataSetChanged();

    // Setting the activity to use the adapter with test data
    SelectTasksActivity sa = main.getActivity();
    sa.setAdapter(adapter);

    // check activity 1 is added in listView
    onView(withId(R.id.select_tasks_recycler_view))
        .check(matches(hasDescendant(withText(activityName1))));
    onView(withText(activityName1)).perform(click());

    // check activity 2 is added in listView
    onView(withId(R.id.select_tasks_recycler_view))
        .check(matches(hasDescendant(withText(activityName2))));
    onView(withText(activityName2)).perform(click());

    // check toast is displayed
    onView(withId(R.id.action_done)).perform(click());

    // Set a progress of 10 to the activity
    onView(withId(R.id.add_time_to_task_seekbar)).perform(setProgress(1));

    // Press next button
    onView(withId(R.id.add_time_to_task_nextBtn)).perform(click());

    // Set a progress of 10 to the activity
    onView(withId(R.id.add_time_to_task_seekbar)).perform(setProgress(1));

    // Press next button
    onView(withId(R.id.add_time_to_task_nextBtn)).perform(click());
  }