Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(287)

Side by Side Diff: chrome/renderer/render_thread_unittest.cc

Issue 126086: Switch child threads so that current() only works on the correct thread and t... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/renderer/render_thread.cc ('k') | chrome/worker/worker_thread.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/waitable_event.h" 5 #include "base/waitable_event.h"
6 #include "chrome/common/ipc_sync_channel.h" 6 #include "chrome/common/ipc_sync_channel.h"
7 #include "chrome/common/render_messages.h" 7 #include "chrome/common/render_messages.h"
8 #include "chrome/renderer/mock_render_process.h" 8 #include "chrome/renderer/mock_render_process.h"
9 #include "chrome/renderer/render_thread.h" 9 #include "chrome/renderer/render_thread.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 22 matching lines...) Expand all
33 delete channel_; 33 delete channel_;
34 } 34 }
35 35
36 protected: 36 protected:
37 MessageLoopForIO message_loop_; 37 MessageLoopForIO message_loop_;
38 scoped_ptr<MockProcess> mock_process_; 38 scoped_ptr<MockProcess> mock_process_;
39 IPC::Channel *channel_; 39 IPC::Channel *channel_;
40 }; 40 };
41 41
42 TEST_F(RenderThreadTest, TestGlobal) { 42 TEST_F(RenderThreadTest, TestGlobal) {
43 ASSERT_TRUE(RenderThread::current()); 43 // Can't reach the RenderThread object on other threads, since it's not
44 // thread-safe!
45 ASSERT_FALSE(RenderThread::current());
44 } 46 }
45 47
46 TEST_F(RenderThreadTest, TestVisitedMsg) { 48 TEST_F(RenderThreadTest, TestVisitedMsg) {
47 #if defined(OS_WIN) 49 #if defined(OS_WIN)
48 IPC::Message* msg = new ViewMsg_VisitedLink_NewTable(NULL); 50 IPC::Message* msg = new ViewMsg_VisitedLink_NewTable(NULL);
49 #elif defined(OS_POSIX) 51 #elif defined(OS_POSIX)
50 IPC::Message* msg = new ViewMsg_VisitedLink_NewTable( 52 IPC::Message* msg = new ViewMsg_VisitedLink_NewTable(
51 base::SharedMemoryHandle(0, false)); 53 base::SharedMemoryHandle(0, false));
52 #endif 54 #endif
53 ASSERT_TRUE(msg); 55 ASSERT_TRUE(msg);
54 // Message goes nowhere, but this confirms Init() has happened. 56 // Message goes nowhere, but this confirms Init() has happened.
55 // Unusually (?), RenderThread() Start()s itself in it's constructor. 57 // Unusually (?), RenderThread() Start()s itself in it's constructor.
56 mock_process_->child_thread()->Send(msg); 58 mock_process_->child_thread()->Send(msg);
57 59
58 // No need to delete msg; per Message::Send() documentation, "The 60 // No need to delete msg; per Message::Send() documentation, "The
59 // implementor takes ownership of the given Message regardless of 61 // implementor takes ownership of the given Message regardless of
60 // whether or not this method succeeds." 62 // whether or not this method succeeds."
61 } 63 }
62 64
63 } // namespace 65 } // namespace
OLDNEW
« no previous file with comments | « chrome/renderer/render_thread.cc ('k') | chrome/worker/worker_thread.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698