Commit c260e906 authored by Wan-Teh Chang's avatar Wan-Teh Chang Committed by Commit Bot

Pretty-print struct StaticColorCheckParam

Override operator<< of struct StaticColorCheckParam to std::ostream to
make the error messages of test failures human-readable.

Bug: 960620
Change-Id: Ia4da2578485cdfdcd0078003ca25d52e68d8321f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2196923Reviewed-by: default avatarPeter Kasting <pkasting@chromium.org>
Commit-Queue: Wan-Teh Chang <wtc@google.com>
Cr-Commit-Position: refs/heads/master@{#769020}
parent fce5f3f1
......@@ -6,6 +6,7 @@
#include <cmath>
#include <memory>
#include <ostream>
#include <vector>
#include "testing/gtest/include/gtest/gtest.h"
......@@ -61,6 +62,26 @@ struct StaticColorCheckParam {
std::vector<ExpectedColor> colors;
};
std::ostream& operator<<(std::ostream& os, const StaticColorCheckParam& param) {
const char* alpha_option =
(param.alpha_option == ImageDecoder::kAlphaPremultiplied
? "AlphaPremultiplied"
: "AlphaNotPremultiplied");
const char* color_behavior;
if (param.color_behavior.IsIgnore()) {
color_behavior = "Ignore";
} else if (param.color_behavior.IsTag()) {
color_behavior = "Tag";
} else {
DCHECK(param.color_behavior.IsTransformToSRGB());
color_behavior = "TransformToSRGB";
}
return os << "StaticColorCheckParam { path: \"" << param.path
<< "\", bit_depth: " << param.bit_depth
<< ", alpha_option: " << alpha_option
<< ", color_behavior: " << color_behavior << " }";
}
StaticColorCheckParam kTestParams[] = {
{
"/images/resources/avif/red-at-12-oclock-with-color-profile-lossy.avif",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment