Commit 47a878c6 by Corentin Wallez

Surface: do not leak the default framebuffer

Due to the many merges and changes to 37c3979e the default framebuffer deletion "disappeared". Add it back to the destructor of Surface. Update Surface_unittests and remove one of the two tests as they were equivalent. BUG=524495 BUG=angleproject:1137 Change-Id: I1309285ea00976ae2685628ea3f92731a9259718 Reviewed-on: https://chromium-review.googlesource.com/295153Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 4d5362d0
......@@ -74,6 +74,7 @@ Surface::~Surface()
mTexture.set(nullptr);
}
SafeDelete(mDefaultFramebuffer);
SafeDelete(mImplementation);
}
......
......@@ -84,41 +84,7 @@ class MockFramebufferImpl : public rx::FramebufferImpl
MOCK_METHOD0(destroy, void());
};
class SurfaceTest : public testing::Test
{
protected:
virtual void SetUp()
{
MockFramebufferImpl *framebuffer = new MockFramebufferImpl;
mSurfaceImpl = new MockSurfaceImpl;
EXPECT_CALL(*mSurfaceImpl, getSwapBehavior());
EXPECT_CALL(*mSurfaceImpl, createDefaultFramebuffer(testing::_))
.WillOnce(testing::Return(framebuffer));
EXPECT_CALL(*mSurfaceImpl, destroy());
EXPECT_CALL(*framebuffer, setDrawBuffers(1, testing::_));
EXPECT_CALL(*framebuffer, setReadBuffer(GL_BACK));
EXPECT_CALL(*framebuffer, onUpdateColorAttachment(0));
mSurface = new egl::Surface(mSurfaceImpl, EGL_WINDOW_BIT, &mConfig, egl::AttributeMap());
EXPECT_CALL(*framebuffer, destroy());
SafeDelete(framebuffer);
}
virtual void TearDown()
{
mSurface->onDestroy();
}
MockSurfaceImpl *mSurfaceImpl;
egl::Surface *mSurface;
egl::Config mConfig;
};
TEST_F(SurfaceTest, DestructionDeletesImpl)
TEST(SurfaceTest, DestructionDeletesImpl)
{
MockFramebufferImpl *framebuffer = new MockFramebufferImpl;
......@@ -130,14 +96,14 @@ TEST_F(SurfaceTest, DestructionDeletesImpl)
EXPECT_CALL(*framebuffer, setReadBuffer(GL_BACK));
EXPECT_CALL(*framebuffer, onUpdateColorAttachment(0));
egl::Config config;
egl::Surface *surface = new egl::Surface(impl, EGL_WINDOW_BIT, &config, egl::AttributeMap());
EXPECT_CALL(*framebuffer, destroy()).Times(1).RetiresOnSaturation();
EXPECT_CALL(*impl, destroy()).Times(1).RetiresOnSaturation();
egl::Surface *surface = new egl::Surface(impl, EGL_WINDOW_BIT, &mConfig, egl::AttributeMap());
surface->onDestroy();
EXPECT_CALL(*framebuffer, destroy());
SafeDelete(framebuffer);
// Only needed because the mock is leaked if bugs are present,
// which logs an error, but does not cause the test to fail.
// Ordinarily mocks are verified when destroyed.
......
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