diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/FormHierarchyTest.java b/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/FormHierarchyTest.java index be0a8b90bae..fe97c9a8ae1 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/FormHierarchyTest.java +++ b/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/FormHierarchyTest.java @@ -187,4 +187,17 @@ public void showRepeatsPickerWhenFirstRepeatIsEmpty() { .clickGoUpIcon() .assertTexts("Repeat", "Repeatable Group"); } + + @Test + //https://github.com/getodk/collect/issues/6015 + public void regularGroupThatWrapsARepeatableGroupShouldBeTreatedAsARegularOne() { + rule.startAtMainMenu() + .copyForm("repeat_group_wrapped_with_a_regular_group.xml") + .startBlankForm("Repeat group wrapped with a regular group") + .clickGoToArrow() + .clickGoUpIcon() + .clickGoUpIcon() + .assertPath("Outer") + .assertNotRemovableGroup(); + } } diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/FormStylingTest.kt b/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/FormStylingTest.kt index c77b843e437..8af8bb9dc84 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/FormStylingTest.kt +++ b/collect_app/src/androidTest/java/org/odk/collect/android/feature/formentry/FormStylingTest.kt @@ -223,7 +223,7 @@ class FormStylingTest { .startBlankForm(FORM_NAME) .clickGoToArrow() .clickOnGroup("selectOneQuestions") - .assertText("selectOneQuestions") + .assertPath("selectOneQuestions") .clickOnQuestion("Select one widget") .assertText("selectOneQuestions") } diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/regression/FillBlankFormWithRepeatGroupTest.java b/collect_app/src/androidTest/java/org/odk/collect/android/regression/FillBlankFormWithRepeatGroupTest.java index 27ce731e2d2..685f63a0dab 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/regression/FillBlankFormWithRepeatGroupTest.java +++ b/collect_app/src/androidTest/java/org/odk/collect/android/regression/FillBlankFormWithRepeatGroupTest.java @@ -62,7 +62,7 @@ public void dynamicGroupLabel_should_beCalculatedProperly() { .swipeToNextQuestion("Photo") .assertText("gr1 > 1 > Person: 25") .clickGoToArrow() - .assertText("gr1 > 1 > Person: 25") + .assertPath("gr1 > 1 > Person: 25") .clickOnQuestion("Photo") .swipeToNextQuestionWithRepeatGroup("gr1") .clickOnDoNotAdd(new FormEntryPage("Repeat titles 1648")) @@ -71,7 +71,7 @@ public void dynamicGroupLabel_should_beCalculatedProperly() { .swipeToNextQuestion("Date") .assertText("Part1 > 1 > Xxx: SecondPart") .clickGoToArrow() - .assertText("Part1 > 1 > Xxx: SecondPart") + .assertPath("Part1 > 1 > Xxx: SecondPart") .clickOnQuestion("Date") .swipeToNextQuestion("Multi Select") .swipeToNextQuestionWithRepeatGroup("Part1") @@ -254,7 +254,7 @@ public void when_navigateOnHierarchyView_should_breadcrumbPathBeVisible() { .swipeToNextQuestion("Age") .inputText("3") .clickGoToArrow() - .assertText("People > 3 > Person: C") + .assertPath("People > 3 > Person: C") .clickGoUpIcon() .assertText("3.\u200E Person: C") .clickJumpEndButton() diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormHierarchyPage.java b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormHierarchyPage.java index 535519723e3..5b457e7b4fb 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormHierarchyPage.java +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/FormHierarchyPage.java @@ -40,6 +40,11 @@ public FormHierarchyPage assertOnPage() { return this; } + public FormHierarchyPage assertNotRemovableGroup() { + onView(withId(R.id.menu_delete_child)).check(doesNotExist()); + return this; + } + public FormHierarchyPage clickGoUpIcon() { onView(withId(R.id.menu_go_up)).perform(click()); return this; @@ -83,6 +88,11 @@ public FormHierarchyPage assertHierarchyItem(int position, String primaryText, S return this; } + public FormHierarchyPage assertPath(String text) { + onView(withId(R.id.pathtext)).check(matches(withText(text))); + return this; + } + public FormEntryPage clickOnQuestion(String questionLabel) { return clickOnQuestion(questionLabel, false); } diff --git a/collect_app/src/main/java/org/odk/collect/android/formhierarchy/FormHierarchyActivity.java b/collect_app/src/main/java/org/odk/collect/android/formhierarchy/FormHierarchyActivity.java index af32c04271a..9805ccaf458 100644 --- a/collect_app/src/main/java/org/odk/collect/android/formhierarchy/FormHierarchyActivity.java +++ b/collect_app/src/main/java/org/odk/collect/android/formhierarchy/FormHierarchyActivity.java @@ -333,7 +333,7 @@ private void updateOptionsMenu() { boolean isAtBeginning = screenIndex.isBeginningOfFormIndex() && !shouldShowRepeatGroupPicker(); boolean shouldShowPicker = shouldShowRepeatGroupPicker(); - boolean isInRepeat = formController.indexContainsRepeatableGroup(); + boolean isInRepeat = formController.indexContainsRepeatableGroup(screenIndex); boolean isGroupSizeLocked = shouldShowPicker ? isGroupSizeLocked(repeatGroupPickerIndex) : isGroupSizeLocked(screenIndex); @@ -494,15 +494,7 @@ protected void goUpLevel() { */ private CharSequence getCurrentPath() { FormController formController = formEntryViewModel.getFormController(); - FormIndex index = formController.getFormIndex(); - - // Step out to the enclosing group if the current index is something - // we don't want to display in the path (e.g. a question name or the - // very first group in a form which is auto-entered). - if (formController.getEvent(index) == FormEntryController.EVENT_QUESTION - || getPreviousLevel(index) == null) { - index = getPreviousLevel(index); - } + FormIndex index = screenIndex; List groups = new ArrayList<>(); @@ -622,7 +614,7 @@ private void refreshView(boolean isGoingUp) { groupPathTextView.setVisibility(View.VISIBLE); groupPathTextView.setText(getCurrentPath()); - if (formController.indexContainsRepeatableGroup() || shouldShowRepeatGroupPicker()) { + if (formController.indexContainsRepeatableGroup(screenIndex) || shouldShowRepeatGroupPicker()) { groupIcon.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_repeat)); } else { groupIcon.setImageDrawable(ContextCompat.getDrawable(this, R.drawable.ic_folder_open)); diff --git a/collect_app/src/main/java/org/odk/collect/android/javarosawrapper/FormController.kt b/collect_app/src/main/java/org/odk/collect/android/javarosawrapper/FormController.kt index 0b2bbb4a0e9..641fa401ebc 100644 --- a/collect_app/src/main/java/org/odk/collect/android/javarosawrapper/FormController.kt +++ b/collect_app/src/main/java/org/odk/collect/android/javarosawrapper/FormController.kt @@ -275,6 +275,8 @@ interface FormController { */ fun indexContainsRepeatableGroup(): Boolean + fun indexContainsRepeatableGroup(formIndex: FormIndex?): Boolean + /** * The count of the closest group that repeats or -1. */ diff --git a/collect_app/src/main/java/org/odk/collect/android/javarosawrapper/JavaRosaFormController.java b/collect_app/src/main/java/org/odk/collect/android/javarosawrapper/JavaRosaFormController.java index ae9185234e3..ac0e713d23e 100644 --- a/collect_app/src/main/java/org/odk/collect/android/javarosawrapper/JavaRosaFormController.java +++ b/collect_app/src/main/java/org/odk/collect/android/javarosawrapper/JavaRosaFormController.java @@ -904,7 +904,11 @@ public FormEntryCaption[] getGroupsForCurrentIndex() { } public boolean indexContainsRepeatableGroup() { - FormEntryCaption[] groups = getCaptionHierarchy(); + return indexContainsRepeatableGroup(getFormIndex()); + } + + public boolean indexContainsRepeatableGroup(FormIndex formIndex) { + FormEntryCaption[] groups = getCaptionHierarchy(formIndex); if (groups.length == 0) { return false; } diff --git a/collect_app/src/test/java/org/odk/collect/android/utilities/StubFormController.kt b/collect_app/src/test/java/org/odk/collect/android/utilities/StubFormController.kt index f51061853d3..5e7ac9f0d0c 100644 --- a/collect_app/src/test/java/org/odk/collect/android/utilities/StubFormController.kt +++ b/collect_app/src/test/java/org/odk/collect/android/utilities/StubFormController.kt @@ -135,6 +135,8 @@ open class StubFormController : FormController { override fun indexContainsRepeatableGroup(): Boolean = false + override fun indexContainsRepeatableGroup(formIndex: FormIndex?): Boolean = false + override fun getLastRepeatedGroupRepeatCount(): Int = -1 override fun getLastRepeatedGroupName(): String? = null diff --git a/test-forms/src/main/resources/forms/repeat_group_wrapped_with_a_regular_group.xml b/test-forms/src/main/resources/forms/repeat_group_wrapped_with_a_regular_group.xml new file mode 100644 index 00000000000..58c10696645 --- /dev/null +++ b/test-forms/src/main/resources/forms/repeat_group_wrapped_with_a_regular_group.xml @@ -0,0 +1,45 @@ + + + + Repeat group wrapped with a regular group + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file