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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp

Issue 2080623002: Revert "Remove OwnPtr from Blink." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "platform/graphics/compositing/PaintArtifactCompositor.h" 5 #include "platform/graphics/compositing/PaintArtifactCompositor.h"
6 6
7 #include "base/test/test_simple_task_runner.h" 7 #include "base/test/test_simple_task_runner.h"
8 #include "base/threading/thread_task_runner_handle.h" 8 #include "base/threading/thread_task_runner_handle.h"
9 #include "cc/layers/layer.h" 9 #include "cc/layers/layer.h"
10 #include "cc/test/fake_output_surface.h" 10 #include "cc/test/fake_output_surface.h"
11 #include "cc/trees/layer_tree_host.h" 11 #include "cc/trees/layer_tree_host.h"
12 #include "cc/trees/layer_tree_settings.h" 12 #include "cc/trees/layer_tree_settings.h"
13 #include "platform/RuntimeEnabledFeatures.h" 13 #include "platform/RuntimeEnabledFeatures.h"
14 #include "platform/graphics/paint/PaintArtifact.h" 14 #include "platform/graphics/paint/PaintArtifact.h"
15 #include "platform/testing/PictureMatchers.h" 15 #include "platform/testing/PictureMatchers.h"
16 #include "platform/testing/TestPaintArtifact.h" 16 #include "platform/testing/TestPaintArtifact.h"
17 #include "platform/testing/WebLayerTreeViewImplForTesting.h" 17 #include "platform/testing/WebLayerTreeViewImplForTesting.h"
18 #include "testing/gmock/include/gmock/gmock.h" 18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 #include "wtf/PtrUtil.h"
21 #include <memory>
22 20
23 namespace blink { 21 namespace blink {
24 namespace { 22 namespace {
25 23
26 using ::testing::Pointee; 24 using ::testing::Pointee;
27 25
28 gfx::Transform translation(SkMScalar x, SkMScalar y) 26 gfx::Transform translation(SkMScalar x, SkMScalar y)
29 { 27 {
30 gfx::Transform transform; 28 gfx::Transform transform;
31 transform.Translate(x, y); 29 transform.Translate(x, y);
32 return transform; 30 return transform;
33 } 31 }
34 32
35 class PaintArtifactCompositorTest : public ::testing::Test { 33 class PaintArtifactCompositorTest : public ::testing::Test {
36 protected: 34 protected:
37 void SetUp() override 35 void SetUp() override
38 { 36 {
39 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true); 37 RuntimeEnabledFeatures::setSlimmingPaintV2Enabled(true);
40 38
41 // Delay constructing the compositor until after the feature is set. 39 // Delay constructing the compositor until after the feature is set.
42 m_paintArtifactCompositor = wrapUnique(new PaintArtifactCompositor); 40 m_paintArtifactCompositor = adoptPtr(new PaintArtifactCompositor);
43 } 41 }
44 42
45 void TearDown() override 43 void TearDown() override
46 { 44 {
47 m_featuresBackup.restore(); 45 m_featuresBackup.restore();
48 } 46 }
49 47
50 PaintArtifactCompositor& getPaintArtifactCompositor() { return *m_paintArtif actCompositor; } 48 PaintArtifactCompositor& getPaintArtifactCompositor() { return *m_paintArtif actCompositor; }
51 cc::Layer* rootLayer() { return m_paintArtifactCompositor->rootLayer(); } 49 cc::Layer* rootLayer() { return m_paintArtifactCompositor->rootLayer(); }
52 void update(const PaintArtifact& artifact) { m_paintArtifactCompositor->upda te(artifact); } 50 void update(const PaintArtifact& artifact) { m_paintArtifactCompositor->upda te(artifact); }
53 51
54 private: 52 private:
55 RuntimeEnabledFeatures::Backup m_featuresBackup; 53 RuntimeEnabledFeatures::Backup m_featuresBackup;
56 std::unique_ptr<PaintArtifactCompositor> m_paintArtifactCompositor; 54 OwnPtr<PaintArtifactCompositor> m_paintArtifactCompositor;
57 }; 55 };
58 56
59 TEST_F(PaintArtifactCompositorTest, EmptyPaintArtifact) 57 TEST_F(PaintArtifactCompositorTest, EmptyPaintArtifact)
60 { 58 {
61 PaintArtifact emptyArtifact; 59 PaintArtifact emptyArtifact;
62 update(emptyArtifact); 60 update(emptyArtifact);
63 EXPECT_TRUE(rootLayer()->children().empty()); 61 EXPECT_TRUE(rootLayer()->children().empty());
64 } 62 }
65 63
66 TEST_F(PaintArtifactCompositorTest, OneChunkWithAnOffset) 64 TEST_F(PaintArtifactCompositorTest, OneChunkWithAnOffset)
(...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 { 378 {
381 } 379 }
382 380
383 void SetUp() override 381 void SetUp() override
384 { 382 {
385 PaintArtifactCompositorTest::SetUp(); 383 PaintArtifactCompositorTest::SetUp();
386 384
387 cc::LayerTreeSettings settings = WebLayerTreeViewImplForTesting::default LayerTreeSettings(); 385 cc::LayerTreeSettings settings = WebLayerTreeViewImplForTesting::default LayerTreeSettings();
388 settings.single_thread_proxy_scheduler = false; 386 settings.single_thread_proxy_scheduler = false;
389 settings.use_layer_lists = true; 387 settings.use_layer_lists = true;
390 m_webLayerTreeView = wrapUnique(new WebLayerTreeViewWithOutputSurface(se ttings)); 388 m_webLayerTreeView = adoptPtr(new WebLayerTreeViewWithOutputSurface(sett ings));
391 m_webLayerTreeView->setRootLayer(*getPaintArtifactCompositor().getWebLay er()); 389 m_webLayerTreeView->setRootLayer(*getPaintArtifactCompositor().getWebLay er());
392 } 390 }
393 391
394 const cc::PropertyTrees& propertyTrees() 392 const cc::PropertyTrees& propertyTrees()
395 { 393 {
396 return *m_webLayerTreeView->layerTreeHost()->property_trees(); 394 return *m_webLayerTreeView->layerTreeHost()->property_trees();
397 } 395 }
398 396
399 void update(const PaintArtifact& artifact) 397 void update(const PaintArtifact& artifact)
400 { 398 {
401 PaintArtifactCompositorTest::update(artifact); 399 PaintArtifactCompositorTest::update(artifact);
402 m_webLayerTreeView->layerTreeHost()->LayoutAndUpdateLayers(); 400 m_webLayerTreeView->layerTreeHost()->LayoutAndUpdateLayers();
403 } 401 }
404 402
405 private: 403 private:
406 scoped_refptr<base::TestSimpleTaskRunner> m_taskRunner; 404 scoped_refptr<base::TestSimpleTaskRunner> m_taskRunner;
407 base::ThreadTaskRunnerHandle m_taskRunnerHandle; 405 base::ThreadTaskRunnerHandle m_taskRunnerHandle;
408 std::unique_ptr<WebLayerTreeViewWithOutputSurface> m_webLayerTreeView; 406 OwnPtr<WebLayerTreeViewWithOutputSurface> m_webLayerTreeView;
409 }; 407 };
410 408
411 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact) 409 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact)
412 { 410 {
413 PaintArtifact emptyArtifact; 411 PaintArtifact emptyArtifact;
414 update(emptyArtifact); 412 update(emptyArtifact);
415 EXPECT_TRUE(rootLayer()->children().empty()); 413 EXPECT_TRUE(rootLayer()->children().empty());
416 } 414 }
417 415
418 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneChunkWithAnOffset) 416 TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneChunkWithAnOffset)
419 { 417 {
420 TestPaintArtifact artifact; 418 TestPaintArtifact artifact;
421 artifact.chunk(PaintChunkProperties()) 419 artifact.chunk(PaintChunkProperties())
422 .rectDrawing(FloatRect(50, -50, 100, 100), Color::white); 420 .rectDrawing(FloatRect(50, -50, 100, 100), Color::white);
423 update(artifact.build()); 421 update(artifact.build());
424 422
425 ASSERT_EQ(1u, rootLayer()->children().size()); 423 ASSERT_EQ(1u, rootLayer()->children().size());
426 const cc::Layer* child = rootLayer()->child_at(0); 424 const cc::Layer* child = rootLayer()->child_at(0);
427 EXPECT_THAT(child->GetPicture(), 425 EXPECT_THAT(child->GetPicture(),
428 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); 426 Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white)));
429 EXPECT_EQ(translation(50, -50), child->screen_space_transform()); 427 EXPECT_EQ(translation(50, -50), child->screen_space_transform());
430 EXPECT_EQ(gfx::Size(100, 100), child->bounds()); 428 EXPECT_EQ(gfx::Size(100, 100), child->bounds());
431 } 429 }
432 430
433 } // namespace 431 } // namespace
434 } // namespace blink 432 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698