|
2 | 2 |
|
3 | 3 | import java.util.Random; |
4 | 4 | import java.util.function.Function; |
| 5 | +import java.util.function.Supplier; |
5 | 6 |
|
6 | 7 | import io.quarkus.infra.performance.graphics.PlotDefinition; |
7 | 8 | import io.quarkus.infra.performance.graphics.SingleSeriesPlotDefinition; |
@@ -137,6 +138,23 @@ public void testCanDrawLargeGroupInPreferredDimensions() { |
137 | 138 | @Test |
138 | 139 | public void testCanDrawSoloGroupInPreferredDimensions() { |
139 | 140 | BenchmarkData data = mockBenchmarkData(1); |
| 141 | + System.out.println("Data " + data); |
| 142 | + PlotDefinition plotDefinition = createPlotDefinition(); |
| 143 | + |
| 144 | + Chart chart = createChart(plotDefinition, data); |
| 145 | + |
| 146 | + int width = chart.getPreferredHorizontalSize(); |
| 147 | + int height = chart.getPreferredVerticalSize(); |
| 148 | + |
| 149 | + SVGGraphics2D svgGenerator = getSvgGraphics2D(width, height); |
| 150 | + Theme theme = Theme.LIGHT; |
| 151 | + chart.draw(new Subcanvas(svgGenerator), theme); |
| 152 | + } |
| 153 | + |
| 154 | + // This sometimes fails for the cube chart, if the value is less than the column height |
| 155 | + @Test |
| 156 | + public void testCanDrawSoloGroupWithLowValueInPreferredDimensions() { |
| 157 | + BenchmarkData data = mockBenchmarkData(1, () -> 2.0); |
140 | 158 | PlotDefinition plotDefinition = createPlotDefinition(); |
141 | 159 |
|
142 | 160 | Chart chart = createChart(plotDefinition, data); |
@@ -174,13 +192,18 @@ private static BenchmarkData mockBenchmarkData() { |
174 | 192 | return mockBenchmarkData(4); |
175 | 193 | } |
176 | 194 |
|
| 195 | + |
177 | 196 | private static BenchmarkData mockBenchmarkData(int count) { |
| 197 | + return mockBenchmarkData(count, () -> (double) new Random().nextInt(400)); |
| 198 | + } |
| 199 | + |
| 200 | + private static BenchmarkData mockBenchmarkData(int count, Supplier<Double> value) { |
178 | 201 | BenchmarkData data = mock(BenchmarkData.class); |
179 | 202 | Results results = new Results(); |
180 | 203 | when(data.results()).thenReturn(results); |
181 | 204 | when(data.group()).thenReturn(Group.ALL); |
182 | 205 | for (int i = 0; i < count; i++) { |
183 | | - addDatapoint(data, Framework.values()[i], (double) new Random().nextInt(400)); |
| 206 | + addDatapoint(data, Framework.values()[i], value.get()); |
184 | 207 | } |
185 | 208 | addConfig(data); |
186 | 209 | return data; |
|
0 commit comments