-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow onlyScaleDown() with fit() method #1600
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -401,6 +401,16 @@ public void intoImageViewWithSkipMemoryCachePolicy() { | |
verify(picasso, never()).quickMemoryCacheCheck(URI_KEY_1); | ||
} | ||
|
||
@Test | ||
public void intoImageViewWithFitAndOnlyScaleDown() { | ||
ImageView target = mockFitImageViewTarget(true); | ||
when(target.getWidth()).thenReturn(100); | ||
when(target.getHeight()).thenReturn(100); | ||
new RequestCreator(picasso, URI_1, 0).fit().onlyScaleDown().into(target); | ||
verify(picasso).enqueueAndSubmit(actionCaptor.capture()); | ||
assertThat(actionCaptor.getValue().getRequest().onlyScaleDown).isTrue(); | ||
} | ||
|
||
@Test | ||
public void intoImageViewWithFitAndResizeThrows() { | ||
try { | ||
|
@@ -544,7 +554,7 @@ public void intoRemoteViewsNotificationWithFitThrows() { | |
} | ||
|
||
@Test | ||
public void intoTargetNoResizeWithCenterInsideOrCenterCropThrows() { | ||
public void intoTargetNoResizeWithCenterInsideOrCenterCropOrOnlyScaleDownThrows() { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably also be named |
||
try { | ||
new RequestCreator(picasso, URI_1, 0).centerInside().into(mockTarget()); | ||
fail("Center inside with unknown width should throw exception."); | ||
|
@@ -555,6 +565,11 @@ public void intoTargetNoResizeWithCenterInsideOrCenterCropThrows() { | |
fail("Center inside with unknown height should throw exception."); | ||
} catch (IllegalStateException ignored) { | ||
} | ||
try { | ||
new RequestCreator(picasso, URI_1, 0).onlyScaleDown().into(mockTarget()); | ||
fail("onlyScaleDown with unknown height should throw exception."); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this fail when |
||
} catch (IllegalStateException ignored) { | ||
} | ||
} | ||
|
||
@Test public void appWidgetActionWithDefaultPriority() throws Exception { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
if(deferred || (targetWidth == 0 && targetHeight == 0))
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this check should be moved back to the
onlyScaleDown
method.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@JakeWharton This method is in the
Request
class, which seems to be in line with the other checks such as for null lists, invalid properties, and center[Crop|Inside] checks.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ahh, the
Request
class has no knowledge of fitting, which is done in theRequestCreator
class. I'm going to make my own pull request that will hopefully fix these issues cleanly.