Remove NavigationRequestInfo::is_showing.
[chromium-blink-merge.git] / cc / layers / ui_resource_layer_unittest.cc
blobf6a460e018b54beeec0940a013566a1851ce04d6
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/ui_resource_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/trees/layer_tree_host.h"
17 #include "cc/trees/occlusion_tracker.h"
18 #include "cc/trees/single_thread_proxy.h"
19 #include "testing/gmock/include/gmock/gmock.h"
20 #include "testing/gtest/include/gtest/gtest.h"
21 #include "third_party/skia/include/core/SkBitmap.h"
23 using ::testing::Mock;
24 using ::testing::_;
25 using ::testing::AtLeast;
26 using ::testing::AnyNumber;
28 namespace cc {
29 namespace {
31 class UIResourceLayerTest : public testing::Test {
32 public:
33 UIResourceLayerTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {}
35 protected:
36 virtual void SetUp() {
37 layer_tree_host_ = FakeLayerTreeHost::Create();
38 layer_tree_host_->InitializeSingleThreaded(
39 &fake_client_, base::MessageLoopProxy::current());
42 virtual void TearDown() {
43 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
46 scoped_ptr<FakeLayerTreeHost> layer_tree_host_;
47 FakeLayerTreeHostClient fake_client_;
50 TEST_F(UIResourceLayerTest, SetBitmap) {
51 scoped_refptr<UIResourceLayer> test_layer = UIResourceLayer::Create();
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 SkBitmap bitmap;
69 bitmap.allocN32Pixels(10, 10);
70 bitmap.setImmutable();
72 test_layer->SetBitmap(bitmap);
73 test_layer->Update(&queue, &occlusion_tracker);
75 EXPECT_TRUE(test_layer->DrawsContent());
78 TEST_F(UIResourceLayerTest, SetUIResourceId) {
79 scoped_refptr<UIResourceLayer> test_layer = UIResourceLayer::Create();
80 ASSERT_TRUE(test_layer.get());
81 test_layer->SetIsDrawable(true);
82 test_layer->SetBounds(gfx::Size(100, 100));
84 layer_tree_host_->SetRootLayer(test_layer);
85 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
86 EXPECT_EQ(test_layer->layer_tree_host(), layer_tree_host_.get());
88 ResourceUpdateQueue queue;
89 gfx::Rect screen_space_clip_rect;
90 OcclusionTracker<Layer> occlusion_tracker(screen_space_clip_rect);
91 test_layer->SavePaintProperties();
92 test_layer->Update(&queue, &occlusion_tracker);
94 EXPECT_FALSE(test_layer->DrawsContent());
96 bool is_opaque = false;
97 scoped_ptr<ScopedUIResource> resource = ScopedUIResource::Create(
98 layer_tree_host_.get(), UIResourceBitmap(gfx::Size(10, 10), is_opaque));
99 test_layer->SetUIResourceId(resource->id());
100 test_layer->Update(&queue, &occlusion_tracker);
102 EXPECT_TRUE(test_layer->DrawsContent());
105 } // namespace
106 } // namespace cc