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

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

Issue 9473001: Extract minimal RenderViewHost interface for embedders, leaving (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to LKGR. Created 8 years, 9 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/mock_render_process_host.h" 10 #include "content/browser/renderer_host/mock_render_process_host.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 void PostTask(const tracked_objects::Location& from_here, 44 void PostTask(const tracked_objects::Location& from_here,
45 const base::Closure& task, const int64 delay = kTaskDelayMs) { 45 const base::Closure& task, const int64 delay = kTaskDelayMs) {
46 thread_.message_loop()->PostDelayedTask(from_here, task, delay); 46 thread_.message_loop()->PostDelayedTask(from_here, task, delay);
47 } 47 }
48 48
49 RenderWidgetHostImpl* widget() { 49 RenderWidgetHostImpl* widget() {
50 return &widget_; 50 return &widget_;
51 } 51 }
52 52
53 IPC::TestSink& ipc_sink() { 53 IPC::TestSink& ipc_sink() {
54 return static_cast<MockRenderProcessHost*>(widget()->process())->sink(); 54 return static_cast<MockRenderProcessHost*>(widget()->GetProcess())->sink();
55 } 55 }
56 56
57 private: 57 private:
58 friend class ScopedTestingThread; 58 friend class ScopedTestingThread;
59 59
60 MessageLoop message_loop_; 60 MessageLoop message_loop_;
61 TestBrowserContext browser_context_; 61 TestBrowserContext browser_context_;
62 62
63 // Gets deleted when the last RWH in the "process" gets destroyed. 63 // Gets deleted when the last RWH in the "process" gets destroyed.
64 MockRenderProcessHostFactory process_factory_; 64 MockRenderProcessHostFactory process_factory_;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 ScopedTestingThread thread(this); 123 ScopedTestingThread thread(this);
124 const NSUInteger kPreviousValue = 42; 124 const NSUInteger kPreviousValue = 42;
125 const size_t kNotFoundValue = static_cast<size_t>(-1); 125 const size_t kNotFoundValue = static_cast<size_t>(-1);
126 126
127 // Set an arbitrary value to ensure the index is not |NSNotFound|. 127 // Set an arbitrary value to ensure the index is not |NSNotFound|.
128 PostTask(FROM_HERE, 128 PostTask(FROM_HERE,
129 base::Bind(&TextInputClientMac::SetCharacterIndexAndSignal, 129 base::Bind(&TextInputClientMac::SetCharacterIndexAndSignal,
130 base::Unretained(service()), kPreviousValue)); 130 base::Unretained(service()), kPreviousValue));
131 131
132 scoped_refptr<TextInputClientMessageFilter> filter( 132 scoped_refptr<TextInputClientMessageFilter> filter(
133 new TextInputClientMessageFilter(widget()->process()->GetID())); 133 new TextInputClientMessageFilter(widget()->GetProcess()->GetID()));
134 scoped_ptr<IPC::Message> message( 134 scoped_ptr<IPC::Message> message(
135 new TextInputClientReplyMsg_GotCharacterIndexForPoint( 135 new TextInputClientReplyMsg_GotCharacterIndexForPoint(
136 widget()->routing_id(), kNotFoundValue)); 136 widget()->GetRoutingID(), kNotFoundValue));
137 bool message_ok = true; 137 bool message_ok = true;
138 // Set |WTF::notFound| to the index |kTaskDelayMs| after the previous 138 // Set |WTF::notFound| to the index |kTaskDelayMs| after the previous
139 // setting. 139 // setting.
140 PostTask(FROM_HERE, 140 PostTask(FROM_HERE,
141 base::Bind(&CallOnMessageReceived, filter, *message, &message_ok), 141 base::Bind(&CallOnMessageReceived, filter, *message, &message_ok),
142 kTaskDelayMs * 2); 142 kTaskDelayMs * 2);
143 143
144 NSUInteger index = service()->GetCharacterIndexAtPoint( 144 NSUInteger index = service()->GetCharacterIndexAtPoint(
145 widget(), gfx::Point(2, 2)); 145 widget(), gfx::Point(2, 2));
146 EXPECT_EQ(kPreviousValue, index); 146 EXPECT_EQ(kPreviousValue, index);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 TEST_F(TextInputClientMacTest, TimeoutSubstring) { 204 TEST_F(TextInputClientMacTest, TimeoutSubstring) {
205 NSAttributedString* string = service()->GetAttributedSubstringFromRange( 205 NSAttributedString* string = service()->GetAttributedSubstringFromRange(
206 widget(), NSMakeRange(0, 32)); 206 widget(), NSMakeRange(0, 32));
207 EXPECT_EQ(nil, string); 207 EXPECT_EQ(nil, string);
208 EXPECT_EQ(1U, ipc_sink().message_count()); 208 EXPECT_EQ(1U, ipc_sink().message_count());
209 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( 209 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching(
210 TextInputClientMsg_StringForRange::ID)); 210 TextInputClientMsg_StringForRange::ID));
211 } 211 }
212 212
213 } // namespace 213 } // namespace
OLDNEW
« no previous file with comments | « content/browser/renderer_host/text_input_client_mac.mm ('k') | content/browser/speech/speech_input_manager_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698