Flutter Engine Uber Docs
Docs for the entire Flutter Engine repo.
 
Loading...
Searching...
No Matches
golden_digest_manager.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_TESTING_GOLDEN_DIGEST_MANAGER_H_
6#define FLUTTER_IMPELLER_TESTING_GOLDEN_DIGEST_MANAGER_H_
7
8#include <map>
9#include <string>
10#include <vector>
11
12namespace impeller {
13namespace testing {
14
15/// Manages a global variable for tracking a directory containing
16/// instances of golden images.
18 public:
19 /// Constructs a GoldenDigest that will accumulate golden image filenames
20 /// and Dimension key/value pairs for the specified working directory and
21 /// write them to a file named "digest.json" in that directory when
22 /// |Write| is called.
23 explicit GoldenDigestManager(const std::string& working_directory);
24
26
27 const std::string& GetWorkingDirectory() const;
28
29 std::string GetFullPath(const std::string& filename) const;
30
31 void AddDimension(const std::string& name, const std::string& value);
32
33 void AddImage(const std::string& test_name,
34 const std::string& golden_filename,
35 int32_t width,
36 int32_t height);
37
38 /// Writes a "digest.json" file to the working directory.
39 ///
40 /// (Failing to call either this method or the |ClearDigestData| method
41 /// causes a warning to be written to the console about unwritten data
42 /// left in the digest manater.)
43 ///
44 /// Returns `true` on success.
45 bool Write();
46
47 /// Clears all accumulated dimension and golden image data if the digest
48 /// should not be written.
49 ///
50 /// (Failing to call either this method or the |Write| method causes
51 /// a warning to be written to the console about unwritten data left
52 /// in the digest manater.)
53 void ClearDigestData();
54
55 private:
57
58 GoldenDigestManager& operator=(const GoldenDigestManager&) = delete;
59
60 struct Entry {
61 std::string test_name;
62 std::string filename;
63 int32_t width;
64 int32_t height;
65 double max_diff_pixels_percent;
66 int32_t max_color_delta;
67 };
68
69 std::string working_directory_;
70 std::vector<Entry> entries_;
71 std::map<std::string, std::string> dimensions_;
72 size_t entries_written_ = 0u;
73 size_t dimensions_written_ = 0u;
74};
75
76} // namespace testing
77} // namespace impeller
78
79#endif // FLUTTER_IMPELLER_TESTING_GOLDEN_DIGEST_MANAGER_H_
void AddImage(const std::string &test_name, const std::string &golden_filename, int32_t width, int32_t height)
std::string GetFullPath(const std::string &filename) const
const std::string & GetWorkingDirectory() const
void AddDimension(const std::string &name, const std::string &value)
int32_t value
DEF_SWITCHES_START aot vmservice shared library name
Definition switch_defs.h:27
int32_t height
int32_t width