skia2/tests/FlattenableFactoryToName.cpp
scroggo 56fbbfe609 Reland of Add test for previously unflattenables (patchset #1 id:1 of https://codereview.chromium.org/1532753002/ )
Reason for revert:
The test should now be blacklisted.

Original issue's description:
> Revert of Add test for previously unflattenables (patchset #1 id:1 of https://codereview.chromium.org/1514373003/ )
>
> Reason for revert:
> Speculative fix for skbug.com/4709
>
> Original issue's description:
> > Add test for previously unflattenables
> >
> > BUG=skia:4613
> >
> > Committed: https://skia.googlesource.com/skia/+/061aaa79f7d8a2e93962e8296abaae13f0a7a715
>
> TBR=halcanary@google.com
> NOPRESUBMIT=true
> NOTREECHECKS=true
> NOTRY=true
> BUG=skia:4613
>
> Committed: https://skia.googlesource.com/skia/+/c8f969309cafebeb16ad057f766b61bdc406a8b8

TBR=halcanary@google.com
NOPRESUBMIT=true
NOTREECHECKS=true
NOTRY=true
BUG=skia:4613

Review URL: https://codereview.chromium.org/1535143002
2015-12-18 07:14:24 -08:00

43 lines
1.4 KiB
C++

/*
* Copyright 2015 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#include "SkAlphaThresholdFilter.h"
#include "SkImage.h"
#include "Test.h"
static void test_flattenable(skiatest::Reporter* r,
const SkFlattenable* f,
const char* desc) {
if (f) {
SkFlattenable::Factory factory = f->getFactory();
REPORTER_ASSERT(r, factory);
if (factory) {
if (!SkFlattenable::FactoryToName(factory)) {
ERRORF(r, "SkFlattenable::FactoryToName() fails with %s.", desc);
}
}
}
}
DEF_TEST(FlattenableFactoryToName, r) {
SkIRect rects[2];
rects[0] = SkIRect::MakeXYWH(0, 150, 500, 200);
rects[1] = SkIRect::MakeXYWH(150, 0, 200, 500);
SkRegion region;
region.setRects(rects, 2);
SkAutoTUnref<SkImageFilter> filter( SkAlphaThresholdFilter::Create(region, 0.2f, 0.7f));
test_flattenable(r, filter, "SkAlphaThresholdFilter()");
SkBitmap bm;
bm.allocN32Pixels(8, 8);
bm.eraseColor(SK_ColorCYAN);
SkAutoTUnref<SkImage> image(SkImage::NewFromBitmap(bm));
SkAutoTUnref<SkShader> shader(image->newShader(SkShader::kClamp_TileMode,
SkShader::kClamp_TileMode));
test_flattenable(r, shader, "SkImage::newShader()");
}