diff options
-rw-r--r-- | base/shared_memory_posix.cc | 6 | ||||
-rw-r--r-- | chrome/browser/net/url_fetcher_unittest.cc | 7 | ||||
-rw-r--r-- | chrome/chrome.xcodeproj/project.pbxproj | 12 | ||||
-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 | ||||
-rw-r--r-- | chrome/test/unit/unit_tests.scons | 5 | ||||
-rw-r--r-- | chrome/test/unit/unittests.vcproj | 4 | ||||
-rw-r--r-- | webkit/glue/mock_webkit_glue.cc | 29 |
9 files changed, 96 insertions, 29 deletions
diff --git a/base/shared_memory_posix.cc b/base/shared_memory_posix.cc index a1193aa..aa0c837 100644 --- a/base/shared_memory_posix.cc +++ b/base/shared_memory_posix.cc @@ -141,12 +141,8 @@ bool SharedMemory::ShareToProcessCommon(ProcessHandle process, void SharedMemory::Close() { - if (memory_ != NULL) { - munmap(memory_, max_size_); - memory_ = NULL; - max_size_ = 0; - } + Unmap(); std::string posix_name(WideToUTF8(name_)); if (mapped_file_ > 0) { diff --git a/chrome/browser/net/url_fetcher_unittest.cc b/chrome/browser/net/url_fetcher_unittest.cc index 663fd7c..11aafe7 100644 --- a/chrome/browser/net/url_fetcher_unittest.cc +++ b/chrome/browser/net/url_fetcher_unittest.cc @@ -6,14 +6,7 @@ #include "base/time.h" #include "chrome/browser/net/url_fetcher.h" #include "chrome/browser/net/url_fetcher_protect.h" -#if defined(OS_LINUX) -// TODO(port): ugly hack for linux -namespace ChromePluginLib { - void UnloadAllPlugins() {} -} -#else #include "chrome/common/chrome_plugin_lib.h" -#endif #include "net/base/ssl_test_util.h" #include "net/url_request/url_request_unittest.h" #include "testing/gtest/include/gtest/gtest.h" diff --git a/chrome/chrome.xcodeproj/project.pbxproj b/chrome/chrome.xcodeproj/project.pbxproj index 2a9f725..5d3bf5d 100644 --- a/chrome/chrome.xcodeproj/project.pbxproj +++ b/chrome/chrome.xcodeproj/project.pbxproj @@ -86,6 +86,10 @@ 3380A6A30F2E9207004EF74F /* ipc_sync_channel.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFBB60E9D4C9F009A6919 /* ipc_sync_channel.cc */; }; 3380A6A40F2E9209004EF74F /* ipc_sync_channel.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D7BFBB60E9D4C9F009A6919 /* ipc_sync_channel.cc */; }; 3380A6B60F2E9252004EF74F /* render_thread_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3380A6B50F2E9252004EF74F /* render_thread_unittest.cc */; }; + 3380A9AB0F2FC3BF004EF74F /* mock_webkit_glue.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3380A9AA0F2FC3BF004EF74F /* mock_webkit_glue.cc */; }; + 3380A9C00F2FC61E004EF74F /* render_process_unittest.cc in Sources */ = {isa = PBXBuildFile; fileRef = 3380A9BF0F2FC61E004EF74F /* render_process_unittest.cc */; }; + 3380A9D60F2FC8F6004EF74F /* render_dns_master.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D640CE10EAE86A500EBCFC0 /* render_dns_master.cc */; }; + 3380A9D70F2FC8F9004EF74F /* render_dns_master.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D640CE10EAE86A500EBCFC0 /* render_dns_master.cc */; }; 3AEA44DB19C9D93B63D7A2E4 /* url_fetcher_protect.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0B7CC9C105E90E0665852528 /* url_fetcher_protect.cc */; }; 4D1F59FE0F2A6BBB0040C1E3 /* image_diff.cc in Sources */ = {isa = PBXBuildFile; fileRef = 4D1F59FD0F2A6BBB0040C1E3 /* image_diff.cc */; }; 4D1F5A060F2A6D170040C1E3 /* libbase.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 4D7BFDC70E9D525B009A6919 /* libbase.a */; }; @@ -1100,6 +1104,8 @@ 28AA584AB2ECFB33C7C7FD8A /* template_url_parser.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = template_url_parser.cc; sourceTree = "<group>"; }; 3380A6B50F2E9252004EF74F /* render_thread_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = render_thread_unittest.cc; sourceTree = "<group>"; }; 3380A6B90F2E9275004EF74F /* render_view_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = render_view_unittest.cc; sourceTree = "<group>"; }; + 3380A9AA0F2FC3BF004EF74F /* mock_webkit_glue.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = mock_webkit_glue.cc; path = ../webkit/glue/mock_webkit_glue.cc; sourceTree = SOURCE_ROOT; }; + 3380A9BF0F2FC61E004EF74F /* render_process_unittest.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = render_process_unittest.cc; sourceTree = "<group>"; }; 3CCF8AA8A56FF8FE59F0C299 /* template_url.cc */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = template_url.cc; sourceTree = "<group>"; }; 433B6EFB7A1D931A13C9556F /* url_fetcher_protect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = url_fetcher_protect.h; sourceTree = "<group>"; }; 4D1F59EA0F2A6B590040C1E3 /* image_diff */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = image_diff; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -2146,6 +2152,8 @@ 4D640CCE0EAE868600EBCFC0 /* plugin_channel_host.h */, 4D640CCF0EAE868600EBCFC0 /* render_process.cc */, 4D640CD00EAE868600EBCFC0 /* render_process.h */, + 3380A9BF0F2FC61E004EF74F /* render_process_unittest.cc */, + 3380A9AA0F2FC3BF004EF74F /* mock_webkit_glue.cc */, 4D640CD10EAE868600EBCFC0 /* render_thread.cc */, 3380A6B50F2E9252004EF74F /* render_thread_unittest.cc */, 4D640CD20EAE868600EBCFC0 /* render_thread.h */, @@ -4102,6 +4110,7 @@ 3380A69F0F2E91E5004EF74F /* chrome_plugin_lib.cc in Sources */, 3380A6A10F2E91F9004EF74F /* render_process.cc in Sources */, 3380A6A30F2E9207004EF74F /* ipc_sync_channel.cc in Sources */, + 3380A9D70F2FC8F9004EF74F /* render_dns_master.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -4255,6 +4264,9 @@ 3380A6A20F2E91FB004EF74F /* render_process.cc in Sources */, 3380A6A40F2E9209004EF74F /* ipc_sync_channel.cc in Sources */, 3380A6B60F2E9252004EF74F /* render_thread_unittest.cc in Sources */, + 3380A9AB0F2FC3BF004EF74F /* mock_webkit_glue.cc in Sources */, + 3380A9C00F2FC61E004EF74F /* render_process_unittest.cc in Sources */, + 3380A9D60F2FC8F6004EF74F /* render_dns_master.cc in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; 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); diff --git a/chrome/test/unit/unit_tests.scons b/chrome/test/unit/unit_tests.scons index 8bcb37c..cc95e78 100644 --- a/chrome/test/unit/unit_tests.scons +++ b/chrome/test/unit/unit_tests.scons @@ -259,6 +259,10 @@ input_files = ChromeFileList([ '$CHROME_DIR/renderer/render_view_unittest.cc', '$CHROME_DIR/renderer/render_widget_unittest.cc', '$CHROME_DIR/renderer/user_script_slave_unittest.cc', + '$CHROME_DIR/renderer/render_process_unittest.cc', + '$WEBKIT_DIR/glue/mock_webkit_glue.cc', + '$CHROME_DIR/renderer/net/render_dns_master.cc', + '$CHROME_DIR/renderer/render_thread_unittest.cc', # test_infrastructure '$CHROME_DIR/renderer/mock_render_process.h', @@ -284,6 +288,7 @@ input_files = ChromeFileList([ ]), MSVSFilter('test_infrastructure', [ 'chrome_test_suite.h', + '$CHROME_DIR/common/chrome_plugin_lib.cc', '$CHROME_DIR/common/ipc_test_sink.cc', '$CHROME_DIR/common/ipc_test_sink.h', '$CHROME_DIR/tools/build/win/precompiled_wtl$OBJSUFFIX', diff --git a/chrome/test/unit/unittests.vcproj b/chrome/test/unit/unittests.vcproj index 03f50f0..3e44d38 100644 --- a/chrome/test/unit/unittests.vcproj +++ b/chrome/test/unit/unittests.vcproj @@ -779,6 +779,10 @@ > </File> <File + RelativePath="..\..\renderer\render_process_unittest.cc" + > + </File> + <File RelativePath="..\..\renderer\render_view_unittest.cc" > </File> diff --git a/webkit/glue/mock_webkit_glue.cc b/webkit/glue/mock_webkit_glue.cc new file mode 100644 index 0000000..a894e08 --- /dev/null +++ b/webkit/glue/mock_webkit_glue.cc @@ -0,0 +1,29 @@ +// 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. + +// Stubs for the webkit_glue namespace so chromium unit tests +// (e.g. files in src/chrome/renderer/) don't have to bring in all of +// webkit. For OSX/Linux bootstrapping. + +#if !defined(UNIT_TEST) +#error "This file should only be compiled in a unit test bundle." +#endif + +#if defined(OS_WIN) +#error "You don't need this file on Windows." +#endif + +#include "webkit/glue/webkit_glue.h" + +namespace webkit_glue { + +void SetJavaScriptFlags(const std::wstring& str) { } +void SetRecordPlaybackMode(bool value) { } +void CheckForLeaks() { } + +} // namespace webkit_glue + + + + |