Fix flaky PDFExtensionTest
[chromium-blink-merge.git] / cc / layers / nine_patch_layer_unittest.cc
blobb9fab7661f8cacf3f148c6d580fdc2bec541699a
1 // Copyright 2012 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/nine_patch_layer.h"
7 #include "cc/resources/prioritized_resource_manager.h"
8 #include "cc/resources/resource_provider.h"
9 #include "cc/resources/resource_update_queue.h"
10 #include "cc/resources/scoped_ui_resource.h"
11 #include "cc/test/fake_layer_tree_host.h"
12 #include "cc/test/fake_layer_tree_host_client.h"
13 #include "cc/test/fake_output_surface.h"
14 #include "cc/test/fake_output_surface_client.h"
15 #include "cc/test/geometry_test_utils.h"
16 #include "cc/test/test_shared_bitmap_manager.h"
17 #include "cc/trees/layer_tree_host.h"
18 #include "cc/trees/occlusion_tracker.h"
19 #include "cc/trees/single_thread_proxy.h"
20 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h"
22 #include "third_party/skia/include/core/SkBitmap.h"
24 using ::testing::Mock;
25 using ::testing::_;
26 using ::testing::AtLeast;
27 using ::testing::AnyNumber;
29 namespace cc {
30 namespace {
32 class NinePatchLayerTest : public testing::Test {
33 public:
34 NinePatchLayerTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {}
36 protected:
37 void SetUp() override {
38 layer_tree_host_ = FakeLayerTreeHost::Create(&fake_client_);
41 void TearDown() override {
42 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
45 FakeLayerTreeHostClient fake_client_;
46 scoped_ptr<FakeLayerTreeHost> layer_tree_host_;
49 TEST_F(NinePatchLayerTest, SetLayerProperties) {
50 scoped_refptr<NinePatchLayer> test_layer =
51 NinePatchLayer::Create(LayerSettings());
52 ASSERT_TRUE(test_layer.get());
53 test_layer->SetIsDrawable(true);
54 test_layer->SetBounds(gfx::Size(100, 100));
56 layer_tree_host_->SetRootLayer(test_layer);
57 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
58 EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get());
60 ResourceUpdateQueue queue;
61 gfx::Rect screen_space_clip_rect;
62 OcclusionTracker<Layer> occlusion_tracker(screen_space_clip_rect);
63 test_layer->SavePaintProperties();
64 test_layer->Update(&queue, &occlusion_tracker);
66 EXPECT_FALSE(test_layer->DrawsContent());
68 bool is_opaque = false;
69 scoped_ptr<ScopedUIResource> resource = ScopedUIResource::Create(
70 layer_tree_host_.get(), UIResourceBitmap(gfx::Size(10, 10), is_opaque));
71 gfx::Rect aperture(5, 5, 1, 1);
72 bool fill_center = true;
73 test_layer->SetAperture(aperture);
74 test_layer->SetUIResourceId(resource->id());
75 test_layer->SetFillCenter(fill_center);
76 test_layer->Update(&queue, &occlusion_tracker);
78 EXPECT_TRUE(test_layer->DrawsContent());
81 } // namespace
82 } // namespace cc