OLD | NEW |
1 /* | 1 /* |
2 * libjingle | 2 * libjingle |
3 * Copyright 2013 Google Inc | 3 * Copyright 2013 Google Inc |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are met: | 6 * modification, are permitted provided that the following conditions are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright notice, | 8 * 1. Redistributions of source code must retain the above copyright notice, |
9 * this list of conditions and the following disclaimer. | 9 * this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright notice, | 10 * 2. Redistributions in binary form must reproduce the above copyright notice, |
(...skipping 16 matching lines...) Expand all Loading... |
27 | 27 |
28 #include "talk/app/webrtc/sctputils.h" | 28 #include "talk/app/webrtc/sctputils.h" |
29 #include "webrtc/base/bytebuffer.h" | 29 #include "webrtc/base/bytebuffer.h" |
30 #include "webrtc/base/gunit.h" | 30 #include "webrtc/base/gunit.h" |
31 | 31 |
32 class SctpUtilsTest : public testing::Test { | 32 class SctpUtilsTest : public testing::Test { |
33 public: | 33 public: |
34 void VerifyOpenMessageFormat(const rtc::Buffer& packet, | 34 void VerifyOpenMessageFormat(const rtc::Buffer& packet, |
35 const std::string& label, | 35 const std::string& label, |
36 const webrtc::DataChannelInit& config) { | 36 const webrtc::DataChannelInit& config) { |
37 uint8 message_type; | 37 uint8_t message_type; |
38 uint8 channel_type; | 38 uint8_t channel_type; |
39 uint32 reliability; | 39 uint32_t reliability; |
40 uint16 priority; | 40 uint16_t priority; |
41 uint16 label_length; | 41 uint16_t label_length; |
42 uint16 protocol_length; | 42 uint16_t protocol_length; |
43 | 43 |
44 rtc::ByteBuffer buffer(packet.data(), packet.length()); | 44 rtc::ByteBuffer buffer(packet.data(), packet.length()); |
45 ASSERT_TRUE(buffer.ReadUInt8(&message_type)); | 45 ASSERT_TRUE(buffer.ReadUInt8(&message_type)); |
46 EXPECT_EQ(0x03, message_type); | 46 EXPECT_EQ(0x03, message_type); |
47 | 47 |
48 ASSERT_TRUE(buffer.ReadUInt8(&channel_type)); | 48 ASSERT_TRUE(buffer.ReadUInt8(&channel_type)); |
49 if (config.ordered) { | 49 if (config.ordered) { |
50 EXPECT_EQ(config.maxRetransmits > -1 ? | 50 EXPECT_EQ(config.maxRetransmits > -1 ? |
51 0x01 : (config.maxRetransmitTime > -1 ? 0x02 : 0), | 51 0x01 : (config.maxRetransmitTime > -1 ? 0x02 : 0), |
52 channel_type); | 52 channel_type); |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 EXPECT_EQ(config.protocol, output_config.protocol); | 145 EXPECT_EQ(config.protocol, output_config.protocol); |
146 EXPECT_EQ(config.ordered, output_config.ordered); | 146 EXPECT_EQ(config.ordered, output_config.ordered); |
147 EXPECT_EQ(config.maxRetransmits, output_config.maxRetransmits); | 147 EXPECT_EQ(config.maxRetransmits, output_config.maxRetransmits); |
148 EXPECT_EQ(-1, output_config.maxRetransmitTime); | 148 EXPECT_EQ(-1, output_config.maxRetransmitTime); |
149 } | 149 } |
150 | 150 |
151 TEST_F(SctpUtilsTest, WriteParseAckMessage) { | 151 TEST_F(SctpUtilsTest, WriteParseAckMessage) { |
152 rtc::Buffer packet; | 152 rtc::Buffer packet; |
153 webrtc::WriteDataChannelOpenAckMessage(&packet); | 153 webrtc::WriteDataChannelOpenAckMessage(&packet); |
154 | 154 |
155 uint8 message_type; | 155 uint8_t message_type; |
156 rtc::ByteBuffer buffer(packet.data(), packet.length()); | 156 rtc::ByteBuffer buffer(packet.data(), packet.length()); |
157 ASSERT_TRUE(buffer.ReadUInt8(&message_type)); | 157 ASSERT_TRUE(buffer.ReadUInt8(&message_type)); |
158 EXPECT_EQ(0x02, message_type); | 158 EXPECT_EQ(0x02, message_type); |
159 | 159 |
160 EXPECT_TRUE(webrtc::ParseDataChannelOpenAckMessage(packet)); | 160 EXPECT_TRUE(webrtc::ParseDataChannelOpenAckMessage(packet)); |
161 } | 161 } |
OLD | NEW |