Loading tests/common/com/android/documentsui/DocumentsProviderHelper.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -141,6 +141,10 @@ public class DocumentsProviderHelper { try (AutoCloseOutputStream out = new AutoCloseOutputStream(file)) { try (AutoCloseOutputStream out = new AutoCloseOutputStream(file)) { out.write(contents, 0, contents.length); out.write(contents, 0, contents.length); } } waitForWrite(); } public void waitForWrite() throws RemoteException { mClient.call("waitForWrite", null, null); mClient.call("waitForWrite", null, null); } } Loading tests/unit/com/android/documentsui/services/AbstractCopyJobTest.java +12 −7 Original line number Original line Diff line number Diff line Loading @@ -60,7 +60,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob createJob(newArrayList(testFile)).run(); createJob(newArrayList(testFile)).run(); mJobListener.waitForFinished(); waitForJobFinished(); mDocs.assertChildCount(mDestRoot, 1); mDocs.assertChildCount(mDestRoot, 1); mDocs.assertHasFile(mDestRoot, "virtual.sth.pdf"); // copy should convert file to PDF. mDocs.assertHasFile(mDestRoot, "virtual.sth.pdf"); // copy should convert file to PDF. Loading @@ -74,7 +74,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob createJob(newArrayList(testFile)).run(); createJob(newArrayList(testFile)).run(); mJobListener.waitForFinished(); waitForJobFinished(); mJobListener.assertFailed(); mJobListener.assertFailed(); mJobListener.assertFilesFailed(newArrayList("virtual.sth")); mJobListener.assertFilesFailed(newArrayList("virtual.sth")); Loading @@ -85,7 +85,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob Uri testDir = mDocs.createFolder(mSrcRoot, "emptyDir"); Uri testDir = mDocs.createFolder(mSrcRoot, "emptyDir"); createJob(newArrayList(testDir)).run(); createJob(newArrayList(testDir)).run(); mJobListener.waitForFinished(); waitForJobFinished(); mDocs.assertChildCount(mDestRoot, 1); mDocs.assertChildCount(mDestRoot, 1); mDocs.assertHasDirectory(mDestRoot, "emptyDir"); mDocs.assertHasDirectory(mDestRoot, "emptyDir"); Loading @@ -100,7 +100,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob mDocs.createDocument(testDir2, "text/plain", "test2.txt"); mDocs.createDocument(testDir2, "text/plain", "test2.txt"); createJob(newArrayList(testDir1)).run(); createJob(newArrayList(testDir1)).run(); mJobListener.waitForFinished(); waitForJobFinished(); DocumentInfo dir1Copy = mDocs.findDocument(mDestRoot.documentId, "dir1"); DocumentInfo dir1Copy = mDocs.findDocument(mDestRoot.documentId, "dir1"); Loading @@ -121,7 +121,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob DocumentsContract.buildDocumentUri(AUTHORITY, mSrcRoot.documentId), DocumentsContract.buildDocumentUri(AUTHORITY, mSrcRoot.documentId), testDir).run(); testDir).run(); mJobListener.waitForFinished(); waitForJobFinished(); mJobListener.assertFailed(); mJobListener.assertFailed(); mJobListener.assertFilesFailed(newArrayList("someDir")); mJobListener.assertFilesFailed(newArrayList("someDir")); Loading @@ -137,7 +137,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob DocumentsContract.buildDocumentUri(AUTHORITY, mSrcRoot.documentId), DocumentsContract.buildDocumentUri(AUTHORITY, mSrcRoot.documentId), destDir).run(); destDir).run(); mJobListener.waitForFinished(); waitForJobFinished(); mJobListener.assertFailed(); mJobListener.assertFailed(); mJobListener.assertFilesFailed(newArrayList("someDir")); mJobListener.assertFilesFailed(newArrayList("someDir")); Loading @@ -153,13 +153,18 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob createJob(newArrayList(testFile)).run(); createJob(newArrayList(testFile)).run(); mJobListener.waitForFinished(); waitForJobFinished(); mJobListener.assertFailed(); mJobListener.assertFailed(); mJobListener.assertFilesFailed(newArrayList("test1.txt")); mJobListener.assertFilesFailed(newArrayList("test1.txt")); mDocs.assertChildCount(mDestRoot, 0); 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. * 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 * TODO: Clean up, as mDestRoot.documentInfo may not really be the parent of Loading tests/unit/com/android/documentsui/services/CopyJobTest.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -53,7 +53,7 @@ public class CopyJobTest extends AbstractCopyJobTest<CopyJob> { createJob(newArrayList(testFile)).run(); createJob(newArrayList(testFile)).run(); mJobListener.waitForFinished(); waitForJobFinished(); mDocs.assertChildCount(mDestRoot, 1); mDocs.assertChildCount(mDestRoot, 1); mDocs.assertHasFile(mDestRoot, "tokyo.sth.pdf"); // Copy should convert file to PDF. mDocs.assertHasFile(mDestRoot, "tokyo.sth.pdf"); // Copy should convert file to PDF. } } Loading tests/unit/com/android/documentsui/services/MoveJobTest.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -44,7 +44,7 @@ public class MoveJobTest extends AbstractCopyJobTest<MoveJob> { mDocs.writeDocument(testFile2, FRUITY_BYTES); mDocs.writeDocument(testFile2, FRUITY_BYTES); createJob(newArrayList(testFile1, testFile2), null).run(); createJob(newArrayList(testFile1, testFile2), null).run(); mJobListener.waitForFinished(); waitForJobFinished(); mDocs.assertChildCount(mDestRoot, 2); mDocs.assertChildCount(mDestRoot, 2); mDocs.assertHasFile(mDestRoot, "test1.txt"); mDocs.assertHasFile(mDestRoot, "test1.txt"); Loading @@ -60,7 +60,7 @@ public class MoveJobTest extends AbstractCopyJobTest<MoveJob> { FRUITY_BYTES, "application/pdf", "text/html"); FRUITY_BYTES, "application/pdf", "text/html"); createJob(newArrayList(testFile)).run(); createJob(newArrayList(testFile)).run(); mJobListener.waitForFinished(); waitForJobFinished(); // Should have failed, source not deleted. Moving by bytes for virtual files // Should have failed, source not deleted. Moving by bytes for virtual files // is not supported. // is not supported. Loading @@ -82,7 +82,7 @@ public class MoveJobTest extends AbstractCopyJobTest<MoveJob> { | Document.FLAG_SUPPORTS_MOVE, "application/pdf"); | Document.FLAG_SUPPORTS_MOVE, "application/pdf"); createJob(newArrayList(testFile)).run(); createJob(newArrayList(testFile)).run(); mJobListener.waitForFinished(); waitForJobFinished(); // Should have failed, source not deleted. Moving by bytes for virtual files // Should have failed, source not deleted. Moving by bytes for virtual files // is not supported. // is not supported. Loading Loading
tests/common/com/android/documentsui/DocumentsProviderHelper.java +4 −0 Original line number Original line Diff line number Diff line Loading @@ -141,6 +141,10 @@ public class DocumentsProviderHelper { try (AutoCloseOutputStream out = new AutoCloseOutputStream(file)) { try (AutoCloseOutputStream out = new AutoCloseOutputStream(file)) { out.write(contents, 0, contents.length); out.write(contents, 0, contents.length); } } waitForWrite(); } public void waitForWrite() throws RemoteException { mClient.call("waitForWrite", null, null); mClient.call("waitForWrite", null, null); } } Loading
tests/unit/com/android/documentsui/services/AbstractCopyJobTest.java +12 −7 Original line number Original line Diff line number Diff line Loading @@ -60,7 +60,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob createJob(newArrayList(testFile)).run(); createJob(newArrayList(testFile)).run(); mJobListener.waitForFinished(); waitForJobFinished(); mDocs.assertChildCount(mDestRoot, 1); mDocs.assertChildCount(mDestRoot, 1); mDocs.assertHasFile(mDestRoot, "virtual.sth.pdf"); // copy should convert file to PDF. mDocs.assertHasFile(mDestRoot, "virtual.sth.pdf"); // copy should convert file to PDF. Loading @@ -74,7 +74,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob createJob(newArrayList(testFile)).run(); createJob(newArrayList(testFile)).run(); mJobListener.waitForFinished(); waitForJobFinished(); mJobListener.assertFailed(); mJobListener.assertFailed(); mJobListener.assertFilesFailed(newArrayList("virtual.sth")); mJobListener.assertFilesFailed(newArrayList("virtual.sth")); Loading @@ -85,7 +85,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob Uri testDir = mDocs.createFolder(mSrcRoot, "emptyDir"); Uri testDir = mDocs.createFolder(mSrcRoot, "emptyDir"); createJob(newArrayList(testDir)).run(); createJob(newArrayList(testDir)).run(); mJobListener.waitForFinished(); waitForJobFinished(); mDocs.assertChildCount(mDestRoot, 1); mDocs.assertChildCount(mDestRoot, 1); mDocs.assertHasDirectory(mDestRoot, "emptyDir"); mDocs.assertHasDirectory(mDestRoot, "emptyDir"); Loading @@ -100,7 +100,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob mDocs.createDocument(testDir2, "text/plain", "test2.txt"); mDocs.createDocument(testDir2, "text/plain", "test2.txt"); createJob(newArrayList(testDir1)).run(); createJob(newArrayList(testDir1)).run(); mJobListener.waitForFinished(); waitForJobFinished(); DocumentInfo dir1Copy = mDocs.findDocument(mDestRoot.documentId, "dir1"); DocumentInfo dir1Copy = mDocs.findDocument(mDestRoot.documentId, "dir1"); Loading @@ -121,7 +121,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob DocumentsContract.buildDocumentUri(AUTHORITY, mSrcRoot.documentId), DocumentsContract.buildDocumentUri(AUTHORITY, mSrcRoot.documentId), testDir).run(); testDir).run(); mJobListener.waitForFinished(); waitForJobFinished(); mJobListener.assertFailed(); mJobListener.assertFailed(); mJobListener.assertFilesFailed(newArrayList("someDir")); mJobListener.assertFilesFailed(newArrayList("someDir")); Loading @@ -137,7 +137,7 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob DocumentsContract.buildDocumentUri(AUTHORITY, mSrcRoot.documentId), DocumentsContract.buildDocumentUri(AUTHORITY, mSrcRoot.documentId), destDir).run(); destDir).run(); mJobListener.waitForFinished(); waitForJobFinished(); mJobListener.assertFailed(); mJobListener.assertFailed(); mJobListener.assertFilesFailed(newArrayList("someDir")); mJobListener.assertFilesFailed(newArrayList("someDir")); Loading @@ -153,13 +153,18 @@ public abstract class AbstractCopyJobTest<T extends CopyJob> extends AbstractJob createJob(newArrayList(testFile)).run(); createJob(newArrayList(testFile)).run(); mJobListener.waitForFinished(); waitForJobFinished(); mJobListener.assertFailed(); mJobListener.assertFailed(); mJobListener.assertFilesFailed(newArrayList("test1.txt")); mJobListener.assertFilesFailed(newArrayList("test1.txt")); mDocs.assertChildCount(mDestRoot, 0); 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. * 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 * TODO: Clean up, as mDestRoot.documentInfo may not really be the parent of Loading
tests/unit/com/android/documentsui/services/CopyJobTest.java +1 −1 Original line number Original line Diff line number Diff line Loading @@ -53,7 +53,7 @@ public class CopyJobTest extends AbstractCopyJobTest<CopyJob> { createJob(newArrayList(testFile)).run(); createJob(newArrayList(testFile)).run(); mJobListener.waitForFinished(); waitForJobFinished(); mDocs.assertChildCount(mDestRoot, 1); mDocs.assertChildCount(mDestRoot, 1); mDocs.assertHasFile(mDestRoot, "tokyo.sth.pdf"); // Copy should convert file to PDF. mDocs.assertHasFile(mDestRoot, "tokyo.sth.pdf"); // Copy should convert file to PDF. } } Loading
tests/unit/com/android/documentsui/services/MoveJobTest.java +3 −3 Original line number Original line Diff line number Diff line Loading @@ -44,7 +44,7 @@ public class MoveJobTest extends AbstractCopyJobTest<MoveJob> { mDocs.writeDocument(testFile2, FRUITY_BYTES); mDocs.writeDocument(testFile2, FRUITY_BYTES); createJob(newArrayList(testFile1, testFile2), null).run(); createJob(newArrayList(testFile1, testFile2), null).run(); mJobListener.waitForFinished(); waitForJobFinished(); mDocs.assertChildCount(mDestRoot, 2); mDocs.assertChildCount(mDestRoot, 2); mDocs.assertHasFile(mDestRoot, "test1.txt"); mDocs.assertHasFile(mDestRoot, "test1.txt"); Loading @@ -60,7 +60,7 @@ public class MoveJobTest extends AbstractCopyJobTest<MoveJob> { FRUITY_BYTES, "application/pdf", "text/html"); FRUITY_BYTES, "application/pdf", "text/html"); createJob(newArrayList(testFile)).run(); createJob(newArrayList(testFile)).run(); mJobListener.waitForFinished(); waitForJobFinished(); // Should have failed, source not deleted. Moving by bytes for virtual files // Should have failed, source not deleted. Moving by bytes for virtual files // is not supported. // is not supported. Loading @@ -82,7 +82,7 @@ public class MoveJobTest extends AbstractCopyJobTest<MoveJob> { | Document.FLAG_SUPPORTS_MOVE, "application/pdf"); | Document.FLAG_SUPPORTS_MOVE, "application/pdf"); createJob(newArrayList(testFile)).run(); createJob(newArrayList(testFile)).run(); mJobListener.waitForFinished(); waitForJobFinished(); // Should have failed, source not deleted. Moving by bytes for virtual files // Should have failed, source not deleted. Moving by bytes for virtual files // is not supported. // is not supported. Loading