Commit cdadb3ff by Martin Radev Committed by Commit Bot

Decouple ANGLETest functionality and test parameters

ANGLETest provides useful functionality for end2end tests, but it cannot be used for tests which take other test parameters than the platform. The patch introduces another level of abstraction by moving all of ANGLETest's functionality to another class - ANGLETestBase - which does not inherit from ::testing::TestWithParam<>. New tests can either inherit from ANGLETest as before to have only platform parameters, or they can inherit from ANGLETestBase and add handling of custom test parameters. Example: // The new parameter type must inherit from PlatformParameters. struct MyCustomParameters : PlatformParameters { bool mWorkaroundState; }; class MyTest : public ANGLETestBase, public ::testing::TestWithParam<MyCustomParameters> { protected: void overrideWorkaroundsD3D( angle::WorkaroundsD3D *workaroundsD3D) override { workaroundsD3D->myCustomWorkaround = GetParam().mWorkaroundState; } }; ANGLE_INSTANTIATE_TEST(MyTest, MyCustomParameters(ES3_D3D11(), false), MyCustomParameters(ES3_D3D11(), true)); BUG=angleproject:2062 TEST=angle_end2end_tests Change-Id: Ia36e429cff8c4c291fc87a286a1d1a3004d6fad6 Reviewed-on: https://chromium-review.googlesource.com/530945 Commit-Queue: Olli Etuaho <oetuaho@nvidia.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 9f01a0d4
......@@ -188,7 +188,7 @@ GLColor32F ReadColor32F(GLint x, GLint y)
} // namespace angle
// static
std::array<angle::Vector3, 6> ANGLETest::GetQuadVertices()
std::array<angle::Vector3, 6> ANGLETestBase::GetQuadVertices()
{
std::array<angle::Vector3, 6> vertices;
vertices[0] = angle::Vector3(-1.0f, 1.0f, 0.5f);
......@@ -200,7 +200,7 @@ std::array<angle::Vector3, 6> ANGLETest::GetQuadVertices()
return vertices;
}
ANGLETest::ANGLETest()
ANGLETestBase::ANGLETestBase(const angle::PlatformParameters &params)
: mEGLWindow(nullptr),
mWidth(16),
mHeight(16),
......@@ -209,11 +209,10 @@ ANGLETest::ANGLETest()
mQuadIndexBuffer(0),
mDeferContextInit(false)
{
mEGLWindow =
new EGLWindow(GetParam().majorVersion, GetParam().minorVersion, GetParam().eglParameters);
mEGLWindow = new EGLWindow(params.majorVersion, params.minorVersion, params.eglParameters);
// Default vulkan layers to enabled.
EGLint renderer = GetParam().getRenderer();
EGLint renderer = params.getRenderer();
if (renderer == EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE)
{
mEGLWindow->setVulkanLayersEnabled(true);
......@@ -235,7 +234,7 @@ ANGLETest::ANGLETest()
mLastRendererType = renderer;
}
ANGLETest::~ANGLETest()
ANGLETestBase::~ANGLETestBase()
{
if (mQuadVertexBuffer)
{
......@@ -248,7 +247,7 @@ ANGLETest::~ANGLETest()
SafeDelete(mEGLWindow);
}
void ANGLETest::SetUp()
void ANGLETestBase::ANGLETestSetUp()
{
mPlatformContext.ignoreMessages = false;
mPlatformContext.currentTest = this;
......@@ -299,7 +298,7 @@ void ANGLETest::SetUp()
angle::WriteDebugMessage("Entering %s.%s\n", info->test_case_name(), info->name());
}
void ANGLETest::TearDown()
void ANGLETestBase::ANGLETestTearDown()
{
mEGLWindow->setPlatformMethods(nullptr);
......@@ -334,7 +333,7 @@ void ANGLETest::TearDown()
}
}
void ANGLETest::swapBuffers()
void ANGLETestBase::swapBuffers()
{
if (mEGLWindow->isGLInitialized())
{
......@@ -342,7 +341,7 @@ void ANGLETest::swapBuffers()
}
}
void ANGLETest::setupQuadVertexBuffer(GLfloat positionAttribZ, GLfloat positionAttribXYScale)
void ANGLETestBase::setupQuadVertexBuffer(GLfloat positionAttribZ, GLfloat positionAttribXYScale)
{
if (mQuadVertexBuffer == 0)
{
......@@ -361,7 +360,8 @@ void ANGLETest::setupQuadVertexBuffer(GLfloat positionAttribZ, GLfloat positionA
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 3 * 6, quadVertices.data(), GL_STATIC_DRAW);
}
void ANGLETest::setupIndexedQuadVertexBuffer(GLfloat positionAttribZ, GLfloat positionAttribXYScale)
void ANGLETestBase::setupIndexedQuadVertexBuffer(GLfloat positionAttribZ,
GLfloat positionAttribXYScale)
{
if (mQuadVertexBuffer == 0)
{
......@@ -380,7 +380,7 @@ void ANGLETest::setupIndexedQuadVertexBuffer(GLfloat positionAttribZ, GLfloat po
glBufferData(GL_ARRAY_BUFFER, sizeof(GLfloat) * 3 * 4, quadVertices.data(), GL_STATIC_DRAW);
}
void ANGLETest::setupIndexedQuadIndexBuffer()
void ANGLETestBase::setupIndexedQuadIndexBuffer()
{
if (mQuadIndexBuffer == 0)
{
......@@ -393,27 +393,27 @@ void ANGLETest::setupIndexedQuadIndexBuffer()
}
// static
void ANGLETest::drawQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ)
void ANGLETestBase::drawQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ)
{
drawQuad(program, positionAttribName, positionAttribZ, 1.0f);
}
// static
void ANGLETest::drawQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ,
GLfloat positionAttribXYScale)
void ANGLETestBase::drawQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ,
GLfloat positionAttribXYScale)
{
drawQuad(program, positionAttribName, positionAttribZ, positionAttribXYScale, false);
}
void ANGLETest::drawQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ,
GLfloat positionAttribXYScale,
bool useVertexBuffer)
void ANGLETestBase::drawQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ,
GLfloat positionAttribXYScale,
bool useVertexBuffer)
{
GLint previousProgram = 0;
glGetIntegerv(GL_CURRENT_PROGRAM, &previousProgram);
......@@ -455,26 +455,26 @@ void ANGLETest::drawQuad(GLuint program,
}
}
void ANGLETest::drawIndexedQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ)
void ANGLETestBase::drawIndexedQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ)
{
drawIndexedQuad(program, positionAttribName, positionAttribZ, 1.0f);
}
void ANGLETest::drawIndexedQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ,
GLfloat positionAttribXYScale)
void ANGLETestBase::drawIndexedQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ,
GLfloat positionAttribXYScale)
{
drawIndexedQuad(program, positionAttribName, positionAttribZ, positionAttribXYScale, false);
}
void ANGLETest::drawIndexedQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ,
GLfloat positionAttribXYScale,
bool useIndexBuffer)
void ANGLETestBase::drawIndexedQuad(GLuint program,
const std::string &positionAttribName,
GLfloat positionAttribZ,
GLfloat positionAttribXYScale,
bool useIndexBuffer)
{
GLint positionLocation = glGetAttribLocation(program, positionAttribName.c_str());
......@@ -525,7 +525,7 @@ void ANGLETest::drawIndexedQuad(GLuint program,
}
}
GLuint ANGLETest::compileShader(GLenum type, const std::string &source)
GLuint ANGLETestBase::compileShader(GLenum type, const std::string &source)
{
GLuint shader = glCreateShader(type);
......@@ -560,7 +560,7 @@ GLuint ANGLETest::compileShader(GLenum type, const std::string &source)
return shader;
}
void ANGLETest::checkD3D11SDKLayersMessages()
void ANGLETestBase::checkD3D11SDKLayersMessages()
{
#if defined(ANGLE_PLATFORM_WINDOWS) && !defined(NDEBUG)
// In debug D3D11 mode, check ID3D11InfoQueue to see if any D3D11 SDK Layers messages
......@@ -639,29 +639,29 @@ void ANGLETest::checkD3D11SDKLayersMessages()
#endif
}
bool ANGLETest::extensionEnabled(const std::string &extName)
bool ANGLETestBase::extensionEnabled(const std::string &extName)
{
return CheckExtensionExists(reinterpret_cast<const char *>(glGetString(GL_EXTENSIONS)),
extName);
}
bool ANGLETest::extensionRequestable(const std::string &extName)
bool ANGLETestBase::extensionRequestable(const std::string &extName)
{
return CheckExtensionExists(
reinterpret_cast<const char *>(glGetString(GL_REQUESTABLE_EXTENSIONS_ANGLE)), extName);
}
bool ANGLETest::eglDisplayExtensionEnabled(EGLDisplay display, const std::string &extName)
bool ANGLETestBase::eglDisplayExtensionEnabled(EGLDisplay display, const std::string &extName)
{
return CheckExtensionExists(eglQueryString(display, EGL_EXTENSIONS), extName);
}
bool ANGLETest::eglClientExtensionEnabled(const std::string &extName)
bool ANGLETestBase::eglClientExtensionEnabled(const std::string &extName)
{
return EGLWindow::ClientExtensionEnabled(extName);
}
bool ANGLETest::eglDeviceExtensionEnabled(EGLDeviceEXT device, const std::string &extName)
bool ANGLETestBase::eglDeviceExtensionEnabled(EGLDeviceEXT device, const std::string &extName)
{
PFNEGLQUERYDEVICESTRINGEXTPROC eglQueryDeviceStringEXT =
reinterpret_cast<PFNEGLQUERYDEVICESTRINGEXTPROC>(
......@@ -669,139 +669,139 @@ bool ANGLETest::eglDeviceExtensionEnabled(EGLDeviceEXT device, const std::string
return CheckExtensionExists(eglQueryDeviceStringEXT(device, EGL_EXTENSIONS), extName);
}
void ANGLETest::setWindowWidth(int width)
void ANGLETestBase::setWindowWidth(int width)
{
mWidth = width;
}
void ANGLETest::setWindowHeight(int height)
void ANGLETestBase::setWindowHeight(int height)
{
mHeight = height;
}
void ANGLETest::setConfigRedBits(int bits)
void ANGLETestBase::setConfigRedBits(int bits)
{
mEGLWindow->setConfigRedBits(bits);
}
void ANGLETest::setConfigGreenBits(int bits)
void ANGLETestBase::setConfigGreenBits(int bits)
{
mEGLWindow->setConfigGreenBits(bits);
}
void ANGLETest::setConfigBlueBits(int bits)
void ANGLETestBase::setConfigBlueBits(int bits)
{
mEGLWindow->setConfigBlueBits(bits);
}
void ANGLETest::setConfigAlphaBits(int bits)
void ANGLETestBase::setConfigAlphaBits(int bits)
{
mEGLWindow->setConfigAlphaBits(bits);
}
void ANGLETest::setConfigDepthBits(int bits)
void ANGLETestBase::setConfigDepthBits(int bits)
{
mEGLWindow->setConfigDepthBits(bits);
}
void ANGLETest::setConfigStencilBits(int bits)
void ANGLETestBase::setConfigStencilBits(int bits)
{
mEGLWindow->setConfigStencilBits(bits);
}
void ANGLETest::setConfigComponentType(EGLenum componentType)
void ANGLETestBase::setConfigComponentType(EGLenum componentType)
{
mEGLWindow->setConfigComponentType(componentType);
}
void ANGLETest::setMultisampleEnabled(bool enabled)
void ANGLETestBase::setMultisampleEnabled(bool enabled)
{
mEGLWindow->setMultisample(enabled);
}
void ANGLETest::setSamples(EGLint samples)
void ANGLETestBase::setSamples(EGLint samples)
{
mEGLWindow->setSamples(samples);
}
void ANGLETest::setDebugEnabled(bool enabled)
void ANGLETestBase::setDebugEnabled(bool enabled)
{
mEGLWindow->setDebugEnabled(enabled);
}
void ANGLETest::setNoErrorEnabled(bool enabled)
void ANGLETestBase::setNoErrorEnabled(bool enabled)
{
mEGLWindow->setNoErrorEnabled(enabled);
}
void ANGLETest::setWebGLCompatibilityEnabled(bool webglCompatibility)
void ANGLETestBase::setWebGLCompatibilityEnabled(bool webglCompatibility)
{
mEGLWindow->setWebGLCompatibilityEnabled(webglCompatibility);
}
void ANGLETest::setBindGeneratesResource(bool bindGeneratesResource)
void ANGLETestBase::setBindGeneratesResource(bool bindGeneratesResource)
{
mEGLWindow->setBindGeneratesResource(bindGeneratesResource);
}
void ANGLETest::setVulkanLayersEnabled(bool enabled)
void ANGLETestBase::setVulkanLayersEnabled(bool enabled)
{
mEGLWindow->setVulkanLayersEnabled(enabled);
}
void ANGLETest::setClientArraysEnabled(bool enabled)
void ANGLETestBase::setClientArraysEnabled(bool enabled)
{
mEGLWindow->setClientArraysEnabled(enabled);
}
void ANGLETest::setRobustResourceInit(bool enabled)
void ANGLETestBase::setRobustResourceInit(bool enabled)
{
mEGLWindow->setRobustResourceInit(enabled);
}
void ANGLETest::setDeferContextInit(bool enabled)
void ANGLETestBase::setDeferContextInit(bool enabled)
{
mDeferContextInit = enabled;
}
int ANGLETest::getClientMajorVersion() const
int ANGLETestBase::getClientMajorVersion() const
{
return mEGLWindow->getClientMajorVersion();
}
int ANGLETest::getClientMinorVersion() const
int ANGLETestBase::getClientMinorVersion() const
{
return mEGLWindow->getClientMinorVersion();
}
EGLWindow *ANGLETest::getEGLWindow() const
EGLWindow *ANGLETestBase::getEGLWindow() const
{
return mEGLWindow;
}
int ANGLETest::getWindowWidth() const
int ANGLETestBase::getWindowWidth() const
{
return mWidth;
}
int ANGLETest::getWindowHeight() const
int ANGLETestBase::getWindowHeight() const
{
return mHeight;
}
bool ANGLETest::isMultisampleEnabled() const
bool ANGLETestBase::isMultisampleEnabled() const
{
return mEGLWindow->isMultisample();
}
bool ANGLETest::destroyEGLContext()
bool ANGLETestBase::destroyEGLContext()
{
mEGLWindow->destroyGL();
return true;
}
// static
bool ANGLETest::InitTestWindow()
bool ANGLETestBase::InitTestWindow()
{
mOSWindow = CreateOSWindow();
if (!mOSWindow->initialize("ANGLE_TEST", 128, 128))
......@@ -817,7 +817,7 @@ bool ANGLETest::InitTestWindow()
}
// static
bool ANGLETest::DestroyTestWindow()
bool ANGLETestBase::DestroyTestWindow()
{
if (mOSWindow)
{
......@@ -831,11 +831,25 @@ bool ANGLETest::DestroyTestWindow()
return true;
}
void ANGLETest::SetWindowVisible(bool isVisible)
void ANGLETestBase::SetWindowVisible(bool isVisible)
{
mOSWindow->setVisible(isVisible);
}
ANGLETest::ANGLETest() : ANGLETestBase(GetParam())
{
}
void ANGLETest::SetUp()
{
ANGLETestBase::ANGLETestSetUp();
}
void ANGLETest::TearDown()
{
ANGLETestBase::ANGLETestTearDown();
}
bool IsIntel()
{
std::string rendererString(reinterpret_cast<const char *>(glGetString(GL_RENDERER)));
......@@ -972,25 +986,25 @@ bool IsRelease()
return !IsDebug();
}
EGLint ANGLETest::getPlatformRenderer() const
EGLint ANGLETestBase::getPlatformRenderer() const
{
assert(mEGLWindow);
return mEGLWindow->getPlatform().renderer;
}
void ANGLETest::ignoreD3D11SDKLayersWarnings()
void ANGLETestBase::ignoreD3D11SDKLayersWarnings()
{
// Some tests may need to disable the D3D11 SDK Layers Warnings checks
mIgnoreD3D11SDKLayersWarnings = true;
}
OSWindow *ANGLETest::mOSWindow = nullptr;
Optional<EGLint> ANGLETest::mLastRendererType;
std::unique_ptr<angle::Library> ANGLETest::mGLESLibrary;
OSWindow *ANGLETestBase::mOSWindow = nullptr;
Optional<EGLint> ANGLETestBase::mLastRendererType;
std::unique_ptr<angle::Library> ANGLETestBase::mGLESLibrary;
void ANGLETestEnvironment::SetUp()
{
if (!ANGLETest::InitTestWindow())
if (!ANGLETestBase::InitTestWindow())
{
FAIL() << "Failed to create ANGLE test window.";
}
......@@ -998,5 +1012,5 @@ void ANGLETestEnvironment::SetUp()
void ANGLETestEnvironment::TearDown()
{
ANGLETest::DestroyTestWindow();
ANGLETestBase::DestroyTestWindow();
}
......@@ -201,19 +201,19 @@ GLColor32F ReadColor32F(GLint x, GLint y);
class EGLWindow;
class OSWindow;
class ANGLETest;
class ANGLETestBase;
struct TestPlatformContext final : private angle::NonCopyable
{
bool ignoreMessages = false;
ANGLETest *currentTest = nullptr;
ANGLETestBase *currentTest = nullptr;
};
class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
class ANGLETestBase
{
protected:
ANGLETest();
~ANGLETest();
ANGLETestBase(const angle::PlatformParameters &params);
virtual ~ANGLETestBase();
public:
static bool InitTestWindow();
......@@ -224,8 +224,8 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
virtual void overrideWorkaroundsD3D(angle::WorkaroundsD3D *workaroundsD3D) {}
protected:
virtual void SetUp();
virtual void TearDown();
void ANGLETestSetUp();
void ANGLETestTearDown();
virtual void swapBuffers();
......@@ -328,6 +328,16 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
static std::unique_ptr<angle::Library> mGLESLibrary;
};
class ANGLETest : public ANGLETestBase, public ::testing::TestWithParam<angle::PlatformParameters>
{
protected:
ANGLETest();
public:
void SetUp() override;
void TearDown() override;
};
class ANGLETestEnvironment : public testing::Environment
{
public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment