diff options
author | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-28 01:30:17 +0000 |
---|---|---|
committer | jrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-28 01:30:17 +0000 |
commit | 7497c1e3754bc85a0fa2b2a453b536872933e180 (patch) | |
tree | a33783cf132cf6ba46c93329f00842152b7e7892 /chrome/renderer | |
parent | d8bc79bfb604f3c10c3cd0bc0e35e0b8ec7b8d7d (diff) | |
download | chromium_src-7497c1e3754bc85a0fa2b2a453b536872933e180.zip chromium_src-7497c1e3754bc85a0fa2b2a453b536872933e180.tar.gz chromium_src-7497c1e3754bc85a0fa2b2a453b536872933e180.tar.bz2 |
Unit test addition, cleanup for render_process/thread.
Review URL: http://codereview.chromium.org/19606
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8782 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer')
-rw-r--r-- | chrome/renderer/render_process.cc | 21 | ||||
-rw-r--r-- | chrome/renderer/render_process_unittest.cc | 35 | ||||
-rw-r--r-- | chrome/renderer/render_thread.cc | 6 |
3 files changed, 45 insertions, 17 deletions
diff --git a/chrome/renderer/render_process.cc b/chrome/renderer/render_process.cc index 648c8a8..91fd430 100644 --- a/chrome/renderer/render_process.cc +++ b/chrome/renderer/render_process.cc @@ -72,20 +72,12 @@ bool RenderProcess::GlobalInit(const std::wstring &channel_name) { const CommandLine& command_line = *CommandLine::ForCurrentProcess(); if (command_line.HasSwitch(switches::kJavaScriptFlags)) { - // TODO(port) - // Try and limit what we pull in for our non-Win unit test bundle -#if defined(OS_WIN) || (!defined(UNIT_TEST)) webkit_glue::SetJavaScriptFlags( command_line.GetSwitchValue(switches::kJavaScriptFlags)); -#endif } if (command_line.HasSwitch(switches::kPlaybackMode) || command_line.HasSwitch(switches::kRecordMode)) { - // TODO(port) - // Try and limit what we pull in for our non-Win unit test bundle -#if defined(OS_WIN) || (!defined(UNIT_TEST)) webkit_glue::SetRecordPlaybackMode(true); -#endif } if (command_line.HasSwitch(switches::kInProcessPlugins) || @@ -129,6 +121,15 @@ bool RenderProcess::ShouldLoadPluginsInProcess() { // static base::SharedMemory* RenderProcess::AllocSharedMemory(size_t size) { +#if defined(OS_LINUX) + // Linux has trouble with ""; the Create() call below will fail when + // triggered by RenderProcessTest.TestSharedMemoryAllocOne(), every + // time. + std::wstring root_name(L"root"); +#else + std::wstring root_name(L""); +#endif + self()->clearer_factory_.RevokeAll(); base::SharedMemory* mem = self()->GetSharedMemFromCache(size); @@ -143,7 +144,7 @@ base::SharedMemory* RenderProcess::AllocSharedMemory(size_t size) { mem = new base::SharedMemory(); if (!mem) return NULL; - if (!mem->Create(L"", false, true, size)) { + if (!mem->Create(root_name, false, true, size)) { delete mem; return NULL; } @@ -221,10 +222,8 @@ void RenderProcess::ScheduleCacheClearer() { void RenderProcess::Cleanup() { // TODO(port) // Try and limit what we pull in for our non-Win unit test bundle -#if defined(OS_WIN) || (!defined(UNIT_TEST)) #ifndef NDEBUG // log important leaked objects webkit_glue::CheckForLeaks(); #endif -#endif } diff --git a/chrome/renderer/render_process_unittest.cc b/chrome/renderer/render_process_unittest.cc new file mode 100644 index 0000000..d1a3255 --- /dev/null +++ b/chrome/renderer/render_process_unittest.cc @@ -0,0 +1,35 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/sys_info.h" +#include "base/string_util.h" +#include "chrome/renderer/render_process.h" +#include "testing/gtest/include/gtest/gtest.h" + + +class RenderProcessTest : public testing::Test { + public: + virtual void SetUp() { + // Must have a message loop to create a RenderThread() + message_loop_ = new MessageLoop(MessageLoop::TYPE_DEFAULT); + } + + virtual void TearDown() { + delete message_loop_; + } + + private: + MessageLoop *message_loop_; +}; + + +TEST_F(RenderProcessTest, TestSharedMemoryAllocOne) { + RenderProcess::GlobalInit(ASCIIToWide("hi mom")); + size_t size = base::SysInfo::VMAllocationGranularity(); + base::SharedMemory* mem = RenderProcess::AllocSharedMemory(size); + ASSERT_TRUE(mem); + RenderProcess::FreeSharedMemory(mem); + RenderProcess::GlobalCleanup(); +} + diff --git a/chrome/renderer/render_thread.cc b/chrome/renderer/render_thread.cc index 355ce8d..5b0dbcb 100644 --- a/chrome/renderer/render_thread.cc +++ b/chrome/renderer/render_thread.cc @@ -124,13 +124,7 @@ void RenderThread::Init() { visited_link_slave_ = new VisitedLinkSlave(); user_script_slave_ = new UserScriptSlave(); - -// TODO(port) -#if defined(OS_WIN) render_dns_master_.reset(new RenderDnsMaster()); -#else - NOTIMPLEMENTED(); -#endif #ifdef IPC_MESSAGE_LOG_ENABLED IPC::Logging::current()->SetIPCSender(this); |