| Index: Source/core/platform/graphics/chromium/Canvas2DLayerBridgeTestHelper.h
|
| diff --git a/Source/core/platform/graphics/gpu/DrawingBufferTest.cpp b/Source/core/platform/graphics/chromium/Canvas2DLayerBridgeTestHelper.h
|
| similarity index 55%
|
| copy from Source/core/platform/graphics/gpu/DrawingBufferTest.cpp
|
| copy to Source/core/platform/graphics/chromium/Canvas2DLayerBridgeTestHelper.h
|
| index 7b393101989d5d5ce9aa0ec7e59a7c5d58330214..2dfe5b092de480605266856219e10f5947154f37 100644
|
| --- a/Source/core/platform/graphics/gpu/DrawingBufferTest.cpp
|
| +++ b/Source/core/platform/graphics/chromium/Canvas2DLayerBridgeTestHelper.h
|
| @@ -28,56 +28,55 @@
|
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
| */
|
|
|
| -#include "config.h"
|
| -
|
| -#include "core/platform/graphics/gpu/DrawingBuffer.h"
|
| +#ifndef Canvas2DLayerBridgeTestHelper_h
|
| +#define Canvas2DLayerBridgeTestHelper_h
|
|
|
| +#include "SkSurface.h"
|
| #include "core/platform/graphics/GraphicsContext3D.h"
|
| +#include "core/platform/graphics/chromium/Canvas2DLayerBridge.h"
|
| #include "core/tests/FakeWebGraphicsContext3D.h"
|
| -#include "public/platform/Platform.h"
|
| -#include "wtf/RefPtr.h"
|
|
|
| #include <gmock/gmock.h>
|
| -#include <gtest/gtest.h>
|
| -
|
| -using namespace WebCore;
|
| -using namespace WebKit;
|
| -using testing::Test;
|
| -using testing::_;
|
|
|
| -namespace {
|
| -
|
| -class FakeContextEvictionManager : public ContextEvictionManager {
|
| +class MockCanvasContext : public WebKit::FakeWebGraphicsContext3D {
|
| public:
|
| - void forciblyLoseOldestContext(const String& reason) { }
|
| - IntSize oldestContextSize() { return IntSize(); }
|
| + MOCK_METHOD0(flush, void(void));
|
| +
|
| + virtual GrGLInterface* onCreateGrGLInterface() OVERRIDE { return 0; }
|
| };
|
|
|
| -} // namespace
|
| +class Canvas2DLayerBridgeTestHelper : public WebCore::Canvas2DLayerBridge::Helper {
|
| +public:
|
| + Canvas2DLayerBridgeTestHelper() : m_context(WebCore::GraphicsContext3D::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext)))
|
| + { }
|
|
|
| -class DrawingBufferTest : public Test {
|
| -protected:
|
| - virtual void SetUp()
|
| + virtual PassRefPtr<WebCore::GraphicsContext3D> getContext() OVERRIDE
|
| {
|
| - RefPtr<FakeContextEvictionManager> contextEvictionManager = adoptRef(new FakeContextEvictionManager());
|
| - RefPtr<GraphicsContext3D> context = GraphicsContext3D::createGraphicsContextFromWebContext(adoptPtr(new FakeWebGraphicsContext3D));
|
| - const IntSize size(100, 100);
|
| - m_drawingBuffer = DrawingBuffer::create(context.get(), size, DrawingBuffer::Discard, contextEvictionManager.release());
|
| + return m_context;
|
| }
|
|
|
| - RefPtr<DrawingBuffer> m_drawingBuffer;
|
| -};
|
| + virtual SkSurface* createSurface(WebCore::GraphicsContext3D* context3D, const WebCore::IntSize& size) OVERRIDE
|
| + {
|
| + SkImage::Info info;
|
| + info.fWidth = size.width();
|
| + info.fHeight = size.height();
|
| + info.fColorType = SkImage::kPMColor_ColorType;
|
| + info.fAlphaType = SkImage::kPremul_AlphaType;
|
| + return SkSurface::NewRaster(info);
|
| + }
|
|
|
| -namespace {
|
| + void regenerateContext()
|
| + {
|
| + m_context = WebCore::GraphicsContext3D::createGraphicsContextFromWebContext(adoptPtr(new MockCanvasContext));
|
| + }
|
|
|
| -TEST_F(DrawingBufferTest, verifyNoNewBuffersAfterContextLostWithMailboxes)
|
| -{
|
| - // Tell the buffer its contents changed and context was lost.
|
| - m_drawingBuffer->markContentsChanged();
|
| - m_drawingBuffer->releaseResources();
|
| + MockCanvasContext& mock()
|
| + {
|
| + return *static_cast<MockCanvasContext*>(m_context->webContext());
|
| + }
|
|
|
| - WebKit::WebExternalTextureMailbox mailbox;
|
| - EXPECT_FALSE(m_drawingBuffer->prepareMailbox(&mailbox, 0));
|
| -}
|
| +private:
|
| + RefPtr<WebCore::GraphicsContext3D> m_context;
|
| +};
|
|
|
| -} // namespace
|
| +#endif
|
|
|