Revert "Reland c91b178b07b0d - Delete dead signin code (SigninGlobalError)"
[chromium-blink-merge.git] / cc / layers / nine_patch_layer_unittest.cc
blob75af3be073e84cf7abd08bff9fc718aba030e409
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/resource_provider.h"
8 #include "cc/resources/scoped_ui_resource.h"
9 #include "cc/test/fake_layer_tree_host.h"
10 #include "cc/test/fake_layer_tree_host_client.h"
11 #include "cc/test/fake_output_surface.h"
12 #include "cc/test/fake_output_surface_client.h"
13 #include "cc/test/geometry_test_utils.h"
14 #include "cc/test/test_task_graph_runner.h"
15 #include "cc/trees/layer_tree_host.h"
16 #include "cc/trees/single_thread_proxy.h"
17 #include "testing/gmock/include/gmock/gmock.h"
18 #include "testing/gtest/include/gtest/gtest.h"
19 #include "third_party/skia/include/core/SkBitmap.h"
21 using ::testing::Mock;
22 using ::testing::_;
23 using ::testing::AtLeast;
24 using ::testing::AnyNumber;
26 namespace cc {
27 namespace {
29 class NinePatchLayerTest : public testing::Test {
30 public:
31 NinePatchLayerTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {}
33 protected:
34 void SetUp() override {
35 layer_tree_host_ =
36 FakeLayerTreeHost::Create(&fake_client_, &task_graph_runner_);
39 void TearDown() override {
40 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
43 FakeLayerTreeHostClient fake_client_;
44 TestTaskGraphRunner task_graph_runner_;
45 scoped_ptr<FakeLayerTreeHost> layer_tree_host_;
48 TEST_F(NinePatchLayerTest, SetLayerProperties) {
49 scoped_refptr<NinePatchLayer> test_layer =
50 NinePatchLayer::Create(LayerSettings());
51 ASSERT_TRUE(test_layer.get());
52 test_layer->SetIsDrawable(true);
53 test_layer->SetBounds(gfx::Size(100, 100));
55 layer_tree_host_->SetRootLayer(test_layer);
56 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
57 EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get());
59 gfx::Rect screen_space_clip_rect;
60 test_layer->SavePaintProperties();
61 test_layer->Update();
63 EXPECT_FALSE(test_layer->DrawsContent());
65 bool is_opaque = false;
66 scoped_ptr<ScopedUIResource> resource = ScopedUIResource::Create(
67 layer_tree_host_.get(), UIResourceBitmap(gfx::Size(10, 10), is_opaque));
68 gfx::Rect aperture(5, 5, 1, 1);
69 bool fill_center = true;
70 test_layer->SetAperture(aperture);
71 test_layer->SetUIResourceId(resource->id());
72 test_layer->SetFillCenter(fill_center);
73 test_layer->Update();
75 EXPECT_TRUE(test_layer->DrawsContent());
78 } // namespace
79 } // namespace cc