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

Side by Side Diff: content/browser/renderer_host/text_input_client_mac_unittest.mm

Issue 10377158: Move keyboard related methods from RenderViewHostDelegate to a new RenderWidgetHostDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove crbug link Created 8 years, 7 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
OLDNEW
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_impl.h" 12 #include "content/browser/renderer_host/render_widget_host_impl.h"
12 #include "content/browser/renderer_host/text_input_client_message_filter.h" 13 #include "content/browser/renderer_host/text_input_client_message_filter.h"
13 #include "content/common/text_input_client_messages.h" 14 #include "content/common/text_input_client_messages.h"
14 #include "content/test//test_browser_context.h" 15 #include "content/test//test_browser_context.h"
15 #include "content/test/mock_render_process_host.h" 16 #include "content/test/mock_render_process_host.h"
16 #include "ipc/ipc_test_sink.h" 17 #include "ipc/ipc_test_sink.h"
17 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/gtest_mac.h" 19 #include "testing/gtest_mac.h"
19 20
20 using content::MockRenderProcessHost; 21 using content::MockRenderProcessHost;
21 using content::MockRenderProcessHostFactory; 22 using content::MockRenderProcessHostFactory;
22 using content::RenderWidgetHostImpl; 23 using content::RenderWidgetHostImpl;
23 24
24 namespace { 25 namespace {
25 26
26 const int64 kTaskDelayMs = 200; 27 const int64 kTaskDelayMs = 200;
27 28
29 class MockRenderWidgetHostDelegate : public content::RenderWidgetHostDelegate {
30 public:
31 MockRenderWidgetHostDelegate() {}
32 virtual ~MockRenderWidgetHostDelegate() {}
33 };
34
28 // This test does not test the WebKit side of the dictionary system (which 35 // This test does not test the WebKit side of the dictionary system (which
29 // performs the actual data fetching), but rather this just tests that the 36 // performs the actual data fetching), but rather this just tests that the
30 // service's signaling system works. 37 // service's signaling system works.
31 class TextInputClientMacTest : public testing::Test { 38 class TextInputClientMacTest : public testing::Test {
32 public: 39 public:
33 TextInputClientMacTest() 40 TextInputClientMacTest()
34 : message_loop_(MessageLoop::TYPE_UI), 41 : message_loop_(MessageLoop::TYPE_UI),
35 browser_context_(), 42 browser_context_(),
36 process_factory_(), 43 process_factory_(),
37 widget_(process_factory_.CreateRenderProcessHost(&browser_context_), 44 delegate_(),
45 widget_(&delegate_,
46 process_factory_.CreateRenderProcessHost(&browser_context_),
38 MSG_ROUTING_NONE), 47 MSG_ROUTING_NONE),
39 thread_("TextInputClientMacTestThread") {} 48 thread_("TextInputClientMacTestThread") {}
40 49
41 // Accessor for the TextInputClientMac instance. 50 // Accessor for the TextInputClientMac instance.
42 TextInputClientMac* service() { 51 TextInputClientMac* service() {
43 return TextInputClientMac::GetInstance(); 52 return TextInputClientMac::GetInstance();
44 } 53 }
45 54
46 // Helper method to post a task on the testing thread's MessageLoop after 55 // Helper method to post a task on the testing thread's MessageLoop after
47 // a short delay. 56 // a short delay.
(...skipping 17 matching lines...) Expand all
65 } 74 }
66 75
67 private: 76 private:
68 friend class ScopedTestingThread; 77 friend class ScopedTestingThread;
69 78
70 MessageLoop message_loop_; 79 MessageLoop message_loop_;
71 TestBrowserContext browser_context_; 80 TestBrowserContext browser_context_;
72 81
73 // Gets deleted when the last RWH in the "process" gets destroyed. 82 // Gets deleted when the last RWH in the "process" gets destroyed.
74 MockRenderProcessHostFactory process_factory_; 83 MockRenderProcessHostFactory process_factory_;
84 MockRenderWidgetHostDelegate delegate_;
75 RenderWidgetHostImpl widget_; 85 RenderWidgetHostImpl widget_;
76 86
77 base::Thread thread_; 87 base::Thread thread_;
78 }; 88 };
79 89
80 //////////////////////////////////////////////////////////////////////////////// 90 ////////////////////////////////////////////////////////////////////////////////
81 91
82 // Helper class that Start()s and Stop()s a thread according to the scope of the 92 // Helper class that Start()s and Stop()s a thread according to the scope of the
83 // object. 93 // object.
84 class ScopedTestingThread { 94 class ScopedTestingThread {
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 TEST_F(TextInputClientMacTest, TimeoutSubstring) { 224 TEST_F(TextInputClientMacTest, TimeoutSubstring) {
215 NSAttributedString* string = service()->GetAttributedSubstringFromRange( 225 NSAttributedString* string = service()->GetAttributedSubstringFromRange(
216 widget(), NSMakeRange(0, 32)); 226 widget(), NSMakeRange(0, 32));
217 EXPECT_EQ(nil, string); 227 EXPECT_EQ(nil, string);
218 EXPECT_EQ(1U, ipc_sink().message_count()); 228 EXPECT_EQ(1U, ipc_sink().message_count());
219 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( 229 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching(
220 TextInputClientMsg_StringForRange::ID)); 230 TextInputClientMsg_StringForRange::ID));
221 } 231 }
222 232
223 } // namespace 233 } // namespace
OLDNEW
« no previous file with comments | « content/browser/renderer_host/test_render_view_host.cc ('k') | content/browser/web_contents/interstitial_page_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698