Bug 767231 - Part 2: Add a sample TiledLayerBuffer test. r=ted,bjacob
authorBenoit Girard <b56girard@gmail.com>
Fri, 22 Feb 2013 16:25:58 -0500
changeset 122704 351462147f91
parent 122703 2e3a491f3631
child 122705 e62fcee5ce5e
push id24356
push usergszorc@mozilla.com
push date2013-02-24 01:00 +0000
treeherdermozilla-central@195e706140d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersted, bjacob
bugs767231
milestone22.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 767231 - Part 2: Add a sample TiledLayerBuffer test. r=ted,bjacob
gfx/layers/Makefile.in
gfx/layers/TestTiledLayerBuffer.cpp
--- a/gfx/layers/Makefile.in
+++ b/gfx/layers/Makefile.in
@@ -78,16 +78,20 @@ CPPSRCS = \
         ReusableTileStoreOGL.cpp \
         LayerManagerOGLProgram.cpp \
         LayerSorter.cpp \
         LayerTreeInvalidation.cpp \
         ImageLayers.cpp \
         TexturePoolOGL.cpp \
         $(NULL)
 
+GTEST_CPPSRCS = \
+        TestTiledLayerBuffer.cpp \
+        $(NULL)
+
 ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
 ifdef MOZ_ENABLE_D3D9_LAYER
 EXPORTS += \
         LayerManagerD3D9.h \
         DeviceManagerD3D9.h \
         $(NULL)
 
 CPPSRCS += \
new file mode 100644
--- /dev/null
+++ b/gfx/layers/TestTiledLayerBuffer.cpp
@@ -0,0 +1,78 @@
+/* vim:set ts=2 sw=2 sts=2 et: */
+/* Any copyright is dedicated to the Public Domain.
+ * http://creativecommons.org/publicdomain/zero/1.0/
+ */
+
+#include "TiledLayerBuffer.h"
+
+#include "gtest/gtest.h"
+
+namespace mozilla {
+namespace layers {
+
+struct TestTiledLayerTile {
+  int value;
+  TestTiledLayerTile() {
+    value = 0;
+  }
+  bool operator== (const TestTiledLayerTile& o) const {
+    return value == o.value;
+  }
+  bool operator!= (const TestTiledLayerTile& o) const {
+    return value != o.value;
+  }
+};
+
+class TestTiledLayerBuffer : public TiledLayerBuffer<TestTiledLayerBuffer, TestTiledLayerTile>
+{
+  friend class TiledLayerBuffer<TestTiledLayerBuffer, TestTiledLayerTile>;
+
+public:
+  TestTiledLayerTile GetPlaceholderTile() const {
+    return TestTiledLayerTile();
+  }
+
+  TestTiledLayerTile ValidateTile(TestTiledLayerTile aTile, const nsIntPoint& aTileOrigin, const nsIntRegion& aDirtyRect) {
+    return TestTiledLayerTile();
+  }
+
+  void ReleaseTile(TestTiledLayerTile aTile)
+  {
+
+  }
+
+  void SwapTiles(TestTiledLayerTile& aTileA, TestTiledLayerTile& aTileB)
+  {
+    TestTiledLayerTile oldTileA = aTileA;
+    aTileA = aTileB;
+    aTileB = oldTileA;
+  }
+
+  void TestUpdate(const nsIntRegion& aNewValidRegion, const nsIntRegion& aPaintRegion)
+  {
+    Update(aNewValidRegion, aPaintRegion);
+  }
+};
+
+TEST(TiledLayerBuffer, TileConstructor) {
+  TestTiledLayerBuffer buffer;
+}
+
+TEST(TiledLayerBuffer, TileStart) {
+  TestTiledLayerBuffer buffer;
+
+  ASSERT_EQ(buffer.RoundDownToTileEdge(10), 0);
+  ASSERT_EQ(buffer.RoundDownToTileEdge(-10), -256);
+}
+
+TEST(TiledLayerBuffer, EmptyUpdate) {
+  TestTiledLayerBuffer buffer;
+
+  nsIntRegion validRegion(nsIntRect(0, 0, 10, 10));
+  buffer.TestUpdate(validRegion, validRegion);
+
+  ASSERT_EQ(buffer.GetValidRegion(), validRegion);
+}
+
+}
+}