private CommandResponse clickOnActionBarItem(String[] params) { String command = "the command click on actionbar item: "; CommandResponse result = new CommandResponse(); try { solo.clickOnActionBarItem(Integer.parseInt(params[0])); result.setSucceeded(true); result.setResponse("Unable to tell whether the action suceeded or not"); } catch (Throwable e) { result = handleException(command, e); } return result; }
/** * The first walkthrough. Documented on the wiki. Starts on the login, ends up navigating to a * lesson after logging in. */ @Test public void testWalkthroughLoginToDashboardToCoursesToCourseToLesson() { // Login first EditText user = solo.getEditText(0); EditText pass = solo.getEditText(1); solo.typeText(user, "*****@*****.**"); solo.typeText(pass, "password"); solo.clickOnButton(solo.getString(com.huskysoft.eduki.R.string.login)); // Need to sleep to allow the activity to finish solo.sleep(8000); solo.assertCurrentActivity("Wrong activity", MainActivity.class); // Click on the all courses button solo.clickOnActionBarItem(com.huskysoft.eduki.R.id.action_courses); solo.sleep(1000); solo.assertCurrentActivity("Did not start the Course list Activity", CoursesListActivity.class); // Wait for the courses list to appear solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.courseListView)); solo.sleep(1000); List<Course> courseList = ((CoursesListActivity) solo.getCurrentActivity()).getCourseList(); assertNotSame(courseList.size(), 0); solo.clickOnText("INTRODUCTION"); solo.assertCurrentActivity("Wrong activity", CourseActivity.class); // Wait for the course page to appear solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.course_activity)); solo.sleep(1000); // Click a lesson, wait for it to appear List<Lesson> lessonList = ((CourseActivity) solo.getCurrentActivity()).getLessonList(); assertNotSame(lessonList.size(), 0); solo.clickOnText(lessonList.get(0).toString()); solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.lessonViewLayoutText)); solo.sleep(1000); String content = ((TextView) solo.getCurrentActivity() .findViewById(com.huskysoft.eduki.R.id.lessonViewLayoutText)) .getText() .toString(); assertFalse(content.equals("")); }
/** * The second test, documented on the wiki. Starts on login. Does not login, instead navigates to * a course list and ends up at a quiz. */ @Test public void testWalkthroughLoginToCoursesListToCourseToQuiz() { // Need to sleep to allow the activity to finish solo.clickOnActionBarItem(com.huskysoft.eduki.R.id.action_courses); solo.sleep(1000); solo.assertCurrentActivity("Did not start the Course list Activity", CoursesListActivity.class); // Wait for the courses list to appear solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.courseListView)); solo.sleep(1000); List<Course> courseList = ((CoursesListActivity) solo.getCurrentActivity()).getCourseList(); assertNotSame(courseList.size(), 0); solo.clickOnText("INTRODUCTION"); solo.assertCurrentActivity("Wrong activity", CourseActivity.class); // Wait for the course page to appear solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.course_activity)); solo.sleep(1000); // Click a quiz, wait for it to appear List<Quiz> quizList = ((CourseActivity) solo.getCurrentActivity()).getQuizList(); assertNotSame(quizList.size(), 0); solo.clickOnText(quizList.get(0).toString()); solo.waitForView(solo.getView(com.huskysoft.eduki.R.id.quizScrollView)); solo.sleep(2000); // Sleep to wait for the answers to populate List<RadioGroup> answersGroupList = ((QuizzesViewActivity) solo.getCurrentActivity()).getAnswerGroup(); for (int i = 0; i < answersGroupList.size(); i++) { RadioGroup current_rg = answersGroupList.get(i); List<RadioButton> list_rb = getRadioButtons(current_rg); assertTrue(list_rb.size() != 0); solo.clickOnView(list_rb.get(0)); // Answer "A" for everything solo.sleep(500); } solo.sleep(1000); solo.clickOnButton("SUBMIT"); solo.waitForActivity(QuizzesResultsActivity.class); solo.assertCurrentActivity("Wrong activity", QuizzesResultsActivity.class); }