private void populateCourseList() { CourseContainer.instance().clear(); for (int i = 0; i < 9; i++) { Course course = new Course(); course.name = "Course #" + i; course.lecturer = "Our leader"; course.number = "course." + i; course.term = "SS"; course.type = "VO"; CourseContainer.instance().add(course); } }
@Override protected void setUp() throws Exception { super.setUp(); populateCourseList(); UpdateService.setCrawlerToUse(SimpleMockCrawler.class); solo = new Solo(getInstrumentation(), getActivity()); DailyListener.setNewPendingIntentAndCancelOld(getActivity(), null); // Cancel schedule CourseContainer.instance().deleteObservers(); PreferenceManager.getDefaultSharedPreferences(getActivity()) .edit() .clear() .commit(); // Reset default preferences!! PreferenceManager.setDefaultValues(getActivity(), R.xml.preferences, true); }
public void testCourseDetails() { Course course = CourseContainer.instance().get(0); course.exams = SimpleMockCrawler.createExams(course); solo.clickOnText("Course #0"); assertEquals(course.name, ((TextView) solo.getView(R.id.course_name, 0)).getText()); View exam_view; exam_view = solo.getView(R.id.exam_item, 0); assertEquals("Course #0", ((TextView) exam_view.findViewById(R.id.course_text)).getText()); solo.goBack(); }
public void testAddCourse() { if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { PreferenceManager.getDefaultSharedPreferences(getActivity()) .edit() .putBoolean("pref_use_android_calendar", true) .putString("pref_android_calendar_to_use", "1") .commit(); } UpdateService.setCrawlerToUse(SimpleMockCrawler.class); solo.clickOnView(getActivity().findViewById(R.id.add)); int oldsize = CourseContainer.instance().size(); solo.clickOnEditText(0); solo.enterText(0, "Course"); solo.clickOnEditText(0); solo.sendKey(Solo.ENTER); solo.waitForText("THE COURSE #2", 1, 5); solo.clickOnText("THE COURSE #2"); solo.waitForText("Courses", 1, 5); assertEquals(oldsize + 1, CourseContainer.instance().size()); assertTrue(solo.searchText("THE COURSE #2", 1, true)); Exam exam = CourseContainer.instance().get(CourseContainer.instance().size() - 1).exams.first(); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { assertFalse("Exam of added course should have a created event", exam.event_id == -1); } oldsize = CourseContainer.instance().size(); solo.clickOnView(getActivity().findViewById(R.id.add)); solo.enterText(0, "Course"); solo.clickOnEditText(0); solo.sendKey(Solo.ENTER); solo.waitForText("THE COURSE #2", 1, 5); solo.clickOnText("THE COURSE #2"); assertEquals( "You should not be able to add the same course twice", oldsize, CourseContainer.instance().size()); solo.goBack(); solo.goBack(); }