use of org.intellij.lang.annotations.Language in project android by JetBrains.
the class LombokPsiConverterTest method testPsiToLombokConversion9.
// This test currently fails; need to tweak handling of whitespace around type parameters
//public void testPsiToLombokConversion8() {
// String testClass =
// "package test.pkg;\n" +
// "import java.util.HashMap;\n" +
// "\n" +
// "/* This stub is for using by IDE only. It is NOT the Manifest class actually packed into APK */\n" +
// "public final class R4 {\n" +
// " Object o = Collections.<Map<String,String>>emptyMap();\n" +
// " Object o2 = Collections.< Map < String , String>>>emptyMap();\n" +
// "}";
// PsiFile file = myFixture.addFileToProject("src/test/pkg/R4.java", testClass);
// check(file, testClass);
//}
public void testPsiToLombokConversion9() {
@Language("JAVA") String testClass = "package test.pkg;\n" + "\n" + "public final class R5 {\n" + " public void foo() {\n" + " setTitleColor(android.R.color.black);\n" + " setTitleColor(R.color.black);\n" + " }\n" + "}";
PsiFile file = myFixture.addFileToProject("src/test/pkg/R5.java", testClass);
check(file, testClass);
}
use of org.intellij.lang.annotations.Language in project android by JetBrains.
the class LombokPsiConverterTest method testPsiToLombokConversion7.
public void testPsiToLombokConversion7() {
@Language("JAVA") String testClass = "package test.pkg;\n" + "import java.util.HashMap;\n" + "\n" + "/* This stub is for using by IDE only. It is NOT the Manifest class actually packed into APK */\n" + "public final class R3<K, V> {\n" + " HashMap<Integer, Map<String, Integer>> s1 = new HashMap<Integer, Map<String, Integer>>();\n" + " Map<Map<String[], List<Integer[]>>,List<String[]>>[] s2;\n" + " Map<Integer, Map<String, List<Integer>>> s3;\n" + " int[][] s4;\n" + "}";
PsiFile file = myFixture.addFileToProject("src/test/pkg/R3.java", testClass);
check(file, testClass);
}
use of org.intellij.lang.annotations.Language in project android by JetBrains.
the class LombokPsiConverterTest method testClassLiterals.
public void testClassLiterals() {
//noinspection IfStatementWithIdenticalBranches,StatementWithEmptyBody
@Language("JAVA") String testClass = "package test.pkg;\n" + "\n" + "import java.lang.reflect.Field;\n" + "\n" + "public class R13 {\n" + " private static void dumpFlags(Field field) {\n" + " if (field.getType().equals(int.class)) {\n" + " } else if (field.getType().equals(int[].class)) {\n" + " } else if (field.getType().equals(int[][].class)) {\n" + " }\n" + " }\n" + "}";
PsiFile file = myFixture.addFileToProject("src/test/pkg/R12.java", testClass);
check(file, testClass);
}
use of org.intellij.lang.annotations.Language in project android by JetBrains.
the class NlDefaultRendererTest method testSimple.
public void testSimple() {
@Language("XML") String source = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\" >" + " <TextView android:id=\"@+id/textView\"/>" + "</RelativeLayout>";
XmlFile xmlFile = (XmlFile) myFixture.addFileToProject("res/layout/layout.xml", source);
XmlTag[] subTags = xmlFile.getRootTag().getSubTags();
assertEquals(1, subTags.length);
Table<String, String, NlPropertyItem> properties = NlProperties.getInstance().getProperties(ImmutableList.of(MockNlComponent.create(subTags[0])));
NlDefaultRenderer renderer = new NlDefaultRenderer();
NlPropertyItem property = properties.get(SdkConstants.ANDROID_URI, "id");
validateRendering(renderer, property, "id", "textView");
property = properties.get(SdkConstants.ANDROID_URI, "text");
validateRendering(renderer, property, "text", "");
property = properties.get(SdkConstants.ANDROID_URI, "focusable");
validateRendering(renderer, property, "focusable", "");
}
use of org.intellij.lang.annotations.Language in project android by JetBrains.
the class ConvertToConstraintLayoutTest method testConvert2.
@Ignore("http://b.android.com/211200")
@Test
public void testConvert2() throws Exception {
guiTest.importSimpleApplication();
EditorFixture editor = guiTest.ideFrame().getEditor();
editor.open("app/src/main/res/layout/frames.xml", EditorFixture.Tab.DESIGN);
NlEditorFixture layout = editor.getLayoutEditor(false);
layout.waitForRenderToFinish();
// Find and click the first text View
NlComponentFixture button = layout.findView("TextView", 0);
button.invokeContextMenuAction("Convert LinearLayout to ConstraintLayout");
// Confirm dialog
DialogFixture quickFixDialog = WindowFinder.findDialog(Matchers.byTitle(Dialog.class, "Convert to ConstraintLayout")).withTimeout(TimeUnit.MINUTES.toMillis(2)).using(guiTest.robot());
// Press OK
JButtonFixture finish = quickFixDialog.button(withText("OK"));
finish.click();
// Check that we've converted to what we expected
layout.waitForRenderToFinish();
editor.selectEditorTab(EditorFixture.Tab.EDITOR);
waitForScout();
editor.invokeAction(EditorFixture.EditorAction.FORMAT);
@Language("XML") String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n" + "<android.support.constraint.ConstraintLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n" + " xmlns:app=\"http://schemas.android.com/apk/res-auto\"\n" + " xmlns:tools=\"http://schemas.android.com/tools\"\n" + " android:id=\"@+id/constraintLayout\"\n" + " android:layout_width=\"match_parent\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:orientation=\"vertical\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\">\n" + "\n" + " <TextView\n" + " android:id=\"@+id/title\"\n" + " android:layout_width=\"wrap_content\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:text=\"Welcome\"\n" + " app:layout_constraintBottom_toBottomOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintLeft_toLeftOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintRight_toLeftOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintTop_toBottomOf=\"@+id/constraintLayout\"\n" + " tools:layout_constraintBottom_creator=\"1\"\n" + " tools:layout_constraintLeft_creator=\"1\"\n" + " tools:layout_constraintRight_creator=\"1\"\n" + " tools:layout_constraintTop_creator=\"1\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + " <FrameLayout\n" + " android:id=\"@+id/attending_remotely\"\n" + " android:layout_width=\"0dp\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:foreground=\"?android:selectableItemBackground\"\n" + " app:layout_constraintBottom_toBottomOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintLeft_toLeftOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintRight_toLeftOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintTop_toBottomOf=\"@+id/constraintLayout\"\n" + " tools:layout_constraintBottom_creator=\"1\"\n" + " tools:layout_constraintLeft_creator=\"1\"\n" + " tools:layout_constraintRight_creator=\"1\"\n" + " tools:layout_constraintTop_creator=\"1\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\">\n" + "\n" + " <ImageView\n" + " android:layout_width=\"100dp\"\n" + " android:layout_height=\"100dp\"\n" + " android:adjustViewBounds=\"true\"\n" + " android:scaleType=\"centerInside\"\n" + " app:layout_constraintLeft_toLeftOf=\"@+id/attending_remotely\"\n" + " tools:layout_constraintLeft_creator=\"1\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + " <TextView\n" + " android:layout_width=\"wrap_content\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:layout_gravity=\"bottom|end|right\"\n" + " android:text=\"Remotely\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + " </FrameLayout>\n" + "\n" + " <FrameLayout\n" + " android:id=\"@+id/attending_in_person\"\n" + " android:layout_width=\"0dp\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:foreground=\"?android:selectableItemBackground\"\n" + " app:layout_constraintBottom_toBottomOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintLeft_toLeftOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintRight_toLeftOf=\"@+id/constraintLayout\"\n" + " app:layout_constraintTop_toBottomOf=\"@+id/constraintLayout\"\n" + " tools:layout_constraintBottom_creator=\"1\"\n" + " tools:layout_constraintLeft_creator=\"1\"\n" + " tools:layout_constraintRight_creator=\"1\"\n" + " tools:layout_constraintTop_creator=\"1\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\">\n" + "\n" + " <ImageView\n" + " android:layout_width=\"100dp\"\n" + " android:layout_height=\"100dp\"\n" + " android:adjustViewBounds=\"true\"\n" + " android:scaleType=\"centerInside\"\n" + " app:layout_constraintLeft_toLeftOf=\"@+id/attending_in_person\"\n" + " tools:layout_constraintLeft_creator=\"1\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + " <TextView\n" + " android:layout_width=\"wrap_content\"\n" + " android:layout_height=\"wrap_content\"\n" + " android:layout_gravity=\"bottom|end|right\"\n" + " android:text=\"In Person\"\n" + " tools:layout_editor_absoluteX=\"<test>\"\n" + " tools:layout_editor_absoluteY=\"<test>\" />\n" + "\n" + " </FrameLayout>\n" + "\n" + "</android.support.constraint.ConstraintLayout>\n";
assertThat(wipeDimensions(editor.getCurrentFileContents())).isEqualTo(wipeDimensions(xml));
}
Aggregations