Commit 9b3a76f7 authored by Anton Tarasov's avatar Anton Tarasov
Browse files

Use assertTiming for IconsLoadTimeTest

parent 8c106084
Branches unavailable Tags unavailable
No related merge requests found
Showing with 11 additions and 7 deletions
+11 -7
......@@ -8,15 +8,19 @@ import com.intellij.internal.IconsLoadTime.StatData;
import com.intellij.openapi.util.registry.Registry;
import com.intellij.openapi.util.registry.RegistryValue;
import com.intellij.testFramework.PlatformTestUtil;
import junit.framework.TestCase;
import org.junit.After;
import org.junit.Assume;
import org.junit.Before;
import org.junit.Test;
import java.io.*;
import static com.intellij.testFramework.PlatformTestUtil.assertTiming;
import static com.intellij.util.ImageLoader.ImageDesc.Type;
import static junit.framework.TestCase.assertEquals;
import static junit.framework.TestCase.assertNotNull;
import static org.junit.Assume.assumeTrue;
/**
* Estimates SVG icon average load time.
......@@ -24,7 +28,7 @@ import static junit.framework.TestCase.assertNotNull;
* @author tav
*/
public class IconsLoadTimeTest {
private static final int SVG_ICON_AVERAGE_LOAD_TIME_ESTIMATE = 10; // ms
private static final int SVG_ICON_AVERAGE_LOAD_TIME_EXPECTED = 30; // ms
private static final int SVG_ICON_QUORUM_COUNT = 50;
// a list of icons for which we have SVG versions
......@@ -53,15 +57,15 @@ public class IconsLoadTimeTest {
}
}
StatData svgData = IconsLoadTime.getStatData(false, Type.SVG);
assertNotNull("failed to gather SVG load statistics", svgData);
assumeTrue("no SVG load statistics gathered", svgData != null);
System.out.println(svgData);
assertEquals("too few icons loaded: " + svgData.count + "; expecting > " + SVG_ICON_QUORUM_COUNT,
true, svgData.count >= SVG_ICON_QUORUM_COUNT);
assumeTrue("too few icons loaded: " + svgData.count + "; expecting > " + SVG_ICON_QUORUM_COUNT,
svgData.count >= SVG_ICON_QUORUM_COUNT);
assertEquals("SVG icon load time raised to " + String.format("%.02fms", svgData.averageTime) +
", exceeding max " + SVG_ICON_AVERAGE_LOAD_TIME_ESTIMATE + "ms",
true, svgData.averageTime <= SVG_ICON_AVERAGE_LOAD_TIME_ESTIMATE);
assertTiming("SVG icon load time raised to " + String.format("%.02fms", svgData.averageTime),
SVG_ICON_AVERAGE_LOAD_TIME_EXPECTED, (int)svgData.averageTime);
}
@After
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment