-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Focal point no longer works in image service #9244
- Loading branch information
Showing
8 changed files
with
121 additions
and
46 deletions.
There are no files selected for viewing
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
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
63 changes: 63 additions & 0 deletions
63
...re/core-image/src/test/java/com/enonic/xp/core/impl/image/effect/ScaleCalculatorTest.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,63 @@ | ||
package com.enonic.xp.core.impl.image.effect; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
class ScaleCalculatorTest | ||
{ | ||
@Test | ||
void block_upscale_focal_upper_left() | ||
{ | ||
final ScaleCalculator.Values values = ScaleCalculator.block( 1000, 1000, 0, 0 ).calc( 100, 200 ); | ||
|
||
assertThat( values ).extracting( v -> v.newWidth, v -> v.newHeight, v -> v.widthOffset, v -> v.heightOffset, v -> v.viewWidth, | ||
v -> v.viewHeight ).containsExactly( 1000, 2000, 0, 0, 1000, 1000 ); | ||
} | ||
|
||
@Test | ||
void block_focal_upper_left() | ||
{ | ||
final ScaleCalculator.Values values = ScaleCalculator.block( 10, 10, 0, 0 ).calc( 100, 200 ); | ||
|
||
assertThat( values ).extracting( v -> v.newWidth, v -> v.newHeight, v -> v.widthOffset, v -> v.heightOffset, v -> v.viewWidth, | ||
v -> v.viewHeight ).containsExactly( 10, 20, 0, 0, 10, 10 ); | ||
} | ||
|
||
@Test | ||
void block_focal_lower_left() | ||
{ | ||
final ScaleCalculator.Values values = ScaleCalculator.block( 10, 10, 0, 1 ).calc( 100, 200 ); | ||
|
||
assertThat( values ).extracting( v -> v.newWidth, v -> v.newHeight, v -> v.widthOffset, v -> v.heightOffset, v -> v.viewWidth, | ||
v -> v.viewHeight ).containsExactly( 10, 20, 0, 10, 10, 10 ); | ||
} | ||
|
||
@Test | ||
void block_mixscale_focal_lower_left() | ||
{ | ||
final ScaleCalculator.Values values = ScaleCalculator.block( 1000, 10, 0, 1 ).calc( 100, 200 ); | ||
|
||
assertThat( values ).extracting( v -> v.newWidth, v -> v.newHeight, v -> v.widthOffset, v -> v.heightOffset, v -> v.viewWidth, | ||
v -> v.viewHeight ).containsExactly( 1000, 2000, 0, 1990, 1000, 10 ); | ||
} | ||
|
||
@Test | ||
void block_focal_upper_right() | ||
{ | ||
final ScaleCalculator.Values values = ScaleCalculator.block( 10, 10, 1, 0 ).calc( 200, 100 ); | ||
|
||
assertThat( values ).extracting( v -> v.newWidth, v -> v.newHeight, v -> v.widthOffset, v -> v.heightOffset, v -> v.viewWidth, | ||
v -> v.viewHeight ).containsExactly( 20, 10, 10, 0, 10, 10 ); | ||
} | ||
|
||
@Test | ||
void block_focal_lower_right() | ||
{ | ||
final ScaleCalculator.Values values = ScaleCalculator.block( 10, 10, 1, 1 ).calc( 200, 100 ); | ||
|
||
assertThat( values ).extracting( v -> v.newWidth, v -> v.newHeight, v -> v.widthOffset, v -> v.heightOffset, v -> v.viewWidth, | ||
v -> v.viewHeight ).containsExactly( 20, 10, 10, 0, 10, 10 ); | ||
} | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
...ore/core-image/src/test/java/com/enonic/xp/core/impl/image/effect/ScaledFunctionTest.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,16 @@ | ||
package com.enonic.xp.core.impl.image.effect; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
class ScaledFunctionTest | ||
{ | ||
@Test | ||
void estimateResolution() | ||
{ | ||
final ScaledFunction scaledFunction = new ScaledFunction( ScaleCalculator.block( 10, 15, 0.5, 0.5 ) ); | ||
assertEquals( 150, scaledFunction.estimateResolution( 1000, 1500 ) ); | ||
|
||
} | ||
} |