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

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura_unittest.cc

Issue 614553002: Make sure the IME composition is canceled before forwarding the mouse pressed event. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: added an unit test. Created 6 years, 2 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 unified diff | Download patch
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/shared_memory.h" 9 #include "base/memory/shared_memory.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after
836 } 836 }
837 // highlighted range 837 // highlighted range
838 EXPECT_EQ(4, params.c) << "Should be the same to the caret pos"; 838 EXPECT_EQ(4, params.c) << "Should be the same to the caret pos";
839 EXPECT_EQ(4, params.d) << "Should be the same to the caret pos"; 839 EXPECT_EQ(4, params.d) << "Should be the same to the caret pos";
840 } 840 }
841 841
842 view_->ImeCancelComposition(); 842 view_->ImeCancelComposition();
843 EXPECT_FALSE(view_->has_composition_text_); 843 EXPECT_FALSE(view_->has_composition_text_);
844 } 844 }
845 845
846 // Checks that sequence of IME-composition-event and mouse-event when mouse
847 // clicking to cancel the composition.
848 TEST_F(RenderWidgetHostViewAuraTest, FinishCompositionByMouse) {
849 view_->InitAsChild(NULL);
850 view_->Show();
851
852 ui::CompositionText composition_text;
853 composition_text.text = base::ASCIIToUTF16("|a|b");
854
855 // Focused segment
856 composition_text.underlines.push_back(
857 ui::CompositionUnderline(0, 3, 0xff000000, true, 0x78563412));
858
859 // Non-focused segment, with different background color.
860 composition_text.underlines.push_back(
861 ui::CompositionUnderline(3, 4, 0xff000000, false, 0xefcdab90));
862
863 // Caret is at the end. (This emulates Japanese MSIME 2007 and later)
864 composition_text.selection = gfx::Range(4);
865
866 view_->SetCompositionText(composition_text);
867 EXPECT_TRUE(view_->has_composition_text_);
868 sink_->ClearMessages();
869
870 // Simulates the mouse press.
871 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED,
872 gfx::Point(), gfx::Point(),
873 ui::EF_LEFT_MOUSE_BUTTON, 0);
874 view_->OnMouseEvent(&mouse_event);
875
876 EXPECT_FALSE(view_->has_composition_text_);
877
878 EXPECT_EQ(2U, sink_->message_count());
879
880 if (sink_->message_count() == 2) {
881 // Verify mouse event happens after the confirm-composition event.
882 EXPECT_EQ(InputMsg_ImeConfirmComposition::ID,
883 sink_->GetMessageAt(0)->type());
884 EXPECT_EQ(InputMsg_HandleInputEvent::ID,
885 sink_->GetMessageAt(1)->type());
886 }
887 }
888
846 // Checks that touch-event state is maintained correctly. 889 // Checks that touch-event state is maintained correctly.
847 TEST_F(RenderWidgetHostViewAuraTest, TouchEventState) { 890 TEST_F(RenderWidgetHostViewAuraTest, TouchEventState) {
848 view_->InitAsChild(NULL); 891 view_->InitAsChild(NULL);
849 view_->Show(); 892 view_->Show();
850 893
851 // Start with no touch-event handler in the renderer. 894 // Start with no touch-event handler in the renderer.
852 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false)); 895 widget_host_->OnMessageReceived(ViewHostMsg_HasTouchEventHandlers(0, false));
853 EXPECT_FALSE(widget_host_->ShouldForwardTouchEvent()); 896 EXPECT_FALSE(widget_host_->ShouldForwardTouchEvent());
854 897
855 ui::TouchEvent press(ui::ET_TOUCH_PRESSED, 898 ui::TouchEvent press(ui::ET_TOUCH_PRESSED,
(...skipping 1949 matching lines...) Expand 10 before | Expand all | Expand 10 after
2805 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode()); 2848 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->completed_mode());
2806 2849
2807 SimulateGestureEvent(WebInputEvent::GestureScrollEnd, 2850 SimulateGestureEvent(WebInputEvent::GestureScrollEnd,
2808 blink::WebGestureDeviceTouchscreen); 2851 blink::WebGestureDeviceTouchscreen);
2809 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode()); 2852 EXPECT_EQ(OVERSCROLL_NONE, overscroll_delegate()->current_mode());
2810 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode()); 2853 EXPECT_EQ(OVERSCROLL_EAST, overscroll_delegate()->completed_mode());
2811 EXPECT_EQ(3U, sink_->message_count()); 2854 EXPECT_EQ(3U, sink_->message_count());
2812 } 2855 }
2813 2856
2814 } // namespace content 2857 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698