skia2/tests/GrSurfaceTest.cpp
tfarina 9ea53f93e7 Preprend Test to test function name generated by DEF_TEST() macro.
That way when declaring a test with DEF_TEST() macro, you don't have to
uniquify the test name because it might colide with the class it is
being testing.

For example, if you are testing SkBase64 and do:

DEF_TEST(SkBase64, reporter) {
}

That will generate an error because the macro will declare a function
named SkBase64 which colides with the type SkBase64.

By adding Test to the function name we avoid this problem.

Fixed the entries found with the following command line:

$ git grep "Test, r" | grep DEF

BUG=None
TEST=make tests && out/Debug/tests
R=mtklein@google.com

Author: tfarina@chromium.org

Review URL: https://codereview.chromium.org/345753007
2014-06-24 06:50:39 -07:00

62 lines
2.4 KiB
C++

/*
* Copyright 2013 Google Inc.
*
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file.
*/
#if SK_SUPPORT_GPU
#include "GrContext.h"
#include "GrContextFactory.h"
#include "GrRenderTarget.h"
#include "GrTexture.h"
#include "SkTypes.h"
#include "Test.h"
DEF_GPUTEST(GrSurface, reporter, factory) {
GrContext* context = factory->get(GrContextFactory::kNull_GLContextType);
if (NULL != context) {
GrTextureDesc desc;
desc.fConfig = kSkia8888_GrPixelConfig;
desc.fFlags = kRenderTarget_GrTextureFlagBit;
desc.fWidth = 256;
desc.fHeight = 256;
desc.fSampleCnt = 0;
GrSurface* texRT1 = context->createUncachedTexture(desc, NULL, 0);
GrSurface* texRT2 = context->createUncachedTexture(desc, NULL, 0);
desc.fFlags = kNone_GrTextureFlags;
GrSurface* tex1 = context->createUncachedTexture(desc, NULL, 0);
REPORTER_ASSERT(reporter, texRT1->isSameAs(texRT1));
REPORTER_ASSERT(reporter, texRT1->isSameAs(texRT1->asRenderTarget()));
REPORTER_ASSERT(reporter, texRT1->asRenderTarget()->isSameAs(texRT1));
REPORTER_ASSERT(reporter, !texRT2->isSameAs(texRT1));
REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->isSameAs(texRT1));
REPORTER_ASSERT(reporter, !texRT2->isSameAs(texRT1->asRenderTarget()));
REPORTER_ASSERT(reporter, !texRT2->isSameAs(tex1));
REPORTER_ASSERT(reporter, !texRT2->asRenderTarget()->isSameAs(tex1));
GrBackendTextureDesc backendDesc;
backendDesc.fConfig = kSkia8888_GrPixelConfig;
backendDesc.fFlags = kRenderTarget_GrBackendTextureFlag;
backendDesc.fWidth = 256;
backendDesc.fHeight = 256;
backendDesc.fSampleCnt = 0;
backendDesc.fTextureHandle = 5;
GrSurface* externalTexRT = context->wrapBackendTexture(backendDesc);
REPORTER_ASSERT(reporter, externalTexRT->isSameAs(externalTexRT));
REPORTER_ASSERT(reporter, externalTexRT->isSameAs(externalTexRT->asRenderTarget()));
REPORTER_ASSERT(reporter, externalTexRT->asRenderTarget()->isSameAs(externalTexRT));
REPORTER_ASSERT(reporter, !externalTexRT->isSameAs(texRT1));
REPORTER_ASSERT(reporter, !externalTexRT->asRenderTarget()->isSameAs(texRT1));
texRT1->unref();
texRT2->unref();
tex1->unref();
externalTexRT->unref();
}
}
#endif