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

Unified Diff: content/browser/renderer_host/render_widget_host_view_mac_unittest.mm

Issue 2228633005: Cancel composition on RenderWidgetHostCocoaView after a child frame's RWHV receives the correspondi… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added a unit test Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.mm ('k') | content/test/test_render_view_host.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/renderer_host/render_widget_host_view_mac_unittest.mm
diff --git a/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm b/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm
index a177cc0b8bfc21f889b82e8a258c6a0d35196c5d..83053927b9222292587668b855f769b9a7abb343 100644
--- a/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm
+++ b/content/browser/renderer_host/render_widget_host_view_mac_unittest.mm
@@ -1253,4 +1253,31 @@ TEST_F(RenderWidgetHostViewMacTest, EventLatencyOSMouseWheelHistogram) {
host->ShutdownAndDestroyWidget(true);
}
+// This test creates a test view to mimic a child frame's view and verifies that
+// calling ImeCancelComposition on either the child view or the tab's view will
+// always lead to a call to cancelComposition on the cocoa view.
+TEST_F(RenderWidgetHostViewMacTest, ImeCancelCompositionForAllViews) {
+ TestRenderWidgetHostView* child_view =
+ new TestRenderWidgetHostView(rvh()->GetWidget());
+ // Set the marked test on cocoa view.
+ NSString* text = [[NSString alloc] initWithString:@"sample text"];
+ NSRange selectedRange = NSMakeRange(0, 1);
+ NSRange replacementRange = NSMakeRange(0, 1);
+ // Make Cocoa view assume there is marked text.
+ [rwhv_cocoa_ setMarkedText:text
+ selectedRange:selectedRange
+ replacementRange:replacementRange];
+ EXPECT_TRUE([rwhv_cocoa_ hasMarkedText]);
+ child_view->ImeCancelComposition();
+ EXPECT_FALSE([rwhv_cocoa_ hasMarkedText]);
+
+ // Repeat for the tab's view.
+ [rwhv_cocoa_ setMarkedText:text
+ selectedRange:selectedRange
+ replacementRange:replacementRange];
+ EXPECT_TRUE([rwhv_cocoa_ hasMarkedText]);
+ rwhv_mac_->ImeCancelComposition();
+ EXPECT_FALSE([rwhv_cocoa_ hasMarkedText]);
+}
+
} // namespace content
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.mm ('k') | content/test/test_render_view_host.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698