Pass ImplFactory to Texture constructor
This improves encapsulation inside the Texture class, and removes
duplication of createTexture calls. This is a necessary step towards
adding a shared "Data" structure to the Texture classes, following a
similar pattern as for example the Framebuffer class.
This patch also shares the same MockFactory class among different
unit tests.
BUG=angleproject:596
TEST=angle_unittests
Change-Id: Ie8d3a9aa4ec35565d7ecbabb8c40e7b1ba068721
Reviewed-on: https://chromium-review.googlesource.com/340200
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
diff --git a/src/libANGLE/validationES_unittest.cpp b/src/libANGLE/validationES_unittest.cpp
index ef049f9..5766c5f 100644
--- a/src/libANGLE/validationES_unittest.cpp
+++ b/src/libANGLE/validationES_unittest.cpp
@@ -26,14 +26,6 @@
namespace
{
-class MockFactory : public NullFactory
-{
- public:
- MOCK_METHOD1(createFramebuffer, FramebufferImpl *(const gl::Framebuffer::Data &));
- MOCK_METHOD1(createProgram, ProgramImpl *(const gl::Program::Data &));
- MOCK_METHOD1(createVertexArray, VertexArrayImpl *(const gl::VertexArray::Data &));
-};
-
class MockValidationContext : public ValidationContext
{
public:
@@ -95,10 +87,11 @@
state.initialize(caps, extensions, 3, false);
NiceMock<MockTextureImpl> *textureImpl = new NiceMock<MockTextureImpl>();
+ EXPECT_CALL(mockFactory, createTexture(_)).WillOnce(Return(textureImpl));
EXPECT_CALL(*textureImpl, setStorage(_, _, _, _)).WillOnce(Return(Error(GL_NO_ERROR)));
EXPECT_CALL(*textureImpl, destructor()).Times(1).RetiresOnSaturation();
- Texture *texture = new Texture(textureImpl, 0, GL_TEXTURE_2D);
+ Texture *texture = new Texture(&mockFactory, 0, GL_TEXTURE_2D);
texture->addRef();
texture->setStorage(GL_TEXTURE_2D, 1, GL_RGBA8, Extents(1, 1, 0));