-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix performance testing methods (#1012)
Update Flow beta2 which contains poll() implementation
- Loading branch information
Showing
5 changed files
with
105 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
vaadin-testbench-integration-tests/src/main/java/com/vaadin/testUI/PerformanceView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.vaadin.testUI; | ||
|
||
import com.vaadin.flow.component.html.Div; | ||
import com.vaadin.flow.component.html.NativeButton; | ||
import com.vaadin.flow.component.html.Span; | ||
import com.vaadin.flow.router.Route; | ||
|
||
@Route("PerformanceView") | ||
public class PerformanceView extends Div { | ||
|
||
public PerformanceView() { | ||
NativeButton button = new NativeButton("1s delay", e -> { | ||
try { | ||
Thread.sleep(1000); | ||
} catch (InterruptedException e1) { | ||
} | ||
add(new Span("Done sleeping")); | ||
}); | ||
add(button); | ||
} | ||
|
||
} |
51 changes: 51 additions & 0 deletions
51
vaadin-testbench-integration-tests/src/test/java/com/vaadin/tests/PerfomanceIT.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.vaadin.tests; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
import com.vaadin.flow.component.Component; | ||
import com.vaadin.testUI.PerformanceView; | ||
import com.vaadin.tests.elements.NativeButtonElement; | ||
|
||
public class PerfomanceIT extends AbstractTB6Test { | ||
|
||
@Override | ||
protected Class<? extends Component> getTestView() { | ||
return PerformanceView.class; | ||
} | ||
|
||
@Test | ||
@Ignore("Profiling info not available in production mode until beta3") | ||
public void serverTime() { | ||
openTestURL(); | ||
$(NativeButtonElement.class).first().click(); | ||
|
||
Assert.assertEquals(1000.0, testBench().timeSpentServicingLastRequest(), | ||
100.0); | ||
$(NativeButtonElement.class).first().click(); | ||
Assert.assertEquals(2000.0, | ||
testBench().totalTimeSpentServicingRequests(), 200.0); | ||
} | ||
|
||
@Test | ||
@Ignore("Profiling info not available in production mode until beta3") | ||
public void renderingTime() { | ||
openTestURL(); | ||
long initialRendering = testBench().timeSpentRenderingLastRequest(); | ||
// Assuming initial rendering is done in 5-195ms | ||
Assert.assertEquals(150, initialRendering, 145); | ||
Assert.assertEquals(initialRendering, | ||
testBench().totalTimeSpentRendering()); | ||
$(NativeButtonElement.class).first().click(); | ||
$(NativeButtonElement.class).first().click(); | ||
$(NativeButtonElement.class).first().click(); | ||
|
||
// Assuming rendering three poll responses is done in 50ms | ||
Assert.assertTrue( | ||
testBench().totalTimeSpentRendering() > initialRendering); | ||
Assert.assertEquals(initialRendering, | ||
testBench().totalTimeSpentRendering(), 50); | ||
} | ||
|
||
} |