diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-15 10:20:33 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2018-05-15 10:28:57 +0000 |
commit | d17ea114e5ef69ad5d5d7413280a13e6428098aa (patch) | |
tree | 2c01a75df69f30d27b1432467cfe7c1467a498da /chromium/third_party/blink/renderer/platform/graphics/paint/drawing_recorder_test.cc | |
parent | 8c5c43c7b138c9b4b0bf56d946e61d3bbc111bec (diff) | |
download | qtwebengine-chromium-d17ea114e5ef69ad5d5d7413280a13e6428098aa.tar.gz |
BASELINE: Update Chromium to 67.0.3396.47
Change-Id: Idcb1341782e417561a2473eeecc82642dafda5b7
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'chromium/third_party/blink/renderer/platform/graphics/paint/drawing_recorder_test.cc')
-rw-r--r-- | chromium/third_party/blink/renderer/platform/graphics/paint/drawing_recorder_test.cc | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/platform/graphics/paint/drawing_recorder_test.cc b/chromium/third_party/blink/renderer/platform/graphics/paint/drawing_recorder_test.cc new file mode 100644 index 00000000000..4882dba1339 --- /dev/null +++ b/chromium/third_party/blink/renderer/platform/graphics/paint/drawing_recorder_test.cc @@ -0,0 +1,85 @@ +// Copyright 2014 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 "third_party/blink/renderer/platform/graphics/paint/drawing_recorder.h" + +#include "testing/gtest/include/gtest/gtest.h" +#include "third_party/blink/renderer/platform/graphics/graphics_context.h" +#include "third_party/blink/renderer/platform/graphics/paint/paint_controller_test.h" +#include "third_party/blink/renderer/platform/testing/fake_display_item_client.h" + +namespace blink { + +using DrawingRecorderTest = PaintControllerTestBase; + +namespace { + +const IntRect kBounds(1, 2, 3, 4); + +TEST_F(DrawingRecorderTest, Nothing) { + FakeDisplayItemClient client; + GraphicsContext context(GetPaintController()); + InitRootChunk(); + DrawNothing(context, client, kForegroundType); + GetPaintController().CommitNewDisplayItems(); + EXPECT_DISPLAY_LIST(GetPaintController().GetDisplayItemList(), 1, + TestDisplayItem(client, kForegroundType)); + EXPECT_FALSE(static_cast<const DrawingDisplayItem&>( + GetPaintController().GetDisplayItemList()[0]) + .GetPaintRecord()); +} + +TEST_F(DrawingRecorderTest, Rect) { + FakeDisplayItemClient client; + GraphicsContext context(GetPaintController()); + InitRootChunk(); + DrawRect(context, client, kForegroundType, kBounds); + GetPaintController().CommitNewDisplayItems(); + EXPECT_DISPLAY_LIST(GetPaintController().GetDisplayItemList(), 1, + TestDisplayItem(client, kForegroundType)); +} + +TEST_F(DrawingRecorderTest, Cached) { + FakeDisplayItemClient client; + GraphicsContext context(GetPaintController()); + InitRootChunk(); + DrawNothing(context, client, kBackgroundType); + DrawRect(context, client, kForegroundType, kBounds); + GetPaintController().CommitNewDisplayItems(); + + EXPECT_DISPLAY_LIST(GetPaintController().GetDisplayItemList(), 2, + TestDisplayItem(client, kBackgroundType), + TestDisplayItem(client, kForegroundType)); + + InitRootChunk(); + DrawNothing(context, client, kBackgroundType); + DrawRect(context, client, kForegroundType, kBounds); + + EXPECT_EQ(2, NumCachedNewItems()); + + GetPaintController().CommitNewDisplayItems(); + + EXPECT_DISPLAY_LIST(GetPaintController().GetDisplayItemList(), 2, + TestDisplayItem(client, kBackgroundType), + TestDisplayItem(client, kForegroundType)); +} + +template <typename T> +FloatRect DrawAndGetCullRect(PaintController& controller, + const DisplayItemClient& client, + const T& bounds) { + { + // Draw some things which will produce a non-null picture. + GraphicsContext context(controller); + DrawingRecorder recorder(context, client, kBackgroundType, bounds); + context.DrawRect(EnclosedIntRect(FloatRect(bounds))); + } + controller.CommitNewDisplayItems(); + const auto& drawing = static_cast<const DrawingDisplayItem&>( + controller.GetDisplayItemList()[0]); + return FloatRect(drawing.VisualRect()); +} + +} // namespace +} // namespace blink |