| 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_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <tuple> | 10 #include <tuple> |
| (...skipping 1213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1224 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), | 1224 ui::MouseEvent mouse_event(ui::ET_MOUSE_PRESSED, gfx::Point(), gfx::Point(), |
| 1225 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, | 1225 ui::EventTimeForNow(), ui::EF_LEFT_MOUSE_BUTTON, |
| 1226 0); | 1226 0); |
| 1227 view_->OnMouseEvent(&mouse_event); | 1227 view_->OnMouseEvent(&mouse_event); |
| 1228 | 1228 |
| 1229 EXPECT_FALSE(view_->has_composition_text_); | 1229 EXPECT_FALSE(view_->has_composition_text_); |
| 1230 | 1230 |
| 1231 EXPECT_EQ(2U, sink_->message_count()); | 1231 EXPECT_EQ(2U, sink_->message_count()); |
| 1232 | 1232 |
| 1233 if (sink_->message_count() == 2) { | 1233 if (sink_->message_count() == 2) { |
| 1234 // Verify mouse event happens after the confirm-composition event. | 1234 // Verify mouse event happens after the finish composing text event. |
| 1235 EXPECT_EQ(InputMsg_ImeConfirmComposition::ID, | 1235 EXPECT_EQ(InputMsg_ImeFinishComposingText::ID, |
| 1236 sink_->GetMessageAt(0)->type()); | 1236 sink_->GetMessageAt(0)->type()); |
| 1237 EXPECT_EQ(InputMsg_HandleInputEvent::ID, | 1237 EXPECT_EQ(InputMsg_HandleInputEvent::ID, |
| 1238 sink_->GetMessageAt(1)->type()); | 1238 sink_->GetMessageAt(1)->type()); |
| 1239 } | 1239 } |
| 1240 } | 1240 } |
| 1241 | 1241 |
| 1242 // Checks that touch-event state is maintained correctly. | 1242 // Checks that touch-event state is maintained correctly. |
| 1243 TEST_F(RenderWidgetHostViewAuraTest, TouchEventState) { | 1243 TEST_F(RenderWidgetHostViewAuraTest, TouchEventState) { |
| 1244 view_->InitAsChild(nullptr); | 1244 view_->InitAsChild(nullptr); |
| 1245 view_->Show(); | 1245 view_->Show(); |
| (...skipping 3102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4348 | 4348 |
| 4349 // This test is for ui::TextInputClient::ConfirmCompositionText. | 4349 // This test is for ui::TextInputClient::ConfirmCompositionText. |
| 4350 TEST_F(InputMethodResultAuraTest, ConfirmCompositionText) { | 4350 TEST_F(InputMethodResultAuraTest, ConfirmCompositionText) { |
| 4351 base::Closure ime_call = | 4351 base::Closure ime_call = |
| 4352 base::Bind(&ui::TextInputClient::ConfirmCompositionText, | 4352 base::Bind(&ui::TextInputClient::ConfirmCompositionText, |
| 4353 base::Unretained(text_input_client())); | 4353 base::Unretained(text_input_client())); |
| 4354 for (auto index : active_view_sequence_) { | 4354 for (auto index : active_view_sequence_) { |
| 4355 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT); | 4355 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT); |
| 4356 SetHasCompositionTextToTrue(); | 4356 SetHasCompositionTextToTrue(); |
| 4357 EXPECT_TRUE(!!RunAndReturnIPCSent(ime_call, processes_[index], | 4357 EXPECT_TRUE(!!RunAndReturnIPCSent(ime_call, processes_[index], |
| 4358 InputMsg_ImeConfirmComposition::ID)); | 4358 InputMsg_ImeFinishComposingText::ID)); |
| 4359 } | 4359 } |
| 4360 } | 4360 } |
| 4361 | 4361 |
| 4362 // This test is for ui::TextInputClient::ConfirmCompositionText. | 4362 // This test is for ui::TextInputClient::ClearCompositionText. |
| 4363 TEST_F(InputMethodResultAuraTest, ClearCompositionText) { | 4363 TEST_F(InputMethodResultAuraTest, ClearCompositionText) { |
| 4364 base::Closure ime_call = | 4364 base::Closure ime_call = |
| 4365 base::Bind(&ui::TextInputClient::ClearCompositionText, | 4365 base::Bind(&ui::TextInputClient::ClearCompositionText, |
| 4366 base::Unretained(text_input_client())); | 4366 base::Unretained(text_input_client())); |
| 4367 for (auto index : active_view_sequence_) { | 4367 for (auto index : active_view_sequence_) { |
| 4368 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT); | 4368 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT); |
| 4369 SetHasCompositionTextToTrue(); | 4369 SetHasCompositionTextToTrue(); |
| 4370 EXPECT_TRUE(!!RunAndReturnIPCSent(ime_call, processes_[index], | 4370 EXPECT_TRUE(!!RunAndReturnIPCSent(ime_call, processes_[index], |
| 4371 InputMsg_ImeSetComposition::ID)); | 4371 InputMsg_ImeSetComposition::ID)); |
| 4372 } | 4372 } |
| 4373 } | 4373 } |
| 4374 | 4374 |
| 4375 // This test is for that ui::TextInputClient::InsertText. | 4375 // This test is for ui::TextInputClient::InsertText with empty text. |
| 4376 TEST_F(InputMethodResultAuraTest, InsertText) { | 4376 TEST_F(InputMethodResultAuraTest, FinishComposingText) { |
| 4377 base::Closure ime_call = | 4377 base::Closure ime_call = |
| 4378 base::Bind(&ui::TextInputClient::InsertText, | 4378 base::Bind(&ui::TextInputClient::InsertText, |
| 4379 base::Unretained(text_input_client()), base::string16()); | 4379 base::Unretained(text_input_client()), base::string16()); |
| 4380 for (auto index : active_view_sequence_) { | 4380 for (auto index : active_view_sequence_) { |
| 4381 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT); | 4381 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT); |
| 4382 SetHasCompositionTextToTrue(); |
| 4382 EXPECT_TRUE(!!RunAndReturnIPCSent(ime_call, processes_[index], | 4383 EXPECT_TRUE(!!RunAndReturnIPCSent(ime_call, processes_[index], |
| 4383 InputMsg_ImeConfirmComposition::ID)); | 4384 InputMsg_ImeFinishComposingText::ID)); |
| 4384 } | 4385 } |
| 4385 } | 4386 } |
| 4386 | 4387 |
| 4388 // This test is for ui::TextInputClient::InsertText with non-empty text. |
| 4389 TEST_F(InputMethodResultAuraTest, CommitText) { |
| 4390 base::Closure ime_call = base::Bind(&ui::TextInputClient::InsertText, |
| 4391 base::Unretained(text_input_client()), |
| 4392 base::UTF8ToUTF16("hello")); |
| 4393 for (auto index : active_view_sequence_) { |
| 4394 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT); |
| 4395 EXPECT_TRUE(!!RunAndReturnIPCSent(ime_call, processes_[index], |
| 4396 InputMsg_ImeCommitText::ID)); |
| 4397 } |
| 4398 } |
| 4399 |
| 4387 // This test is for RenderWidgetHostViewAura::FinishImeCompositionSession which | 4400 // This test is for RenderWidgetHostViewAura::FinishImeCompositionSession which |
| 4388 // is in response to a mouse click during an ongoing composition. | 4401 // is in response to a mouse click during an ongoing composition. |
| 4389 TEST_F(InputMethodResultAuraTest, FinishImeCompositionSession) { | 4402 TEST_F(InputMethodResultAuraTest, FinishImeCompositionSession) { |
| 4390 base::Closure ime_finish_session_call = | 4403 base::Closure ime_finish_session_call = |
| 4391 base::Bind(&RenderWidgetHostViewAura::FinishImeCompositionSession, | 4404 base::Bind(&RenderWidgetHostViewAura::FinishImeCompositionSession, |
| 4392 base::Unretained(tab_view())); | 4405 base::Unretained(tab_view())); |
| 4393 for (auto index : active_view_sequence_) { | 4406 for (auto index : active_view_sequence_) { |
| 4394 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT); | 4407 ActivateViewForTextInputManager(views_[index], ui::TEXT_INPUT_TYPE_TEXT); |
| 4395 SetHasCompositionTextToTrue(); | 4408 SetHasCompositionTextToTrue(); |
| 4396 EXPECT_TRUE(!!RunAndReturnIPCSent(ime_finish_session_call, | 4409 EXPECT_TRUE(!!RunAndReturnIPCSent(ime_finish_session_call, |
| 4397 processes_[index], | 4410 processes_[index], |
| 4398 InputMsg_ImeConfirmComposition::ID)); | 4411 InputMsg_ImeFinishComposingText::ID)); |
| 4399 } | 4412 } |
| 4400 } | 4413 } |
| 4401 | 4414 |
| 4402 // This test is for ui::TextInputClient::ChangeTextDirectionAndLayoutAlignment. | 4415 // This test is for ui::TextInputClient::ChangeTextDirectionAndLayoutAlignment. |
| 4403 TEST_F(InputMethodResultAuraTest, ChangeTextDirectionAndLayoutAlignment) { | 4416 TEST_F(InputMethodResultAuraTest, ChangeTextDirectionAndLayoutAlignment) { |
| 4404 base::Closure ime_finish_session_call = base::Bind( | 4417 base::Closure ime_finish_session_call = base::Bind( |
| 4405 base::IgnoreResult( | 4418 base::IgnoreResult( |
| 4406 &RenderWidgetHostViewAura::ChangeTextDirectionAndLayoutAlignment), | 4419 &RenderWidgetHostViewAura::ChangeTextDirectionAndLayoutAlignment), |
| 4407 base::Unretained(tab_view()), base::i18n::LEFT_TO_RIGHT); | 4420 base::Unretained(tab_view()), base::i18n::LEFT_TO_RIGHT); |
| 4408 for (auto index : active_view_sequence_) { | 4421 for (auto index : active_view_sequence_) { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4574 | 4587 |
| 4575 // Retrieve the selected text from clipboard and verify it is as expected. | 4588 // Retrieve the selected text from clipboard and verify it is as expected. |
| 4576 base::string16 result_text; | 4589 base::string16 result_text; |
| 4577 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text); | 4590 clipboard->ReadText(ui::CLIPBOARD_TYPE_SELECTION, &result_text); |
| 4578 EXPECT_EQ(expected_text, result_text); | 4591 EXPECT_EQ(expected_text, result_text); |
| 4579 } | 4592 } |
| 4580 } | 4593 } |
| 4581 #endif | 4594 #endif |
| 4582 | 4595 |
| 4583 } // namespace content | 4596 } // namespace content |
| OLD | NEW |