| 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 "ppapi/tests/test_ime_input_event.h" | 5 #include "ppapi/tests/test_ime_input_event.h" |
| 6 | 6 |
| 7 #include "ppapi/c/dev/ppb_ime_input_event_dev.h" | |
| 8 #include "ppapi/c/dev/ppb_testing_dev.h" | 7 #include "ppapi/c/dev/ppb_testing_dev.h" |
| 9 #include "ppapi/c/pp_errors.h" | 8 #include "ppapi/c/pp_errors.h" |
| 10 #include "ppapi/c/ppb_input_event.h" | 9 #include "ppapi/c/ppb_input_event.h" |
| 11 #include "ppapi/cpp/dev/ime_input_event_dev.h" | |
| 12 #include "ppapi/cpp/input_event.h" | 10 #include "ppapi/cpp/input_event.h" |
| 13 #include "ppapi/cpp/module.h" | 11 #include "ppapi/cpp/module.h" |
| 14 #include "ppapi/tests/test_utils.h" | 12 #include "ppapi/tests/test_utils.h" |
| 15 #include "ppapi/tests/testing_instance.h" | 13 #include "ppapi/tests/testing_instance.h" |
| 16 | 14 |
| 17 REGISTER_TEST_CASE(ImeInputEvent); | 15 REGISTER_TEST_CASE(ImeInputEvent); |
| 18 | 16 |
| 19 namespace { | 17 namespace { |
| 20 | 18 |
| 21 // Japanese Kanji letters meaning "a string" ('mo' 'ji' 'retsu' in Kanji) | 19 // Japanese Kanji letters meaning "a string" ('mo' 'ji' 'retsu' in Kanji) |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 56 RUN_TEST(ImeUnawareCancel, filter); | 54 RUN_TEST(ImeUnawareCancel, filter); |
| 57 } | 55 } |
| 58 | 56 |
| 59 bool TestImeInputEvent::Init() { | 57 bool TestImeInputEvent::Init() { |
| 60 input_event_interface_ = static_cast<const PPB_InputEvent*>( | 58 input_event_interface_ = static_cast<const PPB_InputEvent*>( |
| 61 pp::Module::Get()->GetBrowserInterface(PPB_INPUT_EVENT_INTERFACE)); | 59 pp::Module::Get()->GetBrowserInterface(PPB_INPUT_EVENT_INTERFACE)); |
| 62 keyboard_input_event_interface_ = | 60 keyboard_input_event_interface_ = |
| 63 static_cast<const PPB_KeyboardInputEvent*>( | 61 static_cast<const PPB_KeyboardInputEvent*>( |
| 64 pp::Module::Get()->GetBrowserInterface( | 62 pp::Module::Get()->GetBrowserInterface( |
| 65 PPB_KEYBOARD_INPUT_EVENT_INTERFACE)); | 63 PPB_KEYBOARD_INPUT_EVENT_INTERFACE)); |
| 66 ime_input_event_interface_ = static_cast<const PPB_IMEInputEvent_Dev*>( | 64 ime_input_event_interface_ = static_cast<const PPB_IMEInputEvent*>( |
| 67 pp::Module::Get()->GetBrowserInterface( | 65 pp::Module::Get()->GetBrowserInterface( |
| 68 PPB_IME_INPUT_EVENT_DEV_INTERFACE)); | 66 PPB_IME_INPUT_EVENT_INTERFACE)); |
| 69 | 67 |
| 70 bool success = | 68 bool success = |
| 71 input_event_interface_ && | 69 input_event_interface_ && |
| 72 keyboard_input_event_interface_ && | 70 keyboard_input_event_interface_ && |
| 73 ime_input_event_interface_ && | 71 ime_input_event_interface_ && |
| 74 CheckTestingInterface(); | 72 CheckTestingInterface(); |
| 75 | 73 |
| 76 // Set up a listener for our message that signals that all input events have | 74 // Set up a listener for our message that signals that all input events have |
| 77 // been received. | 75 // been received. |
| 78 // Note the following code is dependent on some features of test_case.html. | 76 // Note the following code is dependent on some features of test_case.html. |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 testing_interface_->QuitMessageLoop(instance_->pp_instance()); | 127 testing_interface_->QuitMessageLoop(instance_->pp_instance()); |
| 130 received_finish_message_ = true; | 128 received_finish_message_ = true; |
| 131 } | 129 } |
| 132 } | 130 } |
| 133 | 131 |
| 134 void TestImeInputEvent::DidChangeView(const pp::View& view) { | 132 void TestImeInputEvent::DidChangeView(const pp::View& view) { |
| 135 view_rect_ = view.GetRect(); | 133 view_rect_ = view.GetRect(); |
| 136 } | 134 } |
| 137 | 135 |
| 138 pp::InputEvent TestImeInputEvent::CreateImeCompositionStartEvent() { | 136 pp::InputEvent TestImeInputEvent::CreateImeCompositionStartEvent() { |
| 139 return pp::IMEInputEvent_Dev( | 137 return pp::IMEInputEvent( |
| 140 instance_, | 138 instance_, |
| 141 PP_INPUTEVENT_TYPE_IME_COMPOSITION_START, | 139 PP_INPUTEVENT_TYPE_IME_COMPOSITION_START, |
| 142 100, // time_stamp | 140 100, // time_stamp |
| 143 pp::Var(""), | 141 pp::Var(""), |
| 144 std::vector<uint32_t>(), | 142 std::vector<uint32_t>(), |
| 145 -1, // target_segment | 143 -1, // target_segment |
| 146 std::make_pair(0U, 0U) // selection | 144 std::make_pair(0U, 0U) // selection |
| 147 ); | 145 ); |
| 148 } | 146 } |
| 149 | 147 |
| 150 pp::InputEvent TestImeInputEvent::CreateImeCompositionUpdateEvent( | 148 pp::InputEvent TestImeInputEvent::CreateImeCompositionUpdateEvent( |
| 151 const std::string& text, | 149 const std::string& text, |
| 152 const std::vector<uint32_t>& segments, | 150 const std::vector<uint32_t>& segments, |
| 153 int32_t target_segment, | 151 int32_t target_segment, |
| 154 const std::pair<uint32_t, uint32_t>& selection) { | 152 const std::pair<uint32_t, uint32_t>& selection) { |
| 155 return pp::IMEInputEvent_Dev( | 153 return pp::IMEInputEvent( |
| 156 instance_, | 154 instance_, |
| 157 PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE, | 155 PP_INPUTEVENT_TYPE_IME_COMPOSITION_UPDATE, |
| 158 100, // time_stamp | 156 100, // time_stamp |
| 159 text, | 157 text, |
| 160 segments, | 158 segments, |
| 161 target_segment, | 159 target_segment, |
| 162 selection | 160 selection |
| 163 ); | 161 ); |
| 164 } | 162 } |
| 165 | 163 |
| 166 pp::InputEvent TestImeInputEvent::CreateImeCompositionEndEvent( | 164 pp::InputEvent TestImeInputEvent::CreateImeCompositionEndEvent( |
| 167 const std::string& text) { | 165 const std::string& text) { |
| 168 return pp::IMEInputEvent_Dev( | 166 return pp::IMEInputEvent( |
| 169 instance_, | 167 instance_, |
| 170 PP_INPUTEVENT_TYPE_IME_COMPOSITION_END, | 168 PP_INPUTEVENT_TYPE_IME_COMPOSITION_END, |
| 171 100, // time_stamp | 169 100, // time_stamp |
| 172 pp::Var(text), | 170 pp::Var(text), |
| 173 std::vector<uint32_t>(), | 171 std::vector<uint32_t>(), |
| 174 -1, // target_segment | 172 -1, // target_segment |
| 175 std::make_pair(0U, 0U) // selection | 173 std::make_pair(0U, 0U) // selection |
| 176 ); | 174 ); |
| 177 } | 175 } |
| 178 | 176 |
| 179 pp::InputEvent TestImeInputEvent::CreateImeTextEvent(const std::string& text) { | 177 pp::InputEvent TestImeInputEvent::CreateImeTextEvent(const std::string& text) { |
| 180 return pp::IMEInputEvent_Dev( | 178 return pp::IMEInputEvent( |
| 181 instance_, | 179 instance_, |
| 182 PP_INPUTEVENT_TYPE_IME_TEXT, | 180 PP_INPUTEVENT_TYPE_IME_TEXT, |
| 183 100, // time_stamp | 181 100, // time_stamp |
| 184 pp::Var(text), | 182 pp::Var(text), |
| 185 std::vector<uint32_t>(), | 183 std::vector<uint32_t>(), |
| 186 -1, // target_segment | 184 -1, // target_segment |
| 187 std::make_pair(0U, 0U) // selection | 185 std::make_pair(0U, 0U) // selection |
| 188 ); | 186 ); |
| 189 } | 187 } |
| 190 | 188 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 416 expected_events_.clear(); | 414 expected_events_.clear(); |
| 417 | 415 |
| 418 // Test for IME-unaware plugins. Cancel won't issue any events. | 416 // Test for IME-unaware plugins. Cancel won't issue any events. |
| 419 ASSERT_TRUE(SimulateInputEvent(update_event)); | 417 ASSERT_TRUE(SimulateInputEvent(update_event)); |
| 420 ASSERT_TRUE(SimulateInputEvent(CreateImeCompositionEndEvent(std::string()))); | 418 ASSERT_TRUE(SimulateInputEvent(CreateImeCompositionEndEvent(std::string()))); |
| 421 | 419 |
| 422 ASSERT_TRUE(expected_events_.empty()); | 420 ASSERT_TRUE(expected_events_.empty()); |
| 423 PASS(); | 421 PASS(); |
| 424 } | 422 } |
| 425 | 423 |
| OLD | NEW |