TEST_F(DrawingBufferTest, verifyDrawingBufferStaysAliveIfResourcesAreLost) { bool live = true; m_drawingBuffer->m_live = &live; WebExternalTextureMailbox mailbox1; WebExternalTextureMailbox mailbox2; WebExternalTextureMailbox mailbox3; m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox1, 0)); m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox2, 0)); m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox3, 0)); m_drawingBuffer->markContentsChanged(); m_drawingBuffer->mailboxReleased(mailbox1, true); EXPECT_EQ(live, true); m_drawingBuffer->beginDestruction(); EXPECT_EQ(live, true); m_drawingBuffer->markContentsChanged(); m_drawingBuffer->mailboxReleased(mailbox2, false); EXPECT_EQ(live, true); DrawingBufferForTests* weakPtr = m_drawingBuffer.get(); m_drawingBuffer.clear(); EXPECT_EQ(live, true); weakPtr->markContentsChanged(); weakPtr->mailboxReleased(mailbox3, true); EXPECT_EQ(live, false); }
TEST_F(DrawingBufferTest, verifyDestructionCompleteAfterAllMailboxesReleased) { bool live = true; m_drawingBuffer->m_live = &live; WebExternalTextureMailbox mailbox1; WebExternalTextureMailbox mailbox2; WebExternalTextureMailbox mailbox3; IntSize initialSize(initialWidth, initialHeight); // Produce mailboxes. m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox1, 0)); m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox2, 0)); m_drawingBuffer->markContentsChanged(); EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&mailbox3, 0)); m_drawingBuffer->markContentsChanged(); m_drawingBuffer->mailboxReleased(mailbox1, false); m_drawingBuffer->beginDestruction(); EXPECT_EQ(live, true); DrawingBufferForTests* weakPointer = m_drawingBuffer.get(); m_drawingBuffer.clear(); EXPECT_EQ(live, true); weakPointer->markContentsChanged(); weakPointer->mailboxReleased(mailbox2, false); EXPECT_EQ(live, true); weakPointer->markContentsChanged(); weakPointer->mailboxReleased(mailbox3, false); EXPECT_EQ(live, false); }