Reland "Non-SFI mode: Switch to newlib. (patchset #4 id:60001 of https://codereview...
[chromium-blink-merge.git] / cc / layers / nine_patch_layer_unittest.cc
blob20082a0e8a55eebf8f3a4ec866b0b659bb983583
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/scoped_ui_resource.h"
10 #include "cc/test/fake_layer_tree_host.h"
11 #include "cc/test/fake_layer_tree_host_client.h"
12 #include "cc/test/fake_output_surface.h"
13 #include "cc/test/fake_output_surface_client.h"
14 #include "cc/test/geometry_test_utils.h"
15 #include "cc/test/test_task_graph_runner.h"
16 #include "cc/trees/layer_tree_host.h"
17 #include "cc/trees/single_thread_proxy.h"
18 #include "testing/gmock/include/gmock/gmock.h"
19 #include "testing/gtest/include/gtest/gtest.h"
20 #include "third_party/skia/include/core/SkBitmap.h"
22 using ::testing::Mock;
23 using ::testing::_;
24 using ::testing::AtLeast;
25 using ::testing::AnyNumber;
27 namespace cc {
28 namespace {
30 class NinePatchLayerTest : public testing::Test {
31 public:
32 NinePatchLayerTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {}
34 protected:
35 void SetUp() override {
36 layer_tree_host_ =
37 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_);
40 void TearDown() override {
41 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
44 FakeLayerTreeHostClient fake_client_;
45 TestTaskGraphRunner task_graph_runner_;
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 gfx::Rect screen_space_clip_rect;
61 test_layer->SavePaintProperties();
62 test_layer->Update();
64 EXPECT_FALSE(test_layer->DrawsContent());
66 bool is_opaque = false;
67 scoped_ptr<ScopedUIResource> resource = ScopedUIResource::Create(
68 layer_tree_host_.get(), UIResourceBitmap(gfx::Size(10, 10), is_opaque));
69 gfx::Rect aperture(5, 5, 1, 1);
70 bool fill_center = true;
71 test_layer->SetAperture(aperture);
72 test_layer->SetUIResourceId(resource->id());
73 test_layer->SetFillCenter(fill_center);
74 test_layer->Update();
76 EXPECT_TRUE(test_layer->DrawsContent());
79 } // namespace
80 } // namespace cc