OLD | NEW |
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 Loading... |
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 |
OLD | NEW |