OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 <memory> | 5 #include <memory> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "blimp/common/proto/blimp_message.pb.h" | 9 #include "blimp/common/proto/blimp_message.pb.h" |
10 #include "blimp/common/proto/input.pb.h" | 10 #include "blimp/common/proto/input.pb.h" |
11 #include "blimp/net/blimp_message_processor.h" | 11 #include "blimp/net/blimp_message_processor.h" |
12 #include "blimp/net/input_message_converter.h" | 12 #include "blimp/net/input_message_converter.h" |
13 #include "blimp/net/input_message_generator.h" | 13 #include "blimp/net/input_message_generator.h" |
14 #include "testing/gtest/include/gtest/gtest.h" | 14 #include "testing/gtest/include/gtest/gtest.h" |
15 #include "third_party/WebKit/public/platform/WebGestureDevice.h" | 15 #include "third_party/WebKit/public/platform/WebGestureDevice.h" |
16 #include "third_party/WebKit/public/web/WebInputEvent.h" | 16 #include "third_party/WebKit/public/web/WebInputEvent.h" |
17 | 17 |
18 namespace blimp { | 18 namespace blimp { |
19 namespace { | 19 namespace { |
20 | 20 |
21 void ValidateWebGestureEventRoundTripping(const blink::WebGestureEvent& event) { | 21 void ValidateWebGestureEventRoundTripping(const blink::WebGestureEvent& event) { |
22 InputMessageGenerator generator; | 22 InputMessageGenerator generator; |
23 InputMessageConverter processor; | 23 InputMessageConverter processor; |
24 | 24 |
25 std::unique_ptr<BlimpMessage> proto = generator.GenerateMessage(event); | 25 std::unique_ptr<BlimpMessage> proto = generator.GenerateMessage(event); |
26 EXPECT_NE(nullptr, proto.get()); | 26 EXPECT_NE(nullptr, proto.get()); |
27 EXPECT_TRUE(proto->has_input()); | 27 EXPECT_EQ(BlimpMessage::kInput, proto->feature_case()); |
28 EXPECT_EQ(BlimpMessage::INPUT, proto->type()); | |
29 | 28 |
30 std::unique_ptr<blink::WebGestureEvent> new_event = | 29 std::unique_ptr<blink::WebGestureEvent> new_event = |
31 processor.ProcessMessage(proto->input()); | 30 processor.ProcessMessage(proto->input()); |
32 EXPECT_NE(nullptr, new_event.get()); | 31 EXPECT_NE(nullptr, new_event.get()); |
33 | 32 |
34 EXPECT_EQ(event.size, new_event->size); | 33 EXPECT_EQ(event.size, new_event->size); |
35 EXPECT_EQ(0, memcmp(&event, new_event.get(), event.size)); | 34 EXPECT_EQ(0, memcmp(&event, new_event.get(), event.size)); |
36 } | 35 } |
37 | 36 |
38 blink::WebGestureEvent BuildBaseTestEvent() { | 37 blink::WebGestureEvent BuildBaseTestEvent() { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 TEST(InputMessageConverterTest, TestTextInputTypeToProtoConversion) { | 132 TEST(InputMessageConverterTest, TestTextInputTypeToProtoConversion) { |
134 for (size_t i = ui::TextInputType::TEXT_INPUT_TYPE_TEXT; | 133 for (size_t i = ui::TextInputType::TEXT_INPUT_TYPE_TEXT; |
135 i < ui::TextInputType::TEXT_INPUT_TYPE_MAX; i++) { | 134 i < ui::TextInputType::TEXT_INPUT_TYPE_MAX; i++) { |
136 ui::TextInputType type = static_cast<ui::TextInputType>(i); | 135 ui::TextInputType type = static_cast<ui::TextInputType>(i); |
137 EXPECT_EQ(type, InputMessageConverter::TextInputTypeFromProto( | 136 EXPECT_EQ(type, InputMessageConverter::TextInputTypeFromProto( |
138 InputMessageConverter::TextInputTypeToProto(type))); | 137 InputMessageConverter::TextInputTypeToProto(type))); |
139 } | 138 } |
140 } | 139 } |
141 | 140 |
142 } // namespace blimp | 141 } // namespace blimp |
OLD | NEW |