diff options
author | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-21 08:05:28 +0000 |
---|---|---|
committer | jam@chromium.org <jam@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-21 08:05:28 +0000 |
commit | 8930d471c128ed74b11beaa78ea1b171c1ac7157 (patch) | |
tree | 5a20cb03c8e5019385709bc069e67f03488c41a1 /chrome/renderer/render_thread_unittest.cc | |
parent | a41fae8db8109bfeed047015b77b0d9227118540 (diff) | |
download | chromium_src-8930d471c128ed74b11beaa78ea1b171c1ac7157.zip chromium_src-8930d471c128ed74b11beaa78ea1b171c1ac7157.tar.gz chromium_src-8930d471c128ed74b11beaa78ea1b171c1ac7157.tar.bz2 |
Refactor code from RenderThread and PluginThread and move it to ChildThread. ChildProcess now owns the ChildThread, which removes duplicate code and simplifies things.
Clean up ChildProcess, there really was no need for all the templates and statics in it and its subclasses.
Committed: http://src.chromium.org/viewvc/chrome?view=rev&revision=10080
Review URL: http://codereview.chromium.org/21502
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10144 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/render_thread_unittest.cc')
-rw-r--r-- | chrome/renderer/render_thread_unittest.cc | 29 |
1 files changed, 14 insertions, 15 deletions
diff --git a/chrome/renderer/render_thread_unittest.cc b/chrome/renderer/render_thread_unittest.cc index 12e6941..3d09c51 100644 --- a/chrome/renderer/render_thread_unittest.cc +++ b/chrome/renderer/render_thread_unittest.cc @@ -2,7 +2,6 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -#include "base/string_util.h" #include "base/waitable_event.h" #include "chrome/common/ipc_sync_channel.h" #include "chrome/common/render_messages.h" @@ -12,39 +11,39 @@ namespace { -const char kThreadName[] = "render_thread_unittest"; +const wchar_t kThreadName[] = L"render_thread_unittest"; class RenderThreadTest : public testing::Test { public: virtual void SetUp() { - 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); + channel_ = new IPC::Channel(kThreadName, IPC::Channel::MODE_SERVER, NULL); + mock_process_.reset(new MockProcess(new RenderThread(kThreadName))); } virtual void TearDown() { message_loop_.RunAllPending(); + mock_process_.reset(); + // Delete the server channel after the RenderThread so that + // IPC::SyncChannel's OnChannelError doesn't fire on the context and attempt + // to use the listener thread which is now gone. delete channel_; - MockProcess::GlobalCleanup(); + // Need to fully destruct IPC::SyncChannel before the message loop goes + // away. + message_loop_.RunAllPending(); } - private: + protected: MessageLoopForIO message_loop_; + scoped_ptr<MockProcess> mock_process_; IPC::Channel *channel_; }; TEST_F(RenderThreadTest, TestGlobal) { - ASSERT_FALSE(g_render_thread); - { - RenderThread thread(ASCIIToWide(kThreadName)); - ASSERT_TRUE(g_render_thread); - } - ASSERT_FALSE(g_render_thread); + ASSERT_TRUE(RenderThread::current()); } TEST_F(RenderThreadTest, TestVisitedMsg) { - RenderThread thread(ASCIIToWide(kThreadName)); #if defined(OS_WIN) IPC::Message* msg = new ViewMsg_VisitedLink_NewTable(NULL); #elif defined(OS_POSIX) @@ -54,7 +53,7 @@ TEST_F(RenderThreadTest, TestVisitedMsg) { ASSERT_TRUE(msg); // Message goes nowhere, but this confirms Init() has happened. // Unusually (?), RenderThread() Start()s itself in it's constructor. - thread.Send(msg); + mock_process_->child_thread()->Send(msg); // No need to delete msg; per Message::Send() documentation, "The // implementor takes ownership of the given Message regardless of |