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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_mac_unittest.mm

Issue 63253002: Rename WebKit namespace to blink (part 3) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 1 month 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) 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 "base/mac/mac_util.h" 7 #include "base/mac/mac_util.h"
8 #include "base/mac/scoped_nsautorelease_pool.h" 8 #include "base/mac/scoped_nsautorelease_pool.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "content/browser/browser_thread_impl.h" 10 #include "content/browser/browser_thread_impl.h"
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 const size_t kDummyOffset = 0; 322 const size_t kDummyOffset = 0;
323 323
324 gfx::Rect caret_rect(10, 11, 0, 10); 324 gfx::Rect caret_rect(10, 11, 0, 10);
325 gfx::Range caret_range(0, 0); 325 gfx::Range caret_range(0, 0);
326 ViewHostMsg_SelectionBounds_Params params; 326 ViewHostMsg_SelectionBounds_Params params;
327 327
328 NSRect rect; 328 NSRect rect;
329 NSRange actual_range; 329 NSRange actual_range;
330 rwhv_mac_->SelectionChanged(kDummyString, kDummyOffset, caret_range); 330 rwhv_mac_->SelectionChanged(kDummyString, kDummyOffset, caret_range);
331 params.anchor_rect = params.focus_rect = caret_rect; 331 params.anchor_rect = params.focus_rect = caret_rect;
332 params.anchor_dir = params.focus_dir = WebKit::WebTextDirectionLeftToRight; 332 params.anchor_dir = params.focus_dir = blink::WebTextDirectionLeftToRight;
333 rwhv_mac_->SelectionBoundsChanged(params); 333 rwhv_mac_->SelectionBoundsChanged(params);
334 EXPECT_TRUE(rwhv_mac_->GetCachedFirstRectForCharacterRange( 334 EXPECT_TRUE(rwhv_mac_->GetCachedFirstRectForCharacterRange(
335 caret_range.ToNSRange(), 335 caret_range.ToNSRange(),
336 &rect, 336 &rect,
337 &actual_range)); 337 &actual_range));
338 EXPECT_EQ(caret_rect, gfx::Rect(NSRectToCGRect(rect))); 338 EXPECT_EQ(caret_rect, gfx::Rect(NSRectToCGRect(rect)));
339 EXPECT_EQ(caret_range, gfx::Range(actual_range)); 339 EXPECT_EQ(caret_range, gfx::Range(actual_range));
340 340
341 EXPECT_FALSE(rwhv_mac_->GetCachedFirstRectForCharacterRange( 341 EXPECT_FALSE(rwhv_mac_->GetCachedFirstRectForCharacterRange(
342 gfx::Range(0, 1).ToNSRange(), 342 gfx::Range(0, 1).ToNSRange(),
(...skipping 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
704 RenderWidgetHostViewMac* view = static_cast<RenderWidgetHostViewMac*>( 704 RenderWidgetHostViewMac* view = static_cast<RenderWidgetHostViewMac*>(
705 RenderWidgetHostView::CreateViewForWidget(host)); 705 RenderWidgetHostView::CreateViewForWidget(host));
706 706
707 // Send an initial wheel event with NSEventPhaseBegan to the view. 707 // Send an initial wheel event with NSEventPhaseBegan to the view.
708 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 0); 708 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 0);
709 [view->cocoa_view() scrollWheel:event1]; 709 [view->cocoa_view() scrollWheel:event1];
710 ASSERT_EQ(1U, process_host->sink().message_count()); 710 ASSERT_EQ(1U, process_host->sink().message_count());
711 711
712 // Send an ACK for the first wheel event, so that the queue will be flushed. 712 // Send an ACK for the first wheel event, so that the queue will be flushed.
713 scoped_ptr<IPC::Message> response(new InputHostMsg_HandleInputEvent_ACK( 713 scoped_ptr<IPC::Message> response(new InputHostMsg_HandleInputEvent_ACK(
714 0, WebKit::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED, 714 0, blink::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_CONSUMED,
715 ui::LatencyInfo())); 715 ui::LatencyInfo()));
716 host->OnMessageReceived(*response); 716 host->OnMessageReceived(*response);
717 717
718 // Post the NSEventPhaseEnded wheel event to NSApp and check whether the 718 // Post the NSEventPhaseEnded wheel event to NSApp and check whether the
719 // render view receives it. 719 // render view receives it.
720 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseEnded), 0); 720 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseEnded), 0);
721 [NSApp postEvent:event2 atStart:NO]; 721 [NSApp postEvent:event2 atStart:NO];
722 base::MessageLoop::current()->RunUntilIdle(); 722 base::MessageLoop::current()->RunUntilIdle();
723 ASSERT_EQ(2U, process_host->sink().message_count()); 723 ASSERT_EQ(2U, process_host->sink().message_count());
724 724
(...skipping 24 matching lines...) Expand all
749 view->SetDelegate(view_delegate.get()); 749 view->SetDelegate(view_delegate.get());
750 750
751 // Send an initial wheel event for scrolling by 3 lines. 751 // Send an initial wheel event for scrolling by 3 lines.
752 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 3); 752 NSEvent* event1 = MockScrollWheelEventWithPhase(@selector(phaseBegan), 3);
753 [view->cocoa_view() scrollWheel:event1]; 753 [view->cocoa_view() scrollWheel:event1];
754 ASSERT_EQ(1U, process_host->sink().message_count()); 754 ASSERT_EQ(1U, process_host->sink().message_count());
755 process_host->sink().ClearMessages(); 755 process_host->sink().ClearMessages();
756 756
757 // Indicate that the wheel event was unhandled. 757 // Indicate that the wheel event was unhandled.
758 scoped_ptr<IPC::Message> response1(new InputHostMsg_HandleInputEvent_ACK(0, 758 scoped_ptr<IPC::Message> response1(new InputHostMsg_HandleInputEvent_ACK(0,
759 WebKit::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_NOT_CONSUMED, 759 blink::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_NOT_CONSUMED,
760 ui::LatencyInfo())); 760 ui::LatencyInfo()));
761 host->OnMessageReceived(*response1); 761 host->OnMessageReceived(*response1);
762 762
763 // Check that the view delegate got an unhandled wheel event. 763 // Check that the view delegate got an unhandled wheel event.
764 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived); 764 ASSERT_EQ(YES, view_delegate.get().unhandledWheelEventReceived);
765 view_delegate.get().unhandledWheelEventReceived = NO; 765 view_delegate.get().unhandledWheelEventReceived = NO;
766 766
767 // Send another wheel event, this time for scrolling by 0 lines (empty event). 767 // Send another wheel event, this time for scrolling by 0 lines (empty event).
768 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseChanged), 0); 768 NSEvent* event2 = MockScrollWheelEventWithPhase(@selector(phaseChanged), 0);
769 [view->cocoa_view() scrollWheel:event2]; 769 [view->cocoa_view() scrollWheel:event2];
770 ASSERT_EQ(1U, process_host->sink().message_count()); 770 ASSERT_EQ(1U, process_host->sink().message_count());
771 771
772 // Indicate that the wheel event was also unhandled. 772 // Indicate that the wheel event was also unhandled.
773 scoped_ptr<IPC::Message> response2(new InputHostMsg_HandleInputEvent_ACK(0, 773 scoped_ptr<IPC::Message> response2(new InputHostMsg_HandleInputEvent_ACK(0,
774 WebKit::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_NOT_CONSUMED, 774 blink::WebInputEvent::MouseWheel, INPUT_EVENT_ACK_STATE_NOT_CONSUMED,
775 ui::LatencyInfo())); 775 ui::LatencyInfo()));
776 host->OnMessageReceived(*response2); 776 host->OnMessageReceived(*response2);
777 777
778 // Check that the view delegate ignored the empty unhandled wheel event. 778 // Check that the view delegate ignored the empty unhandled wheel event.
779 ASSERT_EQ(NO, view_delegate.get().unhandledWheelEventReceived); 779 ASSERT_EQ(NO, view_delegate.get().unhandledWheelEventReceived);
780 780
781 // Clean up. 781 // Clean up.
782 host->Shutdown(); 782 host->Shutdown();
783 } 783 }
784 784
785 } // namespace content 785 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698