Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 916d5be4 authored by François Degros's avatar François Degros
Browse files

Add UnpackJobTest.emptyZip for empty ZIP archive

Bug: 422037920
Flag: com.android.documentsui.flags.use_material3
Flag: com.android.documentsui.flags.zip_ng_ro
Test: atest DocumentsUIGoogleTests:com.android.documentsui.services.UnpackJobTest

Change-Id: I5582e4cf5ec6b2a8bb923af2e3e9b327d5f73cbb
parent c8f5434e
Loading
Loading
Loading
Loading
+22 B

File added.

No diff preview for this file type.

+49 −0
Original line number Diff line number Diff line
@@ -436,6 +436,55 @@ internal class UnpackJobTest : AbstractJobTest<UnpackJob>() {
        )
    }

    /** Tests with an empty ZIP archive. */
    @Test
    fun emptyZip() {
        val uri = createDocument("application/zip", "archives/zip/empty.zip")
        assertTreeIs(mutableMapOf("/empty.zip" to 22))

        val job = createJob(uri)

        with(job.getJobProgress()) {
            assertThat(operationType).isEqualTo(OPERATION_UNPACK)
            assertThat(id).isEqualTo(job.id)
            assertThat(state).isEqualTo(Job.STATE_CREATED)
            assertThat(hasFailures).isFalse()
            assertThat(currentBytes).isEqualTo(0)
            assertThat(requiredBytes).isEqualTo(0)
            assertThat(msRemaining).isLessThan(0)
        }

        job.run()
        mJobListener.assertFinished()

        with(job.getJobProgress()) {
            assertThat(operationType).isEqualTo(OPERATION_UNPACK)
            assertThat(id).isEqualTo(job.id)
            assertThat(state).isEqualTo(Job.STATE_COMPLETED)
            assertThat(hasFailures).isFalse()
            assertThat(msg).isEqualTo("Extracting “empty.zip” to “TEST_ROOT_0”")
            assertThat(currentBytes).isEqualTo(0)
            assertThat(requiredBytes).isEqualTo(0)
            assertThat(msRemaining).isLessThan(0)
            assertThat(destination!!.peek().displayName).isEqualTo("empty")
        }

        with(job.getProgressNotification()) {
            assertThat(category).isEqualTo(CATEGORY_PROGRESS)
            with(extras) {
                assertThat(getCharSequence(EXTRA_TITLE)).isEqualTo("Extracting files")
                assertThat(getBoolean(EXTRA_PROGRESS_INDETERMINATE)).isTrue()
            }
        }

        assertTreeIs(
            mutableMapOf(
                "/empty.zip" to 22,
                "/empty/" to -1,
            )
        )
    }

    /** Tests the various system notifications with a partially encrypted ZIP archive. */
    @Test
    fun notifications() {