Search in sources :

Example 11 with Timer

use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.

the class ImageTest method testOneEventOnly.

public void testOneEventOnly() {
    final Image image = new Image("counting-forwards.png");
    final TestLoadHandler loadHandler = new TestLoadHandler() {

        @Override
        public void onLoad(LoadEvent event) {
            if (isFinished()) {
                fail("LoadHandler fired multiple times.");
            }
            finish();
        }
    };
    image.addErrorHandler(new TestErrorHandler(image));
    image.addLoadHandler(loadHandler);
    RootPanel.get().add(image);
    delayTestFinish(DEFAULT_TEST_TIMEOUT);
    new Timer() {

        @Override
        public void run() {
            assertTrue(loadHandler.isFinished());
            finishTest();
        }
    }.schedule(LOAD_EVENT_TIMEOUT);
}
Also used : LoadEvent(org.gwtproject.event.dom.client.LoadEvent) Timer(org.gwtproject.timer.client.Timer)

Example 12 with Timer

use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.

the class ImageTest method testChangeImageToClippedSynchronously.

/**
 * Tests the transition from the unclipped state to the clipped state
 * before a load event fires.
 */
public void testChangeImageToClippedSynchronously() {
    final Image image = new Image("counting-forwards.png");
    assertEquals("unclipped", getCurrentImageStateName(image));
    image.addErrorHandler(new TestErrorHandler(image));
    final TestLoadHandler loadHandler = new TestLoadHandler() {

        @Override
        public void onLoad(LoadEvent event) {
            if (isFinished()) {
                fail("LoadHandler fired twice. Expected it to fire only once.");
            }
            assertEquals("clipped", getCurrentImageStateName(image));
            assertEquals(12, image.getOriginLeft());
            assertEquals(13, image.getOriginTop());
            assertEquals(8, image.getWidth());
            assertEquals(8, image.getHeight());
            finish();
        }
    };
    image.addLoadHandler(loadHandler);
    /*
     * Change the image to a clipped image before a load event fires. We only
     * expect one asynchronous load event to fire for the final state. This is
     * consistent with the expected behavior of changing the source URL multiple
     * times.
     */
    RootPanel.get().add(image);
    image.setVisibleRect(12, 13, 8, 8);
    assertEquals("clipped", getCurrentImageStateName(image));
    delayTestFinish(DEFAULT_TEST_TIMEOUT);
    new Timer() {

        @Override
        public void run() {
            assertTrue(loadHandler.isFinished());
            finishTest();
        }
    }.schedule(SYNTHETIC_LOAD_EVENT_TIMEOUT);
}
Also used : LoadEvent(org.gwtproject.event.dom.client.LoadEvent) Timer(org.gwtproject.timer.client.Timer)

Example 13 with Timer

use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.

the class FormPanelTest method testWrappedForm.

public void testWrappedForm() {
    // Create a form and frame in the document we can wrap.
    final String iframeId = Document.get().createUniqueId();
    final String iframeName = Document.get().createUniqueId();
    final Element container = Document.get().createDivElement();
    container.setInnerHTML("<form method='post' target='" + iframeName + "' action='" + "formHandler?sendHappyHtml'>" + "<input type='hidden' name='foo' value='bar'></input></form>" + "<iframe src=\"javascript:\'\'\" id='" + iframeId + "' " + "name='" + iframeName + "'></iframe>");
    Document.get().getBody().appendChild(container);
    // Wrap the form and make sure its target frame is intact.
    FormPanel form = FormPanel.wrap(container.getFirstChildElement());
    assertEquals(iframeName, form.getTarget());
    // Ensure that no synthesized iframe was created.
    assertNull(form.getSynthesizedIFrame());
    // Submit the form and make sure the target frame comes back with the right
    // stuff (give it 2.5 s to complete).
    delayTestFinish(TEST_DELAY);
    form.submit();
    new Timer() {

        @Override
        public void run() {
            // Get the targeted frame and make sure it contains the requested
            // 'happyElem'.
            Frame frame = Frame.wrap(Document.get().getElementById(iframeId));
            assertTrue(isHappyDivPresent(frame.getElement()));
            finishTest();
        }
    }.schedule(TEST_DELAY - 2000);
}
Also used : Timer(org.gwtproject.timer.client.Timer) HTMLIFrameElement(elemental2.dom.HTMLIFrameElement) InputElement(org.gwtproject.dom.client.InputElement) Element(org.gwtproject.dom.client.Element)

Example 14 with Timer

use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.

the class FormPanelTest method testSubmitFrame.

/**
 * Tests submitting an alternate frame.
 */
public void testSubmitFrame() {
    final NamedFrame frame = new NamedFrame("myFrame");
    FormPanel form = new FormPanel(frame);
    form.setMethod(FormPanel.METHOD_POST);
    form.setAction("formHandler?sendHappyHtml");
    RootPanel.get().add(form);
    RootPanel.get().add(frame);
    delayTestFinish(TEST_DELAY);
    form.submit();
    Timer t = new Timer() {

        @Override
        public void run() {
            // Make sure the frame got the contents we expected.
            assertTrue(isHappyDivPresent(frame.getElement()));
            finishTest();
        }
    };
    // Wait 5 seconds before checking the results.
    t.schedule(TEST_DELAY - 2000);
}
Also used : Timer(org.gwtproject.timer.client.Timer)

Example 15 with Timer

use of org.gwtproject.timer.client.Timer in project gwtproject by treblereel.

the class DisclosurePanelTest method testCoreFunctionality.

/**
 * Test to ensure css style changes that control core functionality do change
 * appropriately.
 */
public void testCoreFunctionality() {
    final DisclosurePanel panel = createTestPanel();
    assertTrue(DOM.getParent(panel.getContent().getElement()).getStyle().getProperty("display").equalsIgnoreCase("none"));
    panel.setOpen(true);
    delayTestFinish(5000);
    // Allow the animation time to finish
    Timer t = new Timer() {

        @Override
        public void run() {
            assertTrue(DOM.getParent(panel.getContent().getElement()).getStyle().getProperty("display").trim().equals(""));
            finishTest();
        }
    };
    t.schedule(450);
}
Also used : Timer(org.gwtproject.timer.client.Timer)

Aggregations

Timer (org.gwtproject.timer.client.Timer)65 Promise (elemental2.promise.Promise)16 Test (org.junit.Test)15 ScheduledCommand (org.gwtproject.core.client.Scheduler.ScheduledCommand)7 LoadEvent (org.gwtproject.event.dom.client.LoadEvent)7 Button (org.dominokit.domino.ui.button.Button)3 Card (org.dominokit.domino.ui.cards.Card)3 NativeEvent (org.gwtproject.dom.client.NativeEvent)3 HTMLDivElement (elemental2.dom.HTMLDivElement)2 ArrayList (java.util.ArrayList)2 SampleMethod (org.dominokit.domino.SampleMethod)2 UiView (org.dominokit.domino.api.client.annotations.UiView)2 BaseDemoView (org.dominokit.domino.componentcase.client.ui.views.BaseDemoView)2 CodeCard (org.dominokit.domino.componentcase.client.ui.views.CodeCard)2 Column (org.dominokit.domino.ui.grid.Column)2 Row (org.dominokit.domino.ui.grid.Row)2 BlockHeader (org.dominokit.domino.ui.header.BlockHeader)2 Loader (org.dominokit.domino.ui.loaders.Loader)2 Color (org.dominokit.domino.ui.style.Color)2 AnimationHandle (org.gwtproject.animation.client.AnimationScheduler.AnimationHandle)2