| 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 #include "content/browser/renderer_host/render_widget_host_view_mac.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_mac.h" |
| 6 | 6 |
| 7 #include <Cocoa/Cocoa.h> | 7 #include <Cocoa/Cocoa.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1246 // Send an initial wheel event for scrolling by 3 lines. | 1246 // Send an initial wheel event for scrolling by 3 lines. |
| 1247 // Verify that Event.Latency.OS.MOUSE_WHEEL histogram is computed properly. | 1247 // Verify that Event.Latency.OS.MOUSE_WHEEL histogram is computed properly. |
| 1248 NSEvent* wheelEvent = MockScrollWheelEventWithPhase(@selector(phaseBegan),3); | 1248 NSEvent* wheelEvent = MockScrollWheelEventWithPhase(@selector(phaseBegan),3); |
| 1249 [view->cocoa_view() scrollWheel:wheelEvent]; | 1249 [view->cocoa_view() scrollWheel:wheelEvent]; |
| 1250 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); | 1250 histogram_tester.ExpectTotalCount("Event.Latency.OS.MOUSE_WHEEL", 1); |
| 1251 | 1251 |
| 1252 // Clean up. | 1252 // Clean up. |
| 1253 host->ShutdownAndDestroyWidget(true); | 1253 host->ShutdownAndDestroyWidget(true); |
| 1254 } | 1254 } |
| 1255 | 1255 |
| 1256 // This test creates a test view to mimic a child frame's view and verifies that |
| 1257 // calling ImeCancelComposition on either the child view or the tab's view will |
| 1258 // always lead to a call to cancelComposition on the cocoa view. |
| 1259 TEST_F(RenderWidgetHostViewMacTest, ImeCancelCompositionForAllViews) { |
| 1260 TestRenderWidgetHostView* child_view = |
| 1261 new TestRenderWidgetHostView(rvh()->GetWidget()); |
| 1262 // Set the marked test on cocoa view. |
| 1263 NSString* text = [[NSString alloc] initWithString:@"sample text"]; |
| 1264 NSRange selectedRange = NSMakeRange(0, 1); |
| 1265 NSRange replacementRange = NSMakeRange(0, 1); |
| 1266 // Make Cocoa view assume there is marked text. |
| 1267 [rwhv_cocoa_ setMarkedText:text |
| 1268 selectedRange:selectedRange |
| 1269 replacementRange:replacementRange]; |
| 1270 EXPECT_TRUE([rwhv_cocoa_ hasMarkedText]); |
| 1271 child_view->ImeCancelComposition(); |
| 1272 EXPECT_FALSE([rwhv_cocoa_ hasMarkedText]); |
| 1273 |
| 1274 // Repeat for the tab's view. |
| 1275 [rwhv_cocoa_ setMarkedText:text |
| 1276 selectedRange:selectedRange |
| 1277 replacementRange:replacementRange]; |
| 1278 EXPECT_TRUE([rwhv_cocoa_ hasMarkedText]); |
| 1279 rwhv_mac_->ImeCancelComposition(); |
| 1280 EXPECT_FALSE([rwhv_cocoa_ hasMarkedText]); |
| 1281 } |
| 1282 |
| 1256 } // namespace content | 1283 } // namespace content |
| OLD | NEW |