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 #pragma once
6 
7 #include <map>
8 #include <string>
9 #include <vector>
10 
11 #include "flutter/fml/macros.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  FML_DISALLOW_COPY_AND_ASSIGN(GoldenDigest);
36  GoldenDigest();
37  struct Entry {
38  std::string test_name;
39  std::string filename;
40  int32_t width;
41  int32_t height;
42  double max_diff_pixels_percent;
43  int32_t max_color_delta;
44  };
45 
46  static GoldenDigest* instance_;
47  std::vector<Entry> entries_;
48  std::map<std::string, std::string> dimensions_;
49 };
50 } // namespace testing
51 } // namespace impeller
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:16
impeller::testing::GoldenDigest
Manages a global variable for tracking instances of golden images.
Definition: golden_digest.h:18
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_context.cc:10