OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/renderer_host/text_input_client_mac.h" | 5 #import "chrome/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 "chrome/common/text_input_client_messages.h" | 10 #include "chrome/common/text_input_client_messages.h" |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 | 99 |
100 TEST_F(TextInputClientMacTest, TimeoutCharacterIndex) { | 100 TEST_F(TextInputClientMacTest, TimeoutCharacterIndex) { |
101 NSUInteger index = service()->GetCharacterIndexAtPoint( | 101 NSUInteger index = service()->GetCharacterIndexAtPoint( |
102 widget(), gfx::Point(2, 2)); | 102 widget(), gfx::Point(2, 2)); |
103 EXPECT_EQ(1U, ipc_sink().message_count()); | 103 EXPECT_EQ(1U, ipc_sink().message_count()); |
104 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( | 104 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( |
105 TextInputClientMsg_CharacterIndexForPoint::ID)); | 105 TextInputClientMsg_CharacterIndexForPoint::ID)); |
106 EXPECT_EQ(NSNotFound, index); | 106 EXPECT_EQ(NSNotFound, index); |
107 } | 107 } |
108 | 108 |
| 109 TEST_F(TextInputClientMacTest, NotFoundCharacterIndex) { |
| 110 ScopedTestingThread thread(this); |
| 111 const NSUInteger kNotFoundValue = static_cast<NSUInteger>(-1); |
| 112 |
| 113 PostTask(base::Bind(&TextInputClientMac::SetCharacterIndexAndSignal, |
| 114 base::Unretained(service()), kNotFoundValue)); |
| 115 NSUInteger index = service()->GetCharacterIndexAtPoint( |
| 116 widget(), gfx::Point(2, 2)); |
| 117 |
| 118 EXPECT_EQ(1U, ipc_sink().message_count()); |
| 119 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( |
| 120 TextInputClientMsg_CharacterIndexForPoint::ID)); |
| 121 EXPECT_EQ(NSNotFound, index); |
| 122 } |
| 123 |
109 TEST_F(TextInputClientMacTest, GetRectForRange) { | 124 TEST_F(TextInputClientMacTest, GetRectForRange) { |
110 ScopedTestingThread thread(this); | 125 ScopedTestingThread thread(this); |
111 const NSRect kSuccessValue = NSMakeRect(42, 43, 44, 45); | 126 const NSRect kSuccessValue = NSMakeRect(42, 43, 44, 45); |
112 | 127 |
113 PostTask(base::Bind(&TextInputClientMac::SetFirstRectAndSignal, | 128 PostTask(base::Bind(&TextInputClientMac::SetFirstRectAndSignal, |
114 base::Unretained(service()), kSuccessValue)); | 129 base::Unretained(service()), kSuccessValue)); |
115 NSRect rect = service()->GetFirstRectForRange(widget(), NSMakeRange(0, 32)); | 130 NSRect rect = service()->GetFirstRectForRange(widget(), NSMakeRange(0, 32)); |
116 | 131 |
117 EXPECT_EQ(1U, ipc_sink().message_count()); | 132 EXPECT_EQ(1U, ipc_sink().message_count()); |
118 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( | 133 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 TEST_F(TextInputClientMacTest, TimeoutSubstring) { | 167 TEST_F(TextInputClientMacTest, TimeoutSubstring) { |
153 NSAttributedString* string = service()->GetAttributedSubstringFromRange( | 168 NSAttributedString* string = service()->GetAttributedSubstringFromRange( |
154 widget(), NSMakeRange(0, 32)); | 169 widget(), NSMakeRange(0, 32)); |
155 EXPECT_EQ(nil, string); | 170 EXPECT_EQ(nil, string); |
156 EXPECT_EQ(1U, ipc_sink().message_count()); | 171 EXPECT_EQ(1U, ipc_sink().message_count()); |
157 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( | 172 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( |
158 TextInputClientMsg_StringForRange::ID)); | 173 TextInputClientMsg_StringForRange::ID)); |
159 } | 174 } |
160 | 175 |
161 } // namespace | 176 } // namespace |
OLD | NEW |