import org.json.JSONObject;
public final class PerfResultsUtilTest extends UnitTestCase {
public void testResultsJSON() throws Exception {
ResultsJSON resultsJSON = new ResultsJSON(false);
JSONObject json = resultsJSON.getJSON();
// has build info
JSONObject build = json.getJSONObject("build");
assertNotNull(build);
// results files
resultsJSON.addResultsFile(new File(PerfResultsUtil.RESULTS_DIR + "/goldfiles/ui/label.json"));
resultsJSON.addResultsFile(new File(PerfResultsUtil.RESULTS_DIR + "/goldfiles/ui/console.json"));
resultsJSON.addResultsFile(new File(PerfResultsUtil.RESULTS_DIR + "/goldfiles/ui/button.json"));
resultsJSON.addResultsFile(new File(PerfResultsUtil.RESULTS_DIR + "/timelines/iteration.json"));
JSONObject results = json.getJSONObject("results");
assertEquals(
"{\"timelines\":{\"list\":[\"iteration.json\"]},\"goldfiles\":{\"ui\":{\"list\":[\"button.json\",\"console.json\",\"label.json\"]}}}",
results.toString());
// removing results files
resultsJSON.removeResultsFile(new File(PerfResultsUtil.RESULTS_DIR + "/goldfiles/ui/console.json"));
assertEquals(
"{\"timelines\":{\"list\":[\"iteration.json\"]},\"goldfiles\":{\"ui\":{\"list\":[\"button.json\",\"label.json\"]}}}",
results.toString());
}