Search in sources :

Example 1 with DoNotRunWith

use of com.google.gwt.junit.DoNotRunWith in project gwtproject by treblereel.

the class AnimationGwt2SchedulerTest method testRequestAnimationFrame.

// TODO(davido): doesn't work on htmlunit-2.19 (works in 2.18)
// Presumably because of: http://sourceforge.net/p/htmlunit/code/11004
@DoNotRunWith(Platform.HtmlUnitBug)
public void testRequestAnimationFrame() {
    delayTestFinish(TEST_TIMEOUT);
    final double startTime = Duration.currentTimeMillis();
    DivElement element = Document.get().createDivElement();
    scheduler.requestAnimationFrame(timestamp -> {
        // Make sure timestamp is not a high-res timestamp (see issue 8570)
        assertTrue(timestamp >= startTime);
        finishTest();
    }, element);
}
Also used : DivElement(org.gwtproject.dom.client.DivElement) DoNotRunWith(com.google.gwt.junit.DoNotRunWith)

Example 2 with DoNotRunWith

use of com.google.gwt.junit.DoNotRunWith in project gwtproject by treblereel.

the class HistoryTest method testNoDoubleTokenUnEscaping.

/**
 * Test to make sure that there is no double unescaping of hash values. See
 * https://bugzilla.mozilla.org/show_bug.cgi?id=483304
 */
@DoNotRunWith(Platform.HtmlUnitUnknown)
public void testNoDoubleTokenUnEscaping() {
    final String shouldBeEncoded = "abc%20abc";
    delayTestFinish(5000);
    History.newItem(shouldBeEncoded);
    History.newItem("someOtherToken");
    History.back();
    // allow browser to update the url
    timer = new Timer() {

        @Override
        public void run() {
            // make sure that value in url actually matches the original token
            assertEquals(shouldBeEncoded, History.getToken());
            finishTest();
        }
    };
    timer.schedule(200);
}
Also used : Timer(com.google.gwt.user.client.Timer) DoNotRunWith(com.google.gwt.junit.DoNotRunWith)

Example 3 with DoNotRunWith

use of com.google.gwt.junit.DoNotRunWith in project gwtproject by treblereel.

the class HistoryTest method testClickLink.

// TODO(dankurka): Fix up HTML unit hash change handling
@DoNotRunWith(Platform.HtmlUnitUnknown)
public void testClickLink() {
    AnchorElement anchorElement = Document.get().createAnchorElement();
    anchorElement.setHref("#href1");
    Document.get().getBody().appendChild(anchorElement);
    try {
        History.newItem("something_as_base");
        addHistoryListenerImpl(event -> {
            assertEquals("href1", event.getValue());
            finishTest();
        });
        delayTestFinish(5000);
        NativeEvent clickEvent = Document.get().createClickEvent(0, 0, 0, 0, 0, false, false, false, false);
        anchorElement.dispatchEvent(clickEvent);
    } finally {
        Document.get().getBody().removeChild(anchorElement);
    }
}
Also used : AnchorElement(com.google.gwt.dom.client.AnchorElement) NativeEvent(com.google.gwt.dom.client.NativeEvent) DoNotRunWith(com.google.gwt.junit.DoNotRunWith)

Example 4 with DoNotRunWith

use of com.google.gwt.junit.DoNotRunWith in project gwtproject by treblereel.

the class LayoutGwt2Test method testFillParent.

/**
 * Test that fillParent() works properly when the outer div is a child of another div, and that it
 * correctly follows that div's size.
 */
@DoNotRunWith(Platform.HtmlUnitLayout)
public void testFillParent() {
    // We don't use the default elements created in gwtSetUp() because we need
    // to test the behavior when the layout is contained by an element other
    // than the <body>.
    Document doc = Document.get();
    DivElement container = doc.createDivElement();
    DivElement parent = doc.createDivElement();
    DivElement child = doc.createDivElement();
    child.setInnerHTML("&nbsp;");
    doc.getBody().appendChild(container);
    container.appendChild(parent);
    // The container has to be position:relative so that it serves as an offset
    // parent.
    container.getStyle().setPosition(Position.RELATIVE);
    container.getStyle().setWidth(128, PX);
    container.getStyle().setHeight(256, PX);
    Layout layout = new Layout(parent);
    layout.onAttach();
    Layout.Layer layer = layout.attachChild(child);
    layer.setTopBottom(0, PX, 0, PX);
    layer.setLeftRight(0, PX, 0, PX);
    layout.fillParent();
    layout.layout();
    // Test 128x256.
    assertEquals(128, container.getOffsetWidth());
    assertEquals(256, container.getOffsetHeight());
    assertEquals(128, parent.getOffsetWidth());
    assertEquals(256, parent.getOffsetHeight());
    assertEquals(128, child.getOffsetWidth());
    assertEquals(256, child.getOffsetHeight());
    // Expand to 256x256. The layout should react automatically.
    container.getStyle().setWidth(256, PX);
    container.getStyle().setHeight(128, PX);
    assertEquals(256, container.getOffsetWidth());
    assertEquals(256, parent.getOffsetWidth());
    assertEquals(256, child.getOffsetWidth());
    layout.onDetach();
}
Also used : DivElement(org.gwtproject.dom.client.DivElement) Layer(org.gwtproject.layout.client.Layout.Layer) Document(org.gwtproject.dom.client.Document) DoNotRunWith(com.google.gwt.junit.DoNotRunWith)

Example 5 with DoNotRunWith

use of com.google.gwt.junit.DoNotRunWith in project gwtproject by treblereel.

the class JsonpRequestTest method testCancel.

/**
 * Fails in devmode with HtmlUnit, JS "null" exception.
 *
 * <p>Call occurs through postponedActions in HtmlUnit that execute synchronously. Should be
 * async. Need to file HtmlUnitBug.
 */
@DoNotRunWith(Platform.HtmlUnitBug)
public void testCancel() {
    delayTestFinish(2000);
    // setup a server request that will delay for 500ms
    JsonpRequest<String> req = jsonp.requestString(echoDelayed("'A'", 500), new AssertCancelCallback<String>());
    // cancel it before it comes back
    req.cancel();
    // wait 1s to make sure we don't get a callback
    new Timer() {

        @Override
        public void run() {
            finishTest();
        }
    }.schedule(1500);
}
Also used : Timer(org.gwtproject.timer.client.Timer) DoNotRunWith(com.google.gwt.junit.DoNotRunWith)

Aggregations

DoNotRunWith (com.google.gwt.junit.DoNotRunWith)7 Timer (com.google.gwt.user.client.Timer)2 DivElement (org.gwtproject.dom.client.DivElement)2 AnchorElement (com.google.gwt.dom.client.AnchorElement)1 NativeEvent (com.google.gwt.dom.client.NativeEvent)1 Date (java.util.Date)1 Document (org.gwtproject.dom.client.Document)1 Layer (org.gwtproject.layout.client.Layout.Layer)1 Timer (org.gwtproject.timer.client.Timer)1