Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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/fml/macros.h"
13#include "flutter/impeller/golden_tests/working_directory.h"
14
15namespace impeller {
16namespace testing {
17
18/// Manages a global variable for tracking instances of golden images.
20 public:
21 static GoldenDigest* Instance();
22
23 void AddDimension(const std::string& name, const std::string& value);
24
25 void AddImage(const std::string& test_name,
26 const std::string& filename,
27 int32_t width,
28 int32_t height);
29
30 /// Writes a "digest.json" file to `working_directory`.
31 ///
32 /// Returns `true` on success.
33 bool Write(WorkingDirectory* working_directory);
34
35 private:
36 GoldenDigest(const GoldenDigest&) = delete;
37
38 GoldenDigest& operator=(const GoldenDigest&) = delete;
40 struct Entry {
41 std::string test_name;
42 std::string filename;
43 int32_t width;
44 int32_t height;
45 double max_diff_pixels_percent;
46 int32_t max_color_delta;
47 };
48
49 static GoldenDigest* instance_;
50 std::vector<Entry> entries_;
51 std::map<std::string, std::string> dimensions_;
52};
53} // namespace testing
54} // namespace impeller
55
56#endif // FLUTTER_IMPELLER_GOLDEN_TESTS_GOLDEN_DIGEST_H_
Manages a global variable for tracking instances of golden images.
bool Write(WorkingDirectory *working_directory)
static GoldenDigest * Instance()
void AddDimension(const std::string &name, const std::string &value)
void AddImage(const std::string &test_name, const std::string &filename, int32_t width, int32_t height)
uint8_t value
const char * name
Definition fuchsia.cc:50
int32_t height
int32_t width