summaryrefslogtreecommitdiff
path: root/Source/WebKit/chromium/tests/ContentLayerChromiumTest.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-09-10 19:10:20 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-09-10 19:10:20 +0200
commit284837daa07b29d6a63a748544a90b1f5842ac5c (patch)
treeecd258180bde91fe741e0cfd2638beb3c6da7e8e /Source/WebKit/chromium/tests/ContentLayerChromiumTest.cpp
parent2e2ba8ff45915f40ed3e014101269c175f2a89a0 (diff)
downloadqtwebkit-284837daa07b29d6a63a748544a90b1f5842ac5c.tar.gz
Imported WebKit commit 68645295d2e3e09af2c942f092556f06aa5f8b0d (http://svn.webkit.org/repository/webkit/trunk@128073)
New snapshot
Diffstat (limited to 'Source/WebKit/chromium/tests/ContentLayerChromiumTest.cpp')
-rw-r--r--Source/WebKit/chromium/tests/ContentLayerChromiumTest.cpp54
1 files changed, 11 insertions, 43 deletions
diff --git a/Source/WebKit/chromium/tests/ContentLayerChromiumTest.cpp b/Source/WebKit/chromium/tests/ContentLayerChromiumTest.cpp
index fd35e2224..483579fe0 100644
--- a/Source/WebKit/chromium/tests/ContentLayerChromiumTest.cpp
+++ b/Source/WebKit/chromium/tests/ContentLayerChromiumTest.cpp
@@ -27,10 +27,9 @@
#include "ContentLayerChromium.h"
#include "BitmapCanvasLayerTextureUpdater.h"
-#include "CCLayerTreeTestCommon.h"
+#include "CCGeometryTestUtils.h"
#include "CCRenderingStats.h"
-#include "GraphicsContext.h"
-#include "OpaqueRectTrackingContentLayerDelegate.h"
+#include "ContentLayerChromiumClient.h"
#include "skia/ext/platform_canvas.h"
#include <gtest/gtest.h>
#include <public/WebFloatRect.h>
@@ -43,49 +42,20 @@ using namespace WebKit;
namespace {
-class OpaqueRectDrawingGraphicsContextPainter : public GraphicsContextPainter {
+class MockContentLayerChromiumClient : public ContentLayerChromiumClient {
public:
- explicit OpaqueRectDrawingGraphicsContextPainter(const IntRect& opaqueRect, const IntRect& contentRect)
- : m_opaqueRect(opaqueRect)
- , m_contentRect(contentRect)
+ explicit MockContentLayerChromiumClient(IntRect opaqueLayerRect)
+ : m_opaqueLayerRect(opaqueLayerRect)
{
}
- virtual ~OpaqueRectDrawingGraphicsContextPainter()
+ virtual void paintContents(SkCanvas*, const IntRect&, FloatRect& opaque) OVERRIDE
{
- }
-
- virtual void paint(GraphicsContext& context, const IntRect& clip) OVERRIDE
- {
- Color alpha(0, 0, 0, 0);
- context.fillRect(m_contentRect, alpha, ColorSpaceDeviceRGB);
-
- Color white(255, 255, 255, 255);
- context.fillRect(m_opaqueRect, white, ColorSpaceDeviceRGB);
- }
-
-private:
- IntRect m_opaqueRect;
- IntRect m_contentRect;
-};
-
-class MockContentLayerDelegate : public ContentLayerDelegate {
-public:
- explicit MockContentLayerDelegate(OpaqueRectTrackingContentLayerDelegate* client)
- : m_client(client)
- {
- }
-
- virtual void paintContents(SkCanvas* canvas, const IntRect& clip, FloatRect& opaque) OVERRIDE
- {
- WebFloatRect resultingOpaqueRect(opaque.x(), opaque.y(), opaque.width(), opaque.height());
- WebRect webClipRect(clip.x(), clip.y(), clip.width(), clip.height());
- m_client->paintContents(canvas, webClipRect, resultingOpaqueRect);
- opaque = FloatRect(resultingOpaqueRect.x, resultingOpaqueRect.y, resultingOpaqueRect.width, resultingOpaqueRect.height);
+ opaque = FloatRect(m_opaqueLayerRect);
}
private:
- OpaqueRectTrackingContentLayerDelegate* m_client;
+ IntRect m_opaqueLayerRect;
};
TEST(ContentLayerChromiumTest, ContentLayerPainterWithDeviceScale)
@@ -96,16 +66,14 @@ TEST(ContentLayerChromiumTest, ContentLayerPainterWithDeviceScale)
IntRect opaqueRectInContentSpace = opaqueRectInLayerSpace;
opaqueRectInContentSpace.scale(contentsScale);
OwnPtr<SkCanvas> canvas = adoptPtr(skia::CreateBitmapCanvas(contentRect.width(), contentRect.height(), false));
- OpaqueRectDrawingGraphicsContextPainter painter(opaqueRectInLayerSpace, contentRect);
- OpaqueRectTrackingContentLayerDelegate opaqueRectTrackingContentLayerDelegate(&painter);
- MockContentLayerDelegate delegate(&opaqueRectTrackingContentLayerDelegate);
- RefPtr<BitmapCanvasLayerTextureUpdater> updater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(&delegate));
+ MockContentLayerChromiumClient client(opaqueRectInLayerSpace);
+ RefPtr<BitmapCanvasLayerTextureUpdater> updater = BitmapCanvasLayerTextureUpdater::create(ContentLayerPainter::create(&client));
IntRect resultingOpaqueRect;
CCRenderingStats stats;
updater->prepareToUpdate(contentRect, IntSize(256, 256), contentsScale, contentsScale, resultingOpaqueRect, stats);
- EXPECT_INT_RECT_EQ(opaqueRectInContentSpace, resultingOpaqueRect);
+ EXPECT_RECT_EQ(opaqueRectInContentSpace, resultingOpaqueRect);
}
} // namespace