Search in sources :

Example 21 with Language

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);
}
Also used : Language(org.intellij.lang.annotations.Language) PsiFile(com.intellij.psi.PsiFile)

Example 22 with Language

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);
}
Also used : Language(org.intellij.lang.annotations.Language) PsiFile(com.intellij.psi.PsiFile)

Example 23 with Language

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);
}
Also used : Language(org.intellij.lang.annotations.Language) PsiFile(com.intellij.psi.PsiFile)

Example 24 with Language

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", "");
}
Also used : Language(org.intellij.lang.annotations.Language) XmlFile(com.intellij.psi.xml.XmlFile) XmlTag(com.intellij.psi.xml.XmlTag) NlPropertyItem(com.android.tools.idea.uibuilder.property.NlPropertyItem)

Example 25 with Language

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));
}
Also used : JButtonFixture(org.fest.swing.fixture.JButtonFixture) EditorFixture(com.android.tools.idea.tests.gui.framework.fixture.EditorFixture) NlEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.layout.NlEditorFixture) NlEditorFixture(com.android.tools.idea.tests.gui.framework.fixture.layout.NlEditorFixture) DialogFixture(org.fest.swing.fixture.DialogFixture) Language(org.intellij.lang.annotations.Language) NlComponentFixture(com.android.tools.idea.tests.gui.framework.fixture.layout.NlComponentFixture) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Language (org.intellij.lang.annotations.Language)111 TableMetadata (com.facebook.presto.metadata.TableMetadata)25 Test (org.testng.annotations.Test)24 MaterializedResult (com.facebook.presto.testing.MaterializedResult)19 PsiFile (com.intellij.psi.PsiFile)18 MaterializedRow (com.facebook.presto.testing.MaterializedRow)11 List (java.util.List)11 Optional (java.util.Optional)11 Test (org.junit.Test)11 ImmutableList (com.google.common.collect.ImmutableList)10 Session (com.facebook.presto.Session)9 Constraint (com.facebook.presto.spi.Constraint)9 AbstractTestIntegrationSmokeTest (com.facebook.presto.tests.AbstractTestIntegrationSmokeTest)9 BasePlanTest (com.facebook.presto.sql.planner.assertions.BasePlanTest)8 ColumnConstraint (com.facebook.presto.sql.planner.planPrinter.IOPlanPrinter.ColumnConstraint)8 ImmutableMap (com.google.common.collect.ImmutableMap)8 ColumnMetadata (com.facebook.presto.spi.ColumnMetadata)7 ExpectedValueProvider (com.facebook.presto.sql.planner.assertions.ExpectedValueProvider)7 PlanMatchPattern (com.facebook.presto.sql.planner.assertions.PlanMatchPattern)7 SortOrder (com.facebook.presto.common.block.SortOrder)6