diff --git a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/ProjectSettingsDialogPage.kt b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/ProjectSettingsDialogPage.kt index 5ff3acb017a..aeaa8e6b38c 100644 --- a/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/ProjectSettingsDialogPage.kt +++ b/collect_app/src/androidTest/java/org/odk/collect/android/support/pages/ProjectSettingsDialogPage.kt @@ -21,39 +21,86 @@ internal class ProjectSettingsDialogPage : Page() { } fun clickSettings(): ProjectSettingsPage { - return clickOnButtonInDialog(org.odk.collect.strings.R.string.settings, ProjectSettingsPage()) + return clickOnButtonInDialog( + org.odk.collect.strings.R.string.settings, + ProjectSettingsPage() + ) } fun clickAbout(): AboutPage { - return clickOnButtonInDialog(org.odk.collect.strings.R.string.about_preferences, AboutPage()) + return clickOnButtonInDialog( + org.odk.collect.strings.R.string.about_preferences, + AboutPage() + ) } fun clickAddProject(): QrCodeProjectCreatorDialogPage { - return clickOnButtonInDialog(org.odk.collect.strings.R.string.add_project, QrCodeProjectCreatorDialogPage()) + return clickOnButtonInDialog( + org.odk.collect.strings.R.string.add_project, + QrCodeProjectCreatorDialogPage() + ) } fun assertCurrentProject(projectName: String, subtext: String): ProjectSettingsDialogPage { - onView(allOf(hasDescendant(withText(projectName)), hasDescendant(withText(subtext)), withContentDescription(getTranslatedString( - org.odk.collect.strings.R.string.using_project, projectName)))).check(matches(isDisplayed())) + onView( + allOf( + hasDescendant(withText(projectName)), + hasDescendant(withText(subtext)), + withContentDescription( + getTranslatedString( + org.odk.collect.strings.R.string.using_project, + projectName + ) + ) + ) + ).check(matches(isDisplayed())) return this } fun assertInactiveProject(projectName: String, subtext: String): ProjectSettingsDialogPage { - onView(allOf(hasDescendant(withText(projectName)), hasDescendant(withText(subtext)), withContentDescription(getTranslatedString( - org.odk.collect.strings.R.string.switch_to_project, projectName)))).check(matches(isDisplayed())) + onView( + allOf( + hasDescendant(withText(projectName)), + hasDescendant(withText(subtext)), + withContentDescription( + getTranslatedString( + org.odk.collect.strings.R.string.switch_to_project, + projectName + ) + ) + ) + ).check(matches(isDisplayed())) return this } fun assertNotInactiveProject(projectName: String): ProjectSettingsDialogPage { - onView(allOf(hasDescendant(withText(projectName)), withContentDescription(getTranslatedString( - org.odk.collect.strings.R.string.switch_to_project, projectName)))).check(doesNotExist()) + onView( + allOf( + hasDescendant(withText(projectName)), + withContentDescription( + getTranslatedString( + org.odk.collect.strings.R.string.switch_to_project, + projectName + ) + ) + ) + ).check(doesNotExist()) return this } fun selectProject(projectName: String): MainMenuPage { WaitFor.wait250ms() // https://github.com/android/android-test/issues/444 - onView(allOf(hasDescendant(withText(projectName)), withContentDescription(getTranslatedString( - org.odk.collect.strings.R.string.switch_to_project, projectName)))) + onView( + allOf( + hasDescendant(withText(projectName)), + withContentDescription( + getTranslatedString( + org.odk.collect.strings.R.string.switch_to_project, + projectName + ) + ) + ) + ) .inRoot(RootMatchers.isDialog()) .perform(click()) return MainMenuPage().assertOnPage() diff --git a/collect_app/src/main/java/org/odk/collect/android/activities/DeleteSavedFormActivity.kt b/collect_app/src/main/java/org/odk/collect/android/activities/DeleteSavedFormActivity.kt index 725411db572..2afcffec894 100644 --- a/collect_app/src/main/java/org/odk/collect/android/activities/DeleteSavedFormActivity.kt +++ b/collect_app/src/main/java/org/odk/collect/android/activities/DeleteSavedFormActivity.kt @@ -107,8 +107,11 @@ class DeleteSavedFormActivity : LocalizedActivity() { } TabLayoutMediator(binding.tabLayout, viewPager) { tab: TabLayout.Tab, position: Int -> - tab.text = if (position == 0) getString(org.odk.collect.strings.R.string.data) else getString( - org.odk.collect.strings.R.string.forms) + tab.text = if (position == 0) { + getString(org.odk.collect.strings.R.string.data) + } else { + getString(org.odk.collect.strings.R.string.forms) + } }.attach() } diff --git a/collect_app/src/main/java/org/odk/collect/android/configure/qr/QRCodeScannerFragment.kt b/collect_app/src/main/java/org/odk/collect/android/configure/qr/QRCodeScannerFragment.kt index 41f598dd40e..8519e1e1249 100644 --- a/collect_app/src/main/java/org/odk/collect/android/configure/qr/QRCodeScannerFragment.kt +++ b/collect_app/src/main/java/org/odk/collect/android/configure/qr/QRCodeScannerFragment.kt @@ -56,15 +56,27 @@ class QRCodeScannerFragment : BarCodeScannerFragment() { File(storagePathProvider.getProjectRootDirPath() + File.separator + newProjectName).createNewFile() } - showLongToast(requireContext(), getString(org.odk.collect.strings.R.string.successfully_imported_settings)) + showLongToast( + requireContext(), + getString(org.odk.collect.strings.R.string.successfully_imported_settings) + ) ActivityUtils.startActivityAndCloseAllOthers( requireActivity(), MainMenuActivity::class.java ) } - SettingsImportingResult.INVALID_SETTINGS -> showLongToast(requireContext(), getString( - org.odk.collect.strings.R.string.invalid_qrcode)) - SettingsImportingResult.GD_PROJECT -> showLongToast(requireContext(), getString(org.odk.collect.strings.R.string.settings_with_gd_protocol)) + + SettingsImportingResult.INVALID_SETTINGS -> showLongToast( + requireContext(), + getString( + org.odk.collect.strings.R.string.invalid_qrcode + ) + ) + + SettingsImportingResult.GD_PROJECT -> showLongToast( + requireContext(), + getString(org.odk.collect.strings.R.string.settings_with_gd_protocol) + ) } } diff --git a/collect_app/src/main/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialog.kt b/collect_app/src/main/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialog.kt index 356c6465f3a..098d3ac5850 100644 --- a/collect_app/src/main/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialog.kt +++ b/collect_app/src/main/java/org/odk/collect/android/projects/QrCodeProjectCreatorDialog.kt @@ -175,7 +175,10 @@ class QrCodeProjectCreatorDialog : R.id.menu_item_scan_sd_card -> { val photoPickerIntent = Intent(Intent.ACTION_GET_CONTENT) photoPickerIntent.type = "image/*" - intentLauncher.launchForResult(imageQrCodeImportResultLauncher, photoPickerIntent) { + intentLauncher.launchForResult( + imageQrCodeImportResultLauncher, + photoPickerIntent + ) { showShortToast( requireContext(), getString( @@ -249,7 +252,10 @@ class QrCodeProjectCreatorDialog : val settingsJson = try { CompressionUtils.decompress(barcodeResult.text) } catch (e: Exception) { - showShortToast(requireContext(), getString(org.odk.collect.strings.R.string.invalid_qrcode)) + showShortToast( + requireContext(), + getString(org.odk.collect.strings.R.string.invalid_qrcode) + ) "" } createProjectOrError(settingsJson) @@ -288,10 +294,20 @@ class QrCodeProjectCreatorDialog : ) ) } - SettingsImportingResult.INVALID_SETTINGS -> ToastUtils.showLongToast(requireContext(), getString( - org.odk.collect.strings.R.string.invalid_qrcode)) - SettingsImportingResult.GD_PROJECT -> ToastUtils.showLongToast(requireContext(), getString( - org.odk.collect.strings.R.string.settings_with_gd_protocol)) + + SettingsImportingResult.INVALID_SETTINGS -> ToastUtils.showLongToast( + requireContext(), + getString( + org.odk.collect.strings.R.string.invalid_qrcode + ) + ) + + SettingsImportingResult.GD_PROJECT -> ToastUtils.showLongToast( + requireContext(), + getString( + org.odk.collect.strings.R.string.settings_with_gd_protocol + ) + ) } } diff --git a/collect_app/src/test/java/org/odk/collect/android/external/FormUriActivityTest.kt b/collect_app/src/test/java/org/odk/collect/android/external/FormUriActivityTest.kt index aa2fb8de944..ca0f15ec6b4 100644 --- a/collect_app/src/test/java/org/odk/collect/android/external/FormUriActivityTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/external/FormUriActivityTest.kt @@ -116,7 +116,10 @@ class FormUriActivityTest { fun `When there are no projects then display alert dialog`() { val scenario = launcherRule.launchForResult(FormUriActivity::class.java) - assertErrorDialog(scenario, context.getString(org.odk.collect.strings.R.string.app_not_configured)) + assertErrorDialog( + scenario, + context.getString(org.odk.collect.strings.R.string.app_not_configured) + ) } @Test @@ -127,11 +130,25 @@ class FormUriActivityTest { projectsRepository.save(secondProject) whenever(currentProjectProvider.getCurrentProject()).thenReturn(firstProject) - val form = formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + val form = formsRepository.save( + FormUtils.buildForm( + "1", + "1", + TempFiles.createTempDir().absolutePath + ).build() + ) - val scenario = launcherRule.launchForResult(getBlankFormIntent(secondProject.uuid, form.dbId)) + val scenario = launcherRule.launchForResult( + getBlankFormIntent( + secondProject.uuid, + form.dbId + ) + ) - assertErrorDialog(scenario, context.getString(org.odk.collect.strings.R.string.wrong_project_selected_for_form)) + assertErrorDialog( + scenario, + context.getString(org.odk.collect.strings.R.string.wrong_project_selected_for_form) + ) } @Test @@ -142,11 +159,21 @@ class FormUriActivityTest { projectsRepository.save(secondProject) whenever(currentProjectProvider.getCurrentProject()).thenReturn(secondProject) - val form = formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + val form = formsRepository.save( + FormUtils.buildForm( + "1", + "1", + TempFiles.createTempDir().absolutePath + ).build() + ) - val scenario = launcherRule.launchForResult(getBlankFormIntent(null, form.dbId)) + val scenario = + launcherRule.launchForResult(getBlankFormIntent(null, form.dbId)) - assertErrorDialog(scenario, context.getString(org.odk.collect.strings.R.string.wrong_project_selected_for_form)) + assertErrorDialog( + scenario, + context.getString(org.odk.collect.strings.R.string.wrong_project_selected_for_form) + ) } @Test @@ -155,7 +182,13 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - val form = formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + val form = formsRepository.save( + FormUtils.buildForm( + "1", + "1", + TempFiles.createTempDir().absolutePath + ).build() + ) val scenario = launcherRule.launchForResult( getBlankFormIntent(project.uuid, form.dbId).apply { @@ -163,7 +196,10 @@ class FormUriActivityTest { } ) - assertErrorDialog(scenario, context.getString(org.odk.collect.strings.R.string.unrecognized_uri)) + assertErrorDialog( + scenario, + context.getString(org.odk.collect.strings.R.string.unrecognized_uri) + ) } @Test @@ -172,7 +208,13 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - val form = formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + val form = formsRepository.save( + FormUtils.buildForm( + "1", + "1", + TempFiles.createTempDir().absolutePath + ).build() + ) val scenario = launcherRule.launchForResult( getBlankFormIntent(project.uuid, form.dbId).apply { @@ -180,7 +222,10 @@ class FormUriActivityTest { } ) - assertErrorDialog(scenario, context.getString(org.odk.collect.strings.R.string.unrecognized_uri)) + assertErrorDialog( + scenario, + context.getString(org.odk.collect.strings.R.string.unrecognized_uri) + ) } @Test @@ -189,7 +234,8 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - val scenario = launcherRule.launchForResult(getBlankFormIntent(project.uuid, 1)) + val scenario = + launcherRule.launchForResult(getBlankFormIntent(project.uuid, 1)) assertErrorDialog(scenario, context.getString(org.odk.collect.strings.R.string.bad_uri)) } @@ -200,10 +246,21 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - val form = formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + val form = formsRepository.save( + FormUtils.buildForm( + "1", + "1", + TempFiles.createTempDir().absolutePath + ).build() + ) File(form.formFilePath).delete() - val scenario = launcherRule.launchForResult(getBlankFormIntent(project.uuid, form.dbId)) + val scenario = launcherRule.launchForResult( + getBlankFormIntent( + project.uuid, + form.dbId + ) + ) assertErrorDialog(scenario, context.getString(org.odk.collect.strings.R.string.bad_uri)) } @@ -214,7 +271,8 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - val scenario = launcherRule.launchForResult(getSavedIntent(project.uuid, 1)) + val scenario = + launcherRule.launchForResult(getSavedIntent(project.uuid, 1)) assertErrorDialog(scenario, context.getString(org.odk.collect.strings.R.string.bad_uri)) } @@ -225,7 +283,9 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + formsRepository.save( + FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build() + ) val instance = instancesRepository.save( Instance.Builder() @@ -237,10 +297,18 @@ class FormUriActivityTest { ) File(instance.instanceFilePath).delete() - val scenario = launcherRule.launchForResult(getSavedIntent(project.uuid, instance.dbId)) + val scenario = launcherRule.launchForResult( + getSavedIntent( + project.uuid, + instance.dbId + ) + ) assertThat(instancesRepository.get(instance.dbId), equalTo(null)) - assertErrorDialog(scenario, context.getString(org.odk.collect.strings.R.string.instance_deleted_message)) + assertErrorDialog( + scenario, + context.getString(org.odk.collect.strings.R.string.instance_deleted_message) + ) } @Test @@ -257,9 +325,17 @@ class FormUriActivityTest { .build() ) - val scenario = launcherRule.launchForResult(getSavedIntent(project.uuid, instance.dbId)) + val scenario = launcherRule.launchForResult( + getSavedIntent( + project.uuid, + instance.dbId + ) + ) - val expectedMessage = context.getString(org.odk.collect.strings.R.string.parent_form_not_present, instance.formId) + val expectedMessage = context.getString( + org.odk.collect.strings.R.string.parent_form_not_present, + instance.formId + ) assertErrorDialog(scenario, expectedMessage) } @@ -279,11 +355,19 @@ class FormUriActivityTest { .build() ) - val scenario = launcherRule.launchForResult(getSavedIntent(project.uuid, instance.dbId)) + val scenario = launcherRule.launchForResult( + getSavedIntent( + project.uuid, + instance.dbId + ) + ) val expectedMessage = context.getString( - org.odk.collect.strings.R.string.parent_form_not_present, "${instance.formId}\n${context.getString( - org.odk.collect.strings.R.string.version)} ${instance.formVersion}") + org.odk.collect.strings.R.string.parent_form_not_present, + "${instance.formId}\n${ + context.getString(org.odk.collect.strings.R.string.version) + } ${instance.formVersion}" + ) assertErrorDialog(scenario, expectedMessage) } @@ -294,8 +378,22 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath, FormUtils.createXFormBody("1", "1", "Form 1")).build()) - formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath, FormUtils.createXFormBody("1", "1", "Form 2")).build()) + formsRepository.save( + FormUtils.buildForm( + "1", + "1", + TempFiles.createTempDir().absolutePath, + FormUtils.createXFormBody("1", "1", "Form 1") + ).build() + ) + formsRepository.save( + FormUtils.buildForm( + "1", + "1", + TempFiles.createTempDir().absolutePath, + FormUtils.createXFormBody("1", "1", "Form 2") + ).build() + ) val instance = instancesRepository.save( Instance.Builder() @@ -306,9 +404,17 @@ class FormUriActivityTest { .build() ) - val scenario = launcherRule.launchForResult(getSavedIntent(project.uuid, instance.dbId)) + val scenario = launcherRule.launchForResult( + getSavedIntent( + project.uuid, + instance.dbId + ) + ) - assertErrorDialog(scenario, context.getString(org.odk.collect.strings.R.string.survey_multiple_forms_error)) + assertErrorDialog( + scenario, + context.getString(org.odk.collect.strings.R.string.survey_multiple_forms_error) + ) } @Test @@ -317,7 +423,14 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath, FormUtils.createXFormBody("1", "1", "Form 1")).build()) + formsRepository.save( + FormUtils.buildForm( + "1", + "1", + TempFiles.createTempDir().absolutePath, + FormUtils.createXFormBody("1", "1", "Form 1") + ).build() + ) val instance = instancesRepository.save( Instance.Builder() @@ -329,9 +442,17 @@ class FormUriActivityTest { .build() ) - val scenario = launcherRule.launchForResult(getSavedIntent(project.uuid, instance.dbId)) + val scenario = launcherRule.launchForResult( + getSavedIntent( + project.uuid, + instance.dbId + ) + ) - assertErrorDialog(scenario, context.getString(org.odk.collect.strings.R.string.encrypted_form)) + assertErrorDialog( + scenario, + context.getString(org.odk.collect.strings.R.string.encrypted_form) + ) } @Test @@ -342,7 +463,9 @@ class FormUriActivityTest { settingsProvider.getProtectedSettings().save(ProtectedProjectKeys.KEY_EDIT_SAVED, false) - formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + formsRepository.save( + FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build() + ) val instance = instancesRepository.save( Instance.Builder() @@ -366,7 +489,13 @@ class FormUriActivityTest { settingsProvider.getProtectedSettings().save(ProtectedProjectKeys.KEY_EDIT_SAVED, false) - val form = formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + val form = formsRepository.save( + FormUtils.buildForm( + "1", + "1", + TempFiles.createTempDir().absolutePath + ).build() + ) launcherRule.launchForResult(getBlankFormIntent(project.uuid, form.dbId)) @@ -379,7 +508,9 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + formsRepository.save( + FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build() + ) val instance = instancesRepository.save( Instance.Builder() @@ -401,7 +532,9 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + formsRepository.save( + FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build() + ) val instance = instancesRepository.save( Instance.Builder() @@ -423,7 +556,9 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + formsRepository.save( + FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build() + ) val instance = instancesRepository.save( Instance.Builder() @@ -445,9 +580,16 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - val form = formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + val form = formsRepository.save( + FormUtils.buildForm( + "1", + "1", + TempFiles.createTempDir().absolutePath + ).build() + ) - val scenario = launcherRule.launch(getBlankFormIntent(project.uuid, form.dbId)) + val scenario = + launcherRule.launch(getBlankFormIntent(project.uuid, form.dbId)) scenario.recreate() Intents.intended(hasComponent(FormFillingActivity::class.java.name), Intents.times(1)) @@ -459,7 +601,13 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - val form = formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + val form = formsRepository.save( + FormUtils.buildForm( + "1", + "1", + TempFiles.createTempDir().absolutePath + ).build() + ) launcherRule.launch(getBlankFormIntent(project.uuid, form.dbId)) @@ -472,7 +620,9 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + formsRepository.save( + FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build() + ) val instance = instancesRepository.save( Instance.Builder() @@ -494,7 +644,13 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - val form = formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + val form = formsRepository.save( + FormUtils.buildForm( + "1", + "1", + TempFiles.createTempDir().absolutePath + ).build() + ) launcherRule.launch(getBlankFormIntent(null, form.dbId)) @@ -507,7 +663,9 @@ class FormUriActivityTest { projectsRepository.save(project) whenever(currentProjectProvider.getCurrentProject()).thenReturn(project) - formsRepository.save(FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build()) + formsRepository.save( + FormUtils.buildForm("1", "1", TempFiles.createTempDir().absolutePath).build() + ) val instance = instancesRepository.save( Instance.Builder() @@ -592,7 +750,12 @@ class FormUriActivityTest { if (canBeEdited) { Intents.intended(not(hasExtraWithKey(ApplicationConstants.BundleKeys.FORM_MODE))) } else { - Intents.intended(hasExtra(ApplicationConstants.BundleKeys.FORM_MODE, ApplicationConstants.FormModes.VIEW_SENT)) + Intents.intended( + hasExtra( + ApplicationConstants.BundleKeys.FORM_MODE, + ApplicationConstants.FormModes.VIEW_SENT + ) + ) } Intents.intended(hasExtra("KEY_1", "Text")) } diff --git a/collect_app/src/test/java/org/odk/collect/android/formentry/FormEndViewTest.kt b/collect_app/src/test/java/org/odk/collect/android/formentry/FormEndViewTest.kt index 48767c68578..47139913ca3 100644 --- a/collect_app/src/test/java/org/odk/collect/android/formentry/FormEndViewTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/formentry/FormEndViewTest.kt @@ -29,21 +29,35 @@ class FormEndViewTest { @Test fun `form title is displayed correctly`() { val view = FormEndView(context, "blah", formEndViewModel, listener) - assertThat(view.findViewById(R.id.description).text, equalTo(context.getString(org.odk.collect.strings.R.string.save_enter_data_description, "blah"))) + assertThat( + view.findViewById(R.id.description).text, + equalTo( + context.getString( + org.odk.collect.strings.R.string.save_enter_data_description, + "blah" + ) + ) + ) } @Test fun `when saving drafts is enabled in settings should 'Save as draft' button be visible`() { whenever(formEndViewModel.isSaveDraftEnabled()).thenReturn(true) val view = FormEndView(context, "blah", formEndViewModel, listener) - assertThat(view.findViewById(R.id.save_as_draft).visibility, equalTo(View.VISIBLE)) + assertThat( + view.findViewById(R.id.save_as_draft).visibility, + equalTo(View.VISIBLE) + ) } @Test fun `when saving drafts is disabled in settings should 'Save as draft' button be hidden`() { whenever(formEndViewModel.isSaveDraftEnabled()).thenReturn(false) val view = FormEndView(context, "blah", formEndViewModel, listener) - assertThat(view.findViewById(R.id.save_as_draft).visibility, equalTo(View.GONE)) + assertThat( + view.findViewById(R.id.save_as_draft).visibility, + equalTo(View.GONE) + ) } @Test @@ -58,7 +72,10 @@ class FormEndViewTest { fun `when finalizing forms is enabled in settings should 'Finalize' button be visible`() { whenever(formEndViewModel.isFinalizeEnabled()).thenReturn(true) val view = FormEndView(context, "blah", formEndViewModel, listener) - assertThat(view.findViewById(R.id.finalize).visibility, equalTo(View.VISIBLE)) + assertThat( + view.findViewById(R.id.finalize).visibility, + equalTo(View.VISIBLE) + ) } @Test @@ -80,16 +97,24 @@ class FormEndViewTest { fun `when form should not be sent automatically then 'Finalize' button should be displayed`() { whenever(formEndViewModel.shouldFormBeSentAutomatically()).thenReturn(false) val view = FormEndView(context, "blah", formEndViewModel, listener) - assertThat(view.findViewById(R.id.finalize).text, equalTo(context.getString( - org.odk.collect.strings.R.string.finalize))) + assertThat( + view.findViewById(R.id.finalize).text, + equalTo(context.getString(org.odk.collect.strings.R.string.finalize)) + ) } @Test fun `when form should be sent automatically then 'Send' button should be displayed`() { whenever(formEndViewModel.shouldFormBeSentAutomatically()).thenReturn(true) val view = FormEndView(context, "blah", formEndViewModel, listener) - assertThat(view.findViewById(R.id.finalize).text, equalTo(context.getString( - org.odk.collect.strings.R.string.send))) + assertThat( + view.findViewById(R.id.finalize).text, + equalTo( + context.getString( + org.odk.collect.strings.R.string.send + ) + ) + ) } @Test @@ -98,7 +123,10 @@ class FormEndViewTest { val view = FormEndView(context, "blah", formEndViewModel, listener) - assertThat(view.findViewById(R.id.form_edits_warning).visibility, equalTo(View.GONE)) + assertThat( + view.findViewById(R.id.form_edits_warning).visibility, + equalTo(View.GONE) + ) } @Test @@ -107,9 +135,18 @@ class FormEndViewTest { val view = FormEndView(context, "blah", formEndViewModel, listener) - assertThat(view.findViewById(R.id.form_edits_warning).visibility, equalTo(View.VISIBLE)) - assertThat(view.findViewById(R.id.form_edits_warning_message).text, equalTo(context.getString( - org.odk.collect.strings.R.string.form_edits_warning_only_finalize_enabled))) + assertThat( + view.findViewById(R.id.form_edits_warning).visibility, + equalTo(View.VISIBLE) + ) + assertThat( + view.findViewById(R.id.form_edits_warning_message).text, + equalTo( + context.getString( + org.odk.collect.strings.R.string.form_edits_warning_only_finalize_enabled + ) + ) + ) } @Test @@ -119,7 +156,10 @@ class FormEndViewTest { val view = FormEndView(context, "blah", formEndViewModel, listener) - assertThat(view.findViewById(R.id.form_edits_warning).visibility, equalTo(View.GONE)) + assertThat( + view.findViewById(R.id.form_edits_warning).visibility, + equalTo(View.GONE) + ) } @Test @@ -129,9 +169,18 @@ class FormEndViewTest { val view = FormEndView(context, "blah", formEndViewModel, listener) - assertThat(view.findViewById(R.id.form_edits_warning).visibility, equalTo(View.VISIBLE)) - assertThat(view.findViewById(R.id.form_edits_warning_message).text, equalTo(context.getString( - org.odk.collect.strings.R.string.form_edits_warning_save_as_draft_and_finalize_enabled))) + assertThat( + view.findViewById(R.id.form_edits_warning).visibility, + equalTo(View.VISIBLE) + ) + assertThat( + view.findViewById(R.id.form_edits_warning_message).text, + equalTo( + context.getString( + org.odk.collect.strings.R.string.form_edits_warning_save_as_draft_and_finalize_enabled + ) + ) + ) } @Test @@ -142,8 +191,17 @@ class FormEndViewTest { val view = FormEndView(context, "blah", formEndViewModel, listener) - assertThat(view.findViewById(R.id.form_edits_warning).visibility, equalTo(View.VISIBLE)) - assertThat(view.findViewById(R.id.form_edits_warning_message).text, equalTo(context.getString( - org.odk.collect.strings.R.string.form_edits_warning_save_as_draft_and_finalize_with_auto_send_enabled))) + assertThat( + view.findViewById(R.id.form_edits_warning).visibility, + equalTo(View.VISIBLE) + ) + assertThat( + view.findViewById(R.id.form_edits_warning_message).text, + equalTo( + context.getString( + org.odk.collect.strings.R.string.form_edits_warning_save_as_draft_and_finalize_with_auto_send_enabled + ) + ) + ) } } diff --git a/collect_app/src/test/java/org/odk/collect/android/utilities/FormsDownloadResultInterpreterTest.kt b/collect_app/src/test/java/org/odk/collect/android/utilities/FormsDownloadResultInterpreterTest.kt index bccacace31e..8ce8deeda40 100644 --- a/collect_app/src/test/java/org/odk/collect/android/utilities/FormsDownloadResultInterpreterTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/utilities/FormsDownloadResultInterpreterTest.kt @@ -31,16 +31,36 @@ class FormsDownloadResultInterpreterTest { @Test fun `When all forms downloaded successfully getFailures() should return an empty list`() { - assertThat(FormsDownloadResultInterpreter.getFailures(resultWithoutErrors, context).size, `is`(0)) + assertThat( + FormsDownloadResultInterpreter.getFailures(resultWithoutErrors, context).size, + `is`(0) + ) } @Test fun `When not all forms downloaded successfully getFailures() should return list of failures`() { - assertThat(FormsDownloadResultInterpreter.getFailures(resultWithOneError, context).size, `is`(1)) - assertThat(FormsDownloadResultInterpreter.getFailures(resultWithOneError, context)[0].title, `is`("Form 2")) - assertThat(FormsDownloadResultInterpreter.getFailures(resultWithOneError, context)[0].secondaryText, `is`(context.getString( - org.odk.collect.strings.R.string.form_details, "5", "4"))) - assertThat(FormsDownloadResultInterpreter.getFailures(resultWithOneError, context)[0].supportingText, `is`(FormDownloadExceptionMapper(context).getMessage(resultWithOneError[formDetails2]))) + assertThat( + FormsDownloadResultInterpreter.getFailures(resultWithOneError, context).size, + `is`(1) + ) + assertThat( + FormsDownloadResultInterpreter.getFailures(resultWithOneError, context)[0].title, + `is`("Form 2") + ) + assertThat( + FormsDownloadResultInterpreter.getFailures( + resultWithOneError, + context + )[0].secondaryText, + `is`(context.getString(org.odk.collect.strings.R.string.form_details, "5", "4")) + ) + assertThat( + FormsDownloadResultInterpreter.getFailures( + resultWithOneError, + context + )[0].supportingText, + `is`(FormDownloadExceptionMapper(context).getMessage(resultWithOneError[formDetails2])) + ) } @Test @@ -55,11 +75,17 @@ class FormsDownloadResultInterpreterTest { @Test fun `When all forms downloaded successfully allFormsDownloadedSuccessfully() should return true`() { - assertThat(FormsDownloadResultInterpreter.allFormsDownloadedSuccessfully(resultWithoutErrors), `is`(true)) + assertThat( + FormsDownloadResultInterpreter.allFormsDownloadedSuccessfully(resultWithoutErrors), + `is`(true) + ) } @Test fun `When not all forms downloaded successfully allFormsDownloadedSuccessfully() should return false`() { - assertThat(FormsDownloadResultInterpreter.allFormsDownloadedSuccessfully(resultWithOneError), `is`(false)) + assertThat( + FormsDownloadResultInterpreter.allFormsDownloadedSuccessfully(resultWithOneError), + `is`(false) + ) } } diff --git a/collect_app/src/test/java/org/odk/collect/android/utilities/FormsUploadResultInterpreterTest.kt b/collect_app/src/test/java/org/odk/collect/android/utilities/FormsUploadResultInterpreterTest.kt index 23d215111f9..45f69472e52 100644 --- a/collect_app/src/test/java/org/odk/collect/android/utilities/FormsUploadResultInterpreterTest.kt +++ b/collect_app/src/test/java/org/odk/collect/android/utilities/FormsUploadResultInterpreterTest.kt @@ -49,8 +49,10 @@ class FormsUploadResultInterpreterTest { fun `When not all forms uploaded successfully getFailures() should return list of failures`() { assertThat(FormsUploadResultInterpreter.getFailures(resultWithOneError, context).size, `is`(1)) assertThat(FormsUploadResultInterpreter.getFailures(resultWithOneError, context)[0].title, `is`("Instance 2")) - assertThat(FormsUploadResultInterpreter.getFailures(resultWithOneError, context)[0].secondaryText, `is`(context.getString( - org.odk.collect.strings.R.string.form_details, "2", "2"))) + assertThat( + FormsUploadResultInterpreter.getFailures(resultWithOneError, context)[0].secondaryText, + `is`(context.getString(org.odk.collect.strings.R.string.form_details, "2", "2")) + ) assertThat(FormsUploadResultInterpreter.getFailures(resultWithOneError, context)[0].supportingText, `is`("Something went wrong!")) }