Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Functions
HighContrastFilterTest.cpp File Reference
#include "include/core/SkColor.h"
#include "include/core/SkColorFilter.h"
#include "include/core/SkPaint.h"
#include "include/core/SkRefCnt.h"
#include "include/effects/SkHighContrastFilter.h"
#include "tests/Test.h"
#include <initializer_list>

Go to the source code of this file.

Functions

 DEF_TEST (HighContrastFilter_SmokeTest, reporter)
 
 DEF_TEST (HighContrastFilter_InvalidInputs, reporter)
 

Function Documentation

◆ DEF_TEST() [1/2]

DEF_TEST ( HighContrastFilter_InvalidInputs  ,
reporter   
)

Definition at line 31 of file HighContrastFilterTest.cpp.

31 {
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 REPORTER_ASSERT(r, cond,...)
Definition Test.h:286
static sk_sp< SkColorFilter > Make(const SkHighContrastConfig &config)

◆ DEF_TEST() [2/2]

DEF_TEST ( HighContrastFilter_SmokeTest  ,
reporter   
)

Definition at line 17 of file HighContrastFilterTest.cpp.

17 {
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}
constexpr SkColor4f kWhite
Definition SkColor.h:439
constexpr SkColor4f kBlack
Definition SkColor.h:435