1 // Copyright (c) 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. 4 5 #include "content/test/mock_render_process.h" 6 7 #include "ui/gfx/rect.h" 8 #include "ui/surface/transport_dib.h" 9 10 namespace content { 11 12 MockRenderProcess::MockRenderProcess() 13 : transport_dib_next_sequence_number_(0), 14 enabled_bindings_(0) { 15 } 16 17 MockRenderProcess::~MockRenderProcess() { 18 } 19 20 skia::PlatformCanvas* MockRenderProcess::GetDrawingCanvas( 21 TransportDIB** memory, 22 const gfx::Rect& rect) { 23 size_t stride = skia::PlatformCanvasStrideForWidth(rect.width()); 24 size_t size = stride * rect.height(); 25 26 // Unlike RenderProcessImpl, when we're a test, we can just create transport 27 // DIBs in the current process, since there is no sandbox protecting us (and 28 // no browser process to ask for one in any case). 29 *memory = TransportDIB::Create(size, transport_dib_next_sequence_number_++); 30 if (!*memory) 31 return NULL; 32 return (*memory)->GetPlatformCanvas(rect.width(), rect.height()); 33 } 34 35 void MockRenderProcess::ReleaseTransportDIB(TransportDIB* memory) { 36 delete memory; 37 } 38 39 bool MockRenderProcess::UseInProcessPlugins() const { 40 return true; 41 } 42 43 void MockRenderProcess::AddBindings(int bindings) { 44 enabled_bindings_ |= bindings; 45 } 46 47 int MockRenderProcess::GetEnabledBindings() const { 48 return enabled_bindings_; 49 } 50 51 TransportDIB* MockRenderProcess::CreateTransportDIB(size_t size) { 52 return TransportDIB::Create(size, transport_dib_next_sequence_number_++); 53 } 54 55 void MockRenderProcess::FreeTransportDIB(TransportDIB* dib) { 56 delete dib; 57 } 58 59 } // namespace content 60