summaryrefslogtreecommitdiffstats
path: root/chrome/renderer/render_thread_unittest.cc
diff options
context:
space:
mode:
authorjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-29 01:04:15 +0000
committerjrg@chromium.org <jrg@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-01-29 01:04:15 +0000
commit4fa52530e921ffe34ebf8b426eb50a206c4c9842 (patch)
treedb65e92e17cb4aff218508514759a26bd8fb95eb /chrome/renderer/render_thread_unittest.cc
parente61618371a6bd48298a0702de424858373183b6c (diff)
downloadchromium_src-4fa52530e921ffe34ebf8b426eb50a206c4c9842.zip
chromium_src-4fa52530e921ffe34ebf8b426eb50a206c4c9842.tar.gz
chromium_src-4fa52530e921ffe34ebf8b426eb50a206c4c9842.tar.bz2
Fix purify failure.
http://code.google.com/p/chromium/issues/detail?id=7144 Review URL: http://codereview.chromium.org/19642 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@8850 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_thread_unittest.cc')
-rw-r--r--chrome/renderer/render_thread_unittest.cc32
1 files changed, 22 insertions, 10 deletions
diff --git a/chrome/renderer/render_thread_unittest.cc b/chrome/renderer/render_thread_unittest.cc
index 0aadda6..4fb7a24 100644
--- a/chrome/renderer/render_thread_unittest.cc
+++ b/chrome/renderer/render_thread_unittest.cc
@@ -4,44 +4,56 @@
#include "base/string_util.h"
#include "base/waitable_event.h"
+#include "chrome/common/ipc_sync_channel.h"
#include "chrome/common/render_messages.h"
+#include "chrome/renderer/mock_render_process.h"
#include "chrome/renderer/render_thread.h"
#include "testing/gtest/include/gtest/gtest.h"
+namespace {
+
+const char kThreadName[] = "render_thread_unittest";
class RenderThreadTest : public testing::Test {
public:
virtual void SetUp() {
- // Must have a message loop to create a RenderThread()
- message_loop_ = new MessageLoop(MessageLoop::TYPE_DEFAULT);
+ MockProcess::GlobalInit();
+ // Need a MODE_SERVER to make MODE_CLIENTs (like a RenderThread) happy.
+ channel_ = new IPC::Channel(ASCIIToWide(kThreadName),
+ IPC::Channel::MODE_SERVER, NULL);
}
-
+
virtual void TearDown() {
- delete message_loop_;
+ message_loop_.RunAllPending();
+ delete channel_;
+ MockProcess::GlobalCleanup();
}
private:
- MessageLoop *message_loop_;
-
+ MessageLoopForIO message_loop_;
+ IPC::Channel *channel_;
};
-
TEST_F(RenderThreadTest, TestGlobal) {
ASSERT_FALSE(g_render_thread);
{
- RenderThread thread(EmptyWString());
+ RenderThread thread(ASCIIToWide(kThreadName));
ASSERT_TRUE(g_render_thread);
}
ASSERT_FALSE(g_render_thread);
}
TEST_F(RenderThreadTest, TestVisitedMsg) {
- RenderThread thread(EmptyWString());
+ RenderThread thread(ASCIIToWide(kThreadName));
IPC::Message* msg = new ViewMsg_VisitedLink_NewTable(NULL);
ASSERT_TRUE(msg);
// Message goes nowhere, but this confirms Init() has happened.
// Unusually (?), RenderThread() Start()s itself in it's constructor.
thread.Send(msg);
- delete msg;
+
+ // No need to delete msg; per Message::Send() documentation, "The
+ // implementor takes ownership of the given Message regardless of
+ // whether or not this method succeeds."
}
+} // namespace