| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 TEST_F(TextInputClientMacTest, NotFoundCharacterIndex) { | 148 TEST_F(TextInputClientMacTest, NotFoundCharacterIndex) { |
| 149 ScopedTestingThread thread(this); | 149 ScopedTestingThread thread(this); |
| 150 const NSUInteger kPreviousValue = 42; | 150 const NSUInteger kPreviousValue = 42; |
| 151 | 151 |
| 152 // Set an arbitrary value to ensure the index is not |NSNotFound|. | 152 // Set an arbitrary value to ensure the index is not |NSNotFound|. |
| 153 PostTask(FROM_HERE, | 153 PostTask(FROM_HERE, |
| 154 base::Bind(&TextInputClientMac::SetCharacterIndexAndSignal, | 154 base::Bind(&TextInputClientMac::SetCharacterIndexAndSignal, |
| 155 base::Unretained(service()), kPreviousValue)); | 155 base::Unretained(service()), kPreviousValue)); |
| 156 | 156 |
| 157 scoped_refptr<TextInputClientMessageFilter> filter( | 157 scoped_refptr<TextInputClientMessageFilter> filter( |
| 158 new TextInputClientMessageFilter(widget()->GetProcess()->GetID())); | 158 new TextInputClientMessageFilter()); |
| 159 std::unique_ptr<IPC::Message> message( | 159 std::unique_ptr<IPC::Message> message( |
| 160 new TextInputClientReplyMsg_GotCharacterIndexForPoint( | 160 new TextInputClientReplyMsg_GotCharacterIndexForPoint( |
| 161 widget()->GetRoutingID(), UINT32_MAX)); | 161 widget()->GetRoutingID(), UINT32_MAX)); |
| 162 // Set |WTF::notFound| to the index |kTaskDelayMs| after the previous | 162 // Set |WTF::notFound| to the index |kTaskDelayMs| after the previous |
| 163 // setting. | 163 // setting. |
| 164 PostTask(FROM_HERE, | 164 PostTask(FROM_HERE, |
| 165 base::Bind(&CallOnMessageReceived, filter, *message), | 165 base::Bind(&CallOnMessageReceived, filter, *message), |
| 166 base::TimeDelta::FromMilliseconds(kTaskDelayMs) * 2); | 166 base::TimeDelta::FromMilliseconds(kTaskDelayMs) * 2); |
| 167 | 167 |
| 168 NSUInteger index = service()->GetCharacterIndexAtPoint( | 168 NSUInteger index = service()->GetCharacterIndexAtPoint( |
| (...skipping 27 matching lines...) Expand all Loading... |
| 196 | 196 |
| 197 TEST_F(TextInputClientMacTest, TimeoutRectForRange) { | 197 TEST_F(TextInputClientMacTest, TimeoutRectForRange) { |
| 198 NSRect rect = service()->GetFirstRectForRange(widget(), NSMakeRange(0, 32)); | 198 NSRect rect = service()->GetFirstRectForRange(widget(), NSMakeRange(0, 32)); |
| 199 EXPECT_EQ(1U, ipc_sink().message_count()); | 199 EXPECT_EQ(1U, ipc_sink().message_count()); |
| 200 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( | 200 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( |
| 201 TextInputClientMsg_FirstRectForCharacterRange::ID)); | 201 TextInputClientMsg_FirstRectForCharacterRange::ID)); |
| 202 EXPECT_NSEQ(NSZeroRect, rect); | 202 EXPECT_NSEQ(NSZeroRect, rect); |
| 203 } | 203 } |
| 204 | 204 |
| 205 } // namespace content | 205 } // namespace content |
| OLD | NEW |