• Home
  • History
  • Annotate
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  *  Copyright (c) 2012 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  */
10 
11 #ifndef WEBRTC_TEST_TESTSUPPORT_UNITTEST_UTILS_H_
12 #define WEBRTC_TEST_TESTSUPPORT_UNITTEST_UTILS_H_
13 
14 namespace webrtc {
15 namespace test {
16 
17 const size_t kPacketSizeInBytes = 1500;
18 const size_t 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:
29   uint8_t packet1_[kPacketSizeInBytes];
30   uint8_t packet2_[kPacketSizeInBytes];
31   uint8_t packet3_[1];
32   // Construct a data structure containing these packets
33   uint8_t packet_data_[kPacketDataLength];
34   uint8_t* packet_data_pointer_;
35 
PacketRelatedTest()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   }
~PacketRelatedTest()48   virtual ~PacketRelatedTest() {}
SetUp()49   void SetUp() {}
TearDown()50   void TearDown() {}
51 };
52 
53 }  // namespace test
54 }  // namespace webrtc
55 
56 #endif  // WEBRTC_TEST_TESTSUPPORT_UNITTEST_UTILS_H_
57