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

Unified Diff: cc/playback/display_item_list_unittest.cc

Issue 2646623002: cc: Remove all blimp code from cc. (Closed)
Patch Set: test build Created 3 years, 11 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/playback/display_item_list_settings.cc ('k') | cc/playback/display_item_proto_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/playback/display_item_list_unittest.cc
diff --git a/cc/playback/display_item_list_unittest.cc b/cc/playback/display_item_list_unittest.cc
index 9196dfcc52e2df34f98657bc7c608678c72232f0..2fdf3b414ccc9580525eddc8bb7e4eb5acd5b6b1 100644
--- a/cc/playback/display_item_list_unittest.cc
+++ b/cc/playback/display_item_list_unittest.cc
@@ -19,10 +19,6 @@
#include "cc/playback/filter_display_item.h"
#include "cc/playback/float_clip_display_item.h"
#include "cc/playback/transform_display_item.h"
-#include "cc/proto/display_item.pb.h"
-#include "cc/test/fake_client_picture_cache.h"
-#include "cc/test/fake_engine_picture_cache.h"
-#include "cc/test/fake_image_serialization_processor.h"
#include "cc/test/geometry_test_utils.h"
#include "cc/test/skia_common.h"
#include "testing/gmock/include/gmock/gmock.h"
@@ -75,218 +71,8 @@ void AppendFirstSerializationTestPicture(scoped_refptr<DisplayItemList> list,
kVisualRect, recorder.finishRecordingAsPicture());
}
-void AppendSecondSerializationTestPicture(scoped_refptr<DisplayItemList> list,
- const gfx::Size& layer_size) {
- gfx::PointF offset(2.f, 2.f);
- SkPictureRecorder recorder;
-
- SkPaint blue_paint;
- blue_paint.setColor(SK_ColorBLUE);
-
- SkCanvas* canvas = recorder.beginRecording(SkRect::MakeXYWH(
- offset.x(), offset.y(), layer_size.width(), layer_size.height()));
- canvas->translate(offset.x(), offset.y());
- canvas->drawRectCoords(3.f, 3.f, 7.f, 7.f, blue_paint);
- list->CreateAndAppendDrawingItem<DrawingDisplayItem>(
- kVisualRect, recorder.finishRecordingAsPicture());
-}
-
-void ValidateDisplayItemListSerialization(const gfx::Size& layer_size,
- scoped_refptr<DisplayItemList> list) {
- list->Finalize();
-
- std::unique_ptr<FakeImageSerializationProcessor>
- fake_image_serialization_processor =
- base::WrapUnique(new FakeImageSerializationProcessor);
- std::unique_ptr<EnginePictureCache> fake_engine_picture_cache =
- fake_image_serialization_processor->CreateEnginePictureCache();
- FakeEnginePictureCache* fake_engine_picture_cache_ptr =
- static_cast<FakeEnginePictureCache*>(fake_engine_picture_cache.get());
- std::unique_ptr<ClientPictureCache> fake_client_picture_cache =
- fake_image_serialization_processor->CreateClientPictureCache();
-
- fake_engine_picture_cache_ptr->MarkAllSkPicturesAsUsed(list.get());
-
- // Serialize and deserialize the DisplayItemList.
- proto::DisplayItemList proto;
- list->ToProtobuf(&proto);
-
- std::vector<uint32_t> actual_picture_ids;
- scoped_refptr<DisplayItemList> new_list = DisplayItemList::CreateFromProto(
- proto, fake_client_picture_cache.get(), &actual_picture_ids);
-
- EXPECT_THAT(actual_picture_ids,
- testing::UnorderedElementsAreArray(
- fake_engine_picture_cache_ptr->GetAllUsedPictureIds()));
-
- EXPECT_TRUE(AreDisplayListDrawingResultsSame(gfx::Rect(layer_size),
- list.get(), new_list.get()));
-}
-
} // namespace
-TEST(DisplayItemListTest, SerializeDisplayItemListSettings) {
- DisplayItemListSettings settings;
- settings.use_cached_picture = false;
-
- {
- proto::DisplayItemListSettings proto;
- settings.ToProtobuf(&proto);
- DisplayItemListSettings deserialized(proto);
- EXPECT_EQ(settings.use_cached_picture, deserialized.use_cached_picture);
- }
-
- settings.use_cached_picture = true;
- {
- proto::DisplayItemListSettings proto;
- settings.ToProtobuf(&proto);
- DisplayItemListSettings deserialized(proto);
- EXPECT_EQ(settings.use_cached_picture, deserialized.use_cached_picture);
- }
-}
-
-TEST(DisplayItemListTest, SerializeSingleDrawingItem) {
- gfx::Size layer_size(10, 10);
-
- DisplayItemListSettings settings;
- settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
- list->SetRetainVisualRectsForTesting(true);
-
- // Build the DrawingDisplayItem.
- AppendFirstSerializationTestPicture(list, layer_size);
-
- ValidateDisplayItemListSerialization(layer_size, list);
-}
-
-TEST(DisplayItemListTest, SerializeClipItem) {
- gfx::Size layer_size(10, 10);
-
- DisplayItemListSettings settings;
- settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
- list->SetRetainVisualRectsForTesting(true);
-
- // Build the DrawingDisplayItem.
- AppendFirstSerializationTestPicture(list, layer_size);
-
- // Build the ClipDisplayItem.
- gfx::Rect clip_rect(6, 6, 1, 1);
- std::vector<SkRRect> rrects;
- rrects.push_back(SkRRect::MakeOval(SkRect::MakeXYWH(5.f, 5.f, 4.f, 4.f)));
- list->CreateAndAppendPairedBeginItem<ClipDisplayItem>(clip_rect, rrects,
- true);
-
- // Build the second DrawingDisplayItem.
- AppendSecondSerializationTestPicture(list, layer_size);
-
- // Build the EndClipDisplayItem.
- list->CreateAndAppendPairedEndItem<EndClipDisplayItem>();
-
- ValidateDisplayItemListSerialization(layer_size, list);
-}
-
-TEST(DisplayItemListTest, SerializeClipPathItem) {
- gfx::Size layer_size(10, 10);
-
- DisplayItemListSettings settings;
- settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
- list->SetRetainVisualRectsForTesting(true);
-
- // Build the DrawingDisplayItem.
- AppendFirstSerializationTestPicture(list, layer_size);
-
- // Build the ClipPathDisplayItem.
- SkPath path;
- path.addCircle(5.f, 5.f, 2.f, SkPath::Direction::kCW_Direction);
- list->CreateAndAppendPairedBeginItem<ClipPathDisplayItem>(path, false);
-
- // Build the second DrawingDisplayItem.
- AppendSecondSerializationTestPicture(list, layer_size);
-
- // Build the EndClipPathDisplayItem.
- list->CreateAndAppendPairedEndItem<EndClipPathDisplayItem>();
-
- ValidateDisplayItemListSerialization(layer_size, list);
-}
-
-TEST(DisplayItemListTest, SerializeCompositingItem) {
- gfx::Size layer_size(10, 10);
-
- DisplayItemListSettings settings;
- settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
- list->SetRetainVisualRectsForTesting(true);
-
- // Build the DrawingDisplayItem.
- AppendFirstSerializationTestPicture(list, layer_size);
-
- // Build the CompositingDisplayItem.
- list->CreateAndAppendPairedBeginItem<CompositingDisplayItem>(
- 150, SkBlendMode::kDst, nullptr,
- SkColorMatrixFilter::MakeLightingFilter(SK_ColorRED, SK_ColorGREEN),
- false);
-
- // Build the second DrawingDisplayItem.
- AppendSecondSerializationTestPicture(list, layer_size);
-
- // Build the EndCompositingDisplayItem.
- list->CreateAndAppendPairedEndItem<EndCompositingDisplayItem>();
-
- ValidateDisplayItemListSerialization(layer_size, list);
-}
-
-TEST(DisplayItemListTest, SerializeFloatClipItem) {
- gfx::Size layer_size(10, 10);
-
- DisplayItemListSettings settings;
- settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
- list->SetRetainVisualRectsForTesting(true);
-
- // Build the DrawingDisplayItem.
- AppendFirstSerializationTestPicture(list, layer_size);
-
- // Build the FloatClipDisplayItem.
- gfx::RectF clip_rect(6.f, 6.f, 1.f, 1.f);
- list->CreateAndAppendPairedBeginItem<FloatClipDisplayItem>(clip_rect);
-
- // Build the second DrawingDisplayItem.
- AppendSecondSerializationTestPicture(list, layer_size);
-
- // Build the EndFloatClipDisplayItem.
- list->CreateAndAppendPairedEndItem<EndFloatClipDisplayItem>();
-
- ValidateDisplayItemListSerialization(layer_size, list);
-}
-
-TEST(DisplayItemListTest, SerializeTransformItem) {
- gfx::Size layer_size(10, 10);
-
- DisplayItemListSettings settings;
- settings.use_cached_picture = true;
- scoped_refptr<DisplayItemList> list = DisplayItemList::Create(settings);
- list->SetRetainVisualRectsForTesting(true);
-
- // Build the DrawingDisplayItem.
- AppendFirstSerializationTestPicture(list, layer_size);
-
- // Build the TransformDisplayItem.
- gfx::Transform transform;
- transform.Scale(1.25f, 1.25f);
- transform.Translate(-1.f, -1.f);
- list->CreateAndAppendPairedBeginItem<TransformDisplayItem>(transform);
-
- // Build the second DrawingDisplayItem.
- AppendSecondSerializationTestPicture(list, layer_size);
-
- // Build the EndTransformDisplayItem.
- list->CreateAndAppendPairedEndItem<EndTransformDisplayItem>();
-
- ValidateDisplayItemListSerialization(layer_size, list);
-}
-
TEST(DisplayItemListTest, SingleDrawingItem) {
gfx::Rect layer_rect(100, 100);
SkPictureRecorder recorder;
« no previous file with comments | « cc/playback/display_item_list_settings.cc ('k') | cc/playback/display_item_proto_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698