From 665e776257a317f2bc5e6fc8992070d7057de2bb Mon Sep 17 00:00:00 2001 From: Yuan Xulei Date: Tue, 4 Nov 2014 18:06:26 +0800 Subject: [PATCH] Implement FileSystemRegistry.listRoots. --- .../io/file/FileSystemRegistry.java | 5 ++-- tests/automation.js | 2 +- .../io/file/TestFileSystemRegistry.java | 29 +++++++++++++++++++ 3 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 tests/javax/microedition/io/file/TestFileSystemRegistry.java diff --git a/java/custom/javax/microedition/io/file/FileSystemRegistry.java b/java/custom/javax/microedition/io/file/FileSystemRegistry.java index 0a7804fc..4710b69c 100644 --- a/java/custom/javax/microedition/io/file/FileSystemRegistry.java +++ b/java/custom/javax/microedition/io/file/FileSystemRegistry.java @@ -18,8 +18,9 @@ public class FileSystemRegistry { } public static Enumeration listRoots() { - System.out.println("FileSystemRegistry::listRoots() not implemented."); - return new Vector().elements(); + Vector roots = new Vector(); + roots.addElement(""); + return roots.elements(); } } diff --git a/tests/automation.js b/tests/automation.js index e8ce84a1..0158625d 100644 --- a/tests/automation.js +++ b/tests/automation.js @@ -44,7 +44,7 @@ casper.test.begin("unit tests", 7 + gfxTests.length, function(test) { function basicUnitTests() { casper.waitForText("DONE", function() { var content = this.getPageContent(); - if (content.contains("DONE: 71085 pass, 0 fail, 180 known fail, 0 unknown pass")) { + if (content.contains("DONE: 71087 pass, 0 fail, 180 known fail, 0 unknown pass")) { test.pass('main unit tests'); } else { this.debugPage(); diff --git a/tests/javax/microedition/io/file/TestFileSystemRegistry.java b/tests/javax/microedition/io/file/TestFileSystemRegistry.java new file mode 100644 index 00000000..c5fc6dd1 --- /dev/null +++ b/tests/javax/microedition/io/file/TestFileSystemRegistry.java @@ -0,0 +1,29 @@ +package javax.microedition.io.file; + +import gnu.testlet.TestHarness; +import gnu.testlet.Testlet; +import java.io.IOException; +import java.util.Enumeration; +import javax.microedition.io.Connector; + +public class TestFileSystemRegistry implements Testlet { + + public void test(TestHarness th) { + try { + testListRoots(th); + } catch (Throwable e) { + th.todo(false, "Unexpected exception: " + e); + e.printStackTrace(); + } + } + + public void testListRoots(TestHarness th) throws IOException { + Enumeration rootEnum = FileSystemRegistry.listRoots(); + th.check(rootEnum != null); + while (rootEnum.hasMoreElements()) { + String root = (String)rootEnum.nextElement(); + FileConnection fc = (FileConnection)Connector.open("file:///" + root); + th.check(fc != null); + } + } +}