use of butterknife.compiler.ButterKnifeProcessor in project butterknife by JakeWharton.
the class BindArrayTest method typeMustBeSupported.
@Test
public void typeMustBeSupported() {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", "" + "package test;\n" + "import butterknife.BindArray;\n" + "public class Test {\n" + " @BindArray(1) String one;\n" + "}");
assertAbout(javaSource()).that(source).processedWith(new ButterKnifeProcessor()).failsToCompile().withErrorContaining("@BindArray field type must be one of: String[], int[], CharSequence[], " + "android.content.res.TypedArray. (test.Test.one)").in(source).onLine(4);
}
use of butterknife.compiler.ButterKnifeProcessor in project butterknife by JakeWharton.
the class BindArrayTest method textArray.
@Test
public void textArray() throws Exception {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", "" + "package test;\n" + "import butterknife.BindArray;\n" + "public class Test {\n" + " @BindArray(1) CharSequence[] one;\n" + "}");
JavaFileObject bindingSource = JavaFileObjects.forSourceString("test/Test_ViewBinding", "" + "// Generated code from Butter Knife. Do not modify!\n" + "package test;\n" + "import android.content.Context;\n" + "import android.content.res.Resources;\n" + "import android.support.annotation.CallSuper;\n" + "import android.support.annotation.UiThread;\n" + "import android.view.View;\n" + "import butterknife.Unbinder;\n" + "import java.lang.Deprecated;\n" + "import java.lang.Override;\n" + "import java.lang.SuppressWarnings;\n" + "public class Test_ViewBinding implements Unbinder {\n" + " /**\n" + " * @deprecated Use {@link #Test_ViewBinding(Test, Context)} for direct creation.\n" + " * Only present for runtime invocation through {@code ButterKnife.bind()}.\n" + " */\n" + " @Deprecated\n" + " @UiThread\n" + " public Test_ViewBinding(Test target, View source) {\n" + " this(target, source.getContext());\n" + " }\n" + " @UiThread\n" + " @SuppressWarnings(\"ResourceType\")\n" + " public Test_ViewBinding(Test target, Context context) {\n" + " Resources res = context.getResources();\n" + " target.one = res.getTextArray(1);\n" + " }\n" + " @Override\n" + " @CallSuper\n" + " public void unbind() {\n" + " }\n" + "}");
assertAbout(javaSource()).that(source).withCompilerOptions("-Xlint:-processing").processedWith(new ButterKnifeProcessor()).compilesWithoutWarnings().and().generatesSources(bindingSource);
}
use of butterknife.compiler.ButterKnifeProcessor in project butterknife by JakeWharton.
the class BindBitmapTest method typeMustBeBitmap.
@Test
public void typeMustBeBitmap() {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", "" + "package test;\n" + "import butterknife.BindBitmap;\n" + "public class Test {\n" + " @BindBitmap(1) String one;\n" + "}");
assertAbout(javaSource()).that(source).processedWith(new ButterKnifeProcessor()).failsToCompile().withErrorContaining("@BindBitmap field type must be 'Bitmap'. (test.Test.one)").in(source).onLine(4);
}
use of butterknife.compiler.ButterKnifeProcessor in project butterknife by JakeWharton.
the class BindColorTest method simpleColorStateList.
@Test
public void simpleColorStateList() {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", "" + "package test;\n" + "import android.content.res.ColorStateList;\n" + "import butterknife.BindColor;\n" + "public class Test {\n" + " @BindColor(1) ColorStateList one;\n" + "}");
JavaFileObject bindingSource = JavaFileObjects.forSourceString("test/Test_ViewBinding", "" + "// Generated code from Butter Knife. Do not modify!\n" + "package test;\n" + "import android.content.Context;\n" + "import android.support.annotation.CallSuper;\n" + "import android.support.annotation.UiThread;\n" + "import android.support.v4.content.ContextCompat;\n" + "import android.view.View;\n" + "import butterknife.Unbinder;\n" + "import java.lang.Deprecated;\n" + "import java.lang.Override;\n" + "import java.lang.SuppressWarnings;\n" + "public class Test_ViewBinding implements Unbinder {\n" + " /**\n" + " * @deprecated Use {@link #Test_ViewBinding(Test, Context)} for direct creation.\n" + " * Only present for runtime invocation through {@code ButterKnife.bind()}.\n" + " */\n" + " @Deprecated\n" + " @UiThread\n" + " public Test_ViewBinding(Test target, View source) {\n" + " this(target, source.getContext());\n" + " }\n" + " @UiThread\n" + " @SuppressWarnings(\"ResourceType\")\n" + " public Test_ViewBinding(Test target, Context context) {\n" + " target.one = ContextCompat.getColorStateList(context, 1);\n" + " }\n" + " @Override\n" + " @CallSuper\n" + " public void unbind() {\n" + " }\n" + "}");
assertAbout(javaSource()).that(source).withCompilerOptions("-Xlint:-processing").processedWith(new ButterKnifeProcessor()).compilesWithoutWarnings().and().generatesSources(bindingSource);
}
use of butterknife.compiler.ButterKnifeProcessor in project butterknife by JakeWharton.
the class BindDimenTest method simpleFloat.
@Test
public void simpleFloat() {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", "" + "package test;\n" + "import butterknife.BindDimen;\n" + "public class Test {\n" + " @BindDimen(1) float one;\n" + "}");
JavaFileObject bindingSource = JavaFileObjects.forSourceString("test/Test_ViewBinding", "" + "// Generated code from Butter Knife. Do not modify!\n" + "package test;\n" + "import android.content.Context;\n" + "import android.content.res.Resources;\n" + "import android.support.annotation.CallSuper;\n" + "import android.support.annotation.UiThread;\n" + "import android.view.View;\n" + "import butterknife.Unbinder;\n" + "import java.lang.Deprecated;\n" + "import java.lang.Override;\n" + "import java.lang.SuppressWarnings;\n" + "public class Test_ViewBinding implements Unbinder {\n" + " /**\n" + " * @deprecated Use {@link #Test_ViewBinding(Test, Context)} for direct creation.\n" + " * Only present for runtime invocation through {@code ButterKnife.bind()}.\n" + " */\n" + " @Deprecated\n" + " @UiThread\n" + " public Test_ViewBinding(Test target, View source) {\n" + " this(target, source.getContext());\n" + " }\n" + " @UiThread\n" + " @SuppressWarnings(\"ResourceType\")\n" + " public Test_ViewBinding(Test target, Context context) {\n" + " Resources res = context.getResources();\n" + " target.one = res.getDimension(1);\n" + " }\n" + " @Override\n" + " @CallSuper\n" + " public void unbind() {\n" + " }\n" + "}");
assertAbout(javaSource()).that(source).withCompilerOptions("-Xlint:-processing").processedWith(new ButterKnifeProcessor()).compilesWithoutWarnings().and().generatesSources(bindingSource);
}
Aggregations