android UI xml bridge initial
- add frontend.android module - add xml ids to kotlin extension properties converter - add converter basic functional test
This commit is contained in:
committed by
Yan Zhulanow
parent
c8c1ce521b
commit
1e8769b5f7
@@ -21,5 +21,6 @@
|
||||
<orderEntry type="module" module-name="js.tests" />
|
||||
<orderEntry type="module" module-name="preloader" />
|
||||
<orderEntry type="module" module-name="util" />
|
||||
<orderEntry type="module" module-name="frontend.android" scope="TEST" />
|
||||
</component>
|
||||
</module>
|
||||
</module>
|
||||
|
||||
@@ -0,0 +1,49 @@
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.lang.resolve.android.AndroidUIXmlParser;
|
||||
import org.jetbrains.jet.test.TestCaseWithTmpdir;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Scanner;
|
||||
|
||||
public class AndroidXmlTest extends TestCaseWithTmpdir {
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static String getTestDataPath() {
|
||||
return JetTestCaseBuilder.getTestDataPathBase() + "/android";
|
||||
}
|
||||
|
||||
@SuppressWarnings({"ResultOfMethodCallIgnored", "IOResourceOpenedButNotSafelyClosed"})
|
||||
protected static String loadOrCreate(File file, String data) throws IOException {
|
||||
try {
|
||||
return new Scanner(file, "UTF-8" ).useDelimiter("\\A").next();
|
||||
} catch (IOException e) {
|
||||
file.createNewFile();
|
||||
FileWriter fileWriter = new FileWriter(file);
|
||||
fileWriter.write(data);
|
||||
fileWriter.close();
|
||||
fail("Empty expected data, creating from actual");
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
public void testConverterOneFile() throws Exception {
|
||||
ArrayList<File> paths = new ArrayList<File>();
|
||||
paths.add(new File(getTestDataPath() + "/layout.xml"));
|
||||
AndroidUIXmlParser parser = new AndroidUIXmlParser(null, paths);
|
||||
|
||||
String actual = parser.parse();
|
||||
String expected = loadOrCreate(new File(getTestDataPath() + "/layout.kt"), actual);
|
||||
|
||||
assertEquals(expected, actual);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user