Fix Callback Issue During Card Dismissal Request
[chromium-blink-merge.git] / cc / test / fake_scoped_ui_resource.cc
blobbf86f5469b90a98c64655df69f5b219a47176288
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/test/fake_scoped_ui_resource.h"
7 #include "cc/trees/layer_tree_host.h"
9 namespace cc {
11 namespace {
13 UIResourceBitmap CreateMockUIResourceBitmap() {
14 SkBitmap skbitmap;
15 skbitmap.setConfig(SkBitmap::kARGB_8888_Config, 1, 1);
16 skbitmap.allocPixels();
17 skbitmap.setImmutable();
18 return UIResourceBitmap(skbitmap);
21 } // anonymous namespace
23 scoped_ptr<FakeScopedUIResource> FakeScopedUIResource::Create(
24 LayerTreeHost* host) {
25 return make_scoped_ptr(new FakeScopedUIResource(host));
28 FakeScopedUIResource::FakeScopedUIResource(LayerTreeHost* host)
29 : ScopedUIResource(host, CreateMockUIResourceBitmap()) {
30 // The constructor of ScopedUIResource already created a resource so we need
31 // to delete the created resource to wipe the state clean.
32 host_->DeleteUIResource(id_);
33 ResetCounters();
34 id_ = host_->CreateUIResource(this);
37 UIResourceBitmap FakeScopedUIResource::GetBitmap(UIResourceId uid,
38 bool resource_lost) {
39 resource_create_count++;
40 if (resource_lost)
41 lost_resource_count++;
42 return ScopedUIResource::GetBitmap(uid, resource_lost);
45 void FakeScopedUIResource::ResetCounters() {
46 resource_create_count = 0;
47 lost_resource_count = 0;
50 } // namespace cc