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

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

Issue 7327007: Moving notification types which are chrome specific to a new header file chrome_notification_type... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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) 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" 10 #include "chrome/browser/renderer_host/text_input_client_message_filter.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 const NSUInteger kSuccessValue = 42; 98 const NSUInteger kSuccessValue = 42;
99 99
100 PostTask(FROM_HERE, 100 PostTask(FROM_HERE,
101 base::Bind(&TextInputClientMac::SetCharacterIndexAndSignal, 101 base::Bind(&TextInputClientMac::SetCharacterIndexAndSignal,
102 base::Unretained(service()), kSuccessValue)); 102 base::Unretained(service()), kSuccessValue));
103 NSUInteger index = service()->GetCharacterIndexAtPoint( 103 NSUInteger index = service()->GetCharacterIndexAtPoint(
104 widget(), gfx::Point(2, 2)); 104 widget(), gfx::Point(2, 2));
105 105
106 EXPECT_EQ(1U, ipc_sink().message_count()); 106 EXPECT_EQ(1U, ipc_sink().message_count());
107 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( 107 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching(
108 TextInputClientMsg_CharacterIndexForPoint::ID)); 108 TextInputClientMsg_CharacterIndexForPocontent::NOTIFICATION_ID));
109 EXPECT_EQ(kSuccessValue, index); 109 EXPECT_EQ(kSuccessValue, index);
110 } 110 }
111 111
112 TEST_F(TextInputClientMacTest, TimeoutCharacterIndex) { 112 TEST_F(TextInputClientMacTest, TimeoutCharacterIndex) {
113 NSUInteger index = service()->GetCharacterIndexAtPoint( 113 NSUInteger index = service()->GetCharacterIndexAtPoint(
114 widget(), gfx::Point(2, 2)); 114 widget(), gfx::Point(2, 2));
115 EXPECT_EQ(1U, ipc_sink().message_count()); 115 EXPECT_EQ(1U, ipc_sink().message_count());
116 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( 116 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching(
117 TextInputClientMsg_CharacterIndexForPoint::ID)); 117 TextInputClientMsg_CharacterIndexForPocontent::NOTIFICATION_ID));
118 EXPECT_EQ(NSNotFound, index); 118 EXPECT_EQ(NSNotFound, index);
119 } 119 }
120 120
121 TEST_F(TextInputClientMacTest, NotFoundCharacterIndex) { 121 TEST_F(TextInputClientMacTest, NotFoundCharacterIndex) {
122 ScopedTestingThread thread(this); 122 ScopedTestingThread thread(this);
123 const NSUInteger kPreviousValue = 42; 123 const NSUInteger kPreviousValue = 42;
124 const size_t kNotFoundValue = static_cast<size_t>(-1); 124 const size_t kNotFoundValue = static_cast<size_t>(-1);
125 125
126 // Set an arbitrary value to ensure the index is not |NSNotFound|. 126 // Set an arbitrary value to ensure the index is not |NSNotFound|.
127 PostTask(FROM_HERE, 127 PostTask(FROM_HERE,
(...skipping 15 matching lines...) Expand all
143 NSUInteger index = service()->GetCharacterIndexAtPoint( 143 NSUInteger index = service()->GetCharacterIndexAtPoint(
144 widget(), gfx::Point(2, 2)); 144 widget(), gfx::Point(2, 2));
145 EXPECT_EQ(kPreviousValue, index); 145 EXPECT_EQ(kPreviousValue, index);
146 index = service()->GetCharacterIndexAtPoint(widget(), gfx::Point(2, 2)); 146 index = service()->GetCharacterIndexAtPoint(widget(), gfx::Point(2, 2));
147 EXPECT_EQ(NSNotFound, index); 147 EXPECT_EQ(NSNotFound, index);
148 148
149 EXPECT_EQ(2U, ipc_sink().message_count()); 149 EXPECT_EQ(2U, ipc_sink().message_count());
150 for (size_t i = 0; i < ipc_sink().message_count(); ++i) { 150 for (size_t i = 0; i < ipc_sink().message_count(); ++i) {
151 const IPC::Message* ipc_message = ipc_sink().GetMessageAt(i); 151 const IPC::Message* ipc_message = ipc_sink().GetMessageAt(i);
152 EXPECT_EQ(ipc_message->type(), 152 EXPECT_EQ(ipc_message->type(),
153 TextInputClientMsg_CharacterIndexForPoint::ID); 153 TextInputClientMsg_CharacterIndexForPocontent::NOTIFICATION_ID);
154 } 154 }
155 } 155 }
156 156
157 TEST_F(TextInputClientMacTest, GetRectForRange) { 157 TEST_F(TextInputClientMacTest, GetRectForRange) {
158 ScopedTestingThread thread(this); 158 ScopedTestingThread thread(this);
159 const NSRect kSuccessValue = NSMakeRect(42, 43, 44, 45); 159 const NSRect kSuccessValue = NSMakeRect(42, 43, 44, 45);
160 160
161 PostTask(FROM_HERE, 161 PostTask(FROM_HERE,
162 base::Bind(&TextInputClientMac::SetFirstRectAndSignal, 162 base::Bind(&TextInputClientMac::SetFirstRectAndSignal,
163 base::Unretained(service()), kSuccessValue)); 163 base::Unretained(service()), kSuccessValue));
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 TEST_F(TextInputClientMacTest, TimeoutSubstring) { 203 TEST_F(TextInputClientMacTest, TimeoutSubstring) {
204 NSAttributedString* string = service()->GetAttributedSubstringFromRange( 204 NSAttributedString* string = service()->GetAttributedSubstringFromRange(
205 widget(), NSMakeRange(0, 32)); 205 widget(), NSMakeRange(0, 32));
206 EXPECT_EQ(nil, string); 206 EXPECT_EQ(nil, string);
207 EXPECT_EQ(1U, ipc_sink().message_count()); 207 EXPECT_EQ(1U, ipc_sink().message_count());
208 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching( 208 EXPECT_TRUE(ipc_sink().GetUniqueMessageMatching(
209 TextInputClientMsg_StringForRange::ID)); 209 TextInputClientMsg_StringForRange::ID));
210 } 210 }
211 211
212 } // namespace 212 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698