Search in sources :

Example 1 with HeaderMap

use of com.google.devtools.j2objc.util.HeaderMap in project j2objc by google.

the class ObjectiveCHeaderGeneratorTest method testOutputHeaderFileMapping.

public void testOutputHeaderFileMapping() throws IOException {
    options.getHeaderMap().setMappingFiles("testMappings.j2objc");
    options.getHeaderMap().setOutputStyle(HeaderMap.OutputStyleOption.SOURCE);
    addSourceFile("package unit.test; public class Dummy {}", "unit/test/Dummy.java");
    addSourceFile("package unit.test;" + "public class AnotherDummy extends Dummy { " + "    public AnotherDummy() {}" + "}", "unit/test/AnotherDummy.java");
    preprocessFiles("unit/test/Dummy.java", "unit/test/AnotherDummy.java");
    loadHeaderMappings();
    String translation = translateSourceFile(getTranslatedFile("unit/test/AnotherDummy.java"), "AnotherDummy", "AnotherDummy.h");
    assertTranslation(translation, "#include \"unit/test/Dummy.h\"");
    HeaderMap headerMap = options.getHeaderMap();
    assertEquals("unit/test/Dummy.h", headerMap.getMapped("unit.test.Dummy"));
    assertEquals("unit/test/AnotherDummy.h", headerMap.getMapped("unit.test.AnotherDummy"));
    assertEquals("my/mapping/custom/Test.h", headerMap.getMapped("unit.mapping.custom.Test"));
    assertEquals("my/mapping/custom/Test.h", headerMap.getMapped("unit.mapping.custom.AnotherTest"));
}
Also used : HeaderMap(com.google.devtools.j2objc.util.HeaderMap)

Example 2 with HeaderMap

use of com.google.devtools.j2objc.util.HeaderMap in project j2objc by google.

the class ObjectiveCHeaderGeneratorTest method testCombinedJarHeaderMapping.

public void testCombinedJarHeaderMapping() throws IOException {
    File outputHeaderMappingFile = new File(tempDir, "mappings.j2objc");
    options.getHeaderMap().setOutputMappingFile(outputHeaderMappingFile);
    options.getHeaderMap().setOutputStyle(HeaderMap.OutputStyleOption.SOURCE);
    addSourceFile("package unit; public class Test { }", "unit/Test.java");
    addSourceFile("package unit; public class AnotherTest extends Test { }", "unit/AnotherTest.java");
    addSourceFile("package unit2;" + "import unit.Test;" + "public class AnotherTest extends Test { }", "unit2/AnotherTest.java");
    addSourceFile("package unit2;" + "import unit.AnotherTest;" + "public class YetAnotherTest extends AnotherTest { }", "unit2/YetAnotherTest.java");
    translateCombinedFiles("unit/Foo", ".h", "unit/Test.java", "unit/AnotherTest.java");
    String header2 = translateCombinedFiles("unit2/Foo", ".h", "unit2/AnotherTest.java", "unit2/YetAnotherTest.java");
    HeaderMap headerMap = options.getHeaderMap();
    assertEquals("unit/Foo.h", headerMap.getMapped("unit.Test"));
    assertEquals("unit/Foo.h", headerMap.getMapped("unit.AnotherTest"));
    assertTranslation(header2, "#include \"unit/Foo.h\"");
    assertEquals("unit2/Foo.h", headerMap.getMapped("unit2.AnotherTest"));
    assertEquals("unit2/Foo.h", headerMap.getMapped("unit2.YetAnotherTest"));
}
Also used : HeaderMap(com.google.devtools.j2objc.util.HeaderMap) File(java.io.File)

Example 3 with HeaderMap

use of com.google.devtools.j2objc.util.HeaderMap in project j2objc by google.

the class ObjectiveCHeaderGeneratorTest method testOutputHeaderFileMappingWithMultipleClassesInOneHeader.

public void testOutputHeaderFileMappingWithMultipleClassesInOneHeader() throws IOException {
    options.getHeaderMap().setMappingFiles("testMappings.j2objc");
    options.getHeaderMap().setOutputStyle(HeaderMap.OutputStyleOption.SOURCE);
    addSourceFile("package unit.mapping.custom; public class Test { }", "unit/mapping/custom/Test.java");
    addSourceFile("package unit.mapping.custom; public class AnotherTest { }", "unit/mapping/custom/AnotherTest.java");
    addSourceFile("package unit.test;" + "import unit.mapping.custom.Test;" + "public class Dummy extends Test { " + "    public Dummy() {}" + "}", "unit/test/Dummy.java");
    addSourceFile("package unit.test;" + "import unit.mapping.custom.AnotherTest;" + "public class AnotherDummy extends AnotherTest { " + "    public AnotherDummy() {}" + "}", "unit/test/AnotherDummy.java");
    preprocessFiles("unit/test/Dummy.java", "unit/test/AnotherDummy.java");
    loadHeaderMappings();
    String translationForDummy = translateSourceFile(getTranslatedFile("unit/test/Dummy.java"), "Dummy", "Dummy.h");
    String translationForAnotherDummy = translateSourceFile(getTranslatedFile("unit/test/AnotherDummy.java"), "AnotherDummy", "AnotherDummy.h");
    assertTranslation(translationForDummy, "#include \"my/mapping/custom/Test.h\"");
    assertTranslation(translationForAnotherDummy, "#include \"my/mapping/custom/Test.h\"");
    HeaderMap headerMap = options.getHeaderMap();
    assertEquals("unit/test/Dummy.h", headerMap.getMapped("unit.test.Dummy"));
    assertEquals("unit/test/AnotherDummy.h", headerMap.getMapped("unit.test.AnotherDummy"));
    assertEquals("my/mapping/custom/Test.h", headerMap.getMapped("unit.mapping.custom.Test"));
    assertEquals("my/mapping/custom/Test.h", headerMap.getMapped("unit.mapping.custom.AnotherTest"));
}
Also used : HeaderMap(com.google.devtools.j2objc.util.HeaderMap)

Aggregations

HeaderMap (com.google.devtools.j2objc.util.HeaderMap)3 File (java.io.File)1