diff options
Diffstat (limited to 'src/test/java/com/android/volley/toolbox/NetworkImageViewTest.java')
-rw-r--r-- | src/test/java/com/android/volley/toolbox/NetworkImageViewTest.java | 36 |
1 files changed, 23 insertions, 13 deletions
diff --git a/src/test/java/com/android/volley/toolbox/NetworkImageViewTest.java b/src/test/java/com/android/volley/toolbox/NetworkImageViewTest.java index 055005f..af8fad9 100644 --- a/src/test/java/com/android/volley/toolbox/NetworkImageViewTest.java +++ b/src/test/java/com/android/volley/toolbox/NetworkImageViewTest.java @@ -16,31 +16,34 @@ package com.android.volley.toolbox; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; + import android.content.Context; import android.util.AttributeSet; import android.view.ViewGroup.LayoutParams; import android.widget.ImageView.ScaleType; - import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.robolectric.RuntimeEnvironment; import org.robolectric.RobolectricTestRunner; - -import static org.junit.Assert.*; +import org.robolectric.RuntimeEnvironment; @RunWith(RobolectricTestRunner.class) public class NetworkImageViewTest { private NetworkImageView mNIV; private MockImageLoader mMockImageLoader; - @Before public void setUp() throws Exception { + @Before + public void setUp() throws Exception { mMockImageLoader = new MockImageLoader(); mNIV = new NetworkImageView(RuntimeEnvironment.application); } - @Test public void setImageUrl_requestsImage() { - mNIV.setLayoutParams(new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); + @Test + public void setImageUrl_requestsImage() { + mNIV.setLayoutParams( + new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT)); mNIV.setImageUrl("http://foo", mMockImageLoader); assertEquals("http://foo", mMockImageLoader.lastRequestUrl); assertEquals(0, mMockImageLoader.lastMaxWidth); @@ -52,7 +55,7 @@ public class NetworkImageViewTest { // // instrumentation test. Write this test once it's figured out. // } - private class MockImageLoader extends ImageLoader { + private static class MockImageLoader extends ImageLoader { public MockImageLoader() { super(null, null); } @@ -61,8 +64,13 @@ public class NetworkImageViewTest { public int lastMaxWidth; public int lastMaxHeight; - public ImageContainer get(String requestUrl, ImageListener imageListener, int maxWidth, - int maxHeight, ScaleType scaleType) { + @Override + public ImageContainer get( + String requestUrl, + ImageListener imageListener, + int maxWidth, + int maxHeight, + ScaleType scaleType) { lastRequestUrl = requestUrl; lastMaxWidth = maxWidth; lastMaxHeight = maxHeight; @@ -75,10 +83,12 @@ public class NetworkImageViewTest { // Catch-all test to find API-breaking changes. assertNotNull(NetworkImageView.class.getConstructor(Context.class)); assertNotNull(NetworkImageView.class.getConstructor(Context.class, AttributeSet.class)); - assertNotNull(NetworkImageView.class.getConstructor(Context.class, AttributeSet.class, - int.class)); + assertNotNull( + NetworkImageView.class.getConstructor( + Context.class, AttributeSet.class, int.class)); - assertNotNull(NetworkImageView.class.getMethod("setImageUrl", String.class, ImageLoader.class)); + assertNotNull( + NetworkImageView.class.getMethod("setImageUrl", String.class, ImageLoader.class)); assertNotNull(NetworkImageView.class.getMethod("setDefaultImageResId", int.class)); assertNotNull(NetworkImageView.class.getMethod("setErrorImageResId", int.class)); } |