| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 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 "base/sys_info.h" | |
| 6 #include "base/string_util.h" | |
| 7 #include "content/renderer/render_process_impl.h" | |
| 8 #include "ipc/ipc_channel.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 #include "ui/gfx/rect.h" | |
| 11 | |
| 12 namespace { | |
| 13 | |
| 14 static const char kThreadName[] = "render_process_unittest"; | |
| 15 | |
| 16 class RenderProcessTest : public testing::Test { | |
| 17 public: | |
| 18 virtual void SetUp() { | |
| 19 // Need a MODE_SERVER to make MODE_CLIENTs (like a RenderThread) happy. | |
| 20 channel_ = new IPC::Channel(kThreadName, IPC::Channel::MODE_SERVER, NULL); | |
| 21 render_process_.reset(new RenderProcessImpl); | |
| 22 } | |
| 23 | |
| 24 virtual void TearDown() { | |
| 25 message_loop_.RunAllPending(); | |
| 26 render_process_.reset(); | |
| 27 // Need to fully destruct IPC::SyncChannel before the message loop goes | |
| 28 // away. | |
| 29 message_loop_.RunAllPending(); | |
| 30 // Delete the server channel after the RenderThread so that | |
| 31 // IPC::SyncChannel's OnChannelError doesn't fire on the context and attempt | |
| 32 // to use the listener thread which is now gone. | |
| 33 delete channel_; | |
| 34 } | |
| 35 | |
| 36 private: | |
| 37 MessageLoopForIO message_loop_; | |
| 38 scoped_ptr<RenderProcessImpl> render_process_; | |
| 39 IPC::Channel *channel_; | |
| 40 }; | |
| 41 | |
| 42 | |
| 43 TEST_F(RenderProcessTest, TestTransportDIBAllocation) { | |
| 44 // On Mac, we allocate in the browser so this test is invalid. | |
| 45 #if !defined(OS_MACOSX) | |
| 46 const gfx::Rect rect(0, 0, 100, 100); | |
| 47 TransportDIB* dib; | |
| 48 skia::PlatformCanvas* canvas = | |
| 49 RenderProcess::current()->GetDrawingCanvas(&dib, rect); | |
| 50 ASSERT_TRUE(dib); | |
| 51 ASSERT_TRUE(canvas); | |
| 52 RenderProcess::current()->ReleaseTransportDIB(dib); | |
| 53 delete canvas; | |
| 54 #endif | |
| 55 } | |
| 56 | |
| 57 } // namespace | |
| OLD | NEW |