Search in sources :

Example 16 with Timer

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

the class HeaderPanelTest method testResizeHeader.

public void testResizeHeader() {
    final HeaderPanel panel = createPanel();
    panel.setSize("200px", "400px");
    RootPanel.get().add(panel);
    final Label header = new Label();
    header.setSize("100%", "50px");
    panel.setHeaderWidget(header);
    final Label content = new Label();
    content.setHeight("100%");
    panel.setContentWidget(content);
    final Label footer = new Label();
    footer.setSize("100%", "50px");
    panel.setFooterWidget(footer);
    delayTestFinish(5000);
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            assertEquals(300, content.getOffsetHeight());
            // Resize the header.
            header.setHeight("75px");
            new Timer() {

                @Override
                public void run() {
                    assertEquals(275, content.getOffsetHeight());
                    RootPanel.get().remove(panel);
                    finishTest();
                }
            }.schedule(250);
            ;
        }
    });
}
Also used : ScheduledCommand(org.gwtproject.core.client.Scheduler.ScheduledCommand) Timer(org.gwtproject.timer.client.Timer)

Example 17 with Timer

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

the class NativeScrollbarTestBase method testSetScrollPosition.

public void testSetScrollPosition() {
    // Add a scroll handler.
    final TestScrollHandler handler = new TestScrollHandler() {

        @Override
        public void onScroll(ScrollEvent event) {
            finish();
        }
    };
    scrollbar.addScrollHandler(handler);
    // Scroll to a new position.
    setScrollSize(scrollbar, 500);
    // Wait for the scroll size to take effect.
    delayTestFinish(TEST_TIMEOUT);
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            // Set the scroll position.
            setScrollPosition(scrollbar, 100);
            assertEquals(100, getScrollPosition(scrollbar));
            assertEquals(0, getMinimumScrollPosition(scrollbar));
            assertEquals(300, getMaximumScrollPosition(scrollbar));
            // Wait for the scroll event.
            new Timer() {

                @Override
                public void run() {
                    assertTrue(handler.isFinished());
                    finishTest();
                }
            }.schedule(SCROLL_EVENT_TIMEOUT);
        }
    });
}
Also used : ScheduledCommand(org.gwtproject.core.client.Scheduler.ScheduledCommand) Timer(org.gwtproject.timer.client.Timer) ScrollEvent(org.gwtproject.event.dom.client.ScrollEvent)

Example 18 with Timer

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

the class NativeScrollbarTestBase method testSetScrollbarSizeFiresScrollEvent.

/**
 * Test that changing the scrollbar size can affect the scroll position and
 * fires a scroll event.
 */
public void testSetScrollbarSizeFiresScrollEvent() {
    setScrollSize(scrollbar, 400);
    assertEquals(400, getScrollSize(scrollbar));
    // Wait for the scroll size to take effect.
    delayTestFinish(TEST_TIMEOUT);
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            // Scroll to position 100.
            setScrollPosition(scrollbar, 100);
            assertEquals(100, getScrollPosition(scrollbar));
            // Wait for the scroll position to take effect.
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {

                @Override
                public void execute() {
                    // Add a scroll handler.
                    final TestScrollHandler handler = new TestScrollHandler() {

                        @Override
                        public void onScroll(ScrollEvent event) {
                            finish();
                        }
                    };
                    scrollbar.addScrollHandler(handler);
                    // Reduce scroll size to smaller than the scrollbar size.
                    setScrollbarSize(scrollbar, "400px");
                    // Wait for the new scroll size to take effect.
                    new Timer() {

                        @Override
                        public void run() {
                            assertEquals(0, getScrollPosition(scrollbar));
                            assertTrue(handler.isFinished());
                            finishTest();
                        }
                    }.schedule(SCROLL_EVENT_TIMEOUT);
                }
            });
        }
    });
}
Also used : ScheduledCommand(org.gwtproject.core.client.Scheduler.ScheduledCommand) Timer(org.gwtproject.timer.client.Timer) ScrollEvent(org.gwtproject.event.dom.client.ScrollEvent)

Example 19 with Timer

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

the class PopupTest method testDependantPopupPanel.

/**
 * @see #testDependantPopupPanel()
 */
protected void testDependantPopupPanel(final PopupPanel primaryPopup) {
    // Show the popup
    primaryPopup.show();
    // Hide the popup
    new Timer() {

        @Override
        public void run() {
            primaryPopup.hide();
        }
    }.schedule(1000);
    delayTestFinish(5000);
    // Give time for any errors to occur
    new Timer() {

        @Override
        public void run() {
            finishTest();
        }
    }.schedule(2000);
}
Also used : Timer(org.gwtproject.timer.client.Timer)

Example 20 with Timer

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

the class TabLayoutPanelTest method testTabLayout.

/**
 * Tests that tabs actually line up properly (see issue 4447).
 */
public void testTabLayout() {
    final TabLayoutPanel p = new TabLayoutPanel(2, Unit.EM);
    RootPanel.get().add(p);
    p.add(new Button("foo"), new Label("foo"));
    p.add(new Button("bar"), new Label("bar"));
    // Give the browser some time to layout
    new Timer() {

        @Override
        public void run() {
            assertEquals(p.getTabWidget(0).getElement().getOffsetTop(), p.getTabWidget(1).getElement().getOffsetTop());
            finishTest();
        }
    }.schedule(100);
    delayTestFinish(200);
}
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