don't explicitly create SkDevice, as it is intended to be private. Skia now has ways...
[chromium-blink-merge.git] / cc / layers / picture_layer_unittest.cc
blob8f13fd0ed7fee899962bf29bb38d4ed7dd3e3b15
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "cc/layers/picture_layer.h"
7 #include "cc/layers/content_layer_client.h"
8 #include "cc/layers/picture_layer_impl.h"
9 #include "cc/resources/resource_update_queue.h"
10 #include "cc/test/fake_layer_tree_host.h"
11 #include "cc/test/fake_picture_layer_impl.h"
12 #include "cc/test/fake_proxy.h"
13 #include "cc/test/impl_side_painting_settings.h"
14 #include "cc/trees/occlusion_tracker.h"
15 #include "testing/gtest/include/gtest/gtest.h"
17 namespace cc {
18 namespace {
20 class MockContentLayerClient : public ContentLayerClient {
21 public:
22 virtual void PaintContents(SkCanvas* canvas,
23 const gfx::Rect& clip,
24 gfx::RectF* opaque) OVERRIDE {}
25 virtual void DidChangeLayerCanUseLCDText() OVERRIDE {}
28 TEST(PictureLayerTest, NoTilesIfEmptyBounds) {
29 MockContentLayerClient client;
30 scoped_refptr<PictureLayer> layer = PictureLayer::Create(&client);
31 layer->SetBounds(gfx::Size(10, 10));
33 scoped_ptr<FakeLayerTreeHost> host = FakeLayerTreeHost::Create();
34 host->SetRootLayer(layer);
35 layer->SetIsDrawable(true);
36 layer->SavePaintProperties();
38 OcclusionTracker occlusion(gfx::Rect(0, 0, 1000, 1000), false);
39 scoped_ptr<ResourceUpdateQueue> queue(new ResourceUpdateQueue);
40 layer->Update(queue.get(), &occlusion);
42 layer->SetBounds(gfx::Size(0, 0));
43 layer->SavePaintProperties();
44 // Intentionally skipping Update since it would normally be skipped on
45 // a layer with empty bounds.
47 FakeProxy proxy;
48 #ifndef NDEBUG
49 proxy.SetCurrentThreadIsImplThread(true);
50 #endif
52 FakeLayerTreeHostImpl host_impl(ImplSidePaintingSettings(), &proxy);
53 host_impl.CreatePendingTree();
54 scoped_ptr<FakePictureLayerImpl> layer_impl =
55 FakePictureLayerImpl::Create(host_impl.pending_tree(), 1);
57 layer->PushPropertiesTo(layer_impl.get());
58 EXPECT_FALSE(layer_impl->CanHaveTilings());
59 EXPECT_TRUE(layer_impl->bounds() == gfx::Size(0, 0));
60 EXPECT_TRUE(layer_impl->pile()->size() == gfx::Size(0, 0));
61 EXPECT_TRUE(layer_impl->pile()->recorded_region().IsEmpty());
63 #ifndef NDEBUG
64 proxy.SetCurrentThreadIsImplThread(false);
65 #endif
68 } // namespace
69 } // namespace cc