Esempio n. 1
0
static void writeTestName(const char* nameSuffix, SkWStream& outFile) {
    outFile.writeText(testName);
    outFile.writeDecAsText(testNumber);
    if (nameSuffix) {
        outFile.writeText(nameSuffix);
    }
}
Esempio n. 2
0
void SkDiffContext::outputRecords(SkWStream& stream, bool useJSONP) {
    DiffRecord* currentRecord = fRecords;
    if (useJSONP) {
        stream.writeText("var SkPDiffRecords = {\n");
    }
    else
    {
        stream.writeText("{\n");
    }
    stream.writeText("    \"records\": [\n");
    while (NULL != currentRecord) {
        stream.writeText("        {\n");

            stream.writeText("            \"baselinePath\": \"");
            stream.writeText(currentRecord->fBaselinePath.c_str());
            stream.writeText("\",\n");

            stream.writeText("            \"testPath\": \"");
            stream.writeText(currentRecord->fTestPath.c_str());
            stream.writeText("\",\n");

            stream.writeText("            \"diffs\": [\n");
            for (int diffIndex = 0; diffIndex < currentRecord->fDiffs.count(); diffIndex++) {
                DiffData& data = currentRecord->fDiffs[diffIndex];
                stream.writeText("                {\n");

                    stream.writeText("                    \"differName\": \"");
                    stream.writeText(data.fDiffName);
                    stream.writeText("\",\n");

                    stream.writeText("                    \"result\": ");
                    stream.writeScalarAsText(data.fResult);
                    stream.writeText(",\n");

                    stream.writeText("                    \"pointsOfInterest\": [\n");
                    for (int poiIndex = 0; poiIndex < data.fPointsOfInterest.count(); poiIndex++) {
                        SkIPoint poi = data.fPointsOfInterest[poiIndex];
                        stream.writeText("                        [");
                        stream.writeDecAsText(poi.x());
                        stream.writeText(",");
                        stream.writeDecAsText(poi.y());
                        stream.writeText("]");

                        // JSON does not allow trailing commas
                        if (poiIndex + 1 < data.fPointsOfInterest.count())
                        {
                            stream.writeText(",");
                        }
                        stream.writeText("\n");
                    }
                    stream.writeText("                    ]\n");
                stream.writeText("                }");

                // JSON does not allow trailing commas
                if (diffIndex + 1 < currentRecord->fDiffs.count())
                {
                    stream.writeText(",");
                }
                stream.writeText("                \n");
            }
            stream.writeText("            ]\n");

        stream.writeText("        }");

        // JSON does not allow trailing commas
        if (NULL != currentRecord->fNext)
        {
            stream.writeText(",");
        }
        stream.writeText("\n");
        currentRecord = currentRecord->fNext;
    }
    stream.writeText("    ]\n");
    if (useJSONP) {
        stream.writeText("};\n");
    }
    else
    {
        stream.writeText("}\n");
    }
}