| 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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 pos += read; | 84 pos += read; |
| 85 } | 85 } |
| 86 | 86 |
| 87 // Then verify the decoded messages. | 87 // Then verify the decoded messages. |
| 88 EXPECT_EQ(10u, message_list.size()); | 88 EXPECT_EQ(10u, message_list.size()); |
| 89 | 89 |
| 90 unsigned int index = 0; | 90 unsigned int index = 0; |
| 91 for (std::list<EventMessage*>::iterator it = | 91 for (std::list<EventMessage*>::iterator it = |
| 92 message_list.begin(); | 92 message_list.begin(); |
| 93 it != message_list.end(); ++it) { | 93 it != message_list.end(); ++it) { |
| 94 SCOPED_TRACE("Message " + base::IntToString(index)); | 94 SCOPED_TRACE("Message " + base::UintToString(index)); |
| 95 | 95 |
| 96 EventMessage* message = *it; | 96 EventMessage* message = *it; |
| 97 // Partial update stream. | 97 // Partial update stream. |
| 98 EXPECT_TRUE(message->has_key_event()); | 98 EXPECT_TRUE(message->has_key_event()); |
| 99 | 99 |
| 100 // TODO(sergeyu): Don't use index here. Instead store the expected values | 100 // TODO(sergeyu): Don't use index here. Instead store the expected values |
| 101 // in an array. | 101 // in an array. |
| 102 EXPECT_EQ(kTestKey + index, message->key_event().usb_keycode()); | 102 EXPECT_EQ(kTestKey + index, message->key_event().usb_keycode()); |
| 103 EXPECT_EQ((index % 2) != 0, message->key_event().pressed()); | 103 EXPECT_EQ((index % 2) != 0, message->key_event().pressed()); |
| 104 ++index; | 104 ++index; |
| (...skipping 11 matching lines...) Expand all 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 |