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

Commit 8e35e1c7 authored by Garfield Tan's avatar Garfield Tan Committed by android-build-merger
Browse files

Merge "Remove race conditions in CopyJobTest and MoveJobTest." into arc-apps

am: 115f7e9b

Change-Id: I5bbaa03e91e11f6ac617975b0bc4a1a755f46f98
parents a77d4bdc 115f7e9b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -141,6 +141,10 @@ public class DocumentsProviderHelper {
        try (AutoCloseOutputStream out = new AutoCloseOutputStream(file)) {
            out.write(contents, 0, contents.length);
        }
        waitForWrite();
    }

    public void waitForWrite() throws RemoteException {
        mClient.call("waitForWrite", null, null);
    }

+12 −7
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob

        createJob(newArrayList(testFile)).run();

        mJobListener.waitForFinished();
        waitForJobFinished();

        mDocs.assertChildCount(mDestRoot, 1);
        mDocs.assertHasFile(mDestRoot, "virtual.sth.pdf");  // copy should convert file to PDF.
@@ -74,7 +74,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob

        createJob(newArrayList(testFile)).run();

        mJobListener.waitForFinished();
        waitForJobFinished();
        mJobListener.assertFailed();
        mJobListener.assertFilesFailed(newArrayList("virtual.sth"));

@@ -85,7 +85,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob
        Uri testDir = mDocs.createFolder(mSrcRoot, "emptyDir");

        createJob(newArrayList(testDir)).run();
        mJobListener.waitForFinished();
        waitForJobFinished();

        mDocs.assertChildCount(mDestRoot, 1);
        mDocs.assertHasDirectory(mDestRoot, "emptyDir");
@@ -100,7 +100,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob
        mDocs.createDocument(testDir2, "text/plain", "test2.txt");

        createJob(newArrayList(testDir1)).run();
        mJobListener.waitForFinished();
        waitForJobFinished();

        DocumentInfo dir1Copy = mDocs.findDocument(mDestRoot.documentId, "dir1");

@@ -121,7 +121,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob
                DocumentsContract.buildDocumentUri(AUTHORITY, mSrcRoot.documentId),
                testDir).run();

        mJobListener.waitForFinished();
        waitForJobFinished();
        mJobListener.assertFailed();
        mJobListener.assertFilesFailed(newArrayList("someDir"));

@@ -137,7 +137,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob
                DocumentsContract.buildDocumentUri(AUTHORITY, mSrcRoot.documentId),
                destDir).run();

        mJobListener.waitForFinished();
        waitForJobFinished();
        mJobListener.assertFailed();
        mJobListener.assertFilesFailed(newArrayList("someDir"));

@@ -153,13 +153,18 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob

        createJob(newArrayList(testFile)).run();

        mJobListener.waitForFinished();
        waitForJobFinished();
        mJobListener.assertFailed();
        mJobListener.assertFilesFailed(newArrayList("test1.txt"));

        mDocs.assertChildCount(mDestRoot, 0);
    }

    void waitForJobFinished() throws Exception {
        mJobListener.waitForFinished();
        mDocs.waitForWrite();
    }

    /**
     * Creates a job with a stack consisting to the default source and destination.
     * TODO: Clean up, as mDestRoot.documentInfo may not really be the parent of
+1 −1
Original line number Diff line number Diff line
@@ -53,7 +53,7 @@ public class CopyJobTest extends AbstractCopyJobTest<CopyJob> {

        createJob(newArrayList(testFile)).run();

        mJobListener.waitForFinished();
        waitForJobFinished();
        mDocs.assertChildCount(mDestRoot, 1);
        mDocs.assertHasFile(mDestRoot, "tokyo.sth.pdf");  // Copy should convert file to PDF.
    }
+3 −3
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ public class MoveJobTest extends AbstractCopyJobTest<MoveJob> {
        mDocs.writeDocument(testFile2, FRUITY_BYTES);

        createJob(newArrayList(testFile1, testFile2), null).run();
        mJobListener.waitForFinished();
        waitForJobFinished();

        mDocs.assertChildCount(mDestRoot, 2);
        mDocs.assertHasFile(mDestRoot, "test1.txt");
@@ -60,7 +60,7 @@ public class MoveJobTest extends AbstractCopyJobTest<MoveJob> {
                FRUITY_BYTES, "application/pdf", "text/html");
        createJob(newArrayList(testFile)).run();

        mJobListener.waitForFinished();
        waitForJobFinished();

        // Should have failed, source not deleted. Moving by bytes for virtual files
        // is not supported.
@@ -82,7 +82,7 @@ public class MoveJobTest extends AbstractCopyJobTest<MoveJob> {
                        | Document.FLAG_SUPPORTS_MOVE, "application/pdf");

        createJob(newArrayList(testFile)).run();
        mJobListener.waitForFinished();
        waitForJobFinished();

        // Should have failed, source not deleted. Moving by bytes for virtual files
        // is not supported.