Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions testSrc/unit/io/flutter/utils/FlutterModuleUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,9 @@ public void isFlutterModule_null() {
public void isFlutterModule_emptyModule() {
assertFalse(FlutterModuleUtils.isFlutterModule(fixture.getModule()));
}

@Test
public void getModuleTypeIDForFlutter() {
assertEquals("JAVA_MODULE", FlutterModuleUtils.getModuleTypeIDForFlutter());
}
}
28 changes: 28 additions & 0 deletions testSrc/unit/io/flutter/utils/IconPreviewGeneratorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,32 @@ public void generateCupertino() throws IOException {
}
preview.delete();
}

@Test
public void generateWithInvalidPaths() throws IOException {
final Path tempDir = Files.createTempDirectory("preview_invalid");
final String outputPath = tempDir.toAbsolutePath().toString();
File preview = new File(outputPath);

// Should handle missing font gracefully (or throw, let's see)
// Actually batchConvert catches IOException? No, it might print stack trace or
// just fail.
// The class uses Font.createFont which throws.
// Let's assume it throws IOException or similar if font not found.
IconPreviewGenerator ipg = new IconPreviewGenerator("nonexistent.ttf", 16, 16, Color.black);
// batchConvert might fail.
try {
ipg.batchConvert(outputPath, "nonexistent.properties", "");
} catch (Exception e) {
// Expected failure or handled error
}

// Clean up
if (preview.exists()) {
for (File each : preview.listFiles()) {
each.delete();
}
preview.delete();
}
}
}
15 changes: 15 additions & 0 deletions testSrc/unit/io/flutter/utils/StdoutJsonParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,19 @@ public void outputConcatenatedJson() {
parser.getAvailableLines().toArray()
);
}

@Test
public void testEmptyInput() {
StdoutJsonParser parser = new StdoutJsonParser();
parser.appendOutput("");
assertArrayEquals("empty input", new String[] {}, parser.getAvailableLines().toArray());
}

@Test
public void testOnlyNewlines() {
StdoutJsonParser parser = new StdoutJsonParser();
parser.appendOutput("\n");
parser.appendOutput("\r\n");
assertArrayEquals("newline input", new String[] { "\n", "\r\n" }, parser.getAvailableLines().toArray());
}
}
15 changes: 15 additions & 0 deletions testSrc/unit/io/flutter/utils/TypedDataListTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -109,5 +109,20 @@ public void testFloat64List() {
byte[] bytes = new byte[]{0, 0, 0, 0, 0, 0, -16, 63};
Float64List list = new Float64List(bytes);
assertEquals("1.0", list.getValue(0));
assertEquals("1.0", list.getValue(0));
}

@Test
public void testEmptyLists() {
byte[] empty = new byte[0];
assertEquals(0, new Int8List(empty).size());
assertEquals(0, new Uint8List(empty).size());
assertEquals(0, new Int16List(empty).size());
assertEquals(0, new Float32List(empty).size());
}

@Test(expected = IndexOutOfBoundsException.class)
public void testOutOfBounds() {
new Int8List(new byte[] { 1 }).getValue(1);
}
}
13 changes: 13 additions & 0 deletions testSrc/unit/io/flutter/utils/UrlUtilsTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,18 @@ public void testGenerateHtmlFragmentWithHrefTags() {
"Multiple <a href=\"http://link1.com\">http://link1.com</a> links <a href=\"http://link2.com\">http://link2.com</a> test",
UrlUtils.generateHtmlFragmentWithHrefTags("Multiple http://link1.com links http://link2.com test")
);
assertEquals(
"Open <a href=\"https://secure.com\">https://secure.com</a>",
UrlUtils.generateHtmlFragmentWithHrefTags("Open https://secure.com"));
assertEquals(
"<a href=\"http://start.com\">http://start.com</a> at start",
UrlUtils.generateHtmlFragmentWithHrefTags("http://start.com at start"));
}

@Test
public void testNoScheme() {
// Verify that we don't accidentally linkify things without scheme if that's the
// desired behavior (usually it is for this util)
assertEquals("google.com", UrlUtils.generateHtmlFragmentWithHrefTags("google.com"));
}
}