Home | History | Annotate | Download | only in testsupport
      1 /*
      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  */
     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 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:
     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   }
     48   virtual ~PacketRelatedTest() {}
     49   void SetUp() {
     50     // Initialize the random generator with 0 to get deterministic behavior
     51     srand(0);
     52   }
     53   void TearDown() {}
     54 };
     55 
     56 }  // namespace test
     57 }  // namespace webrtc
     58 
     59 #endif  // WEBRTC_TEST_TESTSUPPORT_UNITTEST_UTILS_H_
     60