| 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 | 10 |
| (...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 721 EXPECT_EQ(gfx::Range(10, 20), gfx::Range(actual_range)); | 721 EXPECT_EQ(gfx::Range(10, 20), gfx::Range(actual_range)); |
| 722 EXPECT_EQ( | 722 EXPECT_EQ( |
| 723 GetExpectedRect(kOrigin, kBoundsUnit, gfx::Range(0, 10), 1), | 723 GetExpectedRect(kOrigin, kBoundsUnit, gfx::Range(0, 10), 1), |
| 724 gfx::Rect(NSRectToCGRect(rect))); | 724 gfx::Rect(NSRectToCGRect(rect))); |
| 725 } | 725 } |
| 726 | 726 |
| 727 // Check that events coming from AppKit via -[NSTextInputClient | 727 // Check that events coming from AppKit via -[NSTextInputClient |
| 728 // firstRectForCharacterRange:actualRange] are handled in a sane manner if they | 728 // firstRectForCharacterRange:actualRange] are handled in a sane manner if they |
| 729 // arrive after the C++ RenderWidgetHostView is destroyed. | 729 // arrive after the C++ RenderWidgetHostView is destroyed. |
| 730 TEST_F(RenderWidgetHostViewMacTest, CompositionEventAfterDestroy) { | 730 TEST_F(RenderWidgetHostViewMacTest, CompositionEventAfterDestroy) { |
| 731 // The test view isn't in an NSWindow to perform the final coordinate | |
| 732 // conversion, so use an origin of 0,0, but verify the size. | |
| 733 const gfx::Rect composition_bounds(0, 0, 30, 40); | 731 const gfx::Rect composition_bounds(0, 0, 30, 40); |
| 734 const gfx::Range range(0, 1); | 732 const gfx::Range range(0, 1); |
| 735 rwhv_mac_->ImeCompositionRangeChanged( | 733 rwhv_mac_->ImeCompositionRangeChanged( |
| 736 range, std::vector<gfx::Rect>(1, composition_bounds)); | 734 range, std::vector<gfx::Rect>(1, composition_bounds)); |
| 737 | 735 |
| 738 NSRange actual_range = NSMakeRange(0, 0); | 736 NSRange actual_range = NSMakeRange(0, 0); |
| 737 |
| 738 base::scoped_nsobject<CocoaTestHelperWindow> window( |
| 739 [[CocoaTestHelperWindow alloc] init]); |
| 740 [[window contentView] addSubview:rwhv_cocoa_]; |
| 741 [rwhv_cocoa_ setFrame:NSMakeRect(0, 0, 400, 400)]; |
| 742 |
| 739 NSRect rect = [rwhv_cocoa_ firstRectForCharacterRange:range.ToNSRange() | 743 NSRect rect = [rwhv_cocoa_ firstRectForCharacterRange:range.ToNSRange() |
| 740 actualRange:&actual_range]; | 744 actualRange:&actual_range]; |
| 741 EXPECT_NSEQ(NSMakeRect(0, 0, 30, 40), rect); | 745 EXPECT_EQ(30, rect.size.width); |
| 746 EXPECT_EQ(40, rect.size.height); |
| 742 EXPECT_EQ(range, gfx::Range(actual_range)); | 747 EXPECT_EQ(range, gfx::Range(actual_range)); |
| 743 | 748 |
| 744 DestroyHostViewRetainCocoaView(); | 749 DestroyHostViewRetainCocoaView(); |
| 745 actual_range = NSMakeRange(0, 0); | 750 actual_range = NSMakeRange(0, 0); |
| 746 rect = [rwhv_cocoa_ firstRectForCharacterRange:range.ToNSRange() | 751 rect = [rwhv_cocoa_ firstRectForCharacterRange:range.ToNSRange() |
| 747 actualRange:&actual_range]; | 752 actualRange:&actual_range]; |
| 748 EXPECT_NSEQ(NSZeroRect, rect); | 753 EXPECT_NSEQ(NSZeroRect, rect); |
| 749 EXPECT_EQ(gfx::Range(), gfx::Range(actual_range)); | 754 EXPECT_EQ(gfx::Range(), gfx::Range(actual_range)); |
| 750 } | 755 } |
| 751 | 756 |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 EXPECT_EQ(1U, process_host_->sink().message_count()); | 1135 EXPECT_EQ(1U, process_host_->sink().message_count()); |
| 1131 process_host_->sink().ClearMessages(); | 1136 process_host_->sink().ClearMessages(); |
| 1132 } | 1137 } |
| 1133 | 1138 |
| 1134 // Clean up. | 1139 // Clean up. |
| 1135 host->ShutdownAndDestroyWidget(true); | 1140 host->ShutdownAndDestroyWidget(true); |
| 1136 } | 1141 } |
| 1137 | 1142 |
| 1138 | 1143 |
| 1139 } // namespace content | 1144 } // namespace content |
| OLD | NEW |