Loading tests/src/com/android/documentsui/StubProvider.java +23 −24 Original line number Diff line number Diff line Loading @@ -492,30 +492,6 @@ public class StubProvider extends DocumentsProvider { } } @VisibleForTesting public File createFile(String rootId, String path, String mimeType, byte[] content) throws FileNotFoundException, IOException { Log.d(TAG, "Creating test file " + rootId + ":" + path); StubDocument root = mRoots.get(rootId).document; if (root == null) { throw new FileNotFoundException("No roots with the ID " + rootId + " were found"); } final File file = new File(root.file, path.substring(1)); if (DocumentsContract.Document.MIME_TYPE_DIR.equals(mimeType)) { if (!file.mkdirs()) { throw new FileNotFoundException("Couldn't create directory " + file.getPath()); } } else { if (!file.createNewFile()) { throw new FileNotFoundException("Couldn't create file " + file.getPath()); } try (final FileOutputStream fout = new FileOutputStream(file)) { fout.write(content); } } return file; } @VisibleForTesting public Uri createRegularFile(String rootId, String path, String mimeType, byte[] content) throws FileNotFoundException, IOException { Loading Loading @@ -560,6 +536,29 @@ public class StubProvider extends DocumentsProvider { return found.file; } private File createFile(String rootId, String path, String mimeType, byte[] content) throws FileNotFoundException, IOException { Log.d(TAG, "Creating test file " + rootId + ":" + path); StubDocument root = mRoots.get(rootId).document; if (root == null) { throw new FileNotFoundException("No roots with the ID " + rootId + " were found"); } final File file = new File(root.file, path.substring(1)); if (DocumentsContract.Document.MIME_TYPE_DIR.equals(mimeType)) { if (!file.mkdirs()) { throw new FileNotFoundException("Couldn't create directory " + file.getPath()); } } else { if (!file.createNewFile()) { throw new FileNotFoundException("Couldn't create file " + file.getPath()); } try (final FileOutputStream fout = new FileOutputStream(file)) { fout.write(content); } } return file; } final static class RootInfo { public final String name; public final StubDocument document; Loading Loading
tests/src/com/android/documentsui/StubProvider.java +23 −24 Original line number Diff line number Diff line Loading @@ -492,30 +492,6 @@ public class StubProvider extends DocumentsProvider { } } @VisibleForTesting public File createFile(String rootId, String path, String mimeType, byte[] content) throws FileNotFoundException, IOException { Log.d(TAG, "Creating test file " + rootId + ":" + path); StubDocument root = mRoots.get(rootId).document; if (root == null) { throw new FileNotFoundException("No roots with the ID " + rootId + " were found"); } final File file = new File(root.file, path.substring(1)); if (DocumentsContract.Document.MIME_TYPE_DIR.equals(mimeType)) { if (!file.mkdirs()) { throw new FileNotFoundException("Couldn't create directory " + file.getPath()); } } else { if (!file.createNewFile()) { throw new FileNotFoundException("Couldn't create file " + file.getPath()); } try (final FileOutputStream fout = new FileOutputStream(file)) { fout.write(content); } } return file; } @VisibleForTesting public Uri createRegularFile(String rootId, String path, String mimeType, byte[] content) throws FileNotFoundException, IOException { Loading Loading @@ -560,6 +536,29 @@ public class StubProvider extends DocumentsProvider { return found.file; } private File createFile(String rootId, String path, String mimeType, byte[] content) throws FileNotFoundException, IOException { Log.d(TAG, "Creating test file " + rootId + ":" + path); StubDocument root = mRoots.get(rootId).document; if (root == null) { throw new FileNotFoundException("No roots with the ID " + rootId + " were found"); } final File file = new File(root.file, path.substring(1)); if (DocumentsContract.Document.MIME_TYPE_DIR.equals(mimeType)) { if (!file.mkdirs()) { throw new FileNotFoundException("Couldn't create directory " + file.getPath()); } } else { if (!file.createNewFile()) { throw new FileNotFoundException("Couldn't create file " + file.getPath()); } try (final FileOutputStream fout = new FileOutputStream(file)) { fout.write(content); } } return file; } final static class RootInfo { public final String name; public final StubDocument document; Loading