Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(908)

Unified Diff: cc/ContentLayerChromiumTest.cpp

Issue 10909218: Add some missing unit tests and update cc_unittests and webkit_compositor_bindings_unittests (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Updated to tip of tree Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/CCRendererGLTest.cpp ('k') | cc/LayerChromiumTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/ContentLayerChromiumTest.cpp
diff --git a/cc/ContentLayerChromiumTest.cpp b/cc/ContentLayerChromiumTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..1314b20ec81652f5351fbce41d36e441d9d701b7
--- /dev/null
+++ b/cc/ContentLayerChromiumTest.cpp
@@ -0,0 +1,59 @@
+// Copyright 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "config.h"
+
+#include "ContentLayerChromium.h"
+
+#include "BitmapCanvasLayerTextureUpdater.h"
+#include "CCGeometryTestUtils.h"
+#include "CCRenderingStats.h"
+#include "ContentLayerChromiumClient.h"
+#include "skia/ext/platform_canvas.h"
+#include <gtest/gtest.h>
+#include <public/WebFloatRect.h>
+#include <public/WebRect.h>
+#include <wtf/OwnPtr.h>
+#include <wtf/RefPtr.h>
+
+using namespace cc;
+using namespace WebKit;
+
+namespace {
+
+class MockContentLayerChromiumClient : public ContentLayerChromiumClient {
+public:
+ explicit MockContentLayerChromiumClient(IntRect opaqueLayerRect)
+ : m_opaqueLayerRect(opaqueLayerRect)
+ {
+ }
+
+ virtual void paintContents(SkCanvas*, const IntRect&, FloatRect& opaque) OVERRIDE
+ {
+ opaque = FloatRect(m_opaqueLayerRect);
+ }
+
+private:
+ IntRect m_opaqueLayerRect;
+};
+
+TEST(ContentLayerChromiumTest, ContentLayerPainterWithDeviceScale)
+{
+ float contentsScale = 2;
+ IntRect contentRect(10, 10, 100, 100);
+ IntRect opaqueRectInLayerSpace(5, 5, 20, 20);
+ IntRect opaqueRectInContentSpace = opaqueRectInLayerSpace;
+ opaqueRectInContentSpace.scale(contentsScale);
+ OwnPtr<SkCanvas> canvas = adoptPtr(skia::CreateBitmapCanvas(contentRect.width(), contentRect.height(), false));
+ 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_RECT_EQ(opaqueRectInContentSpace, resultingOpaqueRect);
+}
+
+} // namespace
« no previous file with comments | « cc/CCRendererGLTest.cpp ('k') | cc/LayerChromiumTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698