summaryrefslogtreecommitdiffstats
path: root/cc/content_layer_unittest.cc
diff options
context:
space:
mode:
authorenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-12 19:40:56 +0000
committerenne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2012-10-12 19:40:56 +0000
commitc79f147c0474a311a83829a44b55aaffa42c6237 (patch)
tree8bb41fcb74068042828da31c279b0d53dd0844fa /cc/content_layer_unittest.cc
parente62f2909e0aabf37131a65c7e50e85c1f07473f8 (diff)
downloadchromium_src-c79f147c0474a311a83829a44b55aaffa42c6237.zip
chromium_src-c79f147c0474a311a83829a44b55aaffa42c6237.tar.gz
chromium_src-c79f147c0474a311a83829a44b55aaffa42c6237.tar.bz2
[cc] Change cc_tests.gyp filenames to Chromium style
BUG=155413 Review URL: https://codereview.chromium.org/11108020 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@161642 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'cc/content_layer_unittest.cc')
-rw-r--r--cc/content_layer_unittest.cc59
1 files changed, 59 insertions, 0 deletions
diff --git a/cc/content_layer_unittest.cc b/cc/content_layer_unittest.cc
new file mode 100644
index 0000000..8e6e7e6
--- /dev/null
+++ b/cc/content_layer_unittest.cc
@@ -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 "testing/gtest/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