-
Notifications
You must be signed in to change notification settings - Fork 414
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed bug in Style that was causing unexpected results in statusbar
Previously the padding units or margin units to top/left/bottom/right on a proxy style, were not being applied to the underlying styles. Now they are.
- Loading branch information
Showing
4 changed files
with
232 additions
and
5 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
88 changes: 88 additions & 0 deletions
88
maven/core-unittests/src/test/java/com/codename1/ui/plaf/StyleProxyTest.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,88 @@ | ||
package com.codename1.ui.plaf; | ||
|
||
import com.codename1.ui.Component; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class StyleProxyTest { | ||
@Test | ||
public void testSetMarginUnitLeft() { | ||
Style s = new Style(); | ||
Style proxy = Style.createProxyStyle(s); | ||
proxy.setMarginUnitLeft(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getMarginUnit()[Component.LEFT]); | ||
proxy.setMarginUnitLeft(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getMarginUnit()[Component.LEFT]); | ||
} | ||
|
||
@Test | ||
public void testSetMarginUnitRight() { | ||
Style s = new Style(); | ||
Style proxy = Style.createProxyStyle(s); | ||
proxy.setMarginUnitRight(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getMarginUnit()[Component.RIGHT]); | ||
proxy.setMarginUnitRight(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getMarginUnit()[Component.RIGHT]); | ||
} | ||
|
||
@Test | ||
public void testSetMarginUnitBottom() { | ||
Style s = new Style(); | ||
Style proxy = Style.createProxyStyle(s); | ||
proxy.setMarginUnitBottom(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getMarginUnit()[Component.BOTTOM]); | ||
proxy.setMarginUnitBottom(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getMarginUnit()[Component.BOTTOM]); | ||
} | ||
|
||
@Test | ||
public void testSetMarginUnitTop() { | ||
Style s = new Style(); | ||
Style proxy = Style.createProxyStyle(s); | ||
proxy.setMarginUnitTop(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getMarginUnit()[Component.TOP]); | ||
proxy.setMarginUnitTop(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getMarginUnit()[Component.TOP]); | ||
} | ||
|
||
@Test | ||
public void testSetPaddingUnitTop() { | ||
Style s = new Style(); | ||
Style proxy = Style.createProxyStyle(s); | ||
proxy.setPaddingUnitTop(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getPaddingUnit()[Component.TOP]); | ||
proxy.setPaddingUnitTop(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getPaddingUnit()[Component.TOP]); | ||
} | ||
|
||
@Test | ||
public void testSetPaddingUnitBottom() { | ||
Style s = new Style(); | ||
Style proxy = Style.createProxyStyle(s); | ||
proxy.setPaddingUnitBottom(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getPaddingUnit()[Component.BOTTOM]); | ||
proxy.setPaddingUnitBottom(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getPaddingUnit()[Component.BOTTOM]); | ||
} | ||
|
||
@Test | ||
public void testSetPaddingUnitLeft() { | ||
Style s = new Style(); | ||
Style proxy = Style.createProxyStyle(s); | ||
proxy.setPaddingUnitLeft(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getPaddingUnit()[Component.LEFT]); | ||
proxy.setPaddingUnitLeft(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getPaddingUnit()[Component.LEFT]); | ||
} | ||
|
||
@Test | ||
public void testSetPaddingUnitRight() { | ||
Style s = new Style(); | ||
Style proxy = Style.createProxyStyle(s); | ||
proxy.setPaddingUnitRight(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getPaddingUnit()[Component.RIGHT]); | ||
proxy.setPaddingUnitRight(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getPaddingUnit()[Component.RIGHT]); | ||
} | ||
} |
81 changes: 81 additions & 0 deletions
81
maven/core-unittests/src/test/java/com/codename1/ui/plaf/StyleTest.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,81 @@ | ||
package com.codename1.ui.plaf; | ||
|
||
import com.codename1.ui.Component; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
public class StyleTest { | ||
@Test | ||
public void testSetMarginUnitLeft() { | ||
Style s = new Style(); | ||
s.setMarginUnitLeft(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getMarginUnit()[Component.LEFT]); | ||
s.setMarginUnitLeft(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getMarginUnit()[Component.LEFT]); | ||
} | ||
|
||
@Test | ||
public void testSetMarginUnitRight() { | ||
Style s = new Style(); | ||
s.setMarginUnitRight(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getMarginUnit()[Component.RIGHT]); | ||
s.setMarginUnitRight(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getMarginUnit()[Component.RIGHT]); | ||
} | ||
|
||
@Test | ||
public void testSetMarginUnitBottom() { | ||
Style s = new Style(); | ||
s.setMarginUnitBottom(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getMarginUnit()[Component.BOTTOM]); | ||
s.setMarginUnitBottom(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getMarginUnit()[Component.BOTTOM]); | ||
} | ||
|
||
@Test | ||
public void testSetMarginUnitTop() { | ||
Style s = new Style(); | ||
s.setMarginUnitTop(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getMarginUnit()[Component.TOP]); | ||
s.setMarginUnitTop(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getMarginUnit()[Component.TOP]); | ||
} | ||
|
||
@Test | ||
public void testSetPaddingUnitTop() { | ||
Style s = new Style(); | ||
s.setPaddingUnitTop(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getPaddingUnit()[Component.TOP]); | ||
s.setPaddingUnitTop(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getPaddingUnit()[Component.TOP]); | ||
} | ||
|
||
@Test | ||
public void testSetPaddingUnitBottom() { | ||
Style s = new Style(); | ||
s.setPaddingUnitBottom(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getPaddingUnit()[Component.BOTTOM]); | ||
s.setPaddingUnitBottom(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getPaddingUnit()[Component.BOTTOM]); | ||
} | ||
|
||
@Test | ||
public void testSetPaddingUnitLeft() { | ||
Style s = new Style(); | ||
s.setPaddingUnitLeft(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getPaddingUnit()[Component.LEFT]); | ||
s.setPaddingUnitLeft(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getPaddingUnit()[Component.LEFT]); | ||
} | ||
|
||
@Test | ||
public void testSetPaddingUnitRight() { | ||
Style s = new Style(); | ||
s.setPaddingUnitRight(Style.UNIT_TYPE_PIXELS); | ||
assertEquals(Style.UNIT_TYPE_PIXELS, s.getPaddingUnit()[Component.RIGHT]); | ||
s.setPaddingUnitRight(Style.UNIT_TYPE_DIPS); | ||
assertEquals(Style.UNIT_TYPE_DIPS, s.getPaddingUnit()[Component.RIGHT]); | ||
} | ||
|
||
} |