Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(162)

Side by Side Diff: cc/layers/ui_resource_layer_unittest.cc

Issue 61823008: Introduce separate client and init path for single-threaded cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/layers/tiled_layer_unittest.cc ('k') | cc/test/fake_layer_tree_host.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/layers/ui_resource_layer.h" 5 #include "cc/layers/ui_resource_layer.h"
6 6
7 #include "cc/debug/overdraw_metrics.h" 7 #include "cc/debug/overdraw_metrics.h"
8 #include "cc/resources/prioritized_resource_manager.h" 8 #include "cc/resources/prioritized_resource_manager.h"
9 #include "cc/resources/resource_provider.h" 9 #include "cc/resources/resource_provider.h"
10 #include "cc/resources/resource_update_queue.h" 10 #include "cc/resources/resource_update_queue.h"
11 #include "cc/resources/scoped_ui_resource.h" 11 #include "cc/resources/scoped_ui_resource.h"
12 #include "cc/scheduler/texture_uploader.h" 12 #include "cc/scheduler/texture_uploader.h"
13 #include "cc/test/fake_layer_tree_host.h"
13 #include "cc/test/fake_layer_tree_host_client.h" 14 #include "cc/test/fake_layer_tree_host_client.h"
14 #include "cc/test/fake_output_surface.h" 15 #include "cc/test/fake_output_surface.h"
15 #include "cc/test/fake_output_surface_client.h" 16 #include "cc/test/fake_output_surface_client.h"
16 #include "cc/test/geometry_test_utils.h" 17 #include "cc/test/geometry_test_utils.h"
17 #include "cc/trees/layer_tree_host.h" 18 #include "cc/trees/layer_tree_host.h"
18 #include "cc/trees/occlusion_tracker.h" 19 #include "cc/trees/occlusion_tracker.h"
19 #include "cc/trees/single_thread_proxy.h" 20 #include "cc/trees/single_thread_proxy.h"
20 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
21 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
22 #include "third_party/skia/include/core/SkBitmap.h" 23 #include "third_party/skia/include/core/SkBitmap.h"
23 24
24 using ::testing::Mock; 25 using ::testing::Mock;
25 using ::testing::_; 26 using ::testing::_;
26 using ::testing::AtLeast; 27 using ::testing::AtLeast;
27 using ::testing::AnyNumber; 28 using ::testing::AnyNumber;
28 29
29 namespace cc { 30 namespace cc {
30 namespace { 31 namespace {
31 32
32 class MockLayerTreeHost : public LayerTreeHost {
33 public:
34 explicit MockLayerTreeHost(LayerTreeHostClient* client)
35 : LayerTreeHost(client, NULL, LayerTreeSettings()) {
36 Initialize(NULL);
37 }
38 };
39
40 class UIResourceLayerTest : public testing::Test { 33 class UIResourceLayerTest : public testing::Test {
41 public: 34 public:
42 UIResourceLayerTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {} 35 UIResourceLayerTest() : fake_client_(FakeLayerTreeHostClient::DIRECT_3D) {}
43 36
44 cc::Proxy* Proxy() const { return layer_tree_host_->proxy(); }
45
46 protected: 37 protected:
47 virtual void SetUp() { 38 virtual void SetUp() {
48 layer_tree_host_.reset(new MockLayerTreeHost(&fake_client_)); 39 layer_tree_host_ = FakeLayerTreeHost::Create();
40 layer_tree_host_->InitializeSingleThreaded(&fake_client_);
49 } 41 }
50 42
51 virtual void TearDown() { 43 virtual void TearDown() {
52 Mock::VerifyAndClearExpectations(layer_tree_host_.get()); 44 Mock::VerifyAndClearExpectations(layer_tree_host_.get());
53 } 45 }
54 46
55 scoped_ptr<MockLayerTreeHost> layer_tree_host_; 47 scoped_ptr<FakeLayerTreeHost> layer_tree_host_;
56 FakeLayerTreeHostClient fake_client_; 48 FakeLayerTreeHostClient fake_client_;
57 }; 49 };
58 50
59 TEST_F(UIResourceLayerTest, SetBitmap) { 51 TEST_F(UIResourceLayerTest, SetBitmap) {
60 scoped_refptr<UIResourceLayer> test_layer = UIResourceLayer::Create(); 52 scoped_refptr<UIResourceLayer> test_layer = UIResourceLayer::Create();
61 ASSERT_TRUE(test_layer.get()); 53 ASSERT_TRUE(test_layer.get());
62 test_layer->SetIsDrawable(true); 54 test_layer->SetIsDrawable(true);
63 test_layer->SetBounds(gfx::Size(100, 100)); 55 test_layer->SetBounds(gfx::Size(100, 100));
64 56
65 layer_tree_host_->SetRootLayer(test_layer); 57 layer_tree_host_->SetRootLayer(test_layer);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 scoped_ptr<ScopedUIResource> resource = ScopedUIResource::Create( 105 scoped_ptr<ScopedUIResource> resource = ScopedUIResource::Create(
114 layer_tree_host_.get(), UIResourceBitmap(bitmap)); 106 layer_tree_host_.get(), UIResourceBitmap(bitmap));
115 test_layer->SetUIResourceId(resource->id()); 107 test_layer->SetUIResourceId(resource->id());
116 test_layer->Update(&queue, &occlusion_tracker); 108 test_layer->Update(&queue, &occlusion_tracker);
117 109
118 EXPECT_TRUE(test_layer->DrawsContent()); 110 EXPECT_TRUE(test_layer->DrawsContent());
119 } 111 }
120 112
121 } // namespace 113 } // namespace
122 } // namespace cc 114 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/tiled_layer_unittest.cc ('k') | cc/test/fake_layer_tree_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698