OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 <string> | 5 #include <string> |
6 | 6 |
7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "remoting/proto/event.pb.h" | 10 #include "remoting/proto/event.pb.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 } | 27 } |
28 | 28 |
29 // Construct and prepare data in the |output_stream|. | 29 // Construct and prepare data in the |output_stream|. |
30 static void PrepareData(uint8** buffer, int* size) { | 30 static void PrepareData(uint8** buffer, int* size) { |
31 // Contains all encoded messages. | 31 // Contains all encoded messages. |
32 std::string encoded_data; | 32 std::string encoded_data; |
33 | 33 |
34 // Then append 10 update sequences to the data. | 34 // Then append 10 update sequences to the data. |
35 for (int i = 0; i < 10; ++i) { | 35 for (int i = 0; i < 10; ++i) { |
36 EventMessage msg; | 36 EventMessage msg; |
37 msg.set_sequence_number(i); | 37 msg.set_timestamp(i); |
38 msg.mutable_key_event()->set_usb_keycode(kTestKey + i); | 38 msg.mutable_key_event()->set_usb_keycode(kTestKey + i); |
39 msg.mutable_key_event()->set_pressed((i % 2) != 0); | 39 msg.mutable_key_event()->set_pressed((i % 2) != 0); |
40 AppendMessage(msg, &encoded_data); | 40 AppendMessage(msg, &encoded_data); |
41 } | 41 } |
42 | 42 |
43 *size = encoded_data.length(); | 43 *size = encoded_data.length(); |
44 *buffer = new uint8[*size]; | 44 *buffer = new uint8[*size]; |
45 memcpy(*buffer, encoded_data.c_str(), *size); | 45 memcpy(*buffer, encoded_data.c_str(), *size); |
46 } | 46 } |
47 | 47 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 SimulateReadSequence(kReads, arraysize(kReads)); | 116 SimulateReadSequence(kReads, arraysize(kReads)); |
117 } | 117 } |
118 | 118 |
119 TEST(MessageDecoderTest, EmptyReads) { | 119 TEST(MessageDecoderTest, EmptyReads) { |
120 const int kReads[] = {4, 0, 50, 0}; | 120 const int kReads[] = {4, 0, 50, 0}; |
121 SimulateReadSequence(kReads, arraysize(kReads)); | 121 SimulateReadSequence(kReads, arraysize(kReads)); |
122 } | 122 } |
123 | 123 |
124 } // namespace protocol | 124 } // namespace protocol |
125 } // namespace remoting | 125 } // namespace remoting |
OLD | NEW |