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

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

Issue 7019033: Revert 86246 - Fix assertion failure in range.mm while examining system dictionary popup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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
« no previous file with comments | « no previous file | chrome/browser/renderer_host/text_input_client_message_filter.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/browser/renderer_host/text_input_client_message_filter.h"
11 #include "chrome/common/text_input_client_messages.h" 10 #include "chrome/common/text_input_client_messages.h"
12 #include "chrome/test/testing_profile.h" 11 #include "chrome/test/testing_profile.h"
13 #include "content/browser/renderer_host/mock_render_process_host.h" 12 #include "content/browser/renderer_host/mock_render_process_host.h"
14 #include "content/browser/renderer_host/render_process_host.h" 13 #include "content/browser/renderer_host/render_process_host.h"
15 #include "content/browser/renderer_host/render_widget_host.h" 14 #include "content/browser/renderer_host/render_widget_host.h"
16 #include "ipc/ipc_test_sink.h" 15 #include "ipc/ipc_test_sink.h"
17 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
18 #include "testing/gtest_mac.h" 17 #include "testing/gtest_mac.h"
19 18
20 namespace { 19 namespace {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 99
101 TEST_F(TextInputClientMacTest, TimeoutCharacterIndex) { 100 TEST_F(TextInputClientMacTest, TimeoutCharacterIndex) {
102 NSUInteger index = service()->GetCharacterIndexAtPoint( 101 NSUInteger index = service()->GetCharacterIndexAtPoint(
103 widget(), gfx::Point(2, 2)); 102 widget(), gfx::Point(2, 2));
104 EXPECT_EQ(1U, ipc_sink().message_count()); 103 EXPECT_EQ(1U, ipc_sink().message_count());
105 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( 104 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching(
106 TextInputClientMsg_CharacterIndexForPoint::ID)); 105 TextInputClientMsg_CharacterIndexForPoint::ID));
107 EXPECT_EQ(NSNotFound, index); 106 EXPECT_EQ(NSNotFound, index);
108 } 107 }
109 108
110 TEST_F(TextInputClientMacTest, NotFoundCharacterIndex) {
111 ScopedTestingThread thread(this);
112 const NSUInteger kPreviousValue = 42;
113 const size_t kNotFoundValue = static_cast<size_t>(-1);
114
115 // Set an arbitrary value to ensure the index is not |NSNotFound|.
116 PostTask(base::Bind(&TextInputClientMac::SetCharacterIndexAndSignal,
117 base::Unretained(service()), kPreviousValue));
118
119 scoped_refptr<TextInputClientMessageFilter> filter(
120 new TextInputClientMessageFilter(widget()->process()->id()));
121 scoped_ptr<IPC::Message> message(
122 new TextInputClientReplyMsg_GotCharacterIndexForPoint(
123 widget()->routing_id(), kNotFoundValue));
124 bool message_ok = true;
125 PostTask(base::Bind(&TextInputClientMessageFilter::OnMessageReceived,
126 filter.get(), *message, &message_ok));
127
128 NSUInteger index = service()->GetCharacterIndexAtPoint(
129 widget(), gfx::Point(2, 2));
130 EXPECT_EQ(1U, ipc_sink().message_count());
131 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching(
132 TextInputClientMsg_CharacterIndexForPoint::ID));
133 EXPECT_EQ(NSNotFound, index);
134 }
135
136 TEST_F(TextInputClientMacTest, GetRectForRange) { 109 TEST_F(TextInputClientMacTest, GetRectForRange) {
137 ScopedTestingThread thread(this); 110 ScopedTestingThread thread(this);
138 const NSRect kSuccessValue = NSMakeRect(42, 43, 44, 45); 111 const NSRect kSuccessValue = NSMakeRect(42, 43, 44, 45);
139 112
140 PostTask(base::Bind(&TextInputClientMac::SetFirstRectAndSignal, 113 PostTask(base::Bind(&TextInputClientMac::SetFirstRectAndSignal,
141 base::Unretained(service()), kSuccessValue)); 114 base::Unretained(service()), kSuccessValue));
142 NSRect rect = service()->GetFirstRectForRange(widget(), NSMakeRange(0, 32)); 115 NSRect rect = service()->GetFirstRectForRange(widget(), NSMakeRange(0, 32));
143 116
144 EXPECT_EQ(1U, ipc_sink().message_count()); 117 EXPECT_EQ(1U, ipc_sink().message_count());
145 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( 118 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching(
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 TEST_F(TextInputClientMacTest, TimeoutSubstring) { 152 TEST_F(TextInputClientMacTest, TimeoutSubstring) {
180 NSAttributedString* string = service()->GetAttributedSubstringFromRange( 153 NSAttributedString* string = service()->GetAttributedSubstringFromRange(
181 widget(), NSMakeRange(0, 32)); 154 widget(), NSMakeRange(0, 32));
182 EXPECT_EQ(nil, string); 155 EXPECT_EQ(nil, string);
183 EXPECT_EQ(1U, ipc_sink().message_count()); 156 EXPECT_EQ(1U, ipc_sink().message_count());
184 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( 157 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching(
185 TextInputClientMsg_StringForRange::ID)); 158 TextInputClientMsg_StringForRange::ID));
186 } 159 }
187 160
188 } // namespace 161 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/renderer_host/text_input_client_message_filter.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698