| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "media/base/data_buffer.h" | 8 #include "media/base/data_buffer.h" |
| 9 #include "remoting/base/protocol_decoder.h" | 9 #include "remoting/base/protocol_decoder.h" |
| 10 #include "remoting/base/protocol_util.h" | 10 #include "remoting/base/protocol_util.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 12 |
| 13 namespace remoting { | 13 namespace remoting { |
| 14 | 14 |
| 15 static const int kWidth = 640; | 15 static const int kWidth = 640; |
| 16 static const int kHeight = 480; | 16 static const int kHeight = 480; |
| 17 static const std::string kTestData = "Chromoting rockz"; | 17 static const std::string kTestData = "Chromoting rockz"; |
| 18 | 18 |
| 19 static void AppendMessage(const chromotocol_pb::HostMessage& msg, | 19 static void AppendMessage(const HostMessage& msg, |
| 20 std::string* buffer) { | 20 std::string* buffer) { |
| 21 // Contains one encoded message. | 21 // Contains one encoded message. |
| 22 scoped_refptr<media::DataBuffer> encoded_msg; | 22 scoped_refptr<media::DataBuffer> encoded_msg; |
| 23 encoded_msg = SerializeAndFrameMessage(msg); | 23 encoded_msg = SerializeAndFrameMessage(msg); |
| 24 buffer->append(reinterpret_cast<const char*>(encoded_msg->GetData()), | 24 buffer->append(reinterpret_cast<const char*>(encoded_msg->GetData()), |
| 25 encoded_msg->GetDataSize()); | 25 encoded_msg->GetDataSize()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 // Construct and prepare data in the |output_stream|. | 28 // Construct and prepare data in the |output_stream|. |
| 29 static void PrepareData(uint8** buffer, int* size) { | 29 static void PrepareData(uint8** buffer, int* size) { |
| 30 // Contains all encoded messages. | 30 // Contains all encoded messages. |
| 31 std::string encoded_data; | 31 std::string encoded_data; |
| 32 | 32 |
| 33 // The first message is InitClient. | 33 // The first message is InitClient. |
| 34 chromotocol_pb::HostMessage msg; | 34 HostMessage msg; |
| 35 msg.mutable_init_client()->set_width(kWidth); | 35 msg.mutable_init_client()->set_width(kWidth); |
| 36 msg.mutable_init_client()->set_height(kHeight); | 36 msg.mutable_init_client()->set_height(kHeight); |
| 37 AppendMessage(msg, &encoded_data); | 37 AppendMessage(msg, &encoded_data); |
| 38 msg.Clear(); | 38 msg.Clear(); |
| 39 | 39 |
| 40 // Then append 10 update sequences to the data. | 40 // Then append 10 update sequences to the data. |
| 41 for (int i = 0; i < 10; ++i) { | 41 for (int i = 0; i < 10; ++i) { |
| 42 msg.mutable_begin_update_stream(); | 42 msg.mutable_begin_update_stream(); |
| 43 AppendMessage(msg, &encoded_data); | 43 AppendMessage(msg, &encoded_data); |
| 44 msg.Clear(); | 44 msg.Clear(); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 104 EXPECT_EQ(kTestData, message_list[i]->update_stream_packet().data()); | 104 EXPECT_EQ(kTestData, message_list[i]->update_stream_packet().data()); |
| 105 } else if (type == 2) { | 105 } else if (type == 2) { |
| 106 // End update stream. | 106 // End update stream. |
| 107 EXPECT_TRUE(message_list[i]->has_end_update_stream()); | 107 EXPECT_TRUE(message_list[i]->has_end_update_stream()); |
| 108 } | 108 } |
| 109 delete message_list[i]; | 109 delete message_list[i]; |
| 110 } | 110 } |
| 111 } | 111 } |
| 112 | 112 |
| 113 } // namespace remoting | 113 } // namespace remoting |
| OLD | NEW |