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

Unified Diff: cc/layers/picture_layer_unittest.cc

Issue 2493523003: cc: Remove unused proto conversion code. (Closed)
Patch Set: test Created 4 years, 1 month 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/layers/picture_layer.cc ('k') | cc/layers/solid_color_scrollbar_layer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/picture_layer_unittest.cc
diff --git a/cc/layers/picture_layer_unittest.cc b/cc/layers/picture_layer_unittest.cc
index 3d9122048bdbdd97f61ae9e0b733a30633dad9b0..bda0e41b916b6e750c73b9739da430a54ae561b0 100644
--- a/cc/layers/picture_layer_unittest.cc
+++ b/cc/layers/picture_layer_unittest.cc
@@ -35,200 +35,8 @@
namespace cc {
-class TestSerializationPictureLayer : public PictureLayer {
- public:
- static scoped_refptr<TestSerializationPictureLayer> Create(
- const gfx::Size& recording_source_viewport) {
- return make_scoped_refptr(new TestSerializationPictureLayer(
- EmptyContentLayerClient::GetInstance(),
- FakeRecordingSource::CreateFilledRecordingSource(
- recording_source_viewport),
- recording_source_viewport));
- }
-
- FakeRecordingSource* recording_source() {
- return static_cast<FakeRecordingSource*>(recording_source_.get());
- }
-
- void set_invalidation(const Region& invalidation) {
- last_updated_invalidation_ = invalidation;
- }
-
- void set_update_source_frame_number(int number) {
- update_source_frame_number_ = number;
- }
-
- void set_is_mask(bool is_mask) { is_mask_ = is_mask; }
-
- void set_nearest_neighbor(bool nearest_neighbor) {
- picture_layer_inputs_.nearest_neighbor = nearest_neighbor;
- }
-
- void ValidateSerialization(
- ImageSerializationProcessor* image_serialization_processor,
- LayerTreeHostInProcess* host) {
- std::vector<uint32_t> engine_picture_ids = GetPictureIds();
- proto::LayerProperties proto;
- LayerSpecificPropertiesToProto(&proto, false);
-
- FakeEnginePictureCache* engine_picture_cache =
- static_cast<FakeEnginePictureCache*>(host->engine_picture_cache());
- EXPECT_THAT(engine_picture_ids,
- testing::UnorderedElementsAreArray(
- engine_picture_cache->GetAllUsedPictureIds()));
-
- scoped_refptr<TestSerializationPictureLayer> layer =
- TestSerializationPictureLayer::Create(recording_source_viewport_);
- host->GetLayerTree()->SetRootLayer(layer);
-
- layer->FromLayerSpecificPropertiesProto(proto);
-
- FakeClientPictureCache* client_picture_cache =
- static_cast<FakeClientPictureCache*>(host->client_picture_cache());
- EXPECT_THAT(engine_picture_ids,
- testing::UnorderedElementsAreArray(
- client_picture_cache->GetAllUsedPictureIds()));
-
- // Validate that the PictureLayer specific fields are properly set.
- EXPECT_TRUE(recording_source()->EqualsTo(*layer->recording_source()));
- EXPECT_EQ(update_source_frame_number_, layer->update_source_frame_number_);
- EXPECT_EQ(is_mask_, layer->is_mask_);
- EXPECT_EQ(picture_layer_inputs_.nearest_neighbor,
- layer->picture_layer_inputs_.nearest_neighbor);
- EXPECT_EQ(picture_layer_inputs_.recorded_viewport,
- layer->picture_layer_inputs_.recorded_viewport);
-
- // The DisplayItemLists are equal if they are both null or they are both not
- // null and render to the same thing.
- bool display_lists_equal = !picture_layer_inputs_.display_list &&
- !layer->picture_layer_inputs_.display_list;
- if (picture_layer_inputs_.display_list &&
- layer->picture_layer_inputs_.display_list) {
- display_lists_equal = AreDisplayListDrawingResultsSame(
- picture_layer_inputs_.recorded_viewport,
- picture_layer_inputs_.display_list.get(),
- layer->picture_layer_inputs_.display_list.get());
- }
- EXPECT_TRUE(display_lists_equal);
- }
-
- std::vector<uint32_t> GetPictureIds() {
- std::vector<uint32_t> ids;
- const DisplayItemList* display_list =
- picture_layer_inputs_.display_list.get();
- if (!display_list)
- return ids;
-
- for (auto it = display_list->begin(); it != display_list->end(); ++it) {
- sk_sp<const SkPicture> picture = it->GetPicture();
- if (!picture)
- continue;
-
- ids.push_back(picture->uniqueID());
- }
- return ids;
- }
-
- private:
- TestSerializationPictureLayer(ContentLayerClient* client,
- std::unique_ptr<RecordingSource> source,
- const gfx::Size& recording_source_viewport)
- : PictureLayer(client, std::move(source)),
- recording_source_viewport_(recording_source_viewport) {}
- ~TestSerializationPictureLayer() override {}
-
- gfx::Size recording_source_viewport_;
-
- DISALLOW_COPY_AND_ASSIGN(TestSerializationPictureLayer);
-};
-
namespace {
-TEST(PictureLayerTest, TestSetAllPropsSerializationDeserialization) {
- FakeLayerTreeHostClient host_client;
- TestTaskGraphRunner task_graph_runner;
- LayerTreeSettings settings = LayerTreeSettingsForTesting();
- std::unique_ptr<FakeImageSerializationProcessor>
- fake_image_serialization_processor =
- base::WrapUnique(new FakeImageSerializationProcessor);
- auto animation_host = AnimationHost::CreateForTesting(ThreadInstance::MAIN);
- std::unique_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(
- &host_client, &task_graph_runner, animation_host.get(), settings,
- CompositorMode::SINGLE_THREADED,
- fake_image_serialization_processor.get());
- host->InitializePictureCacheForTesting();
-
- gfx::Size recording_source_viewport(256, 256);
- scoped_refptr<TestSerializationPictureLayer> layer =
- TestSerializationPictureLayer::Create(recording_source_viewport);
- host->GetLayerTree()->SetRootLayer(layer);
-
- Region region(gfx::Rect(14, 15, 16, 17));
- layer->set_invalidation(region);
- layer->set_is_mask(true);
- layer->set_nearest_neighbor(true);
-
- layer->SetBounds(recording_source_viewport);
- layer->set_update_source_frame_number(0);
- layer->recording_source()->SetDisplayListUsesCachedPicture(false);
- layer->recording_source()->add_draw_rect(
- gfx::Rect(recording_source_viewport));
- layer->recording_source()->SetGenerateDiscardableImagesMetadata(true);
- layer->recording_source()->Rerecord();
- layer->ValidateSerialization(fake_image_serialization_processor.get(),
- host.get());
-}
-
-TEST(PictureLayerTest, TestSerializationDeserialization) {
- FakeLayerTreeHostClient host_client;
- TestTaskGraphRunner task_graph_runner;
- std::unique_ptr<FakeImageSerializationProcessor>
- fake_image_serialization_processor =
- base::WrapUnique(new FakeImageSerializationProcessor);
- auto animation_host = AnimationHost::CreateForTesting(ThreadInstance::MAIN);
- std::unique_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(
- &host_client, &task_graph_runner, animation_host.get(),
- LayerTreeSettings(), CompositorMode::SINGLE_THREADED,
- fake_image_serialization_processor.get());
- host->InitializePictureCacheForTesting();
-
- gfx::Size recording_source_viewport(256, 256);
- scoped_refptr<TestSerializationPictureLayer> layer =
- TestSerializationPictureLayer::Create(recording_source_viewport);
- host->GetLayerTree()->SetRootLayer(layer);
-
- layer->SetBounds(recording_source_viewport);
- layer->set_update_source_frame_number(0);
- layer->recording_source()->SetDisplayListUsesCachedPicture(false);
- layer->recording_source()->add_draw_rect(
- gfx::Rect(recording_source_viewport));
- layer->recording_source()->SetGenerateDiscardableImagesMetadata(true);
- layer->recording_source()->Rerecord();
- layer->ValidateSerialization(fake_image_serialization_processor.get(),
- host.get());
-}
-
-TEST(PictureLayerTest, TestEmptySerializationDeserialization) {
- std::unique_ptr<FakeImageSerializationProcessor>
- fake_image_serialization_processor =
- base::WrapUnique(new FakeImageSerializationProcessor);
- FakeLayerTreeHostClient host_client;
- TestTaskGraphRunner task_graph_runner;
- auto animation_host = AnimationHost::CreateForTesting(ThreadInstance::MAIN);
- std::unique_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create(
- &host_client, &task_graph_runner, animation_host.get(),
- LayerTreeSettings(), CompositorMode::SINGLE_THREADED,
- fake_image_serialization_processor.get());
- host->InitializePictureCacheForTesting();
-
- gfx::Size recording_source_viewport(256, 256);
- scoped_refptr<TestSerializationPictureLayer> layer =
- TestSerializationPictureLayer::Create(recording_source_viewport);
- host->GetLayerTree()->SetRootLayer(layer);
- layer->ValidateSerialization(fake_image_serialization_processor.get(),
- host.get());
-}
-
TEST(PictureLayerTest, NoTilesIfEmptyBounds) {
ContentLayerClient* client = EmptyContentLayerClient::GetInstance();
scoped_refptr<PictureLayer> layer = PictureLayer::Create(client);
« no previous file with comments | « cc/layers/picture_layer.cc ('k') | cc/layers/solid_color_scrollbar_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698