OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #import "content/browser/renderer_host/text_input_client_mac.h" | 5 #import "content/browser/renderer_host/text_input_client_mac.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/threading/thread.h" | 9 #include "base/threading/thread.h" |
10 #include "content/browser/renderer_host/render_process_host_impl.h" | 10 #include "content/browser/renderer_host/render_process_host_impl.h" |
(...skipping 17 matching lines...) Expand all Loading... |
28 MockRenderWidgetHostDelegate() {} | 28 MockRenderWidgetHostDelegate() {} |
29 virtual ~MockRenderWidgetHostDelegate() {} | 29 virtual ~MockRenderWidgetHostDelegate() {} |
30 }; | 30 }; |
31 | 31 |
32 // This test does not test the WebKit side of the dictionary system (which | 32 // This test does not test the WebKit side of the dictionary system (which |
33 // performs the actual data fetching), but rather this just tests that the | 33 // performs the actual data fetching), but rather this just tests that the |
34 // service's signaling system works. | 34 // service's signaling system works. |
35 class TextInputClientMacTest : public testing::Test { | 35 class TextInputClientMacTest : public testing::Test { |
36 public: | 36 public: |
37 TextInputClientMacTest() | 37 TextInputClientMacTest() |
38 : message_loop_(MessageLoop::TYPE_UI), | 38 : message_loop_(base::MessageLoop::TYPE_UI), |
39 browser_context_(), | 39 browser_context_(), |
40 process_factory_(), | 40 process_factory_(), |
41 delegate_(), | 41 delegate_(), |
42 widget_(&delegate_, | 42 widget_(&delegate_, |
43 process_factory_.CreateRenderProcessHost(&browser_context_), | 43 process_factory_.CreateRenderProcessHost(&browser_context_), |
44 MSG_ROUTING_NONE), | 44 MSG_ROUTING_NONE), |
45 thread_("TextInputClientMacTestThread") {} | 45 thread_("TextInputClientMacTestThread") {} |
46 | 46 |
47 // Accessor for the TextInputClientMac instance. | 47 // Accessor for the TextInputClientMac instance. |
48 TextInputClientMac* service() { | 48 TextInputClientMac* service() { |
(...skipping 17 matching lines...) Expand all Loading... |
66 return &widget_; | 66 return &widget_; |
67 } | 67 } |
68 | 68 |
69 IPC::TestSink& ipc_sink() { | 69 IPC::TestSink& ipc_sink() { |
70 return static_cast<MockRenderProcessHost*>(widget()->GetProcess())->sink(); | 70 return static_cast<MockRenderProcessHost*>(widget()->GetProcess())->sink(); |
71 } | 71 } |
72 | 72 |
73 private: | 73 private: |
74 friend class ScopedTestingThread; | 74 friend class ScopedTestingThread; |
75 | 75 |
76 MessageLoop message_loop_; | 76 base::MessageLoop message_loop_; |
77 TestBrowserContext browser_context_; | 77 TestBrowserContext browser_context_; |
78 | 78 |
79 // Gets deleted when the last RWH in the "process" gets destroyed. | 79 // Gets deleted when the last RWH in the "process" gets destroyed. |
80 MockRenderProcessHostFactory process_factory_; | 80 MockRenderProcessHostFactory process_factory_; |
81 MockRenderWidgetHostDelegate delegate_; | 81 MockRenderWidgetHostDelegate delegate_; |
82 RenderWidgetHostImpl widget_; | 82 RenderWidgetHostImpl widget_; |
83 | 83 |
84 base::Thread thread_; | 84 base::Thread thread_; |
85 }; | 85 }; |
86 | 86 |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 TEST_F(TextInputClientMacTest, TimeoutSubstring) { | 223 TEST_F(TextInputClientMacTest, TimeoutSubstring) { |
224 NSAttributedString* string = service()->GetAttributedSubstringFromRange( | 224 NSAttributedString* string = service()->GetAttributedSubstringFromRange( |
225 widget(), NSMakeRange(0, 32)); | 225 widget(), NSMakeRange(0, 32)); |
226 EXPECT_EQ(nil, string); | 226 EXPECT_EQ(nil, string); |
227 EXPECT_EQ(1U, ipc_sink().message_count()); | 227 EXPECT_EQ(1U, ipc_sink().message_count()); |
228 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( | 228 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( |
229 TextInputClientMsg_StringForRange::ID)); | 229 TextInputClientMsg_StringForRange::ID)); |
230 } | 230 } |
231 | 231 |
232 } // namespace content | 232 } // namespace content |
OLD | NEW |