| Flutter Impeller |

golden_digest.h
Go to the documentation of this file.
1 // Copyright 2013 The Flutter Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef FLUTTER_IMPELLER_GOLDEN_TESTS_GOLDEN_DIGEST_H_
6 #define FLUTTER_IMPELLER_GOLDEN_TESTS_GOLDEN_DIGEST_H_
7
8 #include <map>
9 #include <string>
10 #include <vector>
11
12 #include "flutter/impeller/golden_tests/working_directory.h"
13
14 namespace impeller {
15 namespace testing {
16
17 /// Manages a global variable for tracking instances of golden images.
18 class GoldenDigest {
19 public:
20 static GoldenDigest* Instance();
21
22 void AddDimension(const std::string& name, const std::string& value);
23
24 void AddImage(const std::string& test_name,
25 const std::string& filename,
26 int32_t width,
27 int32_t height);
28
29 /// Writes a "digest.json" file to `working_directory`.
30 ///
31 /// Returns `true` on success.
32 bool Write(WorkingDirectory* working_directory);
33
34 private:
35 GoldenDigest(const GoldenDigest&) = delete;
36
37 GoldenDigest& operator=(const GoldenDigest&) = delete;
38 GoldenDigest();
39 struct Entry {
40 std::string test_name;
41 std::string filename;
42 int32_t width;
43 int32_t height;
44 double max_diff_pixels_percent;
45 int32_t max_color_delta;
46 };
47
48 static GoldenDigest* instance_;
49 std::vector<Entry> entries_;
50 std::map<std::string, std::string> dimensions_;
51 };
52 } // namespace testing
53 } // namespace impeller
54
55 #endif // FLUTTER_IMPELLER_GOLDEN_TESTS_GOLDEN_DIGEST_H_
impeller::testing::GoldenDigest
Manages a global variable for tracking instances of golden images.
Definition: golden_digest.h:18
impeller::testing::GoldenDigest::Write
bool Write(WorkingDirectory *working_directory)
Definition: golden_digest.cc:42
impeller::testing::GoldenDigest::Instance
static GoldenDigest * Instance()
Definition: golden_digest.cc:18
impeller::testing::GoldenDigest::AddDimension
void AddDimension(const std::string &name, const std::string &value)
Definition: golden_digest.cc:27
impeller::testing::GoldenDigest::AddImage
void AddImage(const std::string &test_name, const std::string &filename, int32_t width, int32_t height)
Definition: golden_digest.cc:34
impeller::testing::WorkingDirectory
Definition: working_directory.h:15
value
int32_t value
Definition: dl_golden_unittests.cc:459
impeller
Definition: allocation.cc:12
working_directory.h