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

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

Issue 292443004: Remove IPC_BEGIN_MESSAGE_MAP_EX macro since r270839 made all bad IPCs kill their child processes. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 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/message_loop.h" 8 #include "base/message_loop/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 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 thread_.Stop(); 97 thread_.Stop();
98 } 98 }
99 99
100 private: 100 private:
101 base::Thread& thread_; 101 base::Thread& thread_;
102 }; 102 };
103 103
104 // Adapter for OnMessageReceived to ignore return type so it can be posted 104 // Adapter for OnMessageReceived to ignore return type so it can be posted
105 // to a MessageLoop. 105 // to a MessageLoop.
106 void CallOnMessageReceived(scoped_refptr<TextInputClientMessageFilter> filter, 106 void CallOnMessageReceived(scoped_refptr<TextInputClientMessageFilter> filter,
107 const IPC::Message& message, 107 const IPC::Message& message) {
108 bool* message_was_ok) { 108 filter->OnMessageReceived(message);
109 filter->OnMessageReceived(message, message_was_ok);
110 } 109 }
111 110
112 } // namespace 111 } // namespace
113 112
114 // Test Cases ////////////////////////////////////////////////////////////////// 113 // Test Cases //////////////////////////////////////////////////////////////////
115 114
116 TEST_F(TextInputClientMacTest, GetCharacterIndex) { 115 TEST_F(TextInputClientMacTest, GetCharacterIndex) {
117 ScopedTestingThread thread(this); 116 ScopedTestingThread thread(this);
118 const NSUInteger kSuccessValue = 42; 117 const NSUInteger kSuccessValue = 42;
119 118
(...skipping 26 matching lines...) Expand all
146 // Set an arbitrary value to ensure the index is not |NSNotFound|. 145 // Set an arbitrary value to ensure the index is not |NSNotFound|.
147 PostTask(FROM_HERE, 146 PostTask(FROM_HERE,
148 base::Bind(&TextInputClientMac::SetCharacterIndexAndSignal, 147 base::Bind(&TextInputClientMac::SetCharacterIndexAndSignal,
149 base::Unretained(service()), kPreviousValue)); 148 base::Unretained(service()), kPreviousValue));
150 149
151 scoped_refptr<TextInputClientMessageFilter> filter( 150 scoped_refptr<TextInputClientMessageFilter> filter(
152 new TextInputClientMessageFilter(widget()->GetProcess()->GetID())); 151 new TextInputClientMessageFilter(widget()->GetProcess()->GetID()));
153 scoped_ptr<IPC::Message> message( 152 scoped_ptr<IPC::Message> message(
154 new TextInputClientReplyMsg_GotCharacterIndexForPoint( 153 new TextInputClientReplyMsg_GotCharacterIndexForPoint(
155 widget()->GetRoutingID(), kNotFoundValue)); 154 widget()->GetRoutingID(), kNotFoundValue));
156 bool message_ok = true;
157 // Set |WTF::notFound| to the index |kTaskDelayMs| after the previous 155 // Set |WTF::notFound| to the index |kTaskDelayMs| after the previous
158 // setting. 156 // setting.
159 PostTask(FROM_HERE, 157 PostTask(FROM_HERE,
160 base::Bind(&CallOnMessageReceived, filter, *message, &message_ok), 158 base::Bind(&CallOnMessageReceived, filter, *message),
161 base::TimeDelta::FromMilliseconds(kTaskDelayMs) * 2); 159 base::TimeDelta::FromMilliseconds(kTaskDelayMs) * 2);
162 160
163 NSUInteger index = service()->GetCharacterIndexAtPoint( 161 NSUInteger index = service()->GetCharacterIndexAtPoint(
164 widget(), gfx::Point(2, 2)); 162 widget(), gfx::Point(2, 2));
165 EXPECT_EQ(kPreviousValue, index); 163 EXPECT_EQ(kPreviousValue, index);
166 index = service()->GetCharacterIndexAtPoint(widget(), gfx::Point(2, 2)); 164 index = service()->GetCharacterIndexAtPoint(widget(), gfx::Point(2, 2));
167 EXPECT_EQ(NSNotFound, index); 165 EXPECT_EQ(NSNotFound, index);
168 166
169 EXPECT_EQ(2U, ipc_sink().message_count()); 167 EXPECT_EQ(2U, ipc_sink().message_count());
170 for (size_t i = 0; i < ipc_sink().message_count(); ++i) { 168 for (size_t i = 0; i < ipc_sink().message_count(); ++i) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 TEST_F(TextInputClientMacTest, TimeoutSubstring) { 221 TEST_F(TextInputClientMacTest, TimeoutSubstring) {
224 NSAttributedString* string = service()->GetAttributedSubstringFromRange( 222 NSAttributedString* string = service()->GetAttributedSubstringFromRange(
225 widget(), NSMakeRange(0, 32)); 223 widget(), NSMakeRange(0, 32));
226 EXPECT_EQ(nil, string); 224 EXPECT_EQ(nil, string);
227 EXPECT_EQ(1U, ipc_sink().message_count()); 225 EXPECT_EQ(1U, ipc_sink().message_count());
228 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( 226 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching(
229 TextInputClientMsg_StringForRange::ID)); 227 TextInputClientMsg_StringForRange::ID));
230 } 228 }
231 229
232 } // namespace content 230 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698