Permalink
Browse files

Add a Test for the Draggable behavior of the Dialog component

  • Loading branch information...
Gillespie59 committed Feb 9, 2012
1 parent a131ea9 commit 3e7e3bf43fee4eb793c307b5aa98257e31c59fac
@@ -23,17 +23,17 @@
public class DialogTest extends SeleniumTestCase {
+ String dialogLink = "identifier=dialoglink";
+ String dialogAjaxLink = "identifier=dialogajaxlink";
+ final String dialog = "identifier=myDialog";
+ String closeDialog = "css=span[class~=\"ui-icon-closethick\"]";
+ String zone = "identifier=myzone";
+
@Test
public void testDialog()
{
open("/jquerydialog");
- String dialogLink = "identifier=dialoglink";
- String dialogAjaxLink = "identifier=dialogajaxlink";
- final String dialog = "identifier=myDialog";
- String closeDialog = "css=span[class~=\"ui-icon-closethick\"]";
- String zone = "identifier=myzone";
-
checkDialogState(dialogLink, dialog, true);
checkDialogState(closeDialog, dialog, false);
@@ -51,6 +51,29 @@ public void testDialog()
checkDialogState(closeDialog, dialog, false);
}
+ @Test(dependsOnMethods="testDialog")
+ public void testDraggableDialog(){
+
+ open("/jquerydialog");
+
+ checkDialogState(dialogLink, dialog, true);
+
+ final Number top = getElementPositionTop("//div[contains(@class, 'ui-dialog-titlebar')]");
+
+ dragAndDropToObject("//div[contains(@class, 'ui-dialog-titlebar')]", "//div[@id='top']");
+
+ new Wait()
+ {
+ @Override
+ public boolean until()
+ {
+ return top != getElementPositionTop("//div[contains(@class, 'ui-dialog-titlebar')]");
+ }
+ }.wait("The dialog has not been moved !!", JQueryTestConstants.TIMEOUT);
+
+ checkDialogState(closeDialog, dialog, false);
+ }
+
private void checkDialogState(String triggerLocator, final String dialogLocator, final boolean state)
{
click(triggerLocator);
@@ -19,11 +19,13 @@
import java.util.ArrayList;
import java.util.List;
+import org.apache.tapestry5.EventConstants;
import org.apache.tapestry5.annotations.Component;
import org.apache.tapestry5.annotations.OnEvent;
import org.apache.tapestry5.annotations.Persist;
import org.apache.tapestry5.annotations.Property;
import org.apache.tapestry5.ioc.annotations.Inject;
+import org.apache.tapestry5.json.JSONObject;
import org.apache.tapestry5.services.Request;
public class JQueryDialog
@@ -37,7 +39,7 @@
@Inject
private Request request;
- @OnEvent("activate")
+ @OnEvent(value = EventConstants.ACTIVATE)
void init()
{
if (count == null)
@@ -49,7 +51,7 @@ public Integer getCount()
return count++;
}
- @OnEvent(value = "action")
+ @OnEvent(value = EventConstants.ACTION)
Object updateCount()
{
if (!request.isXHR()) { return this; }
@@ -72,5 +74,8 @@ Object updateCount()
return strings;
}
-
+
+ public JSONObject getOptions(){
+ return new JSONObject("draggable", "true");
+ }
}
@@ -1,5 +1,5 @@
<html t:type="layout" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_3.xsd" xmlns:p="tapestry:parameter">
- <t:jquery.dialog t:clientId="myDialog">
+ <t:jquery.dialog t:clientId="myDialog" t:params="options">
Dialog test!
<t:zone t:id="myZone">${count}

0 comments on commit 3e7e3bf

Please sign in to comment.