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/fml/macros.h"
14 
15 namespace impeller {
16 namespace testing {
17 
18 /// Manages a global variable for tracking instances of golden images.
19 class GoldenDigest {
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;
39  GoldenDigest();
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_
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:17
impeller::testing::GoldenDigest
Manages a global variable for tracking instances of golden images.
Definition: golden_digest.h:19
working_directory.h
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
Definition: aiks_blur_unittests.cc:20