Package com.ponysdk.test.UiBuilderTestEntryPoint

Examples of com.ponysdk.test.UiBuilderTestEntryPoint.RequestHandler


    @Test
    public void testPAnchor() {

        // creation
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PAnchor anchor = new PAnchor("An anchor");
                anchor.ensureDebugId("anchor1");
                PRootPanel.get().add(anchor);

                register(anchor);
            }
        });

        WebElement element = findElementById("anchor1");
        Assert.assertEquals("An anchor", element.getText());

        // update text
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PAnchor anchor = get("anchor1");
                anchor.setText("New text of the anchor");
            }
        });

        element = findElementById("anchor1");
        Assert.assertEquals("New text of the anchor", element.getText());

        // update html
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PAnchor anchor = get("anchor1");
                anchor.setHTML("Anchor <font color='red'>with pure html</font>");
View Full Code Here


    @Test
    public void testPButtonBase() {

        // creation
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PButton button1 = new PButton("A button");
                button1.ensureDebugId("button1");
                PRootPanel.get().add(button1);

                register(button1);
            }
        });

        WebElement element = findElementById("button1");
        Assert.assertEquals("A button", element.getText());

        // update text
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PButton button1 = get("button1");
                button1.setText("New text of the button");
            }
        });

        element = findElementById("button1");
        Assert.assertEquals("New text of the button", element.getText());

        // update html
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PButton button1 = get("button1");
                button1.setHTML("Button <font color='red'>with pure html</font>");
View Full Code Here

    @Test
    @SuppressWarnings("unchecked")
    public void testPCheckBox() {

        // creation
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PCheckBox checkbox1 = new PCheckBox("A checkbox");
                checkbox1.ensureDebugId("checkbox1");
View Full Code Here

    @Test
    public void testPComplexPanel() {

        // creation
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PComplexPanel complexPanel1 = new PVerticalPanel();
                complexPanel1.ensureDebugId("complexPanel1");
                PRootPanel.get().add(complexPanel1);
                register(complexPanel1);
            }
        });

        WebElement element = findElementById("complexPanel1");
        final PComplexPanel complexPanel1 = get("complexPanel1");

        // add child
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PComplexPanel complexPanel1 = get("complexPanel1");
                complexPanel1.add(new PAnchor("child1"));
                complexPanel1.add(new PAnchor("child3"));
            }
        });

        element = findElementById("complexPanel1");
        List<WebElement> anchors = element.findElements(By.tagName("a"));
        Assert.assertEquals(2, anchors.size());
        Assert.assertEquals(2, complexPanel1.getWidgetCount());

        // insert child
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PVerticalPanel complexPanel1 = get("complexPanel1");
                final PAnchor child2 = new PAnchor("child2");
                child2.ensureDebugId("child2");
                complexPanel1.insert(child2, 1);
                register(child2);
            }
        });

        element = findElementById("complexPanel1");
        anchors = element.findElements(By.tagName("a"));
        Assert.assertEquals(3, anchors.size());
        Assert.assertEquals("child1", anchors.get(0).getText());
        Assert.assertEquals("child2", anchors.get(1).getText());
        Assert.assertEquals("child3", anchors.get(2).getText());

        Assert.assertEquals(3, complexPanel1.getWidgetCount());
        Assert.assertEquals("child1", ((PAnchor) complexPanel1.getWidget(0)).getText());
        Assert.assertEquals("child2", ((PAnchor) complexPanel1.getWidget(1)).getText());
        Assert.assertEquals("child3", ((PAnchor) complexPanel1.getWidget(2)).getText());

        // remove child
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PComplexPanel complexPanel1 = get("complexPanel1");
                final PAnchor child2 = get("child2");
