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" |
11 #include "content/browser/renderer_host/render_widget_host_delegate.h" | 11 #include "content/browser/renderer_host/render_widget_host_delegate.h" |
12 #include "content/browser/renderer_host/render_widget_host_impl.h" | 12 #include "content/browser/renderer_host/render_widget_host_impl.h" |
13 #include "content/browser/renderer_host/text_input_client_message_filter.h" | 13 #include "content/browser/renderer_host/text_input_client_message_filter.h" |
14 #include "content/common/text_input_client_messages.h" | 14 #include "content/common/text_input_client_messages.h" |
15 #include "content/public/test/mock_render_process_host.h" | 15 #include "content/public/test/mock_render_process_host.h" |
16 #include "content/public/test/test_browser_context.h" | 16 #include "content/public/test/test_browser_context.h" |
17 #include "ipc/ipc_test_sink.h" | 17 #include "ipc/ipc_test_sink.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 18 #include "testing/gtest/include/gtest/gtest.h" |
19 #include "testing/gtest_mac.h" | 19 #include "testing/gtest_mac.h" |
20 | 20 |
21 using content::MockRenderProcessHost; | 21 namespace content { |
22 using content::MockRenderProcessHostFactory; | |
23 using content::RenderWidgetHostImpl; | |
24 | |
25 namespace { | |
26 | 22 |
27 const int64 kTaskDelayMs = 200; | 23 const int64 kTaskDelayMs = 200; |
28 | 24 |
29 class MockRenderWidgetHostDelegate : public content::RenderWidgetHostDelegate { | 25 class MockRenderWidgetHostDelegate : public RenderWidgetHostDelegate { |
30 public: | 26 public: |
31 MockRenderWidgetHostDelegate() {} | 27 MockRenderWidgetHostDelegate() {} |
32 virtual ~MockRenderWidgetHostDelegate() {} | 28 virtual ~MockRenderWidgetHostDelegate() {} |
33 }; | 29 }; |
34 | 30 |
35 // This test does not test the WebKit side of the dictionary system (which | 31 // This test does not test the WebKit side of the dictionary system (which |
36 // performs the actual data fetching), but rather this just tests that the | 32 // performs the actual data fetching), but rather this just tests that the |
37 // service's signaling system works. | 33 // service's signaling system works. |
38 class TextInputClientMacTest : public testing::Test { | 34 class TextInputClientMacTest : public testing::Test { |
39 public: | 35 public: |
(...skipping 30 matching lines...) Expand all Loading... |
70 } | 66 } |
71 | 67 |
72 IPC::TestSink& ipc_sink() { | 68 IPC::TestSink& ipc_sink() { |
73 return static_cast<MockRenderProcessHost*>(widget()->GetProcess())->sink(); | 69 return static_cast<MockRenderProcessHost*>(widget()->GetProcess())->sink(); |
74 } | 70 } |
75 | 71 |
76 private: | 72 private: |
77 friend class ScopedTestingThread; | 73 friend class ScopedTestingThread; |
78 | 74 |
79 MessageLoop message_loop_; | 75 MessageLoop message_loop_; |
80 content::TestBrowserContext browser_context_; | 76 TestBrowserContext browser_context_; |
81 | 77 |
82 // Gets deleted when the last RWH in the "process" gets destroyed. | 78 // Gets deleted when the last RWH in the "process" gets destroyed. |
83 MockRenderProcessHostFactory process_factory_; | 79 MockRenderProcessHostFactory process_factory_; |
84 MockRenderWidgetHostDelegate delegate_; | 80 MockRenderWidgetHostDelegate delegate_; |
85 RenderWidgetHostImpl widget_; | 81 RenderWidgetHostImpl widget_; |
86 | 82 |
87 base::Thread thread_; | 83 base::Thread thread_; |
88 }; | 84 }; |
89 | 85 |
90 //////////////////////////////////////////////////////////////////////////////// | 86 //////////////////////////////////////////////////////////////////////////////// |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 | 219 |
224 TEST_F(TextInputClientMacTest, TimeoutSubstring) { | 220 TEST_F(TextInputClientMacTest, TimeoutSubstring) { |
225 NSAttributedString* string = service()->GetAttributedSubstringFromRange( | 221 NSAttributedString* string = service()->GetAttributedSubstringFromRange( |
226 widget(), NSMakeRange(0, 32)); | 222 widget(), NSMakeRange(0, 32)); |
227 EXPECT_EQ(nil, string); | 223 EXPECT_EQ(nil, string); |
228 EXPECT_EQ(1U, ipc_sink().message_count()); | 224 EXPECT_EQ(1U, ipc_sink().message_count()); |
229 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( | 225 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( |
230 TextInputClientMsg_StringForRange::ID)); | 226 TextInputClientMsg_StringForRange::ID)); |
231 } | 227 } |
232 | 228 |
233 } // namespace | 229 } // namespace content |
OLD | NEW |