Flutter Engine
The Flutter Engine
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
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}) {
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
Definition: FontMgrTest.cpp:39
#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 {
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}
bool isAlphaUnchanged() const
SkColor4f filterColor4f(const SkColor4f &srcColor, SkColorSpace *srcCS, SkColorSpace *dstCS) const
constexpr SkColor4f kWhite
Definition: SkColor.h:439
constexpr SkColor4f kBlack
Definition: SkColor.h:435