View Full Code Here

        final Calendar calendar = new GregorianCalendar(2012, 10, 27);
        final Date date = calendar.getTime();
        final String dateAsString = dateFormat.format(date);

        // creation
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PLabel label1 = new PLabel("Date test");
                label1.ensureDebugId("label1");
                PRootPanel.get().add(label1);
                register(label1);

                final PDateBox dateBox1 = new PDateBox(new SimpleDateFormat(datePattern));
                dateBox1.ensureDebugId("dateBox1");
                PRootPanel.get().add(dateBox1);
                register(dateBox1);
            }
        });

        WebElement element = findElementById("dateBox1");
        final PDateBox dateBox1 = get("dateBox1");
        Assert.assertEquals(datePattern, dateBox1.getDateFormat().toPattern());

        // update date
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PDateBox dateBox1 = get("dateBox1");
                dateBox1.setValue(date);
            }
        });

        element = findElementById("dateBox1");
        Assert.assertEquals(dateAsString, element.getAttribute("value"));
        Assert.assertEquals(dateAsString, dateBox1.getDisplayedValue());

        // add value change handler
        updateUI(new RequestHandler() {

            @SuppressWarnings("unchecked")
            @Override
            public void onRequest() {
                final PDateBox dateBox1 = get("dateBox1");
View Full Code Here

    @Test
    public void testPDialogBox() {

        // creation
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PDialogBox dialogBox1 = new PDialogBox();
                dialogBox1.ensureDebugId("dialogBox1");
                dialogBox1.show();
                register(dialogBox1);
            }
        });

        findElementById("dialogBox1");

        // set caption
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PDialogBox dialogBox1 = get("dialogBox1");
                dialogBox1.setCaption("The Caption");
            }
        });

        final WebElement caption = findElementById("dialogBox1-caption");
        Assert.assertEquals("The Caption", caption.getText());

        // add close button
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PDialogBox dialogBox1 = get("dialogBox1");
                final PButton close1 = new PButton("Close");
View Full Code Here

    @Test
    public void testPDisclosurePanel() {

        // creation
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PDisclosurePanel disclosurePanel1 = new PDisclosurePanel("A disclosure panel");
                disclosurePanel1.ensureDebugId("disclosurePanel1");
                PRootPanel.get().add(disclosurePanel1);
                register(disclosurePanel1);
            }
        });

        WebElement disclosure = findElementById("disclosurePanel1");
        Assert.assertTrue(disclosure.getAttribute("class").contains("gwt-DisclosurePanel-closed"));
        final PDisclosurePanel disclosurePanel1 = get("disclosurePanel1");
        Assert.assertEquals(false, disclosurePanel1.isOpen());

        WebElement disclosureHeader = findElementById("disclosurePanel1-header");
        Assert.assertEquals("A disclosure panel", disclosureHeader.getText());

        // set content
        // open / close
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PDisclosurePanel disclosurePanel1 = get("disclosurePanel1");
                final PLabel label = new PLabel("Text");
                label.ensureDebugId("label1");
                disclosurePanel1.setContent(label);
                disclosurePanel1.addOpenHandler(eventsListener);
                disclosurePanel1.addCloseHandler(eventsListener);
                register(disclosurePanel1);
            }
        });

        disclosureHeader = findElementById("disclosurePanel1-header");
        disclosureHeader.click();
        final POpenEvent e2 = eventsListener.poll();
        Assert.assertNotNull(e2);
        Assert.assertTrue(disclosurePanel1.isOpen());

        disclosure = findElementById("disclosurePanel1");
        final WebElement content = findElementById(disclosure, "label1");
        Assert.assertEquals("Text", content.getText());

        disclosureHeader.click();
        final PCloseEvent e1 = eventsListener.poll();
        Assert.assertNotNull(e1);
        Assert.assertTrue(!disclosurePanel1.isOpen());

        // server side open
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PDisclosurePanel disclosurePanel1 = get("disclosurePanel1");
                disclosurePanel1.setOpen(true);
            }
        });

        disclosure = findElementById("disclosurePanel1");
        Assert.assertTrue(disclosure.getAttribute("class").contains("gwt-DisclosurePanel-open"));

        // server side close
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PDisclosurePanel disclosurePanel1 = get("disclosurePanel1");
                disclosurePanel1.setOpen(false);
View Full Code Here

    }

    @Test
    public void testPElement() {
        // creation
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PElement ul1 = new PElement("ul");
                ul1.ensureDebugId("ul1");
View Full Code Here

    }

    public void testPFlexTable() {

        // creation
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PFlexTable flexTable1 = new PFlexTable();
                flexTable1.ensureDebugId("flexTable1");
                final PLabel cell11 = new PLabel("Cell_1_1");
                cell11.ensureDebugId("cell11");
                flexTable1.setWidget(0, 0, new PLabel("Cell_0_0"));
                flexTable1.setWidget(0, 1, new PLabel("Cell_0_1"));
                flexTable1.setWidget(1, 0, new PLabel("Cell_1_0"));
                flexTable1.setWidget(1, 1, cell11);
                flexTable1.setBorderWidth(1);
                flexTable1.setCellPadding(2);
                flexTable1.setCellSpacing(3);
                PRootPanel.get().add(flexTable1);
                register(flexTable1);
                register(cell11);
            }
        });

        WebElement flexTable1 = findElementById("flexTable1");
        Assert.assertEquals(flexTable1.getAttribute("border"), "1");
        Assert.assertEquals(flexTable1.getAttribute("cellPadding"), "2");
        Assert.assertEquals(flexTable1.getAttribute("cellSpacing"), "3");

        List<WebElement> rows = flexTable1.findElements(By.tagName("tr"));
        Assert.assertEquals(rows.size(), 2);
        List<WebElement> cells = flexTable1.findElements(By.tagName("td"));
        Assert.assertEquals(cells.size(), 4);
        Assert.assertEquals(cells.get(0).getText(), "Cell_0_0");

        final PFlexTable pFlexTable1 = get("flexTable1");
        Assert.assertEquals(2, pFlexTable1.getRowCount());
        Assert.assertEquals(2, pFlexTable1.getCellCount(0));

        // clear cell, insert new elements
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PFlexTable flexTable1 = get("flexTable1");
                final PLabel cell11 = get("cell11");
                flexTable1.remove(cell11);
                flexTable1.insertRow(0);
                flexTable1.setWidget(0, 0, new PLabel("Cell_2_0"));
                flexTable1.setWidget(0, 1, new PLabel("Cell_2_1"));
                flexTable1.setWidget(3, 0, new PLabel("Cell_3_0"));
                flexTable1.setWidget(3, 1, new PLabel("Cell_3_1"));
            }
        });

        flexTable1 = findElementById("flexTable1");
        rows = flexTable1.findElements(By.tagName("tr"));
        Assert.assertEquals(rows.size(), 4);

        cells = flexTable1.findElements(By.tagName("td"));
        Assert.assertEquals(cells.size(), 8);
        Assert.assertEquals(cells.get(0).getText(), "Cell_2_0");
        Assert.assertEquals(cells.get(1).getText(), "Cell_2_1");
        Assert.assertEquals(cells.get(2).getText(), "Cell_0_0");
        Assert.assertEquals(cells.get(3).getText(), "Cell_0_1");
        Assert.assertEquals(cells.get(4).getText(), "Cell_1_0");
        Assert.assertEquals(cells.get(5).getText(), "");
        Assert.assertEquals(cells.get(6).getText(), "Cell_3_0");
        Assert.assertEquals(cells.get(7).getText(), "Cell_3_1");

        Assert.assertEquals(4, pFlexTable1.getRowCount());
        Assert.assertEquals(2, pFlexTable1.getCellCount(0));

        // remove row, add/remove row style, add/remove column style, add/remove cell style
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PFlexTable flexTable1 = get("flexTable1");
                flexTable1.removeRow(2);

                flexTable1.getRowFormatter().addStyleName(1, "row1");
                flexTable1.getRowFormatter().addStyleName(2, "row2");
                flexTable1.getRowFormatter().addStyleName(2, "row2bis");
                flexTable1.getRowFormatter().addStyleName(2, "row2ter");
                flexTable1.getRowFormatter().removeStyleName(2, "row2bis");

                flexTable1.getColumnFormatter().addStyleName(0, "col0");
                flexTable1.getColumnFormatter().addStyleName(1, "col1");
                flexTable1.getColumnFormatter().addStyleName(1, "col1bis");
                flexTable1.getColumnFormatter().addStyleName(1, "col1ter");
                flexTable1.getColumnFormatter().removeStyleName(1, "col1bis");

                flexTable1.getCellFormatter().addStyleName(1, 1, "cell11");
                flexTable1.getCellFormatter().addStyleName(2, 0, "cell20");
                flexTable1.getCellFormatter().addStyleName(2, 0, "cell20bis");
                flexTable1.getCellFormatter().addStyleName(2, 0, "cell20ter");
                flexTable1.getCellFormatter().removeStyleName(2, 0, "cell20bis");
            }
        });

        flexTable1 = findElementById("flexTable1");
        rows = flexTable1.findElements(By.tagName("tr"));
        cells = flexTable1.findElements(By.tagName("td"));
        final List<WebElement> cols = flexTable1.findElements(By.tagName("col"));

        Assert.assertEquals(3, rows.size());
        Assert.assertEquals(6, cells.size());
        Assert.assertEquals(2, cols.size());
        Assert.assertTrue(rows.get(1).getAttribute("class").contains("row1"));
        Assert.assertTrue(rows.get(2).getAttribute("class").contains("row2"));
        Assert.assertTrue(rows.get(2).getAttribute("class").contains("row2ter"));
        Assert.assertTrue(!rows.get(2).getAttribute("class").contains("row2bis"));

        Assert.assertTrue(cols.get(0).getAttribute("class").contains("col0"));
        Assert.assertTrue(cols.get(1).getAttribute("class").contains("col1"));
        Assert.assertTrue(cols.get(1).getAttribute("class").contains("col1ter"));
        Assert.assertTrue(!cols.get(1).getAttribute("class").contains("col1bis"));

        Assert.assertTrue(cells.get(3).getAttribute("class").contains("cell11"));
        Assert.assertTrue(cells.get(4).getAttribute("class").contains("cell20"));
        Assert.assertTrue(cells.get(4).getAttribute("class").contains("cell20ter"));
        Assert.assertTrue(!cells.get(4).getAttribute("class").contains("cell20bis"));

        final PLabel cell00 = (PLabel) pFlexTable1.getWidget(0, 0);
        final PLabel cell31 = (PLabel) pFlexTable1.getWidget(2, 1);
        Assert.assertEquals("Cell_2_0", cell00.getText());
        Assert.assertEquals("Cell_3_1", cell31.getText());

        // colspan / rowspan
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PFlexTable flexTable1 = get("flexTable1");
View Full Code Here

    @Test
    public void testPFlowPanel() {

        // creation
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PFlowPanel flowPanel1 = new PFlowPanel();
                flowPanel1.ensureDebugId("flowPanel1");
                flowPanel1.add(new PHTML("text1"));
                flowPanel1.add(new PHTML("text2"));
                flowPanel1.add(new PHTML("text3"));
                flowPanel1.add(new PHTML("text4"));
                PRootPanel.get().add(flowPanel1);
                register(flowPanel1);
            }
        });

        WebElement flowPanel1 = findElementById("flowPanel1");
        List<WebElement> divs = flowPanel1.findElements(By.tagName("div"));
        Assert.assertEquals(4, divs.size());

        final PFlowPanel pFlowPanel = get("flowPanel1");
        Assert.assertEquals(4, pFlowPanel.getWidgetCount());

        // remove
        updateUI(new RequestHandler() {

            @Override
            public void onRequest() {
                final PFlowPanel flowPanel1 = get("flowPanel1");
                flowPanel1.remove(2);
View Full Code Here

TOP

Related Classes of com.ponysdk.test.UiBuilderTestEntryPoint.RequestHandler

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.