blob: 963a5d3fd1bb24a229507a22cf6d963d9cbf1fbc [file] [log] [blame]
kjellander@webrtc.org5b97b122011-12-08 07:42:18 +00001/*
2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved.
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.org35a17562011-10-06 06:44:54 +000010
kjellander@webrtc.org5b97b122011-12-08 07:42:18 +000011#ifndef WEBRTC_TEST_TESTSUPPORT_UNITTEST_UTILS_H_
12#define WEBRTC_TEST_TESTSUPPORT_UNITTEST_UTILS_H_
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000013
14namespace webrtc {
15namespace test {
16
17const int kPacketSizeInBytes = 1500;
18const int kPacketDataLength = kPacketSizeInBytes * 2 + 1;
19const 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.
26class PacketRelatedTest: public testing::Test {
27 protected:
28 // Tree packet byte arrays with data used for verification:
29 WebRtc_UWord8 packet1_[kPacketSizeInBytes];
30 WebRtc_UWord8 packet2_[kPacketSizeInBytes];
31 WebRtc_UWord8 packet3_[1];
32 // Construct a data structure containing these packets
33 WebRtc_UWord8 packet_data_[kPacketDataLength];
34 WebRtc_UWord8* packet_data_pointer_;
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.org5b97b122011-12-08 07:42:18 +000048 virtual ~PacketRelatedTest() {}
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000049 void SetUp() {
kjellander@webrtc.orgd292b9c2011-11-02 16:34:52 +000050 // Initialize the random generator with 0 to get deterministic behavior
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000051 srand(0);
52 }
kjellander@webrtc.org5b97b122011-12-08 07:42:18 +000053 void TearDown() {}
kjellander@webrtc.org35a17562011-10-06 06:44:54 +000054};
55
56} // namespace test
57} // namespace webrtc
58
kjellander@webrtc.org5b97b122011-12-08 07:42:18 +000059#endif // WEBRTC_TEST_TESTSUPPORT_UNITTEST_UTILS_H_