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 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( | 196 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( |
197 TextInputClientMsg_FirstRectForCharacterRange::ID)); | 197 TextInputClientMsg_FirstRectForCharacterRange::ID)); |
198 EXPECT_TRUE(NSEqualRects(NSZeroRect, rect)); | 198 EXPECT_TRUE(NSEqualRects(NSZeroRect, rect)); |
199 } | 199 } |
200 | 200 |
201 TEST_F(TextInputClientMacTest, GetSubstring) { | 201 TEST_F(TextInputClientMacTest, GetSubstring) { |
202 ScopedTestingThread thread(this); | 202 ScopedTestingThread thread(this); |
203 NSDictionary* attributes = | 203 NSDictionary* attributes = |
204 [NSDictionary dictionaryWithObject:[NSColor purpleColor] | 204 [NSDictionary dictionaryWithObject:[NSColor purpleColor] |
205 forKey:NSForegroundColorAttributeName]; | 205 forKey:NSForegroundColorAttributeName]; |
206 scoped_nsobject<NSAttributedString> kSuccessValue( | 206 base::scoped_nsobject<NSAttributedString> kSuccessValue( |
207 [[NSAttributedString alloc] initWithString:@"Barney is a purple dinosaur" | 207 [[NSAttributedString alloc] initWithString:@"Barney is a purple dinosaur" |
208 attributes:attributes]); | 208 attributes:attributes]); |
209 | 209 |
210 PostTask(FROM_HERE, | 210 PostTask(FROM_HERE, |
211 base::Bind(&TextInputClientMac::SetSubstringAndSignal, | 211 base::Bind(&TextInputClientMac::SetSubstringAndSignal, |
212 base::Unretained(service()), | 212 base::Unretained(service()), |
213 base::Unretained(kSuccessValue.get()))); | 213 base::Unretained(kSuccessValue.get()))); |
214 NSAttributedString* string = service()->GetAttributedSubstringFromRange( | 214 NSAttributedString* string = service()->GetAttributedSubstringFromRange( |
215 widget(), NSMakeRange(0, 32)); | 215 widget(), NSMakeRange(0, 32)); |
216 | 216 |
217 EXPECT_NSEQ(kSuccessValue, string); | 217 EXPECT_NSEQ(kSuccessValue, string); |
218 EXPECT_NE(kSuccessValue.get(), string); // |string| should be a copy. | 218 EXPECT_NE(kSuccessValue.get(), string); // |string| should be a copy. |
219 EXPECT_EQ(1U, ipc_sink().message_count()); | 219 EXPECT_EQ(1U, ipc_sink().message_count()); |
220 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( | 220 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( |
221 TextInputClientMsg_StringForRange::ID)); | 221 TextInputClientMsg_StringForRange::ID)); |
222 } | 222 } |
223 | 223 |
224 TEST_F(TextInputClientMacTest, TimeoutSubstring) { | 224 TEST_F(TextInputClientMacTest, TimeoutSubstring) { |
225 NSAttributedString* string = service()->GetAttributedSubstringFromRange( | 225 NSAttributedString* string = service()->GetAttributedSubstringFromRange( |
226 widget(), NSMakeRange(0, 32)); | 226 widget(), NSMakeRange(0, 32)); |
227 EXPECT_EQ(nil, string); | 227 EXPECT_EQ(nil, string); |
228 EXPECT_EQ(1U, ipc_sink().message_count()); | 228 EXPECT_EQ(1U, ipc_sink().message_count()); |
229 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( | 229 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( |
230 TextInputClientMsg_StringForRange::ID)); | 230 TextInputClientMsg_StringForRange::ID)); |
231 } | 231 } |
232 | 232 |
233 } // namespace content | 233 } // namespace content |
OLD | NEW |