kjellander@webrtc.org | 5b97b12 | 2011-12-08 07:42:18 +0000 | [diff] [blame] | 1 | /* |
kjellander@webrtc.org | cf6a295 | 2012-02-09 09:01:51 +0000 | [diff] [blame] | 2 | * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
kjellander@webrtc.org | 5b97b12 | 2011-12-08 07:42:18 +0000 | [diff] [blame] | 3 | * |
| 4 | * Use of this source code is governed by a BSD-style license |
| 5 | * that can be found in the LICENSE file in the root of the source |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 10 | |
kjellander@webrtc.org | 5b97b12 | 2011-12-08 07:42:18 +0000 | [diff] [blame] | 11 | #ifndef WEBRTC_TEST_TESTSUPPORT_UNITTEST_UTILS_H_ |
| 12 | #define WEBRTC_TEST_TESTSUPPORT_UNITTEST_UTILS_H_ |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 13 | |
| 14 | namespace webrtc { |
| 15 | namespace test { |
| 16 | |
| 17 | const int kPacketSizeInBytes = 1500; |
| 18 | const int kPacketDataLength = kPacketSizeInBytes * 2 + 1; |
| 19 | const int kPacketDataNumberOfPackets = 3; |
| 20 | |
| 21 | // A base test fixture for packet related tests. Contains |
| 22 | // two full prepared packets with 1s, 2s in their data and a third packet with |
| 23 | // a single 3 in it (size=1). |
| 24 | // A packet data structure is also available, that contains these three packets |
| 25 | // in order. |
| 26 | class PacketRelatedTest: public testing::Test { |
| 27 | protected: |
| 28 | // Tree packet byte arrays with data used for verification: |
pbos@webrtc.org | a5f1787 | 2013-04-09 11:10:21 +0000 | [diff] [blame] | 29 | uint8_t packet1_[kPacketSizeInBytes]; |
| 30 | uint8_t packet2_[kPacketSizeInBytes]; |
| 31 | uint8_t packet3_[1]; |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 32 | // Construct a data structure containing these packets |
pbos@webrtc.org | a5f1787 | 2013-04-09 11:10:21 +0000 | [diff] [blame] | 33 | uint8_t packet_data_[kPacketDataLength]; |
| 34 | uint8_t* packet_data_pointer_; |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 35 | |
| 36 | PacketRelatedTest() { |
| 37 | packet_data_pointer_ = packet_data_; |
| 38 | |
| 39 | memset(packet1_, 1, kPacketSizeInBytes); |
| 40 | memset(packet2_, 2, kPacketSizeInBytes); |
| 41 | memset(packet3_, 3, 1); |
| 42 | // Fill the packet_data: |
| 43 | memcpy(packet_data_pointer_, packet1_, kPacketSizeInBytes); |
| 44 | memcpy(packet_data_pointer_ + kPacketSizeInBytes, packet2_, |
| 45 | kPacketSizeInBytes); |
| 46 | memcpy(packet_data_pointer_ + kPacketSizeInBytes * 2, packet3_, 1); |
| 47 | } |
kjellander@webrtc.org | 5b97b12 | 2011-12-08 07:42:18 +0000 | [diff] [blame] | 48 | virtual ~PacketRelatedTest() {} |
kjellander@webrtc.org | cf6a295 | 2012-02-09 09:01:51 +0000 | [diff] [blame] | 49 | void SetUp() {} |
kjellander@webrtc.org | 5b97b12 | 2011-12-08 07:42:18 +0000 | [diff] [blame] | 50 | void TearDown() {} |
kjellander@webrtc.org | 35a1756 | 2011-10-06 06:44:54 +0000 | [diff] [blame] | 51 | }; |
| 52 | |
| 53 | } // namespace test |
| 54 | } // namespace webrtc |
| 55 | |
kjellander@webrtc.org | 5b97b12 | 2011-12-08 07:42:18 +0000 | [diff] [blame] | 56 | #endif // WEBRTC_TEST_TESTSUPPORT_UNITTEST_UTILS_H_ |