Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
HighContrastFilterTest.cpp
Go to the documentation of this file.
1/*
2 * Copyright 2017 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
13#include "tests/Test.h"
14
15#include <initializer_list>
16
17DEF_TEST(HighContrastFilter_SmokeTest, reporter) {
19 config.fInvertStyle = SkHighContrastConfig::InvertStyle::kInvertLightness;
21 REPORTER_ASSERT(reporter, filter->isAlphaUnchanged());
22
23 SkColorSpace* cs = nullptr;
24 SkColor4f white_inverted = filter->filterColor4f(SkColors::kWhite, cs, cs);
25 REPORTER_ASSERT(reporter, white_inverted == SkColors::kBlack);
26
27 SkColor4f black_inverted = filter->filterColor4f(SkColors::kBlack, cs, cs);
28 REPORTER_ASSERT(reporter, black_inverted == SkColors::kWhite);
29}
30
31DEF_TEST(HighContrastFilter_InvalidInputs, reporter) {
34
35 // Valid invert style
36 config.fInvertStyle = SkHighContrastConfig::InvertStyle::kInvertBrightness;
38 config.fInvertStyle = SkHighContrastConfig::InvertStyle::kInvertLightness;
42
43 // Invalid invert style
44 config.fInvertStyle = static_cast<SkHighContrastConfig::InvertStyle>(999);
46 filter = SkHighContrastFilter::Make(config);
47 REPORTER_ASSERT(reporter, !filter);
48
49 // Valid contrast
50 for (float contrast : {0.5f, +1.0f, -1.0f}) {
51 config.fInvertStyle = SkHighContrastConfig::InvertStyle::kInvertBrightness;
52 config.fContrast = contrast;
54 filter = SkHighContrastFilter::Make(config);
56 }
57
58 // Invalid contrast
59 config.fContrast = 1.1f;
61 filter = SkHighContrastFilter::Make(config);
62 REPORTER_ASSERT(reporter, !filter);
63}
reporter
#define DEF_TEST(name, reporter)
Definition Test.h:312
#define REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
constexpr SkColor4f kWhite
Definition SkColor.h:439
constexpr SkColor4f kBlack
Definition SkColor.h:435
static sk_sp< SkColorFilter > Make(const SkHighContrastConfig &config)