Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import com.ichi2.anki.ALL_DECKS_ID
import com.ichi2.anki.CollectionManager
import com.ichi2.anki.CollectionManager.withCol
import com.ichi2.anki.R
import com.ichi2.anki.common.annotations.NeedsTest
import com.ichi2.anki.common.time.TimeManager
import com.ichi2.anki.common.time.getTimestamp
import com.ichi2.anki.databinding.DialogExportOptionsBinding
Expand Down Expand Up @@ -185,7 +184,6 @@ class ExportDialogFragment : DialogFragment() {
/**
* Initializes the views representing the extra options available when exporting a collection.
*/
@NeedsTest("Checkbox value is provided to the correct export functions (true/false)")
private fun DialogExportOptionsBinding.initializeCollectionExportUi() =
with(CollectionManager.TR) {
collectionIncludeMedia.text = exportingIncludeMedia()
Expand All @@ -195,7 +193,6 @@ class ExportDialogFragment : DialogFragment() {
/**
* Initializes the views representing the extra options available when exporting an Anki package.
*/
@NeedsTest("Checkbox value is provided to the correct export functions (true/false)")
private fun DialogExportOptionsBinding.initializeApkgExportUi() =
with(CollectionManager.TR) {
apkgIncludeMedia.text = exportingIncludeMedia()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.test.espresso.matcher.RootMatchers.isDialog
import androidx.test.espresso.matcher.ViewMatchers.isChecked
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import androidx.test.espresso.matcher.ViewMatchers.withText
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.ichi2.anki.CollectionManager.TR
import com.ichi2.anki.R
Expand All @@ -33,6 +34,70 @@ import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class ExportDialogFragmentTest : RobolectricTest() {
@Test
fun `collection export options are initialized correctly`() {
launchFragment<ExportDialogFragment>(
themeResId = R.style.Theme_Light,
).onFragment {
// Select export type as anki collection package.
onView(withId(R.id.export_type_selector)).inRoot(isDialog()).perform(click())
onData(containsString(TR.exportingAnkiCollectionPackage()))
.inAdapterView(withId(R.id.export_type_selector))
.perform(click())

// Check that the UI elements are displayed and have the correct text and default values for checkboxes.
onView(withId(R.id.collection_include_media))
.inRoot(isDialog())
.check(matches(isDisplayed()))
.check(matches(withText(TR.exportingIncludeMedia())))
.check(matches(isChecked()))

onView(withId(R.id.collection_export_legacy))
.inRoot(isDialog())
.check(matches(isDisplayed()))
.check(matches(withText(TR.exportingSupportOlderAnkiVersions())))
.check(matches(not(isChecked())))
}
}

@Test
fun `apkg export options are initialized correctly`() {
launchFragment<ExportDialogFragment>(
themeResId = R.style.Theme_Light,
).onFragment {
// Select export type as anki deck package.
onView(withId(R.id.export_type_selector)).inRoot(isDialog()).perform(click())
onData(containsString(TR.exportingAnkiDeckPackage()))
.inAdapterView(withId(R.id.export_type_selector))
.perform(click())

// Check that the UI elements are displayed and have the correct text and default values for checkboxes.
onView(withId(R.id.apkg_include_media))
.inRoot(isDialog())
.check(matches(isDisplayed()))
.check(matches(withText(TR.exportingIncludeMedia())))
.check(matches(isChecked()))

onView(withId(R.id.apkg_include_deck_configs))
.inRoot(isDialog())
.check(matches(isDisplayed()))
.check(matches(withText(TR.exportingIncludeDeckConfigs())))
.check(matches(not(isChecked())))

onView(withId(R.id.apkg_include_schedule))
.inRoot(isDialog())
.check(matches(isDisplayed()))
.check(matches(withText(TR.exportingIncludeSchedulingInformation())))
.check(matches(isChecked()))

onView(withId(R.id.apkg_export_legacy))
.inRoot(isDialog())
.check(matches(isDisplayed()))
.check(matches(withText(TR.exportingSupportOlderAnkiVersions())))
.check(matches(not(isChecked())))
}
}

@Test
fun `Legacy export checkbox(default false) is shown only for collection and apkg`() {
launchFragment<ExportDialogFragment>(
Expand Down
Loading