use of butterknife.compiler.ButterKnifeProcessor in project butterknife by JakeWharton.
the class BindDrawableTest method typeMustBeDrawable.
@Test
public void typeMustBeDrawable() {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", "" + "package test;\n" + "import butterknife.BindDrawable;\n" + "public class Test {\n" + " @BindDrawable(1) String one;\n" + "}");
assertAbout(javaSource()).that(source).processedWith(new ButterKnifeProcessor()).failsToCompile().withErrorContaining("@BindDrawable field type must be 'Drawable'. (test.Test.one)").in(source).onLine(4);
}
use of butterknife.compiler.ButterKnifeProcessor in project butterknife by JakeWharton.
the class BindFloatTest method simple.
@Test
public void simple() {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", "" + "package test;" + "import butterknife.BindFloat;" + "public class Test {" + " @BindFloat(1) float one;" + "}");
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.view.View;\n" + "import butterknife.Unbinder;\n" + "import butterknife.internal.Utils;\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 = Utils.getFloat(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 BindIntTest method typeMustBeInt.
@Test
public void typeMustBeInt() {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", "" + "package test;\n" + "import butterknife.BindInt;\n" + "public class Test {\n" + " @BindInt(1) String one;\n" + "}");
assertAbout(javaSource()).that(source).processedWith(new ButterKnifeProcessor()).failsToCompile().withErrorContaining("@BindInt field type must be 'int'. (test.Test.one)").in(source).onLine(4);
}
use of butterknife.compiler.ButterKnifeProcessor in project butterknife by JakeWharton.
the class BindStringTest method simple.
@Test
public void simple() {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", "" + "package test;\n" + "import butterknife.BindString;\n" + "public class Test {\n" + " @BindString(1) String 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.getString(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 BindViewTest method failsIfInPrivateClass.
@Test
public void failsIfInPrivateClass() {
JavaFileObject source = JavaFileObjects.forSourceString("test.Test", "" + "package test;\n" + "import android.view.View;\n" + "import butterknife.BindView;\n" + "public class Test {\n" + " private static class Inner {\n" + " @BindView(1) View thing;\n" + " }\n" + "}");
assertAbout(javaSource()).that(source).processedWith(new ButterKnifeProcessor()).failsToCompile().withErrorContaining("@BindView fields may not be contained in private classes. (test.Test.Inner.thing)").in(source).onLine(5);
}
Aggregations