diff --git a/testSrc/unit/io/flutter/utils/FlutterModuleUtilsTest.java b/testSrc/unit/io/flutter/utils/FlutterModuleUtilsTest.java index 628e6a44ff..d8f695991b 100644 --- a/testSrc/unit/io/flutter/utils/FlutterModuleUtilsTest.java +++ b/testSrc/unit/io/flutter/utils/FlutterModuleUtilsTest.java @@ -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()); + } } diff --git a/testSrc/unit/io/flutter/utils/IconPreviewGeneratorTest.java b/testSrc/unit/io/flutter/utils/IconPreviewGeneratorTest.java index a81dac02f6..28b928df51 100644 --- a/testSrc/unit/io/flutter/utils/IconPreviewGeneratorTest.java +++ b/testSrc/unit/io/flutter/utils/IconPreviewGeneratorTest.java @@ -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(); + } + } } diff --git a/testSrc/unit/io/flutter/utils/StdoutJsonParserTest.java b/testSrc/unit/io/flutter/utils/StdoutJsonParserTest.java index 6311cc003c..0e80b7da3b 100644 --- a/testSrc/unit/io/flutter/utils/StdoutJsonParserTest.java +++ b/testSrc/unit/io/flutter/utils/StdoutJsonParserTest.java @@ -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()); + } } diff --git a/testSrc/unit/io/flutter/utils/TypedDataListTest.java b/testSrc/unit/io/flutter/utils/TypedDataListTest.java index 5d7e6066d3..f20cb42dbd 100644 --- a/testSrc/unit/io/flutter/utils/TypedDataListTest.java +++ b/testSrc/unit/io/flutter/utils/TypedDataListTest.java @@ -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); } } diff --git a/testSrc/unit/io/flutter/utils/UrlUtilsTest.java b/testSrc/unit/io/flutter/utils/UrlUtilsTest.java index 99791bcf4b..e2cb64ab2c 100644 --- a/testSrc/unit/io/flutter/utils/UrlUtilsTest.java +++ b/testSrc/unit/io/flutter/utils/UrlUtilsTest.java @@ -17,5 +17,18 @@ public void testGenerateHtmlFragmentWithHrefTags() { "Multiple http://link1.com links http://link2.com test", UrlUtils.generateHtmlFragmentWithHrefTags("Multiple http://link1.com links http://link2.com test") ); + assertEquals( + "Open https://secure.com", + UrlUtils.generateHtmlFragmentWithHrefTags("Open https://secure.com")); + assertEquals( + "http://start.com 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")); } }