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

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

Issue 1357883002: Mac: Fix a crash in TextInputClientMac::GetFirstRectForRange() likely during tab closure (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: cancelComposition, test Created 5 years, 3 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') | no next file » | 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 ceedad6ef350a9e0ea8e5bab3db3cc9014a07aa9..885531e860e075b2b3c7eeca3767767999c24cd4 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
@@ -27,6 +27,7 @@
#include "content/test/test_render_view_host.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "testing/gtest_mac.h"
#import "third_party/ocmock/OCMock/OCMock.h"
#import "third_party/ocmock/ocmock_extensions.h"
#include "ui/events/test/cocoa_test_event_utils.h"
@@ -234,7 +235,12 @@ class RenderWidgetHostViewMacTest : public RenderViewHostImplTestHarness {
base::MessageLoop::current()->RunUntilIdle();
pool_.Recycle();
}
- protected:
+
+ void DestroyHostViewRetainCocoaView() {
+ test_rvh()->SetView(nullptr);
+ rwhv_mac_->Destroy();
+ }
+
private:
// This class isn't derived from PlatformTest.
base::mac::ScopedNSAutoreleasePool pool_;
@@ -660,6 +666,31 @@ TEST_F(RenderWidgetHostViewMacTest, UpdateCompositionMultilineCase) {
gfx::Rect(NSRectToCGRect(rect)));
}
+// Check that events coming from AppKit via -[NSTextInputClient
+// firstRectForCharacterRange:actualRange] are handled in a sane manner if they
+// arrive after the C++ RenderWidgetHostView is destroyed.
+TEST_F(RenderWidgetHostViewMacTest, CompositionEventAfterDestroy) {
+ // The test view isn't in an NSWindow to perform the final coordinate
+ // conversion, so use an origin of 0,0, but verify the size.
+ const gfx::Rect composition_bounds(0, 0, 30, 40);
+ const gfx::Range range(0, 1);
+ rwhv_mac_->ImeCompositionRangeChanged(
+ range, std::vector<gfx::Rect>(1, composition_bounds));
+
+ NSRange actual_range = NSMakeRange(0, 0);
+ NSRect rect = [rwhv_cocoa_ firstRectForCharacterRange:range.ToNSRange()
+ actualRange:&actual_range];
+ EXPECT_NSEQ(NSMakeRect(0, 0, 30, 40), rect);
+ EXPECT_EQ(range, gfx::Range(actual_range));
+
+ DestroyHostViewRetainCocoaView();
+ actual_range = NSMakeRange(0, 0);
+ rect = [rwhv_cocoa_ firstRectForCharacterRange:range.ToNSRange()
+ actualRange:&actual_range];
+ EXPECT_NSEQ(NSZeroRect, rect);
+ EXPECT_EQ(gfx::Range(), gfx::Range(actual_range));
+}
+
// Verify that |SetActive()| calls |RenderWidgetHostImpl::Blur()| and
// |RenderWidgetHostImp::Focus()|.
TEST_F(RenderWidgetHostViewMacTest, BlurAndFocusOnSetActive) {
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_mac.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698