-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1105 from JakeWharton/jw/more-functional/2017-10-13
Port more resource binding to functional tests.
- Loading branch information
Showing
9 changed files
with
112 additions
and
163 deletions.
There are no files selected for viewing
33 changes: 33 additions & 0 deletions
33
butterknife/src/androidTest/java/butterknife/functional/BindBitmapTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package butterknife.functional; | ||
|
||
import android.content.Context; | ||
import android.graphics.Bitmap; | ||
import android.graphics.BitmapFactory; | ||
import android.support.test.InstrumentationRegistry; | ||
import butterknife.BindBitmap; | ||
import butterknife.BindBool; | ||
import butterknife.Unbinder; | ||
import butterknife.test.R; | ||
import org.junit.Test; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public final class BindBitmapTest { | ||
private final Context context = InstrumentationRegistry.getContext(); | ||
|
||
static class Target { | ||
@BindBitmap(R.drawable.pixel) Bitmap actual; | ||
} | ||
|
||
@Test public void asBitmap() { | ||
Target target = new Target(); | ||
Bitmap expected = BitmapFactory.decodeResource(context.getResources(), R.drawable.pixel); | ||
|
||
Unbinder unbinder = new BindBitmapTest$Target_ViewBinding(target, context); | ||
assertTrue(target.actual.sameAs(expected)); | ||
|
||
unbinder.unbind(); | ||
assertTrue(target.actual.sameAs(expected)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
butterknife/src/androidTest/java/butterknife/functional/BindDrawableTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package butterknife.functional; | ||
|
||
import android.content.Context; | ||
import android.graphics.Bitmap; | ||
import android.graphics.BitmapFactory; | ||
import android.graphics.drawable.Drawable; | ||
import android.support.test.InstrumentationRegistry; | ||
import butterknife.BindBitmap; | ||
import butterknife.BindDrawable; | ||
import butterknife.Unbinder; | ||
import butterknife.test.R; | ||
import org.junit.Test; | ||
|
||
import static com.google.common.truth.Truth.assertThat; | ||
import static org.junit.Assert.assertTrue; | ||
|
||
public final class BindDrawableTest { | ||
private final Context context = InstrumentationRegistry.getContext(); | ||
|
||
static class Target { | ||
@BindDrawable(R.drawable.circle) Drawable actual; | ||
} | ||
|
||
@Test public void asDrawable() { | ||
Target target = new Target(); | ||
Drawable expected = context.getResources().getDrawable(R.drawable.circle); | ||
|
||
Unbinder unbinder = new BindDrawableTest$Target_ViewBinding(target, context); | ||
assertThat(target.actual.getConstantState()).isEqualTo(expected.getConstantState()); | ||
|
||
unbinder.unbind(); | ||
assertThat(target.actual.getConstantState()).isEqualTo(expected.getConstantState()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<item | ||
android:color="#ffff0000" | ||
android:state_pressed="true" | ||
/> | ||
<item | ||
android:color="#ff0000ff" | ||
android:state_focused="true" | ||
/> | ||
<item android:color="#ff000000"/> | ||
</selector> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<shape | ||
xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:shape="oval" | ||
> | ||
<size | ||
android:height="10px" | ||
android:width="10px" | ||
/> | ||
<solid | ||
android:color="#fff" | ||
/> | ||
</shape> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters