Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* vim:set ts=2 sw=2 sts=2 et: */ |
michael@0 | 2 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 3 | * http://creativecommons.org/publicdomain/zero/1.0/ |
michael@0 | 4 | */ |
michael@0 | 5 | |
michael@0 | 6 | #include "TiledLayerBuffer.h" |
michael@0 | 7 | |
michael@0 | 8 | #include "gtest/gtest.h" |
michael@0 | 9 | |
michael@0 | 10 | namespace mozilla { |
michael@0 | 11 | namespace layers { |
michael@0 | 12 | |
michael@0 | 13 | struct TestTiledLayerTile { |
michael@0 | 14 | int value; |
michael@0 | 15 | TestTiledLayerTile(int v = 0) { |
michael@0 | 16 | value = v; |
michael@0 | 17 | } |
michael@0 | 18 | bool operator== (const TestTiledLayerTile& o) const { |
michael@0 | 19 | return value == o.value; |
michael@0 | 20 | } |
michael@0 | 21 | bool operator!= (const TestTiledLayerTile& o) const { |
michael@0 | 22 | return value != o.value; |
michael@0 | 23 | } |
michael@0 | 24 | }; |
michael@0 | 25 | |
michael@0 | 26 | class TestTiledLayerBuffer : public TiledLayerBuffer<TestTiledLayerBuffer, TestTiledLayerTile> |
michael@0 | 27 | { |
michael@0 | 28 | friend class TiledLayerBuffer<TestTiledLayerBuffer, TestTiledLayerTile>; |
michael@0 | 29 | |
michael@0 | 30 | public: |
michael@0 | 31 | TestTiledLayerTile GetPlaceholderTile() const { |
michael@0 | 32 | return TestTiledLayerTile(-1); |
michael@0 | 33 | } |
michael@0 | 34 | |
michael@0 | 35 | TestTiledLayerTile ValidateTile(TestTiledLayerTile aTile, const nsIntPoint& aTileOrigin, const nsIntRegion& aDirtyRect) { |
michael@0 | 36 | return TestTiledLayerTile(); |
michael@0 | 37 | } |
michael@0 | 38 | |
michael@0 | 39 | void ReleaseTile(TestTiledLayerTile aTile) |
michael@0 | 40 | { |
michael@0 | 41 | |
michael@0 | 42 | } |
michael@0 | 43 | |
michael@0 | 44 | void SwapTiles(TestTiledLayerTile& aTileA, TestTiledLayerTile& aTileB) |
michael@0 | 45 | { |
michael@0 | 46 | TestTiledLayerTile oldTileA = aTileA; |
michael@0 | 47 | aTileA = aTileB; |
michael@0 | 48 | aTileB = oldTileA; |
michael@0 | 49 | } |
michael@0 | 50 | |
michael@0 | 51 | void TestUpdate(const nsIntRegion& aNewValidRegion, const nsIntRegion& aPaintRegion) |
michael@0 | 52 | { |
michael@0 | 53 | Update(aNewValidRegion, aPaintRegion); |
michael@0 | 54 | } |
michael@0 | 55 | }; |
michael@0 | 56 | |
michael@0 | 57 | TEST(TiledLayerBuffer, TileConstructor) { |
michael@0 | 58 | TestTiledLayerBuffer buffer; |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | TEST(TiledLayerBuffer, TileStart) { |
michael@0 | 62 | TestTiledLayerBuffer buffer; |
michael@0 | 63 | |
michael@0 | 64 | ASSERT_EQ(buffer.RoundDownToTileEdge(10, 256), 0); |
michael@0 | 65 | ASSERT_EQ(buffer.RoundDownToTileEdge(-10, 256), -256); |
michael@0 | 66 | } |
michael@0 | 67 | |
michael@0 | 68 | TEST(TiledLayerBuffer, EmptyUpdate) { |
michael@0 | 69 | TestTiledLayerBuffer buffer; |
michael@0 | 70 | |
michael@0 | 71 | nsIntRegion validRegion(nsIntRect(0, 0, 10, 10)); |
michael@0 | 72 | buffer.TestUpdate(validRegion, validRegion); |
michael@0 | 73 | |
michael@0 | 74 | ASSERT_EQ(buffer.GetValidRegion(), validRegion); |
michael@0 | 75 | } |
michael@0 | 76 | |
michael@0 | 77 | } |
michael@0 | 78 | } |