| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "mojo/public/cpp/bindings/binding_set.h" | 6 #include "mojo/public/cpp/bindings/binding_set.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 #include "ui/events/event.h" |
| 8 #include "ui/events/keycodes/dom/dom_code.h" | 9 #include "ui/events/keycodes/dom/dom_code.h" |
| 10 #include "ui/events/mojo/event.mojom.h" |
| 11 #include "ui/events/mojo/event_struct_traits.h" |
| 12 #include "ui/events/mojo/latency_info_struct_traits.h" |
| 9 #include "ui/events/mojo/traits_test_service.mojom.h" | 13 #include "ui/events/mojo/traits_test_service.mojom.h" |
| 10 | 14 |
| 11 namespace ui { | 15 namespace ui { |
| 12 | 16 |
| 13 namespace { | 17 namespace { |
| 14 | 18 |
| 15 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { | 19 class StructTraitsTest : public testing::Test, public mojom::TraitsTestService { |
| 16 public: | 20 public: |
| 17 StructTraitsTest() {} | 21 StructTraitsTest() {} |
| 18 | 22 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 EXPECT_EQ(ET_POINTER_WHEEL_CHANGED, output_pointer_event->type()); | 248 EXPECT_EQ(ET_POINTER_WHEEL_CHANGED, output_pointer_event->type()); |
| 245 EXPECT_EQ(kTestData[i].flags(), output_pointer_event->flags()); | 249 EXPECT_EQ(kTestData[i].flags(), output_pointer_event->flags()); |
| 246 EXPECT_EQ(kTestData[i].location(), output_pointer_event->location()); | 250 EXPECT_EQ(kTestData[i].location(), output_pointer_event->location()); |
| 247 EXPECT_EQ(kTestData[i].root_location(), | 251 EXPECT_EQ(kTestData[i].root_location(), |
| 248 output_pointer_event->root_location()); | 252 output_pointer_event->root_location()); |
| 249 EXPECT_EQ(kTestData[i].offset(), | 253 EXPECT_EQ(kTestData[i].offset(), |
| 250 output_pointer_event->pointer_details().offset); | 254 output_pointer_event->pointer_details().offset); |
| 251 } | 255 } |
| 252 } | 256 } |
| 253 | 257 |
| 258 TEST_F(StructTraitsTest, KeyEventPropertiesSerialized) { |
| 259 KeyEvent key_event(ET_KEY_PRESSED, VKEY_T, EF_NONE); |
| 260 const std::string key = "key"; |
| 261 const std::vector<uint8_t> value(0xCD, 2); |
| 262 KeyEvent::Properties properties; |
| 263 properties[key] = value; |
| 264 key_event.SetProperties(properties); |
| 265 |
| 266 std::unique_ptr<Event> event_ptr = Event::Clone(key_event); |
| 267 std::unique_ptr<Event> deserialized; |
| 268 ASSERT_TRUE(mojom::Event::Deserialize(mojom::Event::Serialize(&event_ptr), |
| 269 &deserialized)); |
| 270 ASSERT_TRUE(deserialized->IsKeyEvent()); |
| 271 ASSERT_TRUE(deserialized->AsKeyEvent()->properties()); |
| 272 EXPECT_EQ(properties, *(deserialized->AsKeyEvent()->properties())); |
| 273 } |
| 274 |
| 254 } // namespace ui | 275 } // namespace ui |
| OLD | NEW |