blob: 66ce530624b36841b833fa9d999aea8768715922 [file] [log] [blame]
scroggo7a10fb62014-11-04 07:21:10 -08001/*
2 * Copyright 2014 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#ifndef DMJsonWriter_DEFINED
9#define DMJsonWriter_DEFINED
10
11#include "SkString.h"
scroggo0ee26272014-11-07 06:07:32 -080012#include "Test.h"
scroggo7a10fb62014-11-04 07:21:10 -080013
14namespace DM {
15
16/**
17 * Class for collecting results from DM and writing to a json file.
18 * All methods are thread-safe.
19 */
20class JsonWriter {
21public:
22 /**
23 * Info describing a single run.
24 */
25 struct BitmapResult {
26 SkString name; // E.g. "ninepatch-stretch", "desk-gws_skp"
27 SkString config; // "gpu", "8888"
28 SkString mode; // "direct", "default-tilegrid", "pipe"
29 SkString sourceType; // "GM", "SKP"
30 SkString md5; // In ASCII, so 32 bytes long.
31 };
32
33 /**
34 * Add a result to the end of the list of results.
35 */
36 static void AddBitmapResult(const BitmapResult&);
37
38 /**
scroggo0ee26272014-11-07 06:07:32 -080039 * Add a Failure from a Test.
40 */
41 static void AddTestFailure(const skiatest::Failure&);
42
43 /**
scroggo7a10fb62014-11-04 07:21:10 -080044 * Write all collected results to the file FLAGS_writePath[0]/dm.json.
45 */
46 static void DumpJson();
47};
48
49} // namespace DM
50#endif // DMJsonWriter_DEFINED