use of com.google.samples.apps.topeka.model.quiz.TrueFalseQuiz in project android-topeka by googlesamples.
the class CategoryAndroidTest method getQuizzes.
private static List<Quiz> getQuizzes() {
List<Quiz> quizzes = new ArrayList<>();
quizzes.add(new TrueFalseQuiz("huh?", true, false));
quizzes.add(new FillBlankQuiz("so?", "yeah", "go", "stop", false));
return quizzes;
}
use of com.google.samples.apps.topeka.model.quiz.TrueFalseQuiz in project android-topeka by googlesamples.
the class SolveQuizUtil method solveQuiz.
/**
* Solves a given quiz.
*
* @param quiz Quiz to solve.
*/
public static void solveQuiz(Quiz quiz) {
switch(quiz.getType()) {
case ALPHA_PICKER:
setAlphaPickerProgress((AlphaPickerQuiz) quiz);
break;
case PICKER:
setPickerProgress((PickerQuiz) quiz);
break;
case FILL_BLANK:
FillBlankQuiz fillBlankQuiz = (FillBlankQuiz) quiz;
String siblingText = fillBlankQuiz.getStart();
if (TextUtils.isEmpty(siblingText)) {
siblingText = fillBlankQuiz.getEnd();
}
int viewId = R.id.quiz_edit_text;
if (TextUtils.isEmpty(siblingText)) {
siblingText = quiz.getQuestion();
viewId = R.id.quiz_content;
}
typeAndCloseOnView(fillBlankQuiz.getAnswer(), siblingText, viewId);
break;
case FILL_TWO_BLANKS:
FillTwoBlanksQuiz fillTwoBlanksQuiz = (FillTwoBlanksQuiz) quiz;
typeAndCloseOnView(fillTwoBlanksQuiz.getAnswer()[0], R.id.quiz_edit_text);
typeAndCloseOnView(fillTwoBlanksQuiz.getAnswer()[1], R.id.quiz_edit_text_two);
break;
case FOUR_QUARTER:
testOptionsQuizWithType(quiz, GridView.class);
break;
case SINGLE_SELECT:
case SINGLE_SELECT_ITEM:
case MULTI_SELECT:
testOptionsQuizWithType(quiz, ListView.class);
break;
case TOGGLE_TRANSLATE:
ToggleTranslateQuiz toggleTranslateQuiz = (ToggleTranslateQuiz) quiz;
for (int i : toggleTranslateQuiz.getAnswer()) {
onData(equalTo(toggleTranslateQuiz.getReadableOptions()[i])).inAdapterView(allOf(instanceOf(AdapterView.class), withId(R.id.quiz_content), hasSiblingWith(quiz.getQuestion()))).perform(click());
}
break;
case TRUE_FALSE:
TrueFalseQuiz trueFalseQuiz = (TrueFalseQuiz) quiz;
onView(allOf(isDescendantOfA(hasSibling(withText(quiz.getQuestion()))), withText(trueFalseQuiz.getAnswer() ? R.string.btn_true : R.string.btn_false))).perform(click());
break;
}
}
Aggregations