Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
shannah committed Nov 13, 2023
1 parent dbdc294 commit ea026fe
Showing 1 changed file with 26 additions and 11 deletions.
37 changes: 26 additions & 11 deletions tests/core/src/com/codename1/ui/TestComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ private void getComponentAt_int_int_button() {

f.show();
TestUtils.waitForFormTitle("My Form");
Component middleComponent = f.getComponentAt(w/2, h/2);
h = f.getContentPane().getHeight();
int offsetY = f.getContentPane().getAbsoluteY();
Component middleComponent = f.getComponentAt(w/2, offsetY + h/2);
assertEqual(l, middleComponent, "Found wrong component");
}

Expand All @@ -134,7 +136,9 @@ private void getComponentAt_int_int_label() {

f.show();
TestUtils.waitForFormTitle("My Form", 2000);
Component middleComponent = f.getComponentAt(w/2, h/2);
h = f.getContentPane().getHeight();
int offsetY = f.getContentPane().getAbsoluteY();
Component middleComponent = f.getComponentAt(w/2, offsetY + h/2);
assertEqual(l, middleComponent, "Found wrong component");


Expand Down Expand Up @@ -182,7 +186,9 @@ protected Dimension calcPreferredSize() {

f.show();
TestUtils.waitForFormTitle("My Form", 2000);
Component middleComponent = f.getComponentAt(w/2, h/2);
int hInner = f.getContentPane().getHeight();
int offsetY = f.getContentPane().getAbsoluteY();
Component middleComponent = f.getComponentAt(w/2, offsetY + hInner/2);
assertEqual(top, middleComponent, "Found wrong component");
}

Expand Down Expand Up @@ -231,7 +237,9 @@ protected Dimension calcPreferredSize() {

f.show();
TestUtils.waitForFormTitle("My Form", 2000);
Component middleComponent = f.getComponentAt(w/2, h/2);
int hInner = f.getContentPane().getHeight();
int offsetY = f.getContentPane().getAbsoluteY();
Component middleComponent = f.getComponentAt(w/2, offsetY + hInner/2);
assertEqual(content, middleComponent, "Found wrong component");
}

Expand Down Expand Up @@ -264,8 +272,12 @@ public void actionPerformed(ActionEvent e) {
f.show();

TestUtils.waitForFormTitle("Scrolling Labels", 2000);
Component res = f.getComponentAt(w/2, h/2);
assertTrue(res == cnt || res.getParent() == cnt, "getComponentAt(x,y) should return scrollable container on top of button when in layered pane.");
h = f.getContentPane().getHeight();
int offsetY = f.getContentPane().getAbsoluteY();
Component res = f.getComponentAt(w/2, offsetY + h/2);
assertTrue(
res == cnt || res.getParent() == cnt,
"getComponentAt(x,y) should return scrollable container on top of button when in layered pane, but received " + res + ". Form: " + f);

}

Expand All @@ -279,7 +291,9 @@ private void getComponentAt_int_int_container() {

f.show();
TestUtils.waitForFormTitle("My Form", 2000);
Component middleComponent = f.getComponentAt(w/2, h/2);
h = f.getContentPane().getHeight();
int offsetY = f.getContentPane().getAbsoluteY();
Component middleComponent = f.getComponentAt(w/2, offsetY + h/2);
assertEqual(l, middleComponent, "Found wrong component");
}

Expand Down Expand Up @@ -307,20 +321,21 @@ public void actionPerformed(ActionEvent e) {
mapDemo.show();

TestUtils.waitForFormTitle("Maps", 2000);
Component middleComponent = mapDemo.getComponentAt(w/2, h/2);
h = mapDemo.getContentPane().getHeight();
int offsetY = mapDemo.getContentPane().getAbsoluteY();
Component middleComponent = mapDemo.getComponentAt(w/2,offsetY + h/2);
assertTrue(mc == middleComponent || mc.contains(middleComponent), "Wrong component found in middle. Expected "+mc+" but found "+middleComponent);

tb.openSideMenu();
TestUtils.waitFor(500); // wait for side menu to open

Component res = null;

res = tb.getComponentAt(10, h/2);
res = tb.getComponentAt(10, offsetY + h/2);

//System.out.println("tb size = "+tb.getAbsoluteX()+", "+tb.getAbsoluteY()+", "+tb.getWidth()+", "+tb.getHeight());
//System.out.println("mb size = "+tb.getMenuBar().getAbsoluteX()+", "+tb.getMenuBar().getAbsoluteY()+", "+tb.getMenuBar().getWidth()+", "+tb.getMenuBar().getHeight());
//System.out.println("res is "+res);
res = mapDemo.getComponentAt(10, h/2);
res = mapDemo.getComponentAt(10, offsetY + h/2);

// Let's find the interaction dialog on the form
Component interactionDialog = $("*", mapDemo).filter(c->{
Expand Down

0 comments on commit ea026fe

Please sign in to comment.