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
...@@ -201,19 +201,19 @@ GLColor32F ReadColor32F(GLint x, GLint y); ...@@ -201,19 +201,19 @@ GLColor32F ReadColor32F(GLint x, GLint y);
class EGLWindow; class EGLWindow;
class OSWindow; class OSWindow;
class ANGLETest; class ANGLETestBase;
struct TestPlatformContext final : private angle::NonCopyable struct TestPlatformContext final : private angle::NonCopyable
{ {
bool ignoreMessages = false; bool ignoreMessages = false;
ANGLETest *currentTest = nullptr; ANGLETestBase *currentTest = nullptr;
}; };
class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters> class ANGLETestBase
{ {
protected: protected:
ANGLETest(); ANGLETestBase(const angle::PlatformParameters &params);
~ANGLETest(); virtual ~ANGLETestBase();
public: public:
static bool InitTestWindow(); static bool InitTestWindow();
...@@ -224,8 +224,8 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters> ...@@ -224,8 +224,8 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
virtual void overrideWorkaroundsD3D(angle::WorkaroundsD3D *workaroundsD3D) {} virtual void overrideWorkaroundsD3D(angle::WorkaroundsD3D *workaroundsD3D) {}
protected: protected:
virtual void SetUp(); void ANGLETestSetUp();
virtual void TearDown(); void ANGLETestTearDown();
virtual void swapBuffers(); virtual void swapBuffers();
...@@ -328,6 +328,16 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters> ...@@ -328,6 +328,16 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
static std::unique_ptr<angle::Library> mGLESLibrary; 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 class ANGLETestEnvironment : public testing::Environment
{ {
public: 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