From f3c13a1dc6ed78ef7a1859553a8f6c1f82ba0d21 Mon Sep 17 00:00:00 2001 From: sirknightj Date: Thu, 31 Oct 2024 22:41:51 -0700 Subject: [PATCH] Apply linting --- .../amazonaws/kinesis/video/client/Include.h | 6 +- src/client/src/Include_i.h | 16 +- src/client/src/Stream.h | 2 +- .../kinesis/video/common/CommonDefs.h | 12 +- src/heap/src/AivHeap.h | 2 +- src/heap/src/HybridHeap.h | 2 +- .../amazonaws/kinesis/video/mkvgen/Include.h | 26 +- src/mkvgen/src/Include_i.h | 4 +- .../amazonaws/kinesis/video/view/Include.h | 18 +- tst/client/AcksFunctionalityTest.cpp | 99 +-- ...CallbacksAndPressuresFunctionalityTest.cpp | 33 +- tst/client/ClientApiFunctionalityTest.cpp | 20 +- tst/client/ClientApiTest.cpp | 51 +- tst/client/ClientFunctionalityTest.cpp | 76 +-- tst/client/ClientTestFixture.cpp | 245 +++----- tst/client/FrameOrderCoordinatorTest.cpp | 3 +- ...rmittentProducerAutomaticStreamingTest.cpp | 117 ++-- .../IntermittentProducerFunctionalityTest.cpp | 38 +- tst/client/MockConsumer.cpp | 68 +-- tst/client/MockProducer.cpp | 23 +- .../StateTransitionFunctionalityTest.cpp | 155 ++--- .../StreamApiFunctionalityScenarioTest.cpp | 48 +- tst/client/StreamApiFunctionalityTest.cpp | 167 ++--- tst/client/StreamApiServiceCallsTest.cpp | 3 +- tst/client/StreamApiTest.cpp | 4 +- tst/client/StreamDeviceTagsTest.cpp | 31 +- tst/client/StreamFunctionalityTest.cpp | 38 +- tst/client/StreamParallelTest.cpp | 21 +- tst/client/StreamPutGetTest.cpp | 3 +- .../StreamRecoveryFunctionalityTest.cpp | 153 +++-- tst/client/StreamStateTransitionsTest.cpp | 34 +- .../StreamStoppingFunctionalityTest.cpp | 49 +- tst/client/StreamTokenRotationTest.cpp | 83 ++- tst/client/StreamingSession.cpp | 32 +- tst/client/TokenRotationFunctionalityTest.cpp | 100 ++- tst/duration/DurationTest.cpp | 74 ++- tst/heap/HeapApiFunctionalityTest.cpp | 25 +- tst/heap/HeapApiTest.cpp | 222 +++---- tst/heap/HeapPerfTest.cpp | 47 +- tst/heap/HeapTestFixture.cpp | 2 +- tst/heap/HybridFileHeapTest.cpp | 32 +- tst/heap/HybridHeapTest.cpp | 125 +--- tst/mkvgen/AnnexBCpdNalAdapterTest.cpp | 142 ++--- tst/mkvgen/AnnexBNalAdapterTest.cpp | 189 +++--- tst/mkvgen/AudioCpdParserTest.cpp | 22 +- tst/mkvgen/AvccNalAdapterTest.cpp | 11 +- tst/mkvgen/MkvgenApiFunctionalityTest.cpp | 577 ++++++------------ tst/mkvgen/MkvgenApiTest.cpp | 253 ++++---- tst/mkvgen/SpsParserTest.cpp | 308 ++++------ tst/state/StateApiFunctionalityTest.cpp | 26 +- tst/state/StateApiTest.cpp | 68 +-- tst/state/StateTestFixture.cpp | 15 +- tst/trace/TraceApiFunctionalityTest.cpp | 24 +- tst/trace/TraceApiTest.cpp | 27 +- tst/utils/BitField.cpp | 4 +- tst/utils/BitReader.cpp | 3 +- tst/utils/Crc32Test.cpp | 3 +- tst/utils/Directory.cpp | 9 +- tst/utils/DoubleLinkedList.cpp | 29 +- tst/utils/Endianness.cpp | 15 +- tst/utils/ExponentialBackoffUtilsTest.cpp | 119 ++-- tst/utils/FileIo.cpp | 76 +-- tst/utils/FileLogger.cpp | 98 +-- tst/utils/FindStringTest.cpp | 3 +- tst/utils/HashTable.cpp | 7 +- tst/utils/InstrumentedAllocators.cpp | 5 +- tst/utils/IntegerToString.cpp | 25 +- tst/utils/MathTest.cpp | 3 +- tst/utils/Semaphore.cpp | 14 +- tst/utils/SingleLinkedList.cpp | 11 +- tst/utils/StackQueue.cpp | 27 +- tst/utils/StringSearch.cpp | 20 +- tst/utils/StringToInteger.cpp | 72 ++- tst/utils/Tags.cpp | 3 +- tst/utils/Thread.cpp | 12 +- tst/utils/Threadpool.cpp | 16 +- tst/utils/ThreadsafeBlockingQueue.cpp | 89 ++- tst/utils/TimerQueue.cpp | 122 ++-- tst/utils/TrimStringTest.cpp | 10 +- tst/utils/VersionsTest.cpp | 3 +- tst/view/ViewApiFunctionalityTest.cpp | 375 +++++++----- tst/view/ViewApiTest.cpp | 36 +- tst/view/ViewDropPolicyFunctionalityTest.cpp | 123 ++-- tst/view/ViewTestFixture.cpp | 2 +- 84 files changed, 2334 insertions(+), 2971 deletions(-) diff --git a/src/client/include/com/amazonaws/kinesis/video/client/Include.h b/src/client/include/com/amazonaws/kinesis/video/client/Include.h index f2284b7e8..3d153ad1f 100644 --- a/src/client/include/com/amazonaws/kinesis/video/client/Include.h +++ b/src/client/include/com/amazonaws/kinesis/video/client/Include.h @@ -966,9 +966,9 @@ typedef enum { /** * Macros checking for the stream event types */ -#define CHECK_STREAM_EVENT_TYPE_IMAGE_GENERATION(f) (((f) & STREAM_EVENT_TYPE_IMAGE_GENERATION) != STREAM_EVENT_TYPE_NONE) -#define CHECK_STREAM_EVENT_TYPE_NOTIFICATION(f) (((f) & STREAM_EVENT_TYPE_NOTIFICATION) != STREAM_EVENT_TYPE_NONE) -#define CHECK_STREAM_EVENT_TYPE_LAST(f) (((f) & STREAM_EVENT_TYPE_LAST) != STREAM_EVENT_TYPE_NONE) +#define CHECK_STREAM_EVENT_TYPE_IMAGE_GENERATION(f) (((f) &STREAM_EVENT_TYPE_IMAGE_GENERATION) != STREAM_EVENT_TYPE_NONE) +#define CHECK_STREAM_EVENT_TYPE_NOTIFICATION(f) (((f) &STREAM_EVENT_TYPE_NOTIFICATION) != STREAM_EVENT_TYPE_NONE) +#define CHECK_STREAM_EVENT_TYPE_LAST(f) (((f) &STREAM_EVENT_TYPE_LAST) != STREAM_EVENT_TYPE_NONE) typedef enum { diff --git a/src/client/src/Include_i.h b/src/client/src/Include_i.h index aff2748b5..c6626be43 100644 --- a/src/client/src/Include_i.h +++ b/src/client/src/Include_i.h @@ -113,14 +113,14 @@ typedef STATUS (*KinesisVideoClientCallbackHookFunc)(UINT64); /** * Kinesis Video client states definitions */ -#define CLIENT_STATE_NONE ((UINT64) 0) // 0x00 -#define CLIENT_STATE_NEW ((UINT64) (1 << 0)) // 0x01 -#define CLIENT_STATE_AUTH ((UINT64) (1 << 1)) // 0x02 -#define CLIENT_STATE_PROVISION ((UINT64) (1 << 2)) // 0x04 -#define CLIENT_STATE_GET_TOKEN ((UINT64) (1 << 3)) // 0x08 -#define CLIENT_STATE_CREATE ((UINT64) (1 << 4)) // 0x10 -#define CLIENT_STATE_TAG_CLIENT ((UINT64) (1 << 5)) // 0x20 -#define CLIENT_STATE_READY ((UINT64) (1 << 6)) // 0x40 +#define CLIENT_STATE_NONE ((UINT64) 0) // 0x00 +#define CLIENT_STATE_NEW ((UINT64) (1 << 0)) // 0x01 +#define CLIENT_STATE_AUTH ((UINT64) (1 << 1)) // 0x02 +#define CLIENT_STATE_PROVISION ((UINT64) (1 << 2)) // 0x04 +#define CLIENT_STATE_GET_TOKEN ((UINT64) (1 << 3)) // 0x08 +#define CLIENT_STATE_CREATE ((UINT64) (1 << 4)) // 0x10 +#define CLIENT_STATE_TAG_CLIENT ((UINT64) (1 << 5)) // 0x20 +#define CLIENT_STATE_READY ((UINT64) (1 << 6)) // 0x40 /** * Object identifier enum - these will serve as sentinel values to identify diff --git a/src/client/src/Stream.h b/src/client/src/Stream.h index 4594b2919..8e9022b26 100644 --- a/src/client/src/Stream.h +++ b/src/client/src/Stream.h @@ -270,7 +270,7 @@ typedef enum { } UPLOAD_HANDLE_STATE; -#define CHECK_UPLOAD_CONNECTION_STATE_IN_USE(f) (((f) & UPLOAD_CONNECTION_STATE_IN_USE) != UPLOAD_CONNECTION_STATE_NONE) +#define CHECK_UPLOAD_CONNECTION_STATE_IN_USE(f) (((f) &UPLOAD_CONNECTION_STATE_IN_USE) != UPLOAD_CONNECTION_STATE_NONE) /** * Upload connection state enum type definition */ diff --git a/src/common/include/com/amazonaws/kinesis/video/common/CommonDefs.h b/src/common/include/com/amazonaws/kinesis/video/common/CommonDefs.h index b12e3847a..67f293e5d 100644 --- a/src/common/include/com/amazonaws/kinesis/video/common/CommonDefs.h +++ b/src/common/include/com/amazonaws/kinesis/video/common/CommonDefs.h @@ -437,7 +437,7 @@ typedef INT_PTR SSIZE_T, *PSSIZE_T; #define SAFE_DELETE_ARRAY(p) \ do { \ if (p) { \ - delete[] (p); \ + delete[](p); \ (p) = NULL; \ } \ } while (0) @@ -536,11 +536,11 @@ typedef INT_PTR SSIZE_T, *PSSIZE_T; #endif #ifndef S_ISDIR -#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR) +#define S_ISDIR(mode) (((mode) &S_IFMT) == S_IFDIR) #endif #ifndef S_ISREG -#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG) +#define S_ISREG(mode) (((mode) &S_IFMT) == S_IFREG) #endif // Definition of the mkdir for Windows with 1 param @@ -1112,9 +1112,9 @@ typedef SIZE_T ATOMIC_BOOL; #define LOW_INT32(x) ((INT32) (x)) #define HIGH_INT32(x) ((INT32) (((INT64) (x) >> 32) & 0xFFFFFFFF)) -#define MAKE_INT16(a, b) ((INT16) (((UINT8) ((UINT16) (a) & 0xff)) | ((UINT16) ((UINT8) ((UINT16) (b) & 0xff))) << 8)) -#define MAKE_INT32(a, b) ((INT32) (((UINT16) ((UINT32) (a) & 0xffff)) | ((UINT32) ((UINT16) ((UINT32) (b) & 0xffff))) << 16)) -#define MAKE_INT64(a, b) ((INT64) (((UINT32) ((UINT64) (a) & 0xffffffff)) | ((UINT64) ((UINT32) ((UINT64) (b) & 0xffffffff))) << 32)) +#define MAKE_INT16(a, b) ((INT16) (((UINT8) ((UINT16) (a) &0xff)) | ((UINT16) ((UINT8) ((UINT16) (b) &0xff))) << 8)) +#define MAKE_INT32(a, b) ((INT32) (((UINT16) ((UINT32) (a) &0xffff)) | ((UINT32) ((UINT16) ((UINT32) (b) &0xffff))) << 16)) +#define MAKE_INT64(a, b) ((INT64) (((UINT32) ((UINT64) (a) &0xffffffff)) | ((UINT64) ((UINT32) ((UINT64) (b) &0xffffffff))) << 32)) #define SWAP_INT16(x) MAKE_INT16(HIGH_BYTE(x), LOW_BYTE(x)) diff --git a/src/heap/src/AivHeap.h b/src/heap/src/AivHeap.h index 4942fd9ff..5a6cdf763 100644 --- a/src/heap/src/AivHeap.h +++ b/src/heap/src/AivHeap.h @@ -35,7 +35,7 @@ typedef struct AIV_ALLOCATION_HEADER { // Chaining left and right struct AIV_ALLOCATION_HEADER* pNext; struct AIV_ALLOCATION_HEADER* pPrev; -}* PAIV_ALLOCATION_HEADER; +} * PAIV_ALLOCATION_HEADER; // Macros to convert to and from handle #define AIV_HANDLE_SHIFT_BITS 2 diff --git a/src/heap/src/HybridHeap.h b/src/heap/src/HybridHeap.h index 26d052647..e549793ce 100644 --- a/src/heap/src/HybridHeap.h +++ b/src/heap/src/HybridHeap.h @@ -43,7 +43,7 @@ typedef UINT32 (*VramGetMax)(VOID); #define ALIGNMENT_BITS (UINT64) 0x03 #define TO_VRAM_HANDLE(h) ((UINT32) ((UINT64) (h) >> 32)) #define FROM_VRAM_HANDLE(h) (ALLOCATION_HANDLE)(((UINT64) (h) << 32) | ALIGNMENT_BITS) -#define IS_DIRECT_ALLOCATION_HANDLE(h) (((UINT64) (h) & ALIGNMENT_BITS) == (UINT64) 0x00) +#define IS_DIRECT_ALLOCATION_HANDLE(h) (((UINT64) (h) &ALIGNMENT_BITS) == (UINT64) 0x00) /** * Hybrid heap struct diff --git a/src/mkvgen/include/com/amazonaws/kinesis/video/mkvgen/Include.h b/src/mkvgen/include/com/amazonaws/kinesis/video/mkvgen/Include.h index 788f9e4d7..3232d5886 100644 --- a/src/mkvgen/include/com/amazonaws/kinesis/video/mkvgen/Include.h +++ b/src/mkvgen/include/com/amazonaws/kinesis/video/mkvgen/Include.h @@ -155,15 +155,15 @@ extern "C" { /** * Constant definitions for some known codec IDs */ -#define MKV_FOURCC_CODEC_ID ((PCHAR) "V_MS/VFW/FOURCC") -#define MKV_H264_AVC_CODEC_ID ((PCHAR) "V_MPEG4/ISO/AVC") -#define MKV_H265_HEVC_CODEC_ID ((PCHAR) "V_MPEGH/ISO/HEVC") -#define MKV_AAC_MPEG4_MAIN_CODEC_ID ((PCHAR) "A_AAC/MPEG4/MAIN") -#define MKV_AAC_CODEC_ID ((PCHAR) "A_AAC") -#define MKV_PCM_CODEC_ID ((PCHAR) "A_MS/ACM") -#define MKV_PCM_INT_LIT_CODEC_ID ((PCHAR) "A_PCM/INT/LIT") -#define MKV_PCM_INT_BIG_CODEC_ID ((PCHAR) "A_PCM/INT/BIG") -#define MKV_PCM_FLOAT_IEEE_CODEC_ID ((PCHAR) "A_PCM/FLOAT/IEEE") +#define MKV_FOURCC_CODEC_ID ((PCHAR) "V_MS/VFW/FOURCC") +#define MKV_H264_AVC_CODEC_ID ((PCHAR) "V_MPEG4/ISO/AVC") +#define MKV_H265_HEVC_CODEC_ID ((PCHAR) "V_MPEGH/ISO/HEVC") +#define MKV_AAC_MPEG4_MAIN_CODEC_ID ((PCHAR) "A_AAC/MPEG4/MAIN") +#define MKV_AAC_CODEC_ID ((PCHAR) "A_AAC") +#define MKV_PCM_CODEC_ID ((PCHAR) "A_MS/ACM") +#define MKV_PCM_INT_LIT_CODEC_ID ((PCHAR) "A_PCM/INT/LIT") +#define MKV_PCM_INT_BIG_CODEC_ID ((PCHAR) "A_PCM/INT/BIG") +#define MKV_PCM_FLOAT_IEEE_CODEC_ID ((PCHAR) "A_PCM/FLOAT/IEEE") /** * Current versions of the public facing structures @@ -231,10 +231,10 @@ typedef enum { MKV_TREE_TAGS = 0, MKV_TREE_TAG, MKV_TREE_SIMPLE, MKV_TREE_LAST } /** * Macros checking for the frame flags */ -#define CHECK_FRAME_FLAG_KEY_FRAME(f) (((f) & FRAME_FLAG_KEY_FRAME) != FRAME_FLAG_NONE) -#define CHECK_FRAME_FLAG_DISCARDABLE_FRAME(f) (((f) & FRAME_FLAG_DISCARDABLE_FRAME) != FRAME_FLAG_NONE) -#define CHECK_FRAME_FLAG_INVISIBLE_FRAME(f) (((f) & FRAME_FLAG_INVISIBLE_FRAME) != FRAME_FLAG_NONE) -#define CHECK_FRAME_FLAG_END_OF_FRAGMENT(f) (((f) & FRAME_FLAG_END_OF_FRAGMENT) != FRAME_FLAG_NONE) +#define CHECK_FRAME_FLAG_KEY_FRAME(f) (((f) &FRAME_FLAG_KEY_FRAME) != FRAME_FLAG_NONE) +#define CHECK_FRAME_FLAG_DISCARDABLE_FRAME(f) (((f) &FRAME_FLAG_DISCARDABLE_FRAME) != FRAME_FLAG_NONE) +#define CHECK_FRAME_FLAG_INVISIBLE_FRAME(f) (((f) &FRAME_FLAG_INVISIBLE_FRAME) != FRAME_FLAG_NONE) +#define CHECK_FRAME_FLAG_END_OF_FRAGMENT(f) (((f) &FRAME_FLAG_END_OF_FRAGMENT) != FRAME_FLAG_NONE) #define SET_FRAME_FLAG_KEY_FRAME(f) ((f) = (FRAME_FLAGS) (f | FRAME_FLAG_KEY_FRAME)) #define SET_FRAME_FLAG_DISCARDABLE_FRAME(f) ((f) = (FRAME_FLAGS) (f | FRAME_FLAG_DISCARDABLE_FRAME)) diff --git a/src/mkvgen/src/Include_i.h b/src/mkvgen/src/Include_i.h index 928d3e763..efb669f5a 100644 --- a/src/mkvgen/src/Include_i.h +++ b/src/mkvgen/src/Include_i.h @@ -87,7 +87,7 @@ extern DOUBLE gMkvAACSamplingFrequencies[]; extern UINT32 gMkvAACSamplingFrequenciesCount; #define MKV_AAC_SAMPLING_FREQUNECY_IDX_MAX gMkvAACSamplingFrequenciesCount // documented here: https://wiki.multimedia.cx/index.php/MPEG-4_Audio -#define MKV_AAC_CHANNEL_CONFIG_MAX 8 +#define MKV_AAC_CHANNEL_CONFIG_MAX 8 extern BYTE gMkvTrackInfoBits[]; extern UINT32 gMkvTrackInfoBitsSize; @@ -284,7 +284,7 @@ extern UINT32 gMkvTagStringBitsSize; /** * To and from MKV timestamp conversion factoring in the timecode */ -#define TIMESTAMP_TO_MKV_TIMECODE(ts, tcs) ((ts) * DEFAULT_TIME_UNIT_IN_NANOS / (tcs)) +#define TIMESTAMP_TO_MKV_TIMECODE(ts, tcs) ((ts) *DEFAULT_TIME_UNIT_IN_NANOS / (tcs)) #define MKV_TIMECODE_TO_TIMESTAMP(tc, tcs) ((tc) * ((tcs) / DEFAULT_TIME_UNIT_IN_NANOS)) /** diff --git a/src/view/include/com/amazonaws/kinesis/video/view/Include.h b/src/view/include/com/amazonaws/kinesis/video/view/Include.h index 4e2613007..407362495 100644 --- a/src/view/include/com/amazonaws/kinesis/video/view/Include.h +++ b/src/view/include/com/amazonaws/kinesis/video/view/Include.h @@ -68,14 +68,14 @@ extern "C" { /** * Macros for checking/setting/clearing for various flags */ -#define CHECK_ITEM_FRAGMENT_START(f) (((f) & ITEM_FLAG_FRAGMENT_START) != ITEM_FLAG_NONE) -#define CHECK_ITEM_BUFFERING_ACK(f) (((f) & ITEM_FLAG_BUFFERING_ACK) != ITEM_FLAG_NONE) -#define CHECK_ITEM_RECEIVED_ACK(f) (((f) & ITEM_FLAG_RECEIVED_ACK) != ITEM_FLAG_NONE) -#define CHECK_ITEM_STREAM_START(f) (((f) & ITEM_FLAG_STREAM_START) != ITEM_FLAG_NONE) -#define CHECK_ITEM_FRAGMENT_END(f) (((f) & ITEM_FLAG_FRAGMENT_END) != ITEM_FLAG_NONE) -#define CHECK_ITEM_PERSISTED_ACK(f) (((f) & ITEM_FLAG_PERSISTED_ACK) != ITEM_FLAG_NONE) -#define CHECK_ITEM_SKIP_ITEM(f) (((f) & ITEM_FLAG_SKIP_ITEM) != ITEM_FLAG_NONE) -#define CHECK_ITEM_STREAM_START_DEBUG(f) (((f) & ITEM_FLAG_STREAM_START_DEBUG) != ITEM_FLAG_NONE) +#define CHECK_ITEM_FRAGMENT_START(f) (((f) &ITEM_FLAG_FRAGMENT_START) != ITEM_FLAG_NONE) +#define CHECK_ITEM_BUFFERING_ACK(f) (((f) &ITEM_FLAG_BUFFERING_ACK) != ITEM_FLAG_NONE) +#define CHECK_ITEM_RECEIVED_ACK(f) (((f) &ITEM_FLAG_RECEIVED_ACK) != ITEM_FLAG_NONE) +#define CHECK_ITEM_STREAM_START(f) (((f) &ITEM_FLAG_STREAM_START) != ITEM_FLAG_NONE) +#define CHECK_ITEM_FRAGMENT_END(f) (((f) &ITEM_FLAG_FRAGMENT_END) != ITEM_FLAG_NONE) +#define CHECK_ITEM_PERSISTED_ACK(f) (((f) &ITEM_FLAG_PERSISTED_ACK) != ITEM_FLAG_NONE) +#define CHECK_ITEM_SKIP_ITEM(f) (((f) &ITEM_FLAG_SKIP_ITEM) != ITEM_FLAG_NONE) +#define CHECK_ITEM_STREAM_START_DEBUG(f) (((f) &ITEM_FLAG_STREAM_START_DEBUG) != ITEM_FLAG_NONE) #define SET_ITEM_FRAGMENT_START(f) ((f) |= ITEM_FLAG_FRAGMENT_START) #define SET_ITEM_BUFFERING_ACK(f) ((f) |= ITEM_FLAG_BUFFERING_ACK) @@ -96,7 +96,7 @@ extern "C" { #define CLEAR_ITEM_STREAM_START_DEBUG(f) ((f) &= ~ITEM_FLAG_STREAM_START_DEBUG) #define GET_ITEM_DATA_OFFSET(f) ((UINT16) ((f) >> 16)) -#define SET_ITEM_DATA_OFFSET(f, o) ((f) = ((f) & 0x0000ffff) | (((UINT16) (o)) << 16)) +#define SET_ITEM_DATA_OFFSET(f, o) ((f) = ((f) &0x0000ffff) | (((UINT16) (o)) << 16)) /** * This is a sentinel indicating an invalid index value diff --git a/tst/client/AcksFunctionalityTest.cpp b/tst/client/AcksFunctionalityTest.cpp index 3e048812d..6bd6daf44 100644 --- a/tst/client/AcksFunctionalityTest.cpp +++ b/tst/client/AcksFunctionalityTest.cpp @@ -1,14 +1,14 @@ #include "ClientTestFixture.h" -using ::testing::WithParamInterface; using ::testing::Bool; -using ::testing::Values; using ::testing::Combine; +using ::testing::Values; +using ::testing::WithParamInterface; -class AcksFunctionalityTest : public ClientTestBase, - public WithParamInterface< ::std::tuple >{ -protected: - void SetUp() { +class AcksFunctionalityTest : public ClientTestBase, public WithParamInterface< ::std::tuple > { + protected: + void SetUp() + { ClientTestBase::SetUp(); STREAMING_TYPE streamingType; @@ -22,12 +22,12 @@ class AcksFunctionalityTest : public ClientTestBase, } }; #ifdef ALIGNED_MEMORY_MODEL -//Submit various types of error ACKs, Ensure the rollback is done from the ACK error time. +// Submit various types of error ACKs, Ensure the rollback is done from the ACK error time. TEST_P(AcksFunctionalityTest, CheckRollbackFromErrorAckTime) { CreateScenarioTestClient(); BOOL submittedErrorAck = FALSE, didPutFrame, gotStreamData; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; UINT64 stopTime, currentTime, currentIndex; std::vector currentUploadHandles; PViewItem pViewItem; @@ -37,14 +37,14 @@ TEST_P(AcksFunctionalityTest, CheckRollbackFromErrorAckTime) CreateStreamSync(); MockProducer mockProducer(mMockProducerConfig, mStreamHandle); - //putFrame for 10 seconds, should finish putting at least 1 fragment + // putFrame for 10 seconds, should finish putting at least 1 fragment stopTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) + 10 * HUNDREDS_OF_NANOS_IN_A_SECOND; do { currentTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); EXPECT_EQ(STATUS_SUCCESS, mockProducer.timedPutFrame(currentTime, &didPutFrame)); } while (currentTime < stopTime); - //give 10 seconds to getStreamData and submit error ack on the first fragment + // give 10 seconds to getStreamData and submit error ack on the first fragment stopTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) + 10 * HUNDREDS_OF_NANOS_IN_A_SECOND; do { currentTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); @@ -59,13 +59,13 @@ TEST_P(AcksFunctionalityTest, CheckRollbackFromErrorAckTime) retStatus = mockConsumer->timedGetStreamData(currentTime, &gotStreamData); VerifyGetStreamDataResult(retStatus, gotStreamData, uploadHandle, ¤tTime, &mockConsumer); if (mockConsumer != NULL) { - // right now, resetting current is irregardless of the service error code. There just testing SERVICE_CALL_RESULT_FRAGMENT_ARCHIVAL_ERROR is enough + // right now, resetting current is irregardless of the service error code. There just testing + // SERVICE_CALL_RESULT_FRAGMENT_ARCHIVAL_ERROR is enough EXPECT_EQ(STATUS_SUCCESS, mockConsumer->submitErrorAck(SERVICE_CALL_RESULT_FRAGMENT_ARCHIVAL_ERROR, &submittedErrorAck)); } } } while (currentTime < stopTime && !submittedErrorAck); - EXPECT_EQ(TRUE, submittedErrorAck); // check current matches error ack timestamp @@ -80,10 +80,11 @@ TEST_P(AcksFunctionalityTest, CheckRollbackFromErrorAckTime) EXPECT_EQ(pViewItem->ackTimestamp, mFragmentAck.timestamp); } -TEST_P(AcksFunctionalityTest, CreateStreamSubmitPersistedAckBeforeReceivedAckSuccess) { +TEST_P(AcksFunctionalityTest, CreateStreamSubmitPersistedAckBeforeReceivedAckSuccess) +{ CreateScenarioTestClient(); BOOL submittedAck = FALSE, didPutFrame, gotStreamData; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; UINT64 stopTime, currentTime; std::vector currentUploadHandles; STATUS retStatus; @@ -92,7 +93,7 @@ TEST_P(AcksFunctionalityTest, CreateStreamSubmitPersistedAckBeforeReceivedAckSuc CreateStreamSync(); MockProducer mockProducer(mMockProducerConfig, mStreamHandle); - //putFrame for 10 seconds, should finish putting at least 1 fragment + // putFrame for 10 seconds, should finish putting at least 1 fragment stopTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) + 10 * HUNDREDS_OF_NANOS_IN_A_SECOND; do { currentTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); @@ -115,22 +116,19 @@ TEST_P(AcksFunctionalityTest, CreateStreamSubmitPersistedAckBeforeReceivedAckSuc if (mockConsumer != NULL && mockConsumer->mAckQueue.size() > 0) { switch (mockConsumer->mAckQueue.top().mFragmentAck.ackType) { case FRAGMENT_ACK_TYPE_PERSISTED: - EXPECT_EQ(STATUS_SUCCESS, mockConsumer->submitNormalAck(SERVICE_CALL_RESULT_OK, - FRAGMENT_ACK_TYPE_RECEIVED, - mockConsumer->mAckQueue.top().mFragmentAck.timestamp, - &submittedAck)); + EXPECT_EQ(STATUS_SUCCESS, + mockConsumer->submitNormalAck(SERVICE_CALL_RESULT_OK, FRAGMENT_ACK_TYPE_RECEIVED, + mockConsumer->mAckQueue.top().mFragmentAck.timestamp, &submittedAck)); break; case FRAGMENT_ACK_TYPE_RECEIVED: - EXPECT_EQ(STATUS_SUCCESS, mockConsumer->submitNormalAck(SERVICE_CALL_RESULT_OK, - FRAGMENT_ACK_TYPE_PERSISTED, - mockConsumer->mAckQueue.top().mFragmentAck.timestamp, - &submittedAck)); + EXPECT_EQ(STATUS_SUCCESS, + mockConsumer->submitNormalAck(SERVICE_CALL_RESULT_OK, FRAGMENT_ACK_TYPE_PERSISTED, + mockConsumer->mAckQueue.top().mFragmentAck.timestamp, &submittedAck)); break; default: - EXPECT_EQ(STATUS_SUCCESS, mockConsumer->submitNormalAck(SERVICE_CALL_RESULT_OK, - mockConsumer->mAckQueue.top().mFragmentAck.ackType, - mockConsumer->mAckQueue.top().mFragmentAck.timestamp, - &submittedAck)); + EXPECT_EQ(STATUS_SUCCESS, + mockConsumer->submitNormalAck(SERVICE_CALL_RESULT_OK, mockConsumer->mAckQueue.top().mFragmentAck.ackType, + mockConsumer->mAckQueue.top().mFragmentAck.timestamp, &submittedAck)); } mockConsumer->mAckQueue.pop(); } @@ -139,10 +137,11 @@ TEST_P(AcksFunctionalityTest, CreateStreamSubmitPersistedAckBeforeReceivedAckSuc VerifyStopStreamSyncAndFree(); } -TEST_P(AcksFunctionalityTest, CreateStreamSubmitReceivedAckBeforeBufferingAckSuccess) { +TEST_P(AcksFunctionalityTest, CreateStreamSubmitReceivedAckBeforeBufferingAckSuccess) +{ CreateScenarioTestClient(); BOOL submittedAck = FALSE, didPutFrame, gotStreamData; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; UINT64 stopTime, currentTime; std::vector currentUploadHandles; STATUS retStatus; @@ -151,7 +150,7 @@ TEST_P(AcksFunctionalityTest, CreateStreamSubmitReceivedAckBeforeBufferingAckSuc CreateStreamSync(); MockProducer mockProducer(mMockProducerConfig, mStreamHandle); - //putFrame for 10 seconds, should finish putting at least 1 fragment + // putFrame for 10 seconds, should finish putting at least 1 fragment stopTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) + 10 * HUNDREDS_OF_NANOS_IN_A_SECOND; do { currentTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); @@ -174,22 +173,19 @@ TEST_P(AcksFunctionalityTest, CreateStreamSubmitReceivedAckBeforeBufferingAckSuc if (mockConsumer != NULL && mockConsumer->mAckQueue.size() > 0) { switch (mockConsumer->mAckQueue.top().mFragmentAck.ackType) { case FRAGMENT_ACK_TYPE_RECEIVED: - EXPECT_EQ(STATUS_SUCCESS, mockConsumer->submitNormalAck(SERVICE_CALL_RESULT_OK, - FRAGMENT_ACK_TYPE_BUFFERING, - mockConsumer->mAckQueue.top().mFragmentAck.timestamp, - &submittedAck)); + EXPECT_EQ(STATUS_SUCCESS, + mockConsumer->submitNormalAck(SERVICE_CALL_RESULT_OK, FRAGMENT_ACK_TYPE_BUFFERING, + mockConsumer->mAckQueue.top().mFragmentAck.timestamp, &submittedAck)); break; case FRAGMENT_ACK_TYPE_BUFFERING: - EXPECT_EQ(STATUS_SUCCESS, mockConsumer->submitNormalAck(SERVICE_CALL_RESULT_OK, - FRAGMENT_ACK_TYPE_RECEIVED, - mockConsumer->mAckQueue.top().mFragmentAck.timestamp, - &submittedAck)); + EXPECT_EQ(STATUS_SUCCESS, + mockConsumer->submitNormalAck(SERVICE_CALL_RESULT_OK, FRAGMENT_ACK_TYPE_RECEIVED, + mockConsumer->mAckQueue.top().mFragmentAck.timestamp, &submittedAck)); break; default: - EXPECT_EQ(STATUS_SUCCESS, mockConsumer->submitNormalAck(SERVICE_CALL_RESULT_OK, - mockConsumer->mAckQueue.top().mFragmentAck.ackType, - mockConsumer->mAckQueue.top().mFragmentAck.timestamp, - &submittedAck)); + EXPECT_EQ(STATUS_SUCCESS, + mockConsumer->submitNormalAck(SERVICE_CALL_RESULT_OK, mockConsumer->mAckQueue.top().mFragmentAck.ackType, + mockConsumer->mAckQueue.top().mFragmentAck.timestamp, &submittedAck)); } mockConsumer->mAckQueue.pop(); } @@ -198,10 +194,11 @@ TEST_P(AcksFunctionalityTest, CreateStreamSubmitReceivedAckBeforeBufferingAckSuc VerifyStopStreamSyncAndFree(); } -TEST_P(AcksFunctionalityTest, CreateStreamSubmitACKsOutsideOfViewRangeFail) { +TEST_P(AcksFunctionalityTest, CreateStreamSubmitACKsOutsideOfViewRangeFail) +{ CreateScenarioTestClient(); BOOL submittedAck = FALSE, didPutFrame, gotStreamData; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; UINT64 stopTime, currentTime; std::vector currentUploadHandles; STATUS retStatus; @@ -210,7 +207,7 @@ TEST_P(AcksFunctionalityTest, CreateStreamSubmitACKsOutsideOfViewRangeFail) { CreateStreamSync(); MockProducer mockProducer(mMockProducerConfig, mStreamHandle); - //putFrame for 10 seconds, should finish putting at least 1 fragment + // putFrame for 10 seconds, should finish putting at least 1 fragment stopTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) + 10 * HUNDREDS_OF_NANOS_IN_A_SECOND; do { currentTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); @@ -231,16 +228,19 @@ TEST_P(AcksFunctionalityTest, CreateStreamSubmitACKsOutsideOfViewRangeFail) { VerifyGetStreamDataResult(retStatus, gotStreamData, uploadHandle, ¤tTime, &mockConsumer); if (mockConsumer != NULL) { // send one persisted ack falling in future timestamp, should fail as out of content view - EXPECT_EQ(STATUS_ACK_TIMESTAMP_NOT_IN_VIEW_WINDOW, mockConsumer->submitNormalAck(SERVICE_CALL_RESULT_OK, FRAGMENT_ACK_TYPE_PERSISTED, stopTime + 1 * HUNDREDS_OF_NANOS_IN_A_SECOND, &submittedAck)); + EXPECT_EQ(STATUS_ACK_TIMESTAMP_NOT_IN_VIEW_WINDOW, + mockConsumer->submitNormalAck(SERVICE_CALL_RESULT_OK, FRAGMENT_ACK_TYPE_PERSISTED, + stopTime + 1 * HUNDREDS_OF_NANOS_IN_A_SECOND, &submittedAck)); } } } while (currentTime < stopTime && !submittedAck); } -TEST_P(AcksFunctionalityTest, CreateStreamSubmitACKsTerminatedUploadHandle) { +TEST_P(AcksFunctionalityTest, CreateStreamSubmitACKsTerminatedUploadHandle) +{ CreateScenarioTestClient(); BOOL submittedAck = FALSE, didPutFrame, gotStreamData; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; UINT64 stopTime, currentTime, startTime; std::vector currentUploadHandles; STATUS retStatus; @@ -305,5 +305,6 @@ TEST_P(AcksFunctionalityTest, CreateStreamSubmitACKsTerminatedUploadHandle) { } INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, AcksFunctionalityTest, - Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); + Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), + Values(0, TEST_REPLAY_DURATION))); #endif \ No newline at end of file diff --git a/tst/client/CallbacksAndPressuresFunctionalityTest.cpp b/tst/client/CallbacksAndPressuresFunctionalityTest.cpp index fd39e5f61..ab421e5aa 100644 --- a/tst/client/CallbacksAndPressuresFunctionalityTest.cpp +++ b/tst/client/CallbacksAndPressuresFunctionalityTest.cpp @@ -1,15 +1,15 @@ #include "ClientTestFixture.h" -using ::testing::WithParamInterface; using ::testing::Bool; -using ::testing::Values; using ::testing::Combine; +using ::testing::Values; +using ::testing::WithParamInterface; class CallbacksAndPressuresFunctionalityTest : public ClientTestBase, - public WithParamInterface< ::std::tuple >{ - -protected: - void SetUp() { + public WithParamInterface< ::std::tuple > { + protected: + void SetUp() + { ClientTestBase::SetUp(); STREAMING_TYPE streamingType; @@ -23,7 +23,8 @@ class CallbacksAndPressuresFunctionalityTest : public ClientTestBase, } }; #ifdef ALIGNED_MEMORY_MODEL -TEST_P(CallbacksAndPressuresFunctionalityTest, CreateStreamLatencyPressureCallbackCalledSuccess) { +TEST_P(CallbacksAndPressuresFunctionalityTest, CreateStreamLatencyPressureCallbackCalledSuccess) +{ BOOL didPutFrame; UINT64 currentTime, streamStopTime; @@ -51,9 +52,10 @@ TEST_P(CallbacksAndPressuresFunctionalityTest, CreateStreamLatencyPressureCallba } } -TEST_P(CallbacksAndPressuresFunctionalityTest, CreateStreamDelayACKsStaleCallbackCalledSuccess) { +TEST_P(CallbacksAndPressuresFunctionalityTest, CreateStreamDelayACKsStaleCallbackCalledSuccess) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; BOOL didPutFrame, gotStreamData, submittedAck; UINT64 currentTime, streamStopTime, streamStartTime; @@ -152,15 +154,16 @@ TEST_P(CallbacksAndPressuresFunctionalityTest, BiggerBufferDurationThanStorageCh EXPECT_EQ(STATUS_SUCCESS, retStatus); } -// Create Offline stream. Put frame until blocked on availability. StopSync. Send ACK to enable availability. Ensure unblocked put Frame call returns an error. +// Create Offline stream. Put frame until blocked on availability. StopSync. Send ACK to enable availability. Ensure unblocked put Frame call returns +// an error. TEST_P(CallbacksAndPressuresFunctionalityTest, CheckBlockedOfflinePutFrameReturnsErrorAfterStop) { std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; BOOL gotStreamData, submittedAck; UINT64 currentTime, stopTime; TID thread; - STATUS *pRetValue; + STATUS* pRetValue; STREAM_HANDLE streamHandle; PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); @@ -205,12 +208,12 @@ TEST_P(CallbacksAndPressuresFunctionalityTest, CheckBlockedOfflinePutFrameReturn } while (currentTime < stopTime); // The persisted ack should unblock the producer. - THREAD_JOIN(thread, (PVOID *) &pRetValue); + THREAD_JOIN(thread, (PVOID*) &pRetValue); // Check that the last putFrame in producer gets the correct error code. EXPECT_EQ(STATUS_BLOCKING_PUT_INTERRUPTED_STREAM_TERMINATED, mStatus); } - INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, CallbacksAndPressuresFunctionalityTest, - Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); + Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), + Values(0, TEST_REPLAY_DURATION))); #endif \ No newline at end of file diff --git a/tst/client/ClientApiFunctionalityTest.cpp b/tst/client/ClientApiFunctionalityTest.cpp index 29baff5f9..7afd3e549 100644 --- a/tst/client/ClientApiFunctionalityTest.cpp +++ b/tst/client/ClientApiFunctionalityTest.cpp @@ -1,7 +1,7 @@ #include "ClientTestFixture.h" class ClientApiFunctionalityTest : public ClientTestBase { -public: + public: VOID authIntegrationTest(BOOL sync); }; @@ -41,11 +41,9 @@ VOID ClientApiFunctionalityTest::authIntegrationTest(BOOL sync) mClientCallbacks.getSecurityTokenFn = NULL; // Currently provisioning is unsupported so it should fail if (!sync) { - EXPECT_EQ(STATUS_CLIENT_PROVISION_CALL_FAILED, - createKinesisVideoClient(&mDeviceInfo, &mClientCallbacks, &clientHandle)); + EXPECT_EQ(STATUS_CLIENT_PROVISION_CALL_FAILED, createKinesisVideoClient(&mDeviceInfo, &mClientCallbacks, &clientHandle)); } else { - EXPECT_EQ(STATUS_CLIENT_PROVISION_CALL_FAILED, - createKinesisVideoClientSync(&mDeviceInfo, &mClientCallbacks, &clientHandle)); + EXPECT_EQ(STATUS_CLIENT_PROVISION_CALL_FAILED, createKinesisVideoClientSync(&mDeviceInfo, &mClientCallbacks, &clientHandle)); } pKinesisVideoClient = FROM_CLIENT_HANDLE(clientHandle); @@ -65,11 +63,9 @@ VOID ClientApiFunctionalityTest::authIntegrationTest(BOOL sync) mClientCallbacks.getDeviceFingerprintFn = NULL; // Currently provisioning is unsupported so it should fail if (!sync) { - EXPECT_EQ(STATUS_CLIENT_PROVISION_CALL_FAILED, - createKinesisVideoClient(&mDeviceInfo, &mClientCallbacks, &clientHandle)); + EXPECT_EQ(STATUS_CLIENT_PROVISION_CALL_FAILED, createKinesisVideoClient(&mDeviceInfo, &mClientCallbacks, &clientHandle)); } else { - EXPECT_EQ(STATUS_CLIENT_PROVISION_CALL_FAILED, - createKinesisVideoClientSync(&mDeviceInfo, &mClientCallbacks, &clientHandle)); + EXPECT_EQ(STATUS_CLIENT_PROVISION_CALL_FAILED, createKinesisVideoClientSync(&mDeviceInfo, &mClientCallbacks, &clientHandle)); } pKinesisVideoClient = FROM_CLIENT_HANDLE(clientHandle); @@ -145,11 +141,9 @@ VOID ClientApiFunctionalityTest::authIntegrationTest(BOOL sync) mClientCallbacks.getDeviceFingerprintFn = getEmptyDeviceFingerprintFunc; // Currently provisioning is unsupported so it should fail if (!sync) { - EXPECT_EQ(STATUS_CLIENT_PROVISION_CALL_FAILED, - createKinesisVideoClient(&mDeviceInfo, &mClientCallbacks, &clientHandle)); + EXPECT_EQ(STATUS_CLIENT_PROVISION_CALL_FAILED, createKinesisVideoClient(&mDeviceInfo, &mClientCallbacks, &clientHandle)); } else { - EXPECT_EQ(STATUS_CLIENT_PROVISION_CALL_FAILED, - createKinesisVideoClientSync(&mDeviceInfo, &mClientCallbacks, &clientHandle)); + EXPECT_EQ(STATUS_CLIENT_PROVISION_CALL_FAILED, createKinesisVideoClientSync(&mDeviceInfo, &mClientCallbacks, &clientHandle)); } pKinesisVideoClient = FROM_CLIENT_HANDLE(clientHandle); diff --git a/tst/client/ClientApiTest.cpp b/tst/client/ClientApiTest.cpp index 8ed78b387..916e7e398 100644 --- a/tst/client/ClientApiTest.cpp +++ b/tst/client/ClientApiTest.cpp @@ -1,7 +1,6 @@ #include "ClientTestFixture.h" -class ClientApiTest : public ClientTestBase { -}; +class ClientApiTest : public ClientTestBase {}; TEST_F(ClientApiTest, createKinesisVideoClient_NullInput) { @@ -62,8 +61,7 @@ TEST_F(ClientApiTest, createKinesisVideoClient_ValidateCallbacks) mClientCallbacks.getSecurityTokenFn = NULL; mClientCallbacks.getDeviceFingerprintFn = NULL; // We don't support the provisioning yet so it fails - EXPECT_EQ(STATUS_CLIENT_PROVISION_CALL_FAILED, - createKinesisVideoClient(&mDeviceInfo, &mClientCallbacks, &clientHandle)); + EXPECT_EQ(STATUS_CLIENT_PROVISION_CALL_FAILED, createKinesisVideoClient(&mDeviceInfo, &mClientCallbacks, &clientHandle)); EXPECT_TRUE(STATUS_SUCCEEDED(freeKinesisVideoClient(&clientHandle))); mClientCallbacks.getDeviceCertificateFn = getDeviceCertificateFunc; mClientCallbacks.getSecurityTokenFn = getSecurityTokenFunc; @@ -224,21 +222,28 @@ TEST_F(ClientApiTest, createKinesisVideoClient_ValidateDeviceInfo) mDeviceInfo.clientInfo.createClientTimeout = mDeviceInfo.clientInfo.createStreamTimeout = mDeviceInfo.clientInfo.stopStreamTimeout = 0; EXPECT_TRUE(STATUS_SUCCEEDED(createKinesisVideoClient(&mDeviceInfo, &mClientCallbacks, &clientHandle))); PKinesisVideoClient pKinesisVideoClient = FROM_CLIENT_HANDLE(clientHandle); - EXPECT_EQ(CLIENT_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, pKinesisVideoClient->deviceInfo.clientInfo.createClientTimeout); - EXPECT_EQ(STREAM_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, pKinesisVideoClient->deviceInfo.clientInfo.createStreamTimeout); - EXPECT_EQ(STREAM_CLOSED_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, pKinesisVideoClient->deviceInfo.clientInfo.stopStreamTimeout); + EXPECT_EQ(CLIENT_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, + pKinesisVideoClient->deviceInfo.clientInfo.createClientTimeout); + EXPECT_EQ(STREAM_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, + pKinesisVideoClient->deviceInfo.clientInfo.createStreamTimeout); + EXPECT_EQ(STREAM_CLOSED_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, + pKinesisVideoClient->deviceInfo.clientInfo.stopStreamTimeout); mDeviceInfo.clientInfo.createClientTimeout = TEST_DEFAULT_CREATE_CLIENT_TIMEOUT; mDeviceInfo.clientInfo.createStreamTimeout = TEST_DEFAULT_CREATE_STREAM_TIMEOUT; mDeviceInfo.clientInfo.stopStreamTimeout = TEST_DEFAULT_STOP_STREAM_TIMEOUT; EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoClient(&clientHandle)); // Validate the default client timeouts with INVALID_TIMESTAMP_VALUE - mDeviceInfo.clientInfo.createClientTimeout = mDeviceInfo.clientInfo.createStreamTimeout = mDeviceInfo.clientInfo.stopStreamTimeout = INVALID_TIMESTAMP_VALUE; + mDeviceInfo.clientInfo.createClientTimeout = mDeviceInfo.clientInfo.createStreamTimeout = mDeviceInfo.clientInfo.stopStreamTimeout = + INVALID_TIMESTAMP_VALUE; EXPECT_TRUE(STATUS_SUCCEEDED(createKinesisVideoClient(&mDeviceInfo, &mClientCallbacks, &clientHandle))); pKinesisVideoClient = FROM_CLIENT_HANDLE(clientHandle); - EXPECT_EQ(CLIENT_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, pKinesisVideoClient->deviceInfo.clientInfo.createClientTimeout); - EXPECT_EQ(STREAM_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, pKinesisVideoClient->deviceInfo.clientInfo.createStreamTimeout); - EXPECT_EQ(STREAM_CLOSED_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, pKinesisVideoClient->deviceInfo.clientInfo.stopStreamTimeout); + EXPECT_EQ(CLIENT_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, + pKinesisVideoClient->deviceInfo.clientInfo.createClientTimeout); + EXPECT_EQ(STREAM_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, + pKinesisVideoClient->deviceInfo.clientInfo.createStreamTimeout); + EXPECT_EQ(STREAM_CLOSED_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, + pKinesisVideoClient->deviceInfo.clientInfo.stopStreamTimeout); mDeviceInfo.clientInfo.createClientTimeout = TEST_DEFAULT_CREATE_CLIENT_TIMEOUT; mDeviceInfo.clientInfo.createStreamTimeout = TEST_DEFAULT_CREATE_STREAM_TIMEOUT; mDeviceInfo.clientInfo.stopStreamTimeout = TEST_DEFAULT_STOP_STREAM_TIMEOUT; @@ -259,9 +264,12 @@ TEST_F(ClientApiTest, createKinesisVideoClient_ValidateDeviceInfo) mDeviceInfo.version = DEVICE_INFO_CURRENT_VERSION - 1; EXPECT_TRUE(STATUS_SUCCEEDED(createKinesisVideoClient(&mDeviceInfo, &mClientCallbacks, &clientHandle))); pKinesisVideoClient = FROM_CLIENT_HANDLE(clientHandle); - EXPECT_EQ(CLIENT_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, pKinesisVideoClient->deviceInfo.clientInfo.createClientTimeout); - EXPECT_EQ(STREAM_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, pKinesisVideoClient->deviceInfo.clientInfo.createStreamTimeout); - EXPECT_EQ(STREAM_CLOSED_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, pKinesisVideoClient->deviceInfo.clientInfo.stopStreamTimeout); + EXPECT_EQ(CLIENT_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, + pKinesisVideoClient->deviceInfo.clientInfo.createClientTimeout); + EXPECT_EQ(STREAM_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, + pKinesisVideoClient->deviceInfo.clientInfo.createStreamTimeout); + EXPECT_EQ(STREAM_CLOSED_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, + pKinesisVideoClient->deviceInfo.clientInfo.stopStreamTimeout); EXPECT_EQ(FALSE, pKinesisVideoClient->deviceInfo.clientInfo.logMetric); EXPECT_EQ(0, pKinesisVideoClient->deviceInfo.clientInfo.metricLoggingPeriod); mDeviceInfo.version = DEVICE_INFO_CURRENT_VERSION; @@ -275,9 +283,12 @@ TEST_F(ClientApiTest, createKinesisVideoClient_ValidateDeviceInfo) deviceInfo_v0.version = DEVICE_INFO_CURRENT_VERSION - 1; EXPECT_TRUE(STATUS_SUCCEEDED(createKinesisVideoClient((PDeviceInfo) &deviceInfo_v0, &mClientCallbacks, &clientHandle))); pKinesisVideoClient = FROM_CLIENT_HANDLE(clientHandle); - EXPECT_EQ(CLIENT_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, pKinesisVideoClient->deviceInfo.clientInfo.createClientTimeout); - EXPECT_EQ(STREAM_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, pKinesisVideoClient->deviceInfo.clientInfo.createStreamTimeout); - EXPECT_EQ(STREAM_CLOSED_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, pKinesisVideoClient->deviceInfo.clientInfo.stopStreamTimeout); + EXPECT_EQ(CLIENT_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, + pKinesisVideoClient->deviceInfo.clientInfo.createClientTimeout); + EXPECT_EQ(STREAM_READY_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, + pKinesisVideoClient->deviceInfo.clientInfo.createStreamTimeout); + EXPECT_EQ(STREAM_CLOSED_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND, + pKinesisVideoClient->deviceInfo.clientInfo.stopStreamTimeout); EXPECT_EQ('\0', pKinesisVideoClient->deviceInfo.clientId[0]); EXPECT_EQ(FALSE, pKinesisVideoClient->deviceInfo.clientInfo.logMetric); EXPECT_EQ(0, pKinesisVideoClient->deviceInfo.clientInfo.metricLoggingPeriod); @@ -305,7 +316,6 @@ TEST_F(ClientApiTest, client_info_version_test) EXPECT_EQ(SERVICE_CALL_DEFAULT_TIMEOUT, pKinesisVideoClient->deviceInfo.clientInfo.serviceCallCompletionTimeout); EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoClient(&clientHandle)); - // Test with version 1 mDeviceInfo.clientInfo.version = 1; EXPECT_EQ(STATUS_SUCCESS, createKinesisVideoClient(&mDeviceInfo, &mClientCallbacks, &clientHandle)); @@ -464,14 +474,13 @@ TEST_F(ClientApiTest, getKinesisVideoMetrics_Invalid) EXPECT_NE(STATUS_SUCCESS, getKinesisVideoMetrics(INVALID_CLIENT_HANDLE_VALUE, &kinesisVideoClientMetrics)); kinesisVideoClientMetrics.version = CLIENT_METRICS_CURRENT_VERSION + 1; EXPECT_NE(STATUS_SUCCESS, getKinesisVideoMetrics(mClientHandle, &kinesisVideoClientMetrics)); - } TEST_F(ClientApiTest, getKinesisVideoMetrics_Valid) { ClientMetrics kinesisVideoClientMetrics; // Testing all versions - for(UINT64 i = 0; i <= CLIENT_METRICS_CURRENT_VERSION; i++) { + for (UINT64 i = 0; i <= CLIENT_METRICS_CURRENT_VERSION; i++) { kinesisVideoClientMetrics.version = i; EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoMetrics(mClientHandle, &kinesisVideoClientMetrics)); } @@ -504,7 +513,7 @@ TEST_F(ClientApiTest, getStreamMetrics_Valid) EXPECT_EQ(STATUS_SUCCESS, createKinesisVideoStream(mClientHandle, &mStreamInfo, &streamHandle)); // Testing all versions - for(UINT64 i = 0; i <= STREAM_METRICS_CURRENT_VERSION; i++) { + for (UINT64 i = 0; i <= STREAM_METRICS_CURRENT_VERSION; i++) { streamMetrics.version = i; EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamMetrics(streamHandle, &streamMetrics)); } diff --git a/tst/client/ClientFunctionalityTest.cpp b/tst/client/ClientFunctionalityTest.cpp index 98367d8a7..1b984a097 100644 --- a/tst/client/ClientFunctionalityTest.cpp +++ b/tst/client/ClientFunctionalityTest.cpp @@ -1,14 +1,15 @@ #include "ClientTestFixture.h" -using ::testing::WithParamInterface; using ::testing::Bool; -using ::testing::Values; using ::testing::Combine; +using ::testing::Values; +using ::testing::WithParamInterface; class ClientFunctionalityTest : public ClientTestBase, - public WithParamInterface< ::std::tuple >{ -protected: - void SetUp() { + public WithParamInterface< ::std::tuple > { + protected: + void SetUp() + { ClientTestBase::SetUp(); STREAMING_TYPE streamingType; @@ -60,7 +61,7 @@ TEST_P(ClientFunctionalityTest, CreateSyncAndFree) TEST_P(ClientFunctionalityTest, CreateAndFree) { - //Free the existing client + // Free the existing client if (IS_VALID_CLIENT_HANDLE(mClientHandle)) { EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoClient(&mClientHandle)); } @@ -129,7 +130,7 @@ TEST_P(ClientFunctionalityTest, CreateClientCreateStreamSyncStopStreamFreeClient EXPECT_TRUE(!IS_VALID_CLIENT_HANDLE(mClientHandle)); } #ifdef ALIGNED_MEMORY_MODEL -//Create Producer, Create Streams, Await Ready, Put Frame, Free Producer +// Create Producer, Create Streams, Await Ready, Put Frame, Free Producer TEST_P(ClientFunctionalityTest, CreateClientCreateStreamPutFrameFreeClient) { CreateScenarioTestClient(); @@ -143,16 +144,15 @@ TEST_P(ClientFunctionalityTest, CreateClientCreateStreamPutFrameFreeClient) { MockProducer mockProducer(mMockProducerConfig, mStreamHandle); - //Stream is ready by now, so putFrame should succeed + // Stream is ready by now, so putFrame should succeed EXPECT_EQ(STATUS_SUCCESS, mockProducer.putFrame()); } - EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoClient(&mClientHandle)); EXPECT_TRUE(!IS_VALID_CLIENT_HANDLE(mClientHandle)); } -//Create Producer, Create Streams, Await Ready, Put Frame, Stop Stream, Free Producer +// Create Producer, Create Streams, Await Ready, Put Frame, Stop Stream, Free Producer TEST_P(ClientFunctionalityTest, CreateClientCreateStreamPutFrameStopStreamFreeClient) { CreateScenarioTestClient(); @@ -166,7 +166,7 @@ TEST_P(ClientFunctionalityTest, CreateClientCreateStreamPutFrameStopStreamFreeCl { MockProducer mockProducer(mMockProducerConfig, mStreamHandle); - //Stream is ready by now, so putFrame should succeed + // Stream is ready by now, so putFrame should succeed EXPECT_EQ(STATUS_SUCCESS, mockProducer.putFrame()); } @@ -176,7 +176,7 @@ TEST_P(ClientFunctionalityTest, CreateClientCreateStreamPutFrameStopStreamFreeCl EXPECT_TRUE(ATOMIC_LOAD(&mDroppedFrameReportFuncCount) > 0); // the frame put should be dropped. } -//Create Producer, Create Streams Sync, Await Ready, Put Frame, Free Producer +// Create Producer, Create Streams Sync, Await Ready, Put Frame, Free Producer TEST_P(ClientFunctionalityTest, CreateClientCreateStreamSyncPutFrameFreeClient) { TID thread; @@ -211,7 +211,7 @@ TEST_P(ClientFunctionalityTest, CreateClientCreateStreamSyncPutFrameFreeClient) { MockProducer mockProducer(mMockProducerConfig, mStreamHandle); - //Stream is ready by now, so putFrame should succeed + // Stream is ready by now, so putFrame should succeed EXPECT_EQ(STATUS_SUCCESS, mockProducer.putFrame()); } @@ -219,7 +219,7 @@ TEST_P(ClientFunctionalityTest, CreateClientCreateStreamSyncPutFrameFreeClient) EXPECT_TRUE(!IS_VALID_CLIENT_HANDLE(mClientHandle)); } -//Create Producer, Create Streams Sync, Await Ready, Put Frame, Stop Stream, Free Producer +// Create Producer, Create Streams Sync, Await Ready, Put Frame, Stop Stream, Free Producer TEST_P(ClientFunctionalityTest, CreateClientCreateStreamSyncPutFrameStopStreamFreeClient) { TID thread; @@ -254,7 +254,7 @@ TEST_P(ClientFunctionalityTest, CreateClientCreateStreamSyncPutFrameStopStreamFr { MockProducer mockProducer(mMockProducerConfig, mStreamHandle); - //Stream is ready by now, so putFrame should succeed + // Stream is ready by now, so putFrame should succeed EXPECT_EQ(STATUS_SUCCESS, mockProducer.putFrame()); } @@ -263,7 +263,7 @@ TEST_P(ClientFunctionalityTest, CreateClientCreateStreamSyncPutFrameStopStreamFr EXPECT_TRUE(!IS_VALID_CLIENT_HANDLE(mClientHandle)); } #endif -//Create producer, create streams sync, create same stream and fail, free client +// Create producer, create streams sync, create same stream and fail, free client TEST_P(ClientFunctionalityTest, CreateClientCreateStreamSyncCreateSameStreamAndFailFreeClient) { TID thread; @@ -298,7 +298,7 @@ TEST_P(ClientFunctionalityTest, CreateClientCreateStreamSyncCreateSameStreamAndF EXPECT_TRUE(!IS_VALID_CLIENT_HANDLE(mClientHandle)); } -//Create Stream, call streamformatchanged twice with audio and video. make sure proper mkv header is generated. +// Create Stream, call streamformatchanged twice with audio and video. make sure proper mkv header is generated. TEST_P(ClientFunctionalityTest, StreamFormatChangedAudioVideoCorrectMkvHeader) { CreateScenarioTestClient(); @@ -322,10 +322,9 @@ TEST_P(ClientFunctionalityTest, StreamFormatChangedAudioVideoCorrectMkvHeader) mStreamInfo.streamCaps.trackInfoCount = 2; BYTE audioCpd[] = {0x11, 0x90, 0x56, 0xe5, 0x00}; - BYTE videoCpd[] = {0x01, 0x4d, 0x00, 0x20, 0xff, 0xe1, 0x00, 0x22, 0x27, 0x4d, 0x00, 0x20, 0x89, - 0x8b, 0x60, 0x28, 0x02, 0xdd, 0x80, 0x88, 0x00, 0x01, 0x38, 0x80, 0x00, 0x3d, - 0x09, 0x07, 0x03, 0x00, 0x05, 0xdc, 0x00, 0x01, 0x77, 0x05, 0xef, 0x7c, 0x1f, - 0x08, 0x84, 0x6e, 0x01, 0x00, 0x04, 0x28, 0xee, 0x1f, 0x20}; + BYTE videoCpd[] = {0x01, 0x4d, 0x00, 0x20, 0xff, 0xe1, 0x00, 0x22, 0x27, 0x4d, 0x00, 0x20, 0x89, 0x8b, 0x60, 0x28, 0x02, + 0xdd, 0x80, 0x88, 0x00, 0x01, 0x38, 0x80, 0x00, 0x3d, 0x09, 0x07, 0x03, 0x00, 0x05, 0xdc, 0x00, 0x01, + 0x77, 0x05, 0xef, 0x7c, 0x1f, 0x08, 0x84, 0x6e, 0x01, 0x00, 0x04, 0x28, 0xee, 0x1f, 0x20}; STRNCPY(mStreamInfo.streamCaps.contentType, TEST_AUDIO_VIDEO_CONTENT_TYPE, MAX_CONTENT_TYPE_LEN); @@ -352,7 +351,7 @@ TEST_P(ClientFunctionalityTest, StreamFormatChangedAudioVideoCorrectMkvHeader) EXPECT_TRUE(!IS_VALID_CLIENT_HANDLE(mClientHandle)); } -//Create Stream, call streamformatchanged twice with audio and video. make sure proper mkv header is generated. +// Create Stream, call streamformatchanged twice with audio and video. make sure proper mkv header is generated. TEST_P(ClientFunctionalityTest, StreamFormatChangedPcmAudioVideoCorrectMkvHeader) { CreateScenarioTestClient(); @@ -376,10 +375,9 @@ TEST_P(ClientFunctionalityTest, StreamFormatChangedPcmAudioVideoCorrectMkvHeader mStreamInfo.streamCaps.trackInfoCount = 2; BYTE audioCpd[] = {0x06, 0x00, 0x01, 0x00, 0x40, 0x1f, 0x00, 0x00, 0x80, 0x3e, 0x00, 0x00, 0x02, 0x00, 0x10, 0x00, 0x00, 0x00}; - BYTE videoCpd[] = {0x01, 0x4d, 0x00, 0x20, 0xff, 0xe1, 0x00, 0x22, 0x27, 0x4d, 0x00, 0x20, 0x89, - 0x8b, 0x60, 0x28, 0x02, 0xdd, 0x80, 0x88, 0x00, 0x01, 0x38, 0x80, 0x00, 0x3d, - 0x09, 0x07, 0x03, 0x00, 0x05, 0xdc, 0x00, 0x01, 0x77, 0x05, 0xef, 0x7c, 0x1f, - 0x08, 0x84, 0x6e, 0x01, 0x00, 0x04, 0x28, 0xee, 0x1f, 0x20}; + BYTE videoCpd[] = {0x01, 0x4d, 0x00, 0x20, 0xff, 0xe1, 0x00, 0x22, 0x27, 0x4d, 0x00, 0x20, 0x89, 0x8b, 0x60, 0x28, 0x02, + 0xdd, 0x80, 0x88, 0x00, 0x01, 0x38, 0x80, 0x00, 0x3d, 0x09, 0x07, 0x03, 0x00, 0x05, 0xdc, 0x00, 0x01, + 0x77, 0x05, 0xef, 0x7c, 0x1f, 0x08, 0x84, 0x6e, 0x01, 0x00, 0x04, 0x28, 0xee, 0x1f, 0x20}; STRNCPY(mStreamInfo.streamCaps.contentType, "video/h264,audio/alaw", MAX_CONTENT_TYPE_LEN); @@ -449,11 +447,7 @@ TEST_P(ClientFunctionalityTest, StreamFormatChangedGeneratedPcmAlawAudioDirectCp BYTE cpd[KVS_PCM_CPD_SIZE_BYTE]; UINT32 cpdSize = SIZEOF(cpd); - EXPECT_EQ(STATUS_SUCCESS, mkvgenGeneratePcmCpd(KVS_PCM_FORMAT_CODE_ALAW, - 8000, - 2, - cpd, - cpdSize)); + EXPECT_EQ(STATUS_SUCCESS, mkvgenGeneratePcmCpd(KVS_PCM_FORMAT_CODE_ALAW, 8000, 2, cpd, cpdSize)); TrackInfo trackInfo[1]; trackInfo[0].trackId = 1; @@ -493,11 +487,7 @@ TEST_P(ClientFunctionalityTest, StreamFormatChangedGeneratedPcmMlawAudioDirectCp BYTE cpd[KVS_PCM_CPD_SIZE_BYTE]; UINT32 cpdSize = SIZEOF(cpd); - EXPECT_EQ(STATUS_SUCCESS, mkvgenGeneratePcmCpd(KVS_PCM_FORMAT_CODE_MULAW, - 8000, - 2, - cpd, - cpdSize)); + EXPECT_EQ(STATUS_SUCCESS, mkvgenGeneratePcmCpd(KVS_PCM_FORMAT_CODE_MULAW, 8000, 2, cpd, cpdSize)); TrackInfo trackInfo[1]; trackInfo[0].trackId = 1; @@ -537,11 +527,7 @@ TEST_P(ClientFunctionalityTest, StreamFormatChangedGeneratedAacAudioDirectCpdPas BYTE cpd[KVS_AAC_CPD_SIZE_BYTE]; UINT32 cpdSize = SIZEOF(cpd); - EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateAacCpd(AAC_MAIN, - 16000, - 2, - cpd, - cpdSize)); + EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateAacCpd(AAC_MAIN, 16000, 2, cpd, cpdSize)); TrackInfo trackInfo[1]; trackInfo[0].trackId = 1; @@ -576,8 +562,6 @@ TEST_P(ClientFunctionalityTest, StreamFormatChangedGeneratedAacAudioDirectCpdPas } INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, ClientFunctionalityTest, - Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), - Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), - Bool(), - Values(0, TEST_REPLAY_DURATION), - Values(DEVICE_STORAGE_TYPE_IN_MEM, DEVICE_STORAGE_TYPE_IN_MEM_CONTENT_STORE_ALLOC))); \ No newline at end of file + Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), + Values(0, TEST_REPLAY_DURATION), + Values(DEVICE_STORAGE_TYPE_IN_MEM, DEVICE_STORAGE_TYPE_IN_MEM_CONTENT_STORE_ALLOC))); \ No newline at end of file diff --git a/tst/client/ClientTestFixture.cpp b/tst/client/ClientTestFixture.cpp index 05f9b9f6c..74b75820a 100644 --- a/tst/client/ClientTestFixture.cpp +++ b/tst/client/ClientTestFixture.cpp @@ -8,7 +8,7 @@ UINT64 ClientTestBase::getCurrentTimeFunc(UINT64 customData) { DLOGV("TID 0x%016llx getCurrentTimeFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -24,7 +24,7 @@ UINT64 ClientTestBase::getCurrentPresetTimeFunc(UINT64 customData) { DLOGV("TID 0x%016llx getCurrentPresetTimeFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -43,8 +43,7 @@ UINT64 ClientTestBase::getCurrentIncrementalTimeFunc(UINT64 customData) { DLOGV("TID 0x%016llx getCurrentIncrementalTimeFunc called.", GETTID()); - - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; UINT64 time = pClient->getTestTimeVal(); pClient->incrementTestTimeVal(TEST_TIME_INCREMENT); @@ -59,7 +58,7 @@ UINT32 ClientTestBase::getRandomNumberFunc(UINT64 customData) { DLOGV("TID 0x%016llx getRandomNumberFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -75,7 +74,7 @@ UINT32 ClientTestBase::getRandomNumberConstFunc(UINT64 customData) { DLOGV("TID 0x%016llx getRandomNumberConstFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -101,7 +100,7 @@ STATUS ClientTestBase::getDeviceCertificateFunc(UINT64 customData, PBYTE* ppCert { DLOGV("TID 0x%016llx getDeviceCertificateFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -120,7 +119,7 @@ STATUS ClientTestBase::getSecurityTokenFunc(UINT64 customData, PBYTE* ppToken, P { DLOGV("TID 0x%016llx getSecurityTokenFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -139,7 +138,7 @@ STATUS ClientTestBase::getDeviceFingerprintFunc(UINT64 customData, PCHAR* ppFing { DLOGV("TID 0x%016llx getDeviceFingerprintFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -156,7 +155,7 @@ STATUS ClientTestBase::getEmptyDeviceCertificateFunc(UINT64 customData, PBYTE* p { DLOGV("TID 0x%016llx getEmptyDeviceCertificateFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -175,7 +174,7 @@ STATUS ClientTestBase::getEmptySecurityTokenFunc(UINT64 customData, PBYTE* ppTok { DLOGV("TID 0x%016llx getEmptySecurityTokenFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -194,7 +193,7 @@ STATUS ClientTestBase::getEmptyDeviceFingerprintFunc(UINT64 customData, PCHAR* p { DLOGV("TID 0x%016llx getEmptyDeviceFingerprintFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -211,7 +210,7 @@ STATUS ClientTestBase::streamUnderflowReportFunc(UINT64 customData, STREAM_HANDL { DLOGV("TID 0x%016llx streamUnderflowReportFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -228,7 +227,7 @@ STATUS ClientTestBase::storageOverflowPressureFunc(UINT64 customData, UINT64 rem { DLOGV("TID 0x%016llx storageOverflowPressureFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -245,7 +244,7 @@ STATUS ClientTestBase::streamLatencyPressureFunc(UINT64 customData, STREAM_HANDL { DLOGV("TID 0x%016llx streamLatencyPressureFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -263,7 +262,7 @@ STATUS ClientTestBase::droppedFrameReportFunc(UINT64 customData, STREAM_HANDLE s { DLOGV("TID 0x%016llx droppedFrameReportFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -277,10 +276,11 @@ STATUS ClientTestBase::droppedFrameReportFunc(UINT64 customData, STREAM_HANDLE s return STATUS_SUCCESS; } -STATUS ClientTestBase::bufferDurationOverflowPressureFunc(UINT64 customData, STREAM_HANDLE streamHandle, UINT64 remainingDuration){ +STATUS ClientTestBase::bufferDurationOverflowPressureFunc(UINT64 customData, STREAM_HANDLE streamHandle, UINT64 remainingDuration) +{ DLOGV("TID 0x%016llx bufferDurationOverflowPressureFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -297,7 +297,7 @@ STATUS ClientTestBase::droppedFragmentReportFunc(UINT64 customData, STREAM_HANDL { DLOGV("TID 0x%016llx droppedFragmentReportFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -315,7 +315,7 @@ STATUS ClientTestBase::streamReadyFunc(UINT64 customData, STREAM_HANDLE streamHa { DLOGV("TID 0x%016llx streamReadyFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -333,7 +333,7 @@ STATUS ClientTestBase::streamClosedFunc(UINT64 customData, STREAM_HANDLE streamH { DLOGV("TID 0x%016llx streamClosedFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -348,16 +348,12 @@ STATUS ClientTestBase::streamClosedFunc(UINT64 customData, STREAM_HANDLE streamH return STATUS_SUCCESS; } -STATUS ClientTestBase::streamDataAvailableFunc(UINT64 customData, - STREAM_HANDLE streamHandle, - PCHAR streamName, - UINT64 streamUploadHandle, - UINT64 duration, - UINT64 size) +STATUS ClientTestBase::streamDataAvailableFunc(UINT64 customData, STREAM_HANDLE streamHandle, PCHAR streamName, UINT64 streamUploadHandle, + UINT64 duration, UINT64 size) { DLOGV("TID 0x%016llx streamDataAvailableFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -376,15 +372,12 @@ STATUS ClientTestBase::streamDataAvailableFunc(UINT64 customData, return STATUS_SUCCESS; } -STATUS ClientTestBase::streamErrorReportFunc(UINT64 customData, - STREAM_HANDLE streamHandle, - UPLOAD_HANDLE upload_handle, - UINT64 timecode, +STATUS ClientTestBase::streamErrorReportFunc(UINT64 customData, STREAM_HANDLE streamHandle, UPLOAD_HANDLE upload_handle, UINT64 timecode, STATUS status) { DLOGV("TID 0x%016llx streamErrorReportFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -399,13 +392,11 @@ STATUS ClientTestBase::streamErrorReportFunc(UINT64 customData, return STATUS_SUCCESS; } -STATUS ClientTestBase::streamConnectionStaleFunc(UINT64 customData, - STREAM_HANDLE streamHandle, - UINT64 duration) +STATUS ClientTestBase::streamConnectionStaleFunc(UINT64 customData, STREAM_HANDLE streamHandle, UINT64 duration) { DLOGV("TID 0x%016llx streamConnectionStaleFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -419,14 +410,11 @@ STATUS ClientTestBase::streamConnectionStaleFunc(UINT64 customData, return STATUS_SUCCESS; } -STATUS ClientTestBase::fragmentAckReceivedFunc(UINT64 customData, - STREAM_HANDLE streamHandle, - UPLOAD_HANDLE upload_handle, - PFragmentAck pFragmentAck) +STATUS ClientTestBase::fragmentAckReceivedFunc(UINT64 customData, STREAM_HANDLE streamHandle, UPLOAD_HANDLE upload_handle, PFragmentAck pFragmentAck) { DLOGV("TID 0x%016llx fragmentAckReceivedFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -440,7 +428,8 @@ STATUS ClientTestBase::fragmentAckReceivedFunc(UINT64 customData, return STATUS_SUCCESS; } -STATUS ClientTestBase::createRetryStrategyFn(PKvsRetryStrategy pKvsRetryStrategy) { +STATUS ClientTestBase::createRetryStrategyFn(PKvsRetryStrategy pKvsRetryStrategy) +{ STATUS retStatus = STATUS_SUCCESS; PExponentialBackoffRetryStrategyState pExponentialBackoffRetryStrategyState = NULL; @@ -457,15 +446,18 @@ STATUS ClientTestBase::createRetryStrategyFn(PKvsRetryStrategy pKvsRetryStrategy return STATUS_SUCCESS; } -STATUS ClientTestBase::getCurrentRetryAttemptNumberFn(PKvsRetryStrategy pKvsRetryStrategy, PUINT32 pRetryCount) { +STATUS ClientTestBase::getCurrentRetryAttemptNumberFn(PKvsRetryStrategy pKvsRetryStrategy, PUINT32 pRetryCount) +{ return getExponentialBackoffRetryCount(pKvsRetryStrategy, pRetryCount); } -STATUS ClientTestBase::freeRetryStrategyFn(PKvsRetryStrategy pKvsRetryStrategy) { +STATUS ClientTestBase::freeRetryStrategyFn(PKvsRetryStrategy pKvsRetryStrategy) +{ return exponentialBackoffRetryStrategyFree(pKvsRetryStrategy); } -STATUS ClientTestBase::executeRetryStrategyFn(PKvsRetryStrategy pKvsRetryStrategy, PUINT64 retryWaitTime) { +STATUS ClientTestBase::executeRetryStrategyFn(PKvsRetryStrategy pKvsRetryStrategy, PUINT64 retryWaitTime) +{ return getExponentialBackoffRetryStrategyWaitTime(pKvsRetryStrategy, retryWaitTime); } @@ -473,7 +465,7 @@ STATUS ClientTestBase::clientReadyFunc(UINT64 customData, CLIENT_HANDLE clientHa { DLOGV("TID 0x%016llx clientReadyFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -491,7 +483,7 @@ STATUS ClientTestBase::clientShutdownFunc(UINT64 customData, CLIENT_HANDLE clien { DLOGV("TID 0x%016llx clientShutdownFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -509,7 +501,7 @@ STATUS ClientTestBase::streamShutdownFunc(UINT64 customData, STREAM_HANDLE strea { DLOGV("TID 0x%016llx streamShutdownFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -528,7 +520,7 @@ MUTEX ClientTestBase::createMutexFunc(UINT64 customData, BOOL reentant) { DLOGV("TID 0x%016llx createMutexFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -541,7 +533,7 @@ VOID ClientTestBase::lockMutexFunc(UINT64 customData, MUTEX mutex) { DLOGV("TID 0x%016llx lockMutexFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -554,7 +546,7 @@ VOID ClientTestBase::unlockMutexFunc(UINT64 customData, MUTEX mutex) { DLOGV("TID 0x%016llx unlockMutexFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -567,7 +559,7 @@ BOOL ClientTestBase::tryLockMutexFunc(UINT64 customData, MUTEX mutex) { DLOGV("TID 0x%016llx tryLockMutexFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -580,7 +572,7 @@ VOID ClientTestBase::freeMutexFunc(UINT64 customData, MUTEX mutex) { DLOGV("TID 0x%016llx freeMutexFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -593,7 +585,7 @@ CVAR ClientTestBase::createConditionVariableFunc(UINT64 customData) { DLOGV("TID 0x%016llx createConditionVariableFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -606,7 +598,7 @@ STATUS ClientTestBase::signalConditionVariableFunc(UINT64 customData, CVAR cvar) { DLOGV("TID 0x%016llx signalConditionVariableFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -619,7 +611,7 @@ STATUS ClientTestBase::broadcastConditionVariableFunc(UINT64 customData, CVAR cv { DLOGV("TID 0x%016llx broadcastConditionVariableFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -628,14 +620,11 @@ STATUS ClientTestBase::broadcastConditionVariableFunc(UINT64 customData, CVAR cv return CVAR_BROADCAST(cvar); } -STATUS ClientTestBase::waitConditionVariableFunc(UINT64 customData, - CVAR cvar, - MUTEX mutex, - UINT64 timeout) +STATUS ClientTestBase::waitConditionVariableFunc(UINT64 customData, CVAR cvar, MUTEX mutex, UINT64 timeout) { DLOGV("TID 0x%016llx waitConditionVariableFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -648,7 +637,7 @@ VOID ClientTestBase::freeConditionVariableFunc(UINT64 customData, CVAR cvar) { DLOGV("TID 0x%016llx freeConditionVariableFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -657,17 +646,12 @@ VOID ClientTestBase::freeConditionVariableFunc(UINT64 customData, CVAR cvar) return CVAR_FREE(cvar); } -STATUS ClientTestBase::createStreamFunc(UINT64 customData, - PCHAR deviceName, - PCHAR streamName, - PCHAR contentType, - PCHAR kmsKeyId, - UINT64 retention, +STATUS ClientTestBase::createStreamFunc(UINT64 customData, PCHAR deviceName, PCHAR streamName, PCHAR contentType, PCHAR kmsKeyId, UINT64 retention, PServiceCallContext pCallbackContext) { DLOGV("TID 0x%016llx createStreamFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -697,13 +681,11 @@ STATUS ClientTestBase::createStreamFunc(UINT64 customData, return STATUS_SUCCESS; } -STATUS ClientTestBase::describeStreamFunc(UINT64 customData, - PCHAR streamName, - PServiceCallContext pCallbackContext) +STATUS ClientTestBase::describeStreamFunc(UINT64 customData, PCHAR streamName, PServiceCallContext pCallbackContext) { DLOGV("TID 0x%016llx describeStreamFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; STATUS retStatus = STATUS_SUCCESS; MUTEX_LOCK(pClient->mTestClientMutex); @@ -730,7 +712,8 @@ STATUS ClientTestBase::describeStreamFunc(UINT64 customData, pClient->setupStreamDescription(); // Execute a couple of times - pClient->mStreamDescription.streamStatus = ATOMIC_LOAD(&pClient->mDescribeStreamFuncCount) < 3 ? STREAM_STATUS_CREATING : STREAM_STATUS_ACTIVE; + pClient->mStreamDescription.streamStatus = + ATOMIC_LOAD(&pClient->mDescribeStreamFuncCount) < 3 ? STREAM_STATUS_CREATING : STREAM_STATUS_ACTIVE; retStatus = describeStreamResultEvent(pCallbackContext->customData, SERVICE_CALL_RESULT_OK, &pClient->mStreamDescription); } ATOMIC_INCREMENT(&pClient->mDescribeStreamDoneFuncCount); @@ -739,13 +722,11 @@ STATUS ClientTestBase::describeStreamFunc(UINT64 customData, return retStatus; } -STATUS ClientTestBase::describeStreamMultiStreamFunc(UINT64 customData, - PCHAR streamName, - PServiceCallContext pCallbackContext) +STATUS ClientTestBase::describeStreamMultiStreamFunc(UINT64 customData, PCHAR streamName, PServiceCallContext pCallbackContext) { DLOGV("TID 0x%016llx describeStreamMultiStreamFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; STATUS retStatus = STATUS_SUCCESS; MUTEX_LOCK(pClient->mTestClientMutex); @@ -763,14 +744,11 @@ STATUS ClientTestBase::describeStreamMultiStreamFunc(UINT64 customData, return retStatus; } -STATUS ClientTestBase::getStreamingEndpointFunc(UINT64 customData, - PCHAR streamName, - PCHAR apiName, - PServiceCallContext pCallbackContext) +STATUS ClientTestBase::getStreamingEndpointFunc(UINT64 customData, PCHAR streamName, PCHAR apiName, PServiceCallContext pCallbackContext) { DLOGV("TID 0x%016llx getStreamingEndpointFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; STATUS retStatus = STATUS_SUCCESS; MUTEX_LOCK(pClient->mTestClientMutex); @@ -801,14 +779,11 @@ STATUS ClientTestBase::getStreamingEndpointFunc(UINT64 customData, return retStatus; } -STATUS ClientTestBase::getStreamingEndpointMultiStreamFunc(UINT64 customData, - PCHAR streamName, - PCHAR apiName, - PServiceCallContext pCallbackContext) +STATUS ClientTestBase::getStreamingEndpointMultiStreamFunc(UINT64 customData, PCHAR streamName, PCHAR apiName, PServiceCallContext pCallbackContext) { DLOGV("TID 0x%016llx getStreamingEndpointMultiStreamFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; STATUS retStatus = STATUS_SUCCESS; MUTEX_LOCK(pClient->mTestClientMutex); @@ -823,14 +798,11 @@ STATUS ClientTestBase::getStreamingEndpointMultiStreamFunc(UINT64 customData, return retStatus; } -STATUS ClientTestBase::getStreamingTokenFunc(UINT64 customData, - PCHAR streamName, - STREAM_ACCESS_MODE accessMode, - PServiceCallContext pCallbackContext) +STATUS ClientTestBase::getStreamingTokenFunc(UINT64 customData, PCHAR streamName, STREAM_ACCESS_MODE accessMode, PServiceCallContext pCallbackContext) { DLOGV("TID 0x%016llx getStreamingTokenFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; STATUS retStatus = STATUS_SUCCESS; MUTEX_LOCK(pClient->mTestClientMutex); @@ -868,9 +840,7 @@ STATUS ClientTestBase::getStreamingTokenFunc(UINT64 customData, pKinesisVideoClient->clientCallbacks.unlockMutexFn(pKinesisVideoClient->clientCallbacks.customData, pKinesisVideoStream->base.lock); } - retStatus = getStreamingTokenResultEvent(pCallbackContext->customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) TEST_STREAMING_TOKEN, + retStatus = getStreamingTokenResultEvent(pCallbackContext->customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, SIZEOF(TEST_STREAMING_TOKEN), currentTime + HUNDREDS_OF_NANOS_IN_A_SECOND + MIN_STREAMING_TOKEN_EXPIRATION_DURATION); } @@ -879,43 +849,31 @@ STATUS ClientTestBase::getStreamingTokenFunc(UINT64 customData, return retStatus; } -STATUS ClientTestBase::getStreamingTokenMultiStreamFunc(UINT64 customData, - PCHAR streamName, - STREAM_ACCESS_MODE accessMode, - PServiceCallContext pCallbackContext) +STATUS ClientTestBase::getStreamingTokenMultiStreamFunc(UINT64 customData, PCHAR streamName, STREAM_ACCESS_MODE accessMode, + PServiceCallContext pCallbackContext) { DLOGV("TID 0x%016llx getStreamingTokenMultiStreamFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; STATUS retStatus = STATUS_SUCCESS; MUTEX_LOCK(pClient->mTestClientMutex); STRCPY(pClient->mStreamName, streamName); - - retStatus = getStreamingTokenResultEvent(pCallbackContext->customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - MAX_UINT64); + retStatus = getStreamingTokenResultEvent(pCallbackContext->customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), MAX_UINT64); MUTEX_UNLOCK(pClient->mTestClientMutex); return retStatus; } -STATUS ClientTestBase::putStreamFunc(UINT64 customData, - PCHAR streamName, - PCHAR containerType, - UINT64 streamStartTime, - BOOL absoluteFragmentTimestamp, - BOOL ackRequired, - PCHAR streamingEndpoint, - PServiceCallContext pCallbackContext) +STATUS ClientTestBase::putStreamFunc(UINT64 customData, PCHAR streamName, PCHAR containerType, UINT64 streamStartTime, BOOL absoluteFragmentTimestamp, + BOOL ackRequired, PCHAR streamingEndpoint, PServiceCallContext pCallbackContext) { DLOGV("TID 0x%016llx putStreamFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -941,28 +899,21 @@ STATUS ClientTestBase::putStreamFunc(UINT64 customData, } if (pClient->mSubmitServiceCallResultMode >= STOP_AT_PUT_STREAM) { - UPLOAD_HANDLE uploadHandle = pClient->mStreamingSession.addNewConsumerSession(pClient->mMockConsumerConfig, - pClient->mStreamHandle); - EXPECT_EQ(STATUS_SUCCESS, - putStreamResultEvent(pClient->mCallContext.customData, SERVICE_CALL_RESULT_OK, uploadHandle)); + UPLOAD_HANDLE uploadHandle = pClient->mStreamingSession.addNewConsumerSession(pClient->mMockConsumerConfig, pClient->mStreamHandle); + EXPECT_EQ(STATUS_SUCCESS, putStreamResultEvent(pClient->mCallContext.customData, SERVICE_CALL_RESULT_OK, uploadHandle)); } MUTEX_UNLOCK(pClient->mTestClientMutex); return STATUS_SUCCESS; } -STATUS ClientTestBase::putStreamMultiStreamFunc(UINT64 customData, - PCHAR streamName, - PCHAR containerType, - UINT64 streamStartTime, - BOOL absoluteFragmentTimestamp, - BOOL ackRequired, - PCHAR streamingEndpoint, - PServiceCallContext pCallbackContext) +STATUS ClientTestBase::putStreamMultiStreamFunc(UINT64 customData, PCHAR streamName, PCHAR containerType, UINT64 streamStartTime, + BOOL absoluteFragmentTimestamp, BOOL ackRequired, PCHAR streamingEndpoint, + PServiceCallContext pCallbackContext) { DLOGV("TID 0x%016llx putStreamMultiStreamFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); @@ -970,22 +921,17 @@ STATUS ClientTestBase::putStreamMultiStreamFunc(UINT64 customData, STRCPY(pClient->mStreamingEndpoint, streamingEndpoint); pClient->mStreamStartTime = streamStartTime; pClient->mAckRequired = ackRequired; - EXPECT_EQ(STATUS_SUCCESS, - putStreamResultEvent((STREAM_HANDLE) pCallbackContext->customData, SERVICE_CALL_RESULT_OK, (UPLOAD_HANDLE) 0)); + EXPECT_EQ(STATUS_SUCCESS, putStreamResultEvent((STREAM_HANDLE) pCallbackContext->customData, SERVICE_CALL_RESULT_OK, (UPLOAD_HANDLE) 0)); MUTEX_UNLOCK(pClient->mTestClientMutex); return STATUS_SUCCESS; } -STATUS ClientTestBase::tagResourceFunc(UINT64 customData, - PCHAR resourceArn, - UINT32 tagCount, - PTag tags, - PServiceCallContext pCallbackContext) +STATUS ClientTestBase::tagResourceFunc(UINT64 customData, PCHAR resourceArn, UINT32 tagCount, PTag tags, PServiceCallContext pCallbackContext) { DLOGV("TID 0x%016llx tagResourceFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -1011,13 +957,11 @@ STATUS ClientTestBase::tagResourceFunc(UINT64 customData, return STATUS_SUCCESS; } -STATUS ClientTestBase::createDeviceFunc(UINT64 customData, - PCHAR deviceName, - PServiceCallContext pCallbackContext) +STATUS ClientTestBase::createDeviceFunc(UINT64 customData, PCHAR deviceName, PServiceCallContext pCallbackContext) { DLOGV("TID 0x%016llx createDeviceFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -1039,8 +983,7 @@ STATUS ClientTestBase::createDeviceFunc(UINT64 customData, } if (pClient->mClientSyncMode) { - EXPECT_EQ(STATUS_SUCCESS, - createDeviceResultEvent(pCallbackContext->customData, SERVICE_CALL_RESULT_OK, TEST_DEVICE_ARN)); + EXPECT_EQ(STATUS_SUCCESS, createDeviceResultEvent(pCallbackContext->customData, SERVICE_CALL_RESULT_OK, TEST_DEVICE_ARN)); } ATOMIC_INCREMENT(&pClient->mCreateDeviceDoneFuncCount); MUTEX_UNLOCK(pClient->mTestClientMutex); @@ -1048,13 +991,11 @@ STATUS ClientTestBase::createDeviceFunc(UINT64 customData, return STATUS_SUCCESS; } -STATUS ClientTestBase::deviceCertToTokenFunc(UINT64 customData, - PCHAR deviceName, - PServiceCallContext pCallbackContext) +STATUS ClientTestBase::deviceCertToTokenFunc(UINT64 customData, PCHAR deviceName, PServiceCallContext pCallbackContext) { DLOGV("TID 0x%016llx deviceCertToTokenFunc called.", GETTID()); - ClientTestBase *pClient = (ClientTestBase*) customData; + ClientTestBase* pClient = (ClientTestBase*) customData; MUTEX_LOCK(pClient->mTestClientMutex); EXPECT_TRUE(pClient != NULL && ATOMIC_LOAD(&pClient->mMagic) == TEST_CLIENT_MAGIC_NUMBER); @@ -1076,11 +1017,9 @@ STATUS ClientTestBase::deviceCertToTokenFunc(UINT64 customData, } if (pClient->mClientSyncMode) { - EXPECT_EQ(STATUS_SUCCESS, deviceCertToTokenResultEvent(pCallbackContext->customData, - SERVICE_CALL_RESULT_OK, - pClient->mToken, - pClient->mTokenSize, - pClient->mTokenExpiration)); + EXPECT_EQ(STATUS_SUCCESS, + deviceCertToTokenResultEvent(pCallbackContext->customData, SERVICE_CALL_RESULT_OK, pClient->mToken, pClient->mTokenSize, + pClient->mTokenExpiration)); } MUTEX_UNLOCK(pClient->mTestClientMutex); diff --git a/tst/client/FrameOrderCoordinatorTest.cpp b/tst/client/FrameOrderCoordinatorTest.cpp index 78c852d84..583c06229 100644 --- a/tst/client/FrameOrderCoordinatorTest.cpp +++ b/tst/client/FrameOrderCoordinatorTest.cpp @@ -1,7 +1,6 @@ #include "ClientTestFixture.h" -class FrameOrderCoordinatorTest : public ClientTestBase { -}; +class FrameOrderCoordinatorTest : public ClientTestBase {}; TEST_F(FrameOrderCoordinatorTest, avTsComparatorVariations) { diff --git a/tst/client/IntermittentProducerAutomaticStreamingTest.cpp b/tst/client/IntermittentProducerAutomaticStreamingTest.cpp index b32b56f37..da9bb2cf7 100644 --- a/tst/client/IntermittentProducerAutomaticStreamingTest.cpp +++ b/tst/client/IntermittentProducerAutomaticStreamingTest.cpp @@ -1,17 +1,17 @@ #include "ClientTestFixture.h" -using ::testing::WithParamInterface; using ::testing::Bool; -using ::testing::Values; using ::testing::Combine; +using ::testing::Values; +using ::testing::WithParamInterface; -class IntermittentProducerAutomaticStreamingTest : public ClientTestBase, - public WithParamInterface< ::std::tuple > { -protected: - StreamInfo mStreamInfo2; - TrackInfo mTrackInfo2; +class IntermittentProducerAutomaticStreamingTest : public ClientTestBase, public WithParamInterface< ::std::tuple > { + protected: + StreamInfo mStreamInfo2; + TrackInfo mTrackInfo2; - void SetUp() { + void SetUp() + { ClientTestBase::SetUpWithoutClientCreation(); UINT64 callbackInterval; UINT32 clientInfoVersion; @@ -23,7 +23,8 @@ class IntermittentProducerAutomaticStreamingTest : public ClientTestBase, mStreamInfo.streamCaps.absoluteFragmentTimes = TRUE; } - void initStreamInfo2() { + void initStreamInfo2() + { // Initialize stream info mStreamInfo2.version = STREAM_INFO_CURRENT_VERSION; mStreamInfo2.tagCount = 0; @@ -64,7 +65,6 @@ class IntermittentProducerAutomaticStreamingTest : public ClientTestBase, mStreamInfo2.streamCaps.trackInfoList = &mTrackInfo2; } - }; STATUS timerCallbackPreHook(UINT64 hookCustomData) @@ -78,7 +78,8 @@ STATUS timerCallbackPreHook(UINT64 hookCustomData) #ifdef ALIGNED_MEMORY_MODEL -TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerInvokedBeforeTime) { +TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerInvokedBeforeTime) +{ // Create new client so param value of callbackPeriod can be applied ASSERT_EQ(STATUS_SUCCESS, CreateClient()); @@ -89,7 +90,6 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerInvokedBeforeTim client->timerCallbackPreHookFunc = timerCallbackPreHook; client->clientCallbacks.unlockMutexFn(client->clientCallbacks.customData, client->base.lock); - EXPECT_EQ(0, ATOMIC_LOAD(&mTimerCallbackFuncCount)); // Create synchronously @@ -113,7 +113,8 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerInvokedBeforeTim EXPECT_EQ(1, ATOMIC_LOAD(&mTimerCallbackFuncCount)); } -TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerInvokedAfterFirstPeriod) { +TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerInvokedAfterFirstPeriod) +{ // Create new client so param value of callbackPeriod can be applied ASSERT_EQ(STATUS_SUCCESS, CreateClient()); @@ -124,7 +125,7 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerInvokedAfterFirs client->timerCallbackPreHookFunc = timerCallbackPreHook; client->clientCallbacks.unlockMutexFn(client->clientCallbacks.customData, client->base.lock); -// Create synchronously + // Create synchronously CreateStreamSync(); // Produce a frame @@ -145,7 +146,8 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerInvokedAfterFirs EXPECT_EQ(2, ATOMIC_LOAD(&mTimerCallbackFuncCount)); } -TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerContinueInvocationsAfterStopStream) { +TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerContinueInvocationsAfterStopStream) +{ // Create new client so param value of callbackPeriod can be applied ASSERT_EQ(STATUS_SUCCESS, CreateClient()); @@ -156,7 +158,7 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerContinueInvocati client->timerCallbackPreHookFunc = timerCallbackPreHook; client->clientCallbacks.unlockMutexFn(client->clientCallbacks.customData, client->base.lock); -// Create synchronously + // Create synchronously CreateStreamSync(); mStreamUploadHandle = 0; @@ -178,7 +180,7 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerContinueInvocati EXPECT_EQ(STATUS_SUCCESS, notifyStreamClosed(FROM_STREAM_HANDLE(mStreamHandle), mStreamUploadHandle)); - THREAD_SLEEP(2 * HUNDREDS_OF_NANOS_IN_A_SECOND); + THREAD_SLEEP(2 * HUNDREDS_OF_NANOS_IN_A_SECOND); EXPECT_EQ(STATUS_SUCCESS, stopKinesisVideoStreamSync(mStreamHandle)); EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoStream(&mStreamHandle)); @@ -196,9 +198,8 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerContinueInvocati EXPECT_TRUE(afterCount <= beforeCount + m + 1); } - - -TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerNoMoreInvocationsAfterFreeClient) { +TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerNoMoreInvocationsAfterFreeClient) +{ // Create new client so param value of callbackPeriod can be applied ASSERT_EQ(STATUS_SUCCESS, CreateClient()); @@ -236,8 +237,8 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerNoMoreInvocation EXPECT_EQ(val, ATOMIC_LOAD(&mTimerCallbackFuncCount)); } -TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerNoInvocationsWithAutoStreamingOFF) { - +TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerNoInvocationsWithAutoStreamingOFF) +{ mDeviceInfo.clientInfo.automaticStreamingFlags = AUTOMATIC_STREAMING_ALWAYS_CONTINUOUS; // Validate timerqueue is never constructed @@ -249,7 +250,6 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerNoInvocationsWit client->timerCallbackPreHookFunc = timerCallbackPreHook; client->clientCallbacks.unlockMutexFn(client->clientCallbacks.customData, client->base.lock); - // Create synchronously CreateStreamSync(); @@ -272,7 +272,8 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateTimerNoInvocationsWit EXPECT_EQ(0, ATOMIC_LOAD(&mTimerCallbackFuncCount)); } -TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateLastUpdateTimeOfStreamUpdated) { +TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateLastUpdateTimeOfStreamUpdated) +{ // Create new client so param value of callbackPeriod can be applied ASSERT_EQ(STATUS_SUCCESS, CreateClient()); @@ -292,7 +293,7 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateLastUpdateTimeOfStrea EXPECT_EQ(stream->lastPutFrameTimestamp, INVALID_TIMESTAMP_VALUE); client->clientCallbacks.unlockMutexFn(client->clientCallbacks.customData, stream->base.lock); -// Produce a frame + // Produce a frame BYTE temp[100]; Frame frame; frame.trackId = 1; @@ -317,7 +318,7 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateLastUpdateTimeOfStrea EXPECT_EQ(0, ATOMIC_LOAD(&mTimerCallbackFuncCount)); - while(ATOMIC_LOAD(&mTimerCallbackFuncCount) < 1 && waitTime < 1.5*INTERMITTENT_PRODUCER_TIMER_START_DELAY) { + while (ATOMIC_LOAD(&mTimerCallbackFuncCount) < 1 && waitTime < 1.5 * INTERMITTENT_PRODUCER_TIMER_START_DELAY) { THREAD_SLEEP(200 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); waitTime += 200 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND; } @@ -342,7 +343,8 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateLastUpdateTimeOfStrea EXPECT_TRUE(eoFrFrameTs > firstFrameTs); } -TEST_P(IntermittentProducerAutomaticStreamingTest, MultiTrackVerifyNoInvocationsWithSingleTrackProducer) { +TEST_P(IntermittentProducerAutomaticStreamingTest, MultiTrackVerifyNoInvocationsWithSingleTrackProducer) +{ // Create new client so param value of callbackPeriod can be applied mStreamInfo.streamCaps.absoluteFragmentTimes = FALSE; ASSERT_EQ(STATUS_SUCCESS, CreateClient()); @@ -391,12 +393,12 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, MultiTrackVerifyNoInvocations UINT64 startTime; UINT64 ts; - UINT64 expectedFramesInTimeout = INTERMITTENT_PRODUCER_MAX_TIMEOUT/HUNDREDS_OF_NANOS_IN_A_SECOND; - UINT64 track2FrameMax = expectedFramesInTimeout/4; + UINT64 expectedFramesInTimeout = INTERMITTENT_PRODUCER_MAX_TIMEOUT / HUNDREDS_OF_NANOS_IN_A_SECOND; + UINT64 track2FrameMax = expectedFramesInTimeout / 4; - UINT64 expectedCalls = 1.25*INTERMITTENT_PRODUCER_MAX_TIMEOUT / mDeviceInfo.clientInfo.reservedCallbackPeriod; + UINT64 expectedCalls = 1.25 * INTERMITTENT_PRODUCER_MAX_TIMEOUT / mDeviceInfo.clientInfo.reservedCallbackPeriod; - for ( ts = 0; ts < 1.5*INTERMITTENT_PRODUCER_MAX_TIMEOUT; ts+= HUNDREDS_OF_NANOS_IN_A_SECOND ) { + for (ts = 0; ts < 1.5 * INTERMITTENT_PRODUCER_MAX_TIMEOUT; ts += HUNDREDS_OF_NANOS_IN_A_SECOND) { startTime = GETTIME(); frame.presentationTs = ts; frame.decodingTs = ts; @@ -408,14 +410,14 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, MultiTrackVerifyNoInvocations EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFrame(streamHandle, &frame)); // only put frames in track 2 for first 5s - if ( frameCount <= track2FrameMax ) { + if (frameCount <= track2FrameMax) { frame.trackId = 2; EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFrame(streamHandle, &frame)); } frameCount++; - UINT64 diff = GETTIME()-startTime; - if ( diff < HUNDREDS_OF_NANOS_IN_A_SECOND ) { + UINT64 diff = GETTIME() - startTime; + if (diff < HUNDREDS_OF_NANOS_IN_A_SECOND) { THREAD_SLEEP(HUNDREDS_OF_NANOS_IN_A_SECOND - diff); } } @@ -428,7 +430,8 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, MultiTrackVerifyNoInvocations client->clientCallbacks.unlockMutexFn(client->clientCallbacks.customData, stream->base.lock); } -TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateNoConsecutiveEOFR) { +TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateNoConsecutiveEOFR) +{ // Create new client so param value of callbackPeriod can be applied ASSERT_EQ(STATUS_SUCCESS, CreateClient()); @@ -473,14 +476,13 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateNoConsecutiveEOFR) { * an error in put frame). */ - for (ts = 0; ts < 60 * HUNDREDS_OF_NANOS_IN_A_SECOND; ts += HUNDREDS_OF_NANOS_IN_A_SECOND) { startTime = GETTIME(); frame.presentationTs = ts; frame.decodingTs = ts; frame.duration = HUNDREDS_OF_NANOS_IN_A_SECOND; - if ( ts < 5 * HUNDREDS_OF_NANOS_IN_A_SECOND || ts > 55 * HUNDREDS_OF_NANOS_IN_A_SECOND) { + if (ts < 5 * HUNDREDS_OF_NANOS_IN_A_SECOND || ts > 55 * HUNDREDS_OF_NANOS_IN_A_SECOND) { frame.flags = frameCountS1 % 5 == 0 ? FRAME_FLAG_KEY_FRAME : FRAME_FLAG_NONE; frame.index = frameCountS1++; @@ -488,14 +490,15 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateNoConsecutiveEOFR) { EXPECT_EQ(0, ATOMIC_LOAD(&mStreamErrorReportFuncCount)); } - UINT64 diff = GETTIME()-startTime; - if ( diff < HUNDREDS_OF_NANOS_IN_A_SECOND ) { + UINT64 diff = GETTIME() - startTime; + if (diff < HUNDREDS_OF_NANOS_IN_A_SECOND) { THREAD_SLEEP(HUNDREDS_OF_NANOS_IN_A_SECOND - diff); } } } -TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateErrorOnForceConsecutiveEOFR) { +TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateErrorOnForceConsecutiveEOFR) +{ // Create new client so param value of callbackPeriod can be applied ASSERT_EQ(STATUS_SUCCESS, CreateClient()); @@ -548,7 +551,7 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateErrorOnForceConsecuti frame.decodingTs = ts; frame.duration = HUNDREDS_OF_NANOS_IN_A_SECOND; - if ( ts < 5 * HUNDREDS_OF_NANOS_IN_A_SECOND) { + if (ts < 5 * HUNDREDS_OF_NANOS_IN_A_SECOND) { frame.flags = frameCountS1 % 5 == 0 ? FRAME_FLAG_KEY_FRAME : FRAME_FLAG_NONE; frame.index = frameCountS1++; @@ -556,8 +559,7 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateErrorOnForceConsecuti EXPECT_EQ(0, ATOMIC_LOAD(&mStreamErrorReportFuncCount)); } - - if ( ts >= 35 * HUNDREDS_OF_NANOS_IN_A_SECOND) { + if (ts >= 35 * HUNDREDS_OF_NANOS_IN_A_SECOND) { // Lock the Stream because PIC can be reading/writing this value as well client->clientCallbacks.lockMutexFn(client->clientCallbacks.customData, stream->base.lock); EXPECT_TRUE(stream->eofrFrame); @@ -567,14 +569,15 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateErrorOnForceConsecuti EXPECT_EQ(STATUS_MULTIPLE_CONSECUTIVE_EOFR, putKinesisVideoFrame(streamHandle, &eofrFrame)); } - UINT64 diff = GETTIME()-startTime; - if ( diff < HUNDREDS_OF_NANOS_IN_A_SECOND ) { + UINT64 diff = GETTIME() - startTime; + if (diff < HUNDREDS_OF_NANOS_IN_A_SECOND) { THREAD_SLEEP(HUNDREDS_OF_NANOS_IN_A_SECOND - diff); } } } -TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateMultiStream) { +TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateMultiStream) +{ // Create new client so param value of callbackPeriod can be applied mClientCallbacks.describeStreamFn = describeStreamMultiStreamFunc; mClientCallbacks.getStreamingEndpointFn = getStreamingEndpointMultiStreamFunc; @@ -583,7 +586,6 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateMultiStream) { mClientCallbacks.streamReadyFn = NULL; - ASSERT_EQ(STATUS_SUCCESS, CreateClient()); PKinesisVideoClient client = FROM_CLIENT_HANDLE(mClientHandle); @@ -643,20 +645,19 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateMultiStream) { * is NO eofr. Then both streams keep producing streams until t = 60s, no eofrs on either stream */ - for (ts = 0; ts < 3 * INTERMITTENT_PRODUCER_MAX_TIMEOUT; ts += HUNDREDS_OF_NANOS_IN_A_SECOND) { startTime = GETTIME(); frame.presentationTs = ts; frame.decodingTs = ts; frame.duration = HUNDREDS_OF_NANOS_IN_A_SECOND; - if ( ts < 5 * HUNDREDS_OF_NANOS_IN_A_SECOND || ts > 35 * HUNDREDS_OF_NANOS_IN_A_SECOND) { + if (ts < 5 * HUNDREDS_OF_NANOS_IN_A_SECOND || ts > 35 * HUNDREDS_OF_NANOS_IN_A_SECOND) { frame.flags = frameCountS1 % 5 == 0 ? FRAME_FLAG_KEY_FRAME : FRAME_FLAG_NONE; frame.index = frameCountS1++; EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFrame(sh1, &frame)); - if ( (ts > 40 * HUNDREDS_OF_NANOS_IN_A_SECOND) ) { + if ((ts > 40 * HUNDREDS_OF_NANOS_IN_A_SECOND)) { // We should no longer have eofr // Lock the Stream because PIC can be reading/writing this value as well client->clientCallbacks.lockMutexFn(client->clientCallbacks.customData, stream1->base.lock); @@ -666,20 +667,20 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateMultiStream) { } // expect s1 to be in eofr state - if ( ts < 35 * HUNDREDS_OF_NANOS_IN_A_SECOND && ts > 30 * HUNDREDS_OF_NANOS_IN_A_SECOND ) { + if (ts < 35 * HUNDREDS_OF_NANOS_IN_A_SECOND && ts > 30 * HUNDREDS_OF_NANOS_IN_A_SECOND) { // Lock the Stream because PIC can be reading/writing this value as well client->clientCallbacks.lockMutexFn(client->clientCallbacks.customData, stream1->base.lock); EXPECT_TRUE(stream1->eofrFrame); client->clientCallbacks.unlockMutexFn(client->clientCallbacks.customData, stream1->base.lock); } - if ( ts < 15 * HUNDREDS_OF_NANOS_IN_A_SECOND || (ts > 45 * HUNDREDS_OF_NANOS_IN_A_SECOND)) { + if (ts < 15 * HUNDREDS_OF_NANOS_IN_A_SECOND || (ts > 45 * HUNDREDS_OF_NANOS_IN_A_SECOND)) { frame.flags = frameCountS2 % 5 == 0 ? FRAME_FLAG_KEY_FRAME : FRAME_FLAG_NONE; frame.index = frameCountS2++; EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFrame(sh2, &frame)); - if ( (ts > 50 * HUNDREDS_OF_NANOS_IN_A_SECOND) ) { + if ((ts > 50 * HUNDREDS_OF_NANOS_IN_A_SECOND)) { // Lock the Stream because PIC can be reading/writing this value as well client->clientCallbacks.lockMutexFn(client->clientCallbacks.customData, stream2->base.lock); // We should no longer have eofr @@ -689,23 +690,21 @@ TEST_P(IntermittentProducerAutomaticStreamingTest, ValidateMultiStream) { } // expect s2 to be in eofr state - if ( ts < 45 * HUNDREDS_OF_NANOS_IN_A_SECOND && ts > 40 * HUNDREDS_OF_NANOS_IN_A_SECOND ) { + if (ts < 45 * HUNDREDS_OF_NANOS_IN_A_SECOND && ts > 40 * HUNDREDS_OF_NANOS_IN_A_SECOND) { // Lock the Stream because PIC can be reading/writing this value as well client->clientCallbacks.lockMutexFn(client->clientCallbacks.customData, stream2->base.lock); EXPECT_TRUE(stream2->eofrFrame); client->clientCallbacks.unlockMutexFn(client->clientCallbacks.customData, stream2->base.lock); } - UINT64 diff = GETTIME()-startTime; - if ( diff < HUNDREDS_OF_NANOS_IN_A_SECOND ) { + UINT64 diff = GETTIME() - startTime; + if (diff < HUNDREDS_OF_NANOS_IN_A_SECOND) { THREAD_SLEEP(HUNDREDS_OF_NANOS_IN_A_SECOND - diff); } } } - - INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, IntermittentProducerAutomaticStreamingTest, - Combine(Values(1000,2000,3000), Values(0, CLIENT_INFO_CURRENT_VERSION))); + Combine(Values(1000, 2000, 3000), Values(0, CLIENT_INFO_CURRENT_VERSION))); #endif \ No newline at end of file diff --git a/tst/client/IntermittentProducerFunctionalityTest.cpp b/tst/client/IntermittentProducerFunctionalityTest.cpp index 8a5f172d0..0a2b78219 100644 --- a/tst/client/IntermittentProducerFunctionalityTest.cpp +++ b/tst/client/IntermittentProducerFunctionalityTest.cpp @@ -1,14 +1,15 @@ #include "ClientTestFixture.h" -using ::testing::WithParamInterface; using ::testing::Bool; -using ::testing::Values; using ::testing::Combine; +using ::testing::Values; +using ::testing::WithParamInterface; class IntermittentProducerFunctionalityTest : public ClientTestBase, - public WithParamInterface< ::std::tuple >{ -protected: - void SetUp() { + public WithParamInterface< ::std::tuple > { + protected: + void SetUp() + { ClientTestBase::SetUp(); STREAMING_TYPE streamingType; @@ -22,12 +23,13 @@ class IntermittentProducerFunctionalityTest : public ClientTestBase, } }; #ifdef ALIGNED_MEMORY_MODEL -TEST_P(IntermittentProducerFunctionalityTest, CreateSyncStreamWithLargeBufferAwaitForLastAckStopSyncFreeSuccess) { +TEST_P(IntermittentProducerFunctionalityTest, CreateSyncStreamWithLargeBufferAwaitForLastAckStopSyncFreeSuccess) +{ UINT64 currentTime, testTerminationTime, endPutFrameTime; BOOL didPutFrame, gotStreamData, submittedAck; UINT32 tokenRotateCount = 0; std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; STATUS retStatus; int intermittentProducerSessionCount = 0; @@ -37,7 +39,6 @@ TEST_P(IntermittentProducerFunctionalityTest, CreateSyncStreamWithLargeBufferAwa PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); do { - CreateStreamSync(); MockProducer mockProducer(mMockProducerConfig, mStreamHandle); @@ -51,9 +52,8 @@ TEST_P(IntermittentProducerFunctionalityTest, CreateSyncStreamWithLargeBufferAwa } while (currentTime < endPutFrameTime); - - testTerminationTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) - + 1 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 5 * HUNDREDS_OF_NANOS_IN_A_SECOND; + testTerminationTime = + mClientCallbacks.getCurrentTimeFn((UINT64) this) + 1 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 5 * HUNDREDS_OF_NANOS_IN_A_SECOND; do { currentTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); @@ -63,7 +63,7 @@ TEST_P(IntermittentProducerFunctionalityTest, CreateSyncStreamWithLargeBufferAwa for (int i = 0; i < currentUploadHandles.size(); i++) { UPLOAD_HANDLE uploadHandle = currentUploadHandles[i]; mockConsumer = mStreamingSession.getConsumer(uploadHandle); - //GetStreamedData and SubmitAck + // GetStreamedData and SubmitAck retStatus = mockConsumer->timedGetStreamData(currentTime, &gotStreamData); EXPECT_EQ(STATUS_SUCCESS, mockConsumer->timedSubmitNormalAck(currentTime, &submittedAck)); VerifyGetStreamDataResult(retStatus, gotStreamData, uploadHandle, ¤tTime, &mockConsumer); @@ -72,7 +72,7 @@ TEST_P(IntermittentProducerFunctionalityTest, CreateSyncStreamWithLargeBufferAwa } } - } while (currentTime < testTerminationTime ); + } while (currentTime < testTerminationTime); EXPECT_TRUE(mStreamingSession.mActiveUploadHandles.size() == 0); @@ -81,12 +81,12 @@ TEST_P(IntermittentProducerFunctionalityTest, CreateSyncStreamWithLargeBufferAwa mStreamingSession.clearSessions(); } while (intermittentProducerSessionCount++ < 2); - } -TEST_P(IntermittentProducerFunctionalityTest, CreateSyncStreamStopSyncFreeRepeatSuccess) { +TEST_P(IntermittentProducerFunctionalityTest, CreateSyncStreamStopSyncFreeRepeatSuccess) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; BOOL didPutFrame, gotStreamData, submittedAck; UINT64 currentTime, testTerminationTime; @@ -122,14 +122,14 @@ TEST_P(IntermittentProducerFunctionalityTest, RepeatedCreateSyncStopSyncFree) PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); UINT32 repeatTime = 10, i; - for(i = 0; i < repeatTime; i ++) { + for (i = 0; i < repeatTime; i++) { CreateStreamSync(); stopKinesisVideoStreamSync(mStreamHandle); freeKinesisVideoStream(&mStreamHandle); } } - INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, IntermittentProducerFunctionalityTest, - Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); + Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), + Values(0, TEST_REPLAY_DURATION))); #endif \ No newline at end of file diff --git a/tst/client/MockConsumer.cpp b/tst/client/MockConsumer.cpp index 0cc0de681..d76047523 100644 --- a/tst/client/MockConsumer.cpp +++ b/tst/client/MockConsumer.cpp @@ -1,23 +1,12 @@ #include "ClientTestFixture.h" -MockConsumer::MockConsumer(MockConsumerConfig config, - UPLOAD_HANDLE mUploadHandle, - STREAM_HANDLE mStreamHandle) - : mOldCurrent(0), - mDataBufferSize(config.mDataBufferSizeByte), - mUploadSpeed(config.mUploadSpeedBytesPerSecond), - mNextGetStreamDataTime(0), - mUploadHandle(mUploadHandle), - mStreamHandle(mStreamHandle), - mBufferingAckDelay(config.mBufferingAckDelayMs), - mReceiveAckDelay(config.mReceiveAckDelayMs), - mPersistAckDelay(config.mPersistAckDelayMs), - mCurrentInitialized(FALSE), - mConnectionClosed(FALSE), - mEnableAck(config.mEnableAck), - mRetention(config.mRetention), - mFragmentTimestamp(INVALID_TIMESTAMP_VALUE), - mLastGetStreamDataTime(INVALID_TIMESTAMP_VALUE) { +MockConsumer::MockConsumer(MockConsumerConfig config, UPLOAD_HANDLE mUploadHandle, STREAM_HANDLE mStreamHandle) + : mOldCurrent(0), mDataBufferSize(config.mDataBufferSizeByte), mUploadSpeed(config.mUploadSpeedBytesPerSecond), mNextGetStreamDataTime(0), + mUploadHandle(mUploadHandle), mStreamHandle(mStreamHandle), mBufferingAckDelay(config.mBufferingAckDelayMs), + mReceiveAckDelay(config.mReceiveAckDelayMs), mPersistAckDelay(config.mPersistAckDelayMs), mCurrentInitialized(FALSE), mConnectionClosed(FALSE), + mEnableAck(config.mEnableAck), mRetention(config.mRetention), mFragmentTimestamp(INVALID_TIMESTAMP_VALUE), + mLastGetStreamDataTime(INVALID_TIMESTAMP_VALUE) +{ ATOMIC_STORE_BOOL(&mDataAvailable, FALSE); // init FragmentAck struct @@ -29,7 +18,8 @@ MockConsumer::MockConsumer(MockConsumerConfig config, mDataBuffer = (PBYTE) MEMALLOC(mDataBufferSize); } -void MockConsumer::enqueueAckItem(UINT64 fragmentTimestamp, PUINT64 submitAckTime) { +void MockConsumer::enqueueAckItem(UINT64 fragmentTimestamp, PUINT64 submitAckTime) +{ AckItem ackItem; mFragmentAck.timestamp = fragmentTimestamp; mFragmentAck.result = SERVICE_CALL_RESULT_OK; @@ -54,7 +44,8 @@ void MockConsumer::enqueueAckItem(UINT64 fragmentTimestamp, PUINT64 submitAckTim } } -void MockConsumer::initOldCurrent() { +void MockConsumer::initOldCurrent() +{ STATUS retStatus = STATUS_SUCCESS; PKinesisVideoClient pKinesisVideoClient = NULL; PViewItem pViewItem; @@ -81,7 +72,8 @@ void MockConsumer::initOldCurrent() { mCurrentInitialized = TRUE; } -void MockConsumer::createAckEvent(BOOL isEosSent, UINT64 sendAckTime) { +void MockConsumer::createAckEvent(BOOL isEosSent, UINT64 sendAckTime) +{ PKinesisVideoClient pKinesisVideoClient = NULL; PKinesisVideoStream pKinesisVideoStream = FROM_STREAM_HANDLE(mStreamHandle); pKinesisVideoClient = pKinesisVideoStream->pKinesisVideoClient; @@ -93,7 +85,7 @@ void MockConsumer::createAckEvent(BOOL isEosSent, UINT64 sendAckTime) { endIndex++; } - for(UINT64 i = mOldCurrent; i < endIndex; i++) { + for (UINT64 i = mOldCurrent; i < endIndex; i++) { /* not expecting contentViewGetItemAt to always succeed because it may fail in the negative scenario tests. * For example view items were deliberately dropped. */ status = contentViewGetItemAt(pKinesisVideoStream->pView, i, &pViewItem); @@ -147,15 +139,15 @@ void MockConsumer::purgeAckItemWithTimestamp(UINT64 ackTimestamp) } } -STATUS MockConsumer::timedGetStreamData(UINT64 currentTime, PBOOL pDidGetStreamData, PUINT32 pRetrievedSize) { +STATUS MockConsumer::timedGetStreamData(UINT64 currentTime, PBOOL pDidGetStreamData, PUINT32 pRetrievedSize) +{ STATUS retStatus = STATUS_SUCCESS; UINT32 actualDataSize; *pDidGetStreamData = FALSE; if (ATOMIC_LOAD_BOOL(&mDataAvailable) && (currentTime >= mNextGetStreamDataTime)) { *pDidGetStreamData = TRUE; - retStatus = getKinesisVideoStreamData(mStreamHandle, mUploadHandle, mDataBuffer, mDataBufferSize, - &actualDataSize); + retStatus = getKinesisVideoStreamData(mStreamHandle, mUploadHandle, mDataBuffer, mDataBufferSize, &actualDataSize); // stop calling getKinesisVideoStreamData if there is no more data. if (retStatus == STATUS_NO_MORE_DATA_AVAILABLE || retStatus == STATUS_AWAITING_PERSISTED_ACK) { @@ -190,7 +182,8 @@ STATUS MockConsumer::timedGetStreamData(UINT64 currentTime, PBOOL pDidGetStreamD return retStatus; } -STATUS MockConsumer::timedSubmitNormalAck(UINT64 currentTime, PBOOL pSubmittedAck) { +STATUS MockConsumer::timedSubmitNormalAck(UINT64 currentTime, PBOOL pSubmittedAck) +{ STATUS retStatus = STATUS_SUCCESS; *pSubmittedAck = FALSE; AckItem ackItem; @@ -206,7 +199,7 @@ STATUS MockConsumer::timedSubmitNormalAck(UINT64 currentTime, PBOOL pSubmittedAc CHK_STATUS(kinesisVideoStreamFragmentAck(mStreamHandle, mUploadHandle, &ackItem.mFragmentAck)); *pSubmittedAck = TRUE; - switch(ackItem.mFragmentAck.ackType) { + switch (ackItem.mFragmentAck.ackType) { case FRAGMENT_ACK_TYPE_PERSISTED: DLOGD("got persisted ack. timestamp %llu", ackItem.mFragmentAck.timestamp); break; @@ -229,7 +222,8 @@ STATUS MockConsumer::timedSubmitNormalAck(UINT64 currentTime, PBOOL pSubmittedAc return retStatus; } -STATUS MockConsumer::submitErrorAck(SERVICE_CALL_RESULT service_call_result, PBOOL pSubmittedAck) { +STATUS MockConsumer::submitErrorAck(SERVICE_CALL_RESULT service_call_result, PBOOL pSubmittedAck) +{ STATUS retStatus = STATUS_SUCCESS; *pSubmittedAck = FALSE; @@ -242,15 +236,16 @@ STATUS MockConsumer::submitErrorAck(SERVICE_CALL_RESULT service_call_result, PBO mFragmentAck.ackType = FRAGMENT_ACK_TYPE_ERROR; mFragmentAck.timestamp = mAckQueue.top().mFragmentAck.timestamp; purgeAckItemWithTimestamp(mFragmentAck.timestamp); - DLOGD("submitting error ack with call result %u, timestamp %" PRIu64 " to upload handle %" PRIu64, - service_call_result, mFragmentAck.timestamp, mUploadHandle); + DLOGD("submitting error ack with call result %u, timestamp %" PRIu64 " to upload handle %" PRIu64, service_call_result, + mFragmentAck.timestamp, mUploadHandle); retStatus = kinesisVideoStreamFragmentAck(mStreamHandle, mUploadHandle, &mFragmentAck); } return retStatus; } -STATUS MockConsumer::submitErrorAck(SERVICE_CALL_RESULT service_call_result, UINT64 timestamp, PBOOL pSubmittedAck) { +STATUS MockConsumer::submitErrorAck(SERVICE_CALL_RESULT service_call_result, UINT64 timestamp, PBOOL pSubmittedAck) +{ STATUS retStatus = STATUS_SUCCESS; *pSubmittedAck = FALSE; @@ -261,15 +256,15 @@ STATUS MockConsumer::submitErrorAck(SERVICE_CALL_RESULT service_call_result, UIN mFragmentAck.ackType = FRAGMENT_ACK_TYPE_ERROR; mFragmentAck.timestamp = timestamp; purgeAckItemWithTimestamp(mFragmentAck.timestamp); - DLOGD("No ackItem used. submitting error ack with call result %u, timestamp %" PRIu64 " to upload handle %" PRIu64, - service_call_result, mFragmentAck.timestamp, mUploadHandle); + DLOGD("No ackItem used. submitting error ack with call result %u, timestamp %" PRIu64 " to upload handle %" PRIu64, service_call_result, + mFragmentAck.timestamp, mUploadHandle); retStatus = kinesisVideoStreamFragmentAck(mStreamHandle, mUploadHandle, &mFragmentAck); return retStatus; } -STATUS MockConsumer::submitNormalAck(SERVICE_CALL_RESULT service_call_result, FRAGMENT_ACK_TYPE ackType, - UINT64 timestamp, PBOOL pSubmittedAck) { +STATUS MockConsumer::submitNormalAck(SERVICE_CALL_RESULT service_call_result, FRAGMENT_ACK_TYPE ackType, UINT64 timestamp, PBOOL pSubmittedAck) +{ STATUS retStatus = STATUS_SUCCESS; *pSubmittedAck = FALSE; @@ -285,7 +280,8 @@ STATUS MockConsumer::submitNormalAck(SERVICE_CALL_RESULT service_call_result, FR return retStatus; } -STATUS MockConsumer::submitConnectionError(SERVICE_CALL_RESULT service_call_result) { +STATUS MockConsumer::submitConnectionError(SERVICE_CALL_RESULT service_call_result) +{ mConnectionClosed = TRUE; // connection error can happen at any time. diff --git a/tst/client/MockProducer.cpp b/tst/client/MockProducer.cpp index 1d2e86b50..5a180ee70 100644 --- a/tst/client/MockProducer.cpp +++ b/tst/client/MockProducer.cpp @@ -1,15 +1,9 @@ #include "ClientTestFixture.h" -MockProducer::MockProducer(MockProducerConfig config, - STREAM_HANDLE mStreamHandle) - : mFps(config.mFps), - mKeyFrameInterval(config.mKeyFrameInterval), - mIsLive(config.mIsLive), - mSetEOFR(config.mSetEOFR), - mStreamHandle(mStreamHandle), - mNextPutFrameTime(0), - mIndex(0), - mTimestamp(0) { +MockProducer::MockProducer(MockProducerConfig config, STREAM_HANDLE mStreamHandle) + : mFps(config.mFps), mKeyFrameInterval(config.mKeyFrameInterval), mIsLive(config.mIsLive), mSetEOFR(config.mSetEOFR), + mStreamHandle(mStreamHandle), mNextPutFrameTime(0), mIndex(0), mTimestamp(0) +{ mFrame.frameData = (PBYTE) MEMALLOC(config.mFrameSizeByte); MEMSET(mFrame.frameData, 0x00, config.mFrameSizeByte); mFrame.size = config.mFrameSizeByte; @@ -18,7 +12,8 @@ MockProducer::MockProducer(MockProducerConfig config, mFrame.duration = (UINT64) 1000 / mFps * HUNDREDS_OF_NANOS_IN_A_MILLISECOND; } -STATUS MockProducer::putFrame(BOOL isEofr, UINT64 trackId) { +STATUS MockProducer::putFrame(BOOL isEofr, UINT64 trackId) +{ STATUS retStatus = STATUS_SUCCESS; mFrame.trackId = trackId; @@ -45,7 +40,8 @@ STATUS MockProducer::putFrame(BOOL isEofr, UINT64 trackId) { return retStatus; } -STATUS MockProducer::timedPutFrame(UINT64 currentTime, PBOOL pDidPutFrame, UINT64 trackId) { +STATUS MockProducer::timedPutFrame(UINT64 currentTime, PBOOL pDidPutFrame, UINT64 trackId) +{ STATUS putStatus = STATUS_SUCCESS, eofrPutStatus = STATUS_SUCCESS; *pDidPutFrame = FALSE; @@ -73,6 +69,7 @@ STATUS MockProducer::timedPutFrame(UINT64 currentTime, PBOOL pDidPutFrame, UINT6 } } -PFrame MockProducer::getCurrentFrame() { +PFrame MockProducer::getCurrentFrame() +{ return &mFrame; } diff --git a/tst/client/StateTransitionFunctionalityTest.cpp b/tst/client/StateTransitionFunctionalityTest.cpp index f717dd603..df0759a6f 100644 --- a/tst/client/StateTransitionFunctionalityTest.cpp +++ b/tst/client/StateTransitionFunctionalityTest.cpp @@ -1,14 +1,14 @@ #include "ClientTestFixture.h" -using ::testing::WithParamInterface; using ::testing::Bool; -using ::testing::Values; using ::testing::Combine; +using ::testing::Values; +using ::testing::WithParamInterface; -class StateTransitionFunctionalityTest : public ClientTestBase, - public WithParamInterface< ::std::tuple >{ -protected: - void SetUp() { +class StateTransitionFunctionalityTest : public ClientTestBase, public WithParamInterface< ::std::tuple > { + protected: + void SetUp() + { ClientTestBase::SetUp(); STREAMING_TYPE streamingType; @@ -22,7 +22,7 @@ class StateTransitionFunctionalityTest : public ClientTestBase, } }; -//Create stream, fault inject retriable error the first call for Describe, Create, Tag, Get Endpoint, Get Token, ensure retry +// Create stream, fault inject retriable error the first call for Describe, Create, Tag, Get Endpoint, Get Token, ensure retry TEST_P(StateTransitionFunctionalityTest, ControlPlaneServiceCallRetryOnRetriableError) { PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); @@ -56,20 +56,16 @@ TEST_P(StateTransitionFunctionalityTest, ControlPlaneServiceCallRetryOnRetriable EXPECT_EQ(2, ATOMIC_LOAD(&mGetStreamingEndpointFuncCount)); EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_UNKNOWN, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_UNKNOWN, (PBYTE) TEST_STREAMING_TOKEN, SIZEOF(TEST_STREAMING_TOKEN), + TEST_AUTH_EXPIRATION)); EXPECT_EQ(2, ATOMIC_LOAD(&mGetStreamingTokenFuncCount)); - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); } -//Create stream, fault inject non-retriable error the first call for Describe, Create, Tag, Get Endpoint, Get Token, ensure error returned +// Create stream, fault inject non-retriable error the first call for Describe, Create, Tag, Get Endpoint, Get Token, ensure error returned TEST_P(StateTransitionFunctionalityTest, ControlPlaneServiceCallReturnNonRetriableError) { PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); @@ -86,7 +82,8 @@ TEST_P(StateTransitionFunctionalityTest, ControlPlaneServiceCallReturnNonRetriab setupStreamDescription(); // submit non-retriable error - EXPECT_EQ(STATUS_SERVICE_CALL_INVALID_ARG_ERROR, describeStreamResultEvent(mCallContext.customData, SERVICE_CALL_INVALID_ARG, &mStreamDescription)); + EXPECT_EQ(STATUS_SERVICE_CALL_INVALID_ARG_ERROR, + describeStreamResultEvent(mCallContext.customData, SERVICE_CALL_INVALID_ARG, &mStreamDescription)); // submit not found result to move to create state EXPECT_EQ(STATUS_SUCCESS, describeStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESOURCE_NOT_FOUND, &mStreamDescription)); @@ -96,19 +93,16 @@ TEST_P(StateTransitionFunctionalityTest, ControlPlaneServiceCallReturnNonRetriab EXPECT_EQ(STATUS_SERVICE_CALL_INVALID_ARG_ERROR, tagResourceResultEvent(mCallContext.customData, SERVICE_CALL_INVALID_ARG)); EXPECT_EQ(STATUS_SUCCESS, tagResourceResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK)); - EXPECT_EQ(STATUS_SERVICE_CALL_INVALID_ARG_ERROR, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_INVALID_ARG, TEST_STREAMING_ENDPOINT)); + EXPECT_EQ(STATUS_SERVICE_CALL_INVALID_ARG_ERROR, + getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_INVALID_ARG, TEST_STREAMING_ENDPOINT)); EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); - EXPECT_EQ(STATUS_SERVICE_CALL_INVALID_ARG_ERROR, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_INVALID_ARG, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - TEST_AUTH_EXPIRATION)); - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_SERVICE_CALL_INVALID_ARG_ERROR, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_INVALID_ARG, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); } TEST_P(StateTransitionFunctionalityTest, ControlPlaneServiceCallReturnNotAuthorizedError) @@ -144,17 +138,13 @@ TEST_P(StateTransitionFunctionalityTest, ControlPlaneServiceCallReturnNotAuthori EXPECT_EQ(2, ATOMIC_LOAD(&mGetStreamingEndpointFuncCount)); EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); - EXPECT_EQ(STATUS_SERVICE_CALL_NOT_AUTHORIZED_ERROR, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_NOT_AUTHORIZED, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_SERVICE_CALL_NOT_AUTHORIZED_ERROR, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_NOT_AUTHORIZED, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); EXPECT_EQ(1, ATOMIC_LOAD(&mGetStreamingTokenFuncCount)); - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); } // Create stream, fault inject all calls for Describe, Create, Tag, Get Endpoint, Get Token, ensure fails at the end @@ -175,7 +165,7 @@ TEST_P(StateTransitionFunctionalityTest, ControlPlaneServiceCallExhaustRetry) // exhaust retry for describeStreamResultEvent EXPECT_EQ(STATUS_SUCCESS, createKinesisVideoStream(mClientHandle, &mStreamInfo, &mStreamHandle)); - for(i = 0; i < SERVICE_CALL_MAX_RETRY_COUNT; i++) { + for (i = 0; i < SERVICE_CALL_MAX_RETRY_COUNT; i++) { EXPECT_EQ(i + 1, ATOMIC_LOAD(&mDescribeStreamFuncCount)); EXPECT_EQ(STATUS_SUCCESS, describeStreamResultEvent(mCallContext.customData, SERVICE_CALL_UNKNOWN, &mStreamDescription)); } @@ -186,7 +176,7 @@ TEST_P(StateTransitionFunctionalityTest, ControlPlaneServiceCallExhaustRetry) EXPECT_EQ(STATUS_SUCCESS, createKinesisVideoStream(mClientHandle, &mStreamInfo, &mStreamHandle)); // move to create state EXPECT_EQ(STATUS_SUCCESS, describeStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESOURCE_NOT_FOUND, &mStreamDescription)); - for(i = 0; i < SERVICE_CALL_MAX_RETRY_COUNT; i++) { + for (i = 0; i < SERVICE_CALL_MAX_RETRY_COUNT; i++) { EXPECT_EQ(i + 1, ATOMIC_LOAD(&mCreateStreamFuncCount)); EXPECT_EQ(STATUS_SUCCESS, createStreamResultEvent(mCallContext.customData, SERVICE_CALL_UNKNOWN, TEST_STREAM_ARN)); } @@ -201,7 +191,7 @@ TEST_P(StateTransitionFunctionalityTest, ControlPlaneServiceCallExhaustRetry) // tagStream is special because it is not critical to streaming. After retries are exhausted it will move to the next // state and return success. - for(i = 0; i < SERVICE_CALL_MAX_RETRY_COUNT; i++) { + for (i = 0; i < SERVICE_CALL_MAX_RETRY_COUNT; i++) { EXPECT_EQ(i + 1, ATOMIC_LOAD(&mTagResourceFuncCount)); EXPECT_EQ(STATUS_SUCCESS, tagResourceResultEvent(mCallContext.customData, SERVICE_CALL_UNKNOWN)); } @@ -217,11 +207,12 @@ TEST_P(StateTransitionFunctionalityTest, ControlPlaneServiceCallExhaustRetry) EXPECT_EQ(STATUS_SUCCESS, createStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAM_ARN)); EXPECT_EQ(STATUS_SUCCESS, tagResourceResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK)); - for(i = 0; i < SERVICE_CALL_MAX_RETRY_COUNT; i++) { + for (i = 0; i < SERVICE_CALL_MAX_RETRY_COUNT; i++) { EXPECT_EQ(i + 1, ATOMIC_LOAD(&mGetStreamingEndpointFuncCount)); EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_UNKNOWN, TEST_STREAMING_ENDPOINT)); } - EXPECT_EQ(STATUS_GET_STREAMING_ENDPOINT_CALL_FAILED, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_UNKNOWN, TEST_STREAMING_ENDPOINT)); + EXPECT_EQ(STATUS_GET_STREAMING_ENDPOINT_CALL_FAILED, + getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_UNKNOWN, TEST_STREAMING_ENDPOINT)); freeKinesisVideoStream(&mStreamHandle); // exhaust retry for getStreamingTokenResultEvent @@ -232,19 +223,15 @@ TEST_P(StateTransitionFunctionalityTest, ControlPlaneServiceCallExhaustRetry) EXPECT_EQ(STATUS_SUCCESS, tagResourceResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK)); EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); - for(i = 0; i < SERVICE_CALL_MAX_RETRY_COUNT; i++) { + for (i = 0; i < SERVICE_CALL_MAX_RETRY_COUNT; i++) { EXPECT_EQ(i + 1, ATOMIC_LOAD(&mGetStreamingTokenFuncCount)); - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_UNKNOWN, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_UNKNOWN, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); } - EXPECT_EQ(STATUS_GET_STREAMING_TOKEN_CALL_FAILED, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_UNKNOWN, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_GET_STREAMING_TOKEN_CALL_FAILED, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_UNKNOWN, (PBYTE) TEST_STREAMING_TOKEN, SIZEOF(TEST_STREAMING_TOKEN), + TEST_AUTH_EXPIRATION)); freeKinesisVideoStream(&mStreamHandle); } #ifdef ALIGNED_MEMORY_MODEL @@ -255,16 +242,10 @@ TEST_P(StateTransitionFunctionalityTest, StreamTerminatedAndGoToGetEndpointState std::vector currentUploadHandles; UINT32 oldGetStreamingEndpointFuncCount, oldDescribeFuncCount, oldGetTokenFuncCount; initDefaultProducer(); - std::vector getEndpointStateResults = {SERVICE_CALL_RESULT_OK, - SERVICE_CALL_DEVICE_LIMIT, - SERVICE_CALL_STREAM_LIMIT, - SERVICE_CALL_BAD_REQUEST, - SERVICE_CALL_REQUEST_TIMEOUT, - SERVICE_CALL_GATEWAY_TIMEOUT, - SERVICE_CALL_NETWORK_READ_TIMEOUT, - SERVICE_CALL_NETWORK_CONNECTION_TIMEOUT, - SERVICE_CALL_NOT_AUTHORIZED, - SERVICE_CALL_FORBIDDEN}; + std::vector getEndpointStateResults = { + SERVICE_CALL_RESULT_OK, SERVICE_CALL_DEVICE_LIMIT, SERVICE_CALL_STREAM_LIMIT, SERVICE_CALL_BAD_REQUEST, + SERVICE_CALL_REQUEST_TIMEOUT, SERVICE_CALL_GATEWAY_TIMEOUT, SERVICE_CALL_NETWORK_READ_TIMEOUT, SERVICE_CALL_NETWORK_CONNECTION_TIMEOUT, + SERVICE_CALL_NOT_AUTHORIZED, SERVICE_CALL_FORBIDDEN}; mStreamInfo.streamCaps.recoverOnError = TRUE; @@ -340,16 +321,14 @@ TEST_P(StateTransitionFunctionalityTest, StreamTerminatedAndGoToDescribeState) std::vector currentUploadHandles; UINT32 oldDescribeStreamFuncCount; initDefaultProducer(); - std::vector describeStreamStateResults = {SERVICE_CALL_RESOURCE_IN_USE, - SERVICE_CALL_INTERNAL_ERROR, - SERVICE_CALL_RESULT_ACK_INTERNAL_ERROR, - SERVICE_CALL_RESOURCE_NOT_FOUND, + std::vector describeStreamStateResults = {SERVICE_CALL_RESOURCE_IN_USE, SERVICE_CALL_INTERNAL_ERROR, + SERVICE_CALL_RESULT_ACK_INTERNAL_ERROR, SERVICE_CALL_RESOURCE_NOT_FOUND, SERVICE_CALL_RESOURCE_DELETED}; mStreamInfo.streamCaps.recoverOnError = TRUE; for (int i = 0; i < describeStreamStateResults.size(); i++) { - SERVICE_CALL_RESULT service_call_result = describeStreamStateResults[i]; + SERVICE_CALL_RESULT service_call_result = describeStreamStateResults[i]; CreateStreamSync(); MockProducer producer(mMockProducerConfig, mStreamHandle); @@ -374,8 +353,7 @@ TEST_P(StateTransitionFunctionalityTest, StreamTerminatedAndGoToGetTokenState) std::vector currentUploadHandles; UINT32 oldGetStreamingTokenFuncCount; initDefaultProducer(); - std::vector getStreamingTokenStateResults = {SERVICE_CALL_NOT_AUTHORIZED, - SERVICE_CALL_FORBIDDEN}; + std::vector getStreamingTokenStateResults = {SERVICE_CALL_NOT_AUTHORIZED, SERVICE_CALL_FORBIDDEN}; mStreamInfo.streamCaps.recoverOnError = TRUE; @@ -406,9 +384,7 @@ TEST_P(StateTransitionFunctionalityTest, StreamTerminatedAndGoToNewState) std::vector currentUploadHandles; UINT32 oldDescribeStreamFuncCount; initDefaultProducer(); - std::vector newStateResults = {SERVICE_CALL_UNKNOWN, - SERVICE_CALL_INVALID_ARG, - SERVICE_CALL_DEVICE_NOT_FOUND, + std::vector newStateResults = {SERVICE_CALL_UNKNOWN, SERVICE_CALL_INVALID_ARG, SERVICE_CALL_DEVICE_NOT_FOUND, SERVICE_CALL_INTERNAL_ERROR}; for (int i = 0; i < newStateResults.size(); i++) { @@ -432,11 +408,12 @@ TEST_P(StateTransitionFunctionalityTest, StreamTerminatedAndGoToNewState) // Create stream, stream and leave large buffer, StopSync, inject a fault and terminate the upload handle // check the behavior for re-streaming with no putFrame. -TEST_P(StateTransitionFunctionalityTest, FaultInjectUploadHandleAfterStopBeforeTokenRotation) { +TEST_P(StateTransitionFunctionalityTest, FaultInjectUploadHandleAfterStopBeforeTokenRotation) +{ mDeviceInfo.clientInfo.stopStreamTimeout = STREAM_CLOSED_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND; CreateScenarioTestClient(); BOOL submittedErrorAck = FALSE, didPutFrame, gotStreamData; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; UINT64 stopTime, currentTime; std::vector currentUploadHandles; STATUS retStatus; @@ -456,7 +433,7 @@ TEST_P(StateTransitionFunctionalityTest, FaultInjectUploadHandleAfterStopBeforeT // stop while having large buffer not sent EXPECT_EQ(STATUS_SUCCESS, stopKinesisVideoStream(mStreamHandle)); - //give 10 seconds to getStreamData and submit error ack on the first fragment + // give 10 seconds to getStreamData and submit error ack on the first fragment stopTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) + 10 * HUNDREDS_OF_NANOS_IN_A_SECOND; do { currentTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); @@ -484,11 +461,12 @@ TEST_P(StateTransitionFunctionalityTest, FaultInjectUploadHandleAfterStopBeforeT VerifyStopStreamSyncAndFree(); } -TEST_P(StateTransitionFunctionalityTest, FaultInjectUploadHandleAfterStopDuringTokenRotation) { +TEST_P(StateTransitionFunctionalityTest, FaultInjectUploadHandleAfterStopDuringTokenRotation) +{ mDeviceInfo.clientInfo.stopStreamTimeout = STREAM_CLOSED_TIMEOUT_DURATION_IN_SECONDS * HUNDREDS_OF_NANOS_IN_A_SECOND; CreateScenarioTestClient(); BOOL submittedErrorAck = FALSE, didPutFrame, gotStreamData; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; UINT64 stopTime, currentTime; std::vector currentUploadHandles; STATUS retStatus; @@ -508,7 +486,7 @@ TEST_P(StateTransitionFunctionalityTest, FaultInjectUploadHandleAfterStopDuringT // stop while having large buffer not sent EXPECT_EQ(STATUS_SUCCESS, stopKinesisVideoStream(mStreamHandle)); - //give 10 seconds to getStreamData and submit error ack on upload handle 0 (first upload handle) + // give 10 seconds to getStreamData and submit error ack on upload handle 0 (first upload handle) stopTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) + 10 * HUNDREDS_OF_NANOS_IN_A_SECOND; do { currentTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); @@ -520,7 +498,7 @@ TEST_P(StateTransitionFunctionalityTest, FaultInjectUploadHandleAfterStopDuringT retStatus = mockConsumer->timedGetStreamData(currentTime, &gotStreamData); VerifyGetStreamDataResult(retStatus, gotStreamData, uploadHandle, ¤tTime, &mockConsumer); - if (mockConsumer != NULL && uploadHandle == 0 && !submittedErrorAck){ + if (mockConsumer != NULL && uploadHandle == 0 && !submittedErrorAck) { EXPECT_EQ(STATUS_SUCCESS, mockConsumer->submitErrorAck(SERVICE_CALL_RESULT_FRAGMENT_ARCHIVAL_ERROR, &submittedErrorAck)); } } @@ -532,10 +510,11 @@ TEST_P(StateTransitionFunctionalityTest, FaultInjectUploadHandleAfterStopDuringT VerifyStopStreamSyncAndFree(); } -TEST_P(StateTransitionFunctionalityTest, basicResetConnectionTest) { +TEST_P(StateTransitionFunctionalityTest, basicResetConnectionTest) +{ CreateScenarioTestClient(); BOOL didPutFrame = FALSE, gotStreamData = FALSE, submittedAck = FALSE; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; UINT64 stopTime, currentTime, resetConnectionTime; std::vector currentUploadHandles; STATUS retStatus; @@ -592,8 +571,7 @@ TEST_P(StateTransitionFunctionalityTest, TestExecutionOfStreamStateMachineErrorH PKinesisVideoClient pKinesisVideoClient = FROM_STREAM_HANDLE(mCallContext.customData)->pKinesisVideoClient; KvsRetryStrategy* kvsRetryStrategy = &(pKinesisVideoClient->deviceInfo.clientInfo.kvsRetryStrategy); - PExponentialBackoffRetryStrategyState pExponentialBackoffRetryStrategyState = - TO_EXPONENTIAL_BACKOFF_STATE(kvsRetryStrategy->pRetryStrategy); + PExponentialBackoffRetryStrategyState pExponentialBackoffRetryStrategyState = TO_EXPONENTIAL_BACKOFF_STATE(kvsRetryStrategy->pRetryStrategy); EXPECT_EQ(0, pExponentialBackoffRetryStrategyState->currentRetryCount); @@ -618,4 +596,5 @@ TEST_P(StateTransitionFunctionalityTest, TestExecutionOfStreamStateMachineErrorH } INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, StateTransitionFunctionalityTest, - Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); + Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), + Values(0, TEST_REPLAY_DURATION))); diff --git a/tst/client/StreamApiFunctionalityScenarioTest.cpp b/tst/client/StreamApiFunctionalityScenarioTest.cpp index db63b94e8..98d4524ec 100644 --- a/tst/client/StreamApiFunctionalityScenarioTest.cpp +++ b/tst/client/StreamApiFunctionalityScenarioTest.cpp @@ -1,14 +1,15 @@ #include "ClientTestFixture.h" -using ::testing::WithParamInterface; using ::testing::Bool; -using ::testing::Values; using ::testing::Combine; +using ::testing::Values; +using ::testing::WithParamInterface; class StreamApiFunctionalityScenarioTest : public ClientTestBase, - public WithParamInterface< ::std::tuple >{ -protected: - void SetUp() { + public WithParamInterface< ::std::tuple > { + protected: + void SetUp() + { ClientTestBase::SetUp(); STREAMING_TYPE streamingType; @@ -36,14 +37,14 @@ TEST_P(StreamApiFunctionalityScenarioTest, TokenRotationBasicScenario) BOOL didPutFrame, gotStreamData, submittedAck; UINT32 tokenRotateCount = 0; std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); CreateStreamSync(); // should make 1 token rotations within this time. - testTerminationTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) - + 1 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 2 * HUNDREDS_OF_NANOS_IN_A_SECOND; + testTerminationTime = + mClientCallbacks.getCurrentTimeFn((UINT64) this) + 1 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 2 * HUNDREDS_OF_NANOS_IN_A_SECOND; MockProducer mockProducer(mMockProducerConfig, mStreamHandle); do { @@ -78,13 +79,13 @@ TEST_P(StreamApiFunctionalityScenarioTest, TokenRotationBasicScenarioFaultInject BOOL didPutFrame, gotStreamData, submittedAck, didSubmitErrorAck = FALSE; UINT32 tokenRotateCount = 0; std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); CreateStreamSync(); - testTerminationTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) - + 2 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 200 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND; + testTerminationTime = + mClientCallbacks.getCurrentTimeFn((UINT64) this) + 2 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 200 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND; MockProducer mockProducer(mMockProducerConfig, mStreamHandle); do { @@ -101,7 +102,7 @@ TEST_P(StreamApiFunctionalityScenarioTest, TokenRotationBasicScenarioFaultInject if (retStatus == STATUS_END_OF_STREAM) { tokenRotateCount++; } - if (mockConsumer != NULL ) { + if (mockConsumer != NULL) { EXPECT_EQ(STATUS_SUCCESS, mockConsumer->timedSubmitNormalAck(currentTime, &submittedAck)); // fault inject upload handle 1 once. @@ -137,14 +138,14 @@ TEST_P(StreamApiFunctionalityScenarioTest, TokenRotationBasicScenarioEOFR) BOOL didPutFrame, gotStreamData, submittedAck; UINT32 tokenRotateCount = 0; std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); CreateStreamSync(); // should make 1 token rotations within this time. - testTerminationTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) - + 1 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 2 * HUNDREDS_OF_NANOS_IN_A_SECOND; + testTerminationTime = + mClientCallbacks.getCurrentTimeFn((UINT64) this) + 1 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 2 * HUNDREDS_OF_NANOS_IN_A_SECOND; MockProducer mockProducer(mMockProducerConfig, mStreamHandle); do { @@ -181,7 +182,7 @@ TEST_P(StreamApiFunctionalityScenarioTest, TokenRotationFragmentMultiTrackScenar BOOL gotStreamData, submittedAck; UINT32 tokenRotateCount = 0, frameCount = 0; std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); @@ -252,7 +253,7 @@ TEST_P(StreamApiFunctionalityScenarioTest, TokenRotationFragmentMultiTrackScenar BOOL gotStreamData, submittedAck; UINT32 tokenRotateCount = 0, frameCount = 0; std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); @@ -323,7 +324,7 @@ TEST_P(StreamApiFunctionalityScenarioTest, TokenRotationIntermittentMultiTrackSc BOOL gotStreamData, submittedAck; UINT32 tokenRotateCount = 0, frameCount = 0; std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); @@ -394,7 +395,7 @@ TEST_P(StreamApiFunctionalityScenarioTest, TokenRotationIntermittentMultiTrackSc BOOL gotStreamData, submittedAck; UINT32 tokenRotateCount = 0, frameCount = 0; std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); @@ -465,7 +466,7 @@ TEST_P(StreamApiFunctionalityScenarioTest, TokenRotationBasicMultiTrackPassThrou BOOL didPutFrame, gotStreamData, submittedAck; UINT32 tokenRotateCount = 0, frameCount = 0; std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); @@ -483,8 +484,8 @@ TEST_P(StreamApiFunctionalityScenarioTest, TokenRotationBasicMultiTrackPassThrou CreateStreamSync(); // should make 1 token rotations within this time. - testTerminationTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) - + 1 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 2 * HUNDREDS_OF_NANOS_IN_A_SECOND; + testTerminationTime = + mClientCallbacks.getCurrentTimeFn((UINT64) this) + 1 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 2 * HUNDREDS_OF_NANOS_IN_A_SECOND; MockProducer mockProducer(mMockProducerConfig, mStreamHandle); do { @@ -516,6 +517,7 @@ TEST_P(StreamApiFunctionalityScenarioTest, TokenRotationBasicMultiTrackPassThrou } INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, StreamApiFunctionalityScenarioTest, - Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); + Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), + Values(0, TEST_REPLAY_DURATION))); #endif \ No newline at end of file diff --git a/tst/client/StreamApiFunctionalityTest.cpp b/tst/client/StreamApiFunctionalityTest.cpp index 43e3161b8..c11dc45d2 100644 --- a/tst/client/StreamApiFunctionalityTest.cpp +++ b/tst/client/StreamApiFunctionalityTest.cpp @@ -1,7 +1,6 @@ #include "ClientTestFixture.h" -class StreamApiFunctionalityTest : public ClientTestBase { -}; +class StreamApiFunctionalityTest : public ClientTestBase {}; TEST_F(StreamApiFunctionalityTest, putFrame_DescribeStreamDeleted) { @@ -60,7 +59,9 @@ TEST_F(StreamApiFunctionalityTest, putFrame_DescribeStreamNotExisting) // Move to the next state // Reset the stream name mStreamName[0] = '\0'; - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); // Ensure the callbacks have been called EXPECT_EQ(1, ATOMIC_LOAD(&mDescribeStreamFuncCount)); @@ -82,7 +83,8 @@ TEST_F(StreamApiFunctionalityTest, putFrame_DescribeStreamNotExisting_CreateNotA // Reset the stream name EXPECT_EQ(0, ATOMIC_LOAD(&mCreateStreamFuncCount)); // Make sure if it doesn't exist we do not end up creating it - EXPECT_EQ(STATUS_SERVICE_CALL_RESOURCE_NOT_FOUND_ERROR, describeStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESOURCE_NOT_FOUND, NULL)); + EXPECT_EQ(STATUS_SERVICE_CALL_RESOURCE_NOT_FOUND_ERROR, + describeStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESOURCE_NOT_FOUND, NULL)); // Verify describe was called only once, stream not existing is a fatal error and should not be re-tried EXPECT_EQ(1, ATOMIC_LOAD(&mDescribeStreamFuncCount)); @@ -96,7 +98,6 @@ TEST_F(StreamApiFunctionalityTest, putFrame_DescribeStreamNotExisting_CreateNotA EXPECT_EQ(0, ATOMIC_LOAD(&mPutStreamFuncCount)); } - TEST_F(StreamApiFunctionalityTest, streamFormatChange_stateCheck) { UINT32 i; @@ -129,7 +130,9 @@ TEST_F(StreamApiFunctionalityTest, streamFormatChange_stateCheck) // Ensure we can successfully set the CPD EXPECT_EQ(STATUS_SUCCESS, kinesisVideoStreamFormatChanged(mStreamHandle, SIZEOF(cpd), cpd, TEST_TRACKID)); - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); // Ensure we can successfully set the CPD EXPECT_EQ(STATUS_SUCCESS, kinesisVideoStreamFormatChanged(mStreamHandle, SIZEOF(cpd), cpd, TEST_TRACKID)); @@ -205,7 +208,9 @@ TEST_F(StreamApiFunctionalityTest, setNalAdaptionFlags_stateCheck) EXPECT_EQ(STATUS_SUCCESS, kinesisVideoStreamSetNalAdaptationFlags(mStreamHandle, nalFlags)); EXPECT_EQ(nalFlags, pKinesisVideoStream->streamInfo.streamCaps.nalAdaptationFlags); EXPECT_EQ(MKV_NALS_ADAPT_AVCC, ((PStreamMkvGenerator) pKinesisVideoStream->pMkvGenerator)->nalsAdaptation); - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); // Ensure we can successfully set the nal flags nalFlags = NAL_ADAPTATION_ANNEXB_CPD_NALS; @@ -251,7 +256,7 @@ TEST_F(StreamApiFunctionalityTest, putFrame_BasicPutTestItemLimit) ReadyStream(); // We should have space for 40 seconds - maxIteration = 24 * ((UINT32)(TEST_BUFFER_DURATION / HUNDREDS_OF_NANOS_IN_A_SECOND)); + maxIteration = 24 * ((UINT32) (TEST_BUFFER_DURATION / HUNDREDS_OF_NANOS_IN_A_SECOND)); // Iterate 2 items over the buffer limit for (i = 0, timestamp = 0; i < maxIteration + 2; timestamp += TEST_FRAME_DURATION, i++) { @@ -304,7 +309,7 @@ TEST_F(StreamApiFunctionalityTest, putFrame_BasicPutTestItemLimitDropFragment) ReadyStream(); // We should have space for 40 seconds - maxIteration = 24 * ((UINT32)(TEST_BUFFER_DURATION / HUNDREDS_OF_NANOS_IN_A_SECOND)); + maxIteration = 24 * ((UINT32) (TEST_BUFFER_DURATION / HUNDREDS_OF_NANOS_IN_A_SECOND)); // Iterate 2 items over the buffer limit for (i = 0, timestamp = 0; i < maxIteration + 2; timestamp += TEST_FRAME_DURATION, i++) { @@ -486,19 +491,13 @@ TEST_F(StreamApiFunctionalityTest, putFrame_PutGetUnderflow) // Now try to retrieve the data for (timestamp = 0; timestamp < TEST_BUFFER_DURATION / 2; timestamp += TEST_LONG_FRAME_DURATION) { - EXPECT_EQ(STATUS_SUCCESS, - getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize)); + EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize)); EXPECT_EQ(SIZEOF(getDataBuffer), filledSize); } - EXPECT_TRUE(STATUS_FAILED( - getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize))); + EXPECT_TRUE(STATUS_FAILED(getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize))); - EXPECT_TRUE(STATUS_FAILED( - getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize))); + EXPECT_TRUE(STATUS_FAILED(getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize))); } TEST_F(StreamApiFunctionalityTest, putFrame_PutGetNextKeyFrame) @@ -546,9 +545,7 @@ TEST_F(StreamApiFunctionalityTest, putFrame_PutGetNextKeyFrame) EXPECT_EQ(0, mFrameTime); // Now, the first frame should be the 10th - EXPECT_EQ(STATUS_SUCCESS, - getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize)); + EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize)); EXPECT_EQ(SIZEOF(getDataBuffer), filledSize); pData = getDataBuffer; @@ -620,9 +617,7 @@ TEST_F(StreamApiFunctionalityTest, putFrame_PutGetNextKeyFrameDropFragment) EXPECT_EQ(9 * TEST_LONG_FRAME_DURATION, mFrameTime); // Now, the first frame should be the 10th - EXPECT_EQ(STATUS_SUCCESS, - getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize)); + EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize)); EXPECT_EQ(SIZEOF(getDataBuffer), filledSize); pData = getDataBuffer; @@ -989,9 +984,7 @@ TEST_F(StreamApiFunctionalityTest, putFrame_PutGetRestartOkResult) // Now try to retrieve the data for (timestamp = 0; timestamp < TEST_BUFFER_DURATION / 2; timestamp += TEST_LONG_FRAME_DURATION) { - EXPECT_EQ(STATUS_SUCCESS, - getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize)); + EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize)); EXPECT_EQ(SIZEOF(getDataBuffer), filledSize); } @@ -1070,9 +1063,7 @@ TEST_F(StreamApiFunctionalityTest, putFrame_PutGetRestartStreamLimitResult) // Now try to retrieve the data for (timestamp = 0; timestamp < TEST_BUFFER_DURATION / 2; timestamp += TEST_LONG_FRAME_DURATION) { - EXPECT_EQ(STATUS_SUCCESS, - getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize)); + EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize)); EXPECT_EQ(SIZEOF(getDataBuffer), filledSize); } @@ -1151,9 +1142,7 @@ TEST_F(StreamApiFunctionalityTest, putFrame_PutGetRestartUnauthorizedResult) // Now try to retrieve the data for (timestamp = 0; timestamp < TEST_BUFFER_DURATION / 2; timestamp += TEST_LONG_FRAME_DURATION) { - EXPECT_EQ(STATUS_SUCCESS, - getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize)); + EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize)); EXPECT_EQ(SIZEOF(getDataBuffer), filledSize); } @@ -1232,9 +1221,7 @@ TEST_F(StreamApiFunctionalityTest, putFrame_PutGetRestartOtherResult) // Now try to retrieve the data for (timestamp = 0; timestamp < TEST_BUFFER_DURATION / 2; timestamp += TEST_LONG_FRAME_DURATION) { - EXPECT_EQ(STATUS_SUCCESS, - getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize)); + EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize)); EXPECT_EQ(SIZEOF(getDataBuffer), filledSize); } @@ -1315,9 +1302,7 @@ TEST_F(StreamApiFunctionalityTest, putFrame_PutGetRestartNotFoundResult) // Now try to retrieve the data for (timestamp = 0; timestamp < TEST_BUFFER_DURATION / 2; timestamp += TEST_LONG_FRAME_DURATION) { - EXPECT_EQ(STATUS_SUCCESS, - getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize)); + EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize)); EXPECT_EQ(SIZEOF(getDataBuffer), filledSize); } @@ -1396,14 +1381,13 @@ TEST_F(StreamApiFunctionalityTest, putFrame_PutGetRestartBadResult) // Now try to retrieve the data for (timestamp = 0; timestamp < TEST_BUFFER_DURATION / 2; timestamp += TEST_LONG_FRAME_DURATION) { - EXPECT_EQ(STATUS_SUCCESS, - getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize)); + EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize)); EXPECT_EQ(SIZEOF(getDataBuffer), filledSize); } // Send a terminate event to warm reset the stream - EXPECT_EQ(STATUS_SERVICE_CALL_INVALID_ARG_ERROR, kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_INVALID_ARG)); + EXPECT_EQ(STATUS_SERVICE_CALL_INVALID_ARG_ERROR, + kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_INVALID_ARG)); // Try streaming again and ensure the right callbacks are fired frame.index++; @@ -1459,9 +1443,7 @@ TEST_F(StreamApiFunctionalityTest, putFrame_PutGetRestartBadResultRestart) // Now try to retrieve the data for (timestamp = 0; timestamp < TEST_BUFFER_DURATION / 2; timestamp += TEST_LONG_FRAME_DURATION) { - EXPECT_EQ(STATUS_SUCCESS, - getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize)); + EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize)); EXPECT_EQ(SIZEOF(getDataBuffer), filledSize); } @@ -1547,7 +1529,8 @@ TEST_F(StreamApiFunctionalityTest, putFrame_StreamDataAvailable) // Should be encoded size EXPECT_EQ(SIZEOF(tempBuffer) + mkvgenGetMkvHeaderOverhead((PStreamMkvGenerator) FROM_STREAM_HANDLE(mStreamHandle)->pMkvGenerator) + - SIZEOF(tempBuffer) + MKV_SIMPLE_BLOCK_OVERHEAD, mDataReadySize); + SIZEOF(tempBuffer) + MKV_SIMPLE_BLOCK_OVERHEAD, + mDataReadySize); } TEST_F(StreamApiFunctionalityTest, putFrame_SubmitAckWithTimecodeZero) @@ -1651,8 +1634,7 @@ TEST_F(StreamApiFunctionalityTest, submitAck_shouldBeInWindowPutStreamResultAfte EXPECT_EQ(STATUS_SUCCESS, putStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, uploadHandle)); - retStatus = getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize); + retStatus = getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize); EXPECT_EQ(true, STATUS_SUCCESS == retStatus || STATUS_NO_MORE_DATA_AVAILABLE == retStatus); EXPECT_EQ(true, filledSize > 0); @@ -1725,8 +1707,7 @@ TEST_F(StreamApiFunctionalityTest, submitAck_shouldBeInWindowAfterErrorAck) } } - retStatus = getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize); + retStatus = getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize); EXPECT_EQ(true, STATUS_SUCCESS == retStatus || STATUS_NO_MORE_DATA_AVAILABLE == retStatus); EXPECT_EQ(true, filledSize > 0); @@ -1740,8 +1721,7 @@ TEST_F(StreamApiFunctionalityTest, submitAck_shouldBeInWindowAfterErrorAck) uploadHandle++; EXPECT_EQ(STATUS_SUCCESS, putStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, uploadHandle)); - retStatus = getKinesisVideoStreamData(mStreamHandle, uploadHandle, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize); + retStatus = getKinesisVideoStreamData(mStreamHandle, uploadHandle, getDataBuffer, SIZEOF(getDataBuffer), &filledSize); EXPECT_EQ(true, STATUS_SUCCESS == retStatus || STATUS_NO_MORE_DATA_AVAILABLE == retStatus); EXPECT_EQ(true, filledSize > 0); @@ -1784,12 +1764,11 @@ TEST_F(StreamApiFunctionalityTest, PutGet_ConnectionStaleNotification) // Return a put stream result on 1st if (i == 1) { - EXPECT_EQ(STATUS_SUCCESS, putStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_UPLOAD_HANDLE)); + EXPECT_EQ(STATUS_SUCCESS, putStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_UPLOAD_HANDLE)); } if (i >= 1) { - retStatus = getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize); + retStatus = getKinesisVideoStreamData(mStreamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize); EXPECT_EQ(true, STATUS_SUCCESS == retStatus || STATUS_NO_MORE_DATA_AVAILABLE == retStatus); EXPECT_EQ(true, filledSize > 0); } @@ -1829,18 +1808,14 @@ TEST_F(StreamApiFunctionalityTest, streamingTokenJitter_none) EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); // Ensure it fails on less than min duration - EXPECT_EQ(STATUS_INVALID_TOKEN_EXPIRATION, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - getTestTimeVal() + MIN_STREAMING_TOKEN_EXPIRATION_DURATION - 1)); + EXPECT_EQ(STATUS_INVALID_TOKEN_EXPIRATION, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), getTestTimeVal() + MIN_STREAMING_TOKEN_EXPIRATION_DURATION - 1)); UINT64 expiration = getTestTimeVal() + AUTH_INFO_EXPIRATION_RANDOMIZATION_DURATION_THRESHOLD; - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - expiration)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), expiration)); // Ensure no jitter has been introduced PKinesisVideoStream pKinesisVideoStream = FROM_STREAM_HANDLE(mStreamHandle); @@ -1867,17 +1842,13 @@ TEST_F(StreamApiFunctionalityTest, streamingTokenJitter_random) EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); // Ensure it fails on less than min duration - EXPECT_EQ(STATUS_INVALID_TOKEN_EXPIRATION, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - getTestTimeVal() + MIN_STREAMING_TOKEN_EXPIRATION_DURATION - 1)); - - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_INVALID_TOKEN_EXPIRATION, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), getTestTimeVal() + MIN_STREAMING_TOKEN_EXPIRATION_DURATION - 1)); + + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); // Ensure random jitter has been introduced PKinesisVideoStream pKinesisVideoStream = FROM_STREAM_HANDLE(mStreamHandle); @@ -1908,17 +1879,13 @@ TEST_F(StreamApiFunctionalityTest, streamingTokenJitter_preset_min) EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); // Ensure it fails on less than min duration - EXPECT_EQ(STATUS_INVALID_TOKEN_EXPIRATION, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - getTestTimeVal() + MIN_STREAMING_TOKEN_EXPIRATION_DURATION - 1)); - - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_INVALID_TOKEN_EXPIRATION, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), getTestTimeVal() + MIN_STREAMING_TOKEN_EXPIRATION_DURATION - 1)); + + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); // Ensure known jitter has been introduced as the overriden random generator function is returned // an expected random value which we can validate here. @@ -1948,17 +1915,13 @@ TEST_F(StreamApiFunctionalityTest, streamingTokenJitter_preset_max) EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); // Ensure it fails on less than min duration - EXPECT_EQ(STATUS_INVALID_TOKEN_EXPIRATION, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - getTestTimeVal() + MIN_STREAMING_TOKEN_EXPIRATION_DURATION - 1)); - - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_INVALID_TOKEN_EXPIRATION, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), getTestTimeVal() + MIN_STREAMING_TOKEN_EXPIRATION_DURATION - 1)); + + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); // Ensure max amount of jitter has been introduced as the controlled random function creates a jitter which // is greater than the max permitted jitter value controlled by MAX_AUTH_INFO_EXPIRATION_RANDOMIZATION define. @@ -1972,10 +1935,8 @@ TEST_F(StreamApiFunctionalityTest, streamingTokenJitter_preset_max) TEST_F(StreamApiFunctionalityTest, putFrame_AdaptAnnexB) { - BYTE frameData[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00, 0x1e, - 0xa9, 0x50, 0x14, 0x07, 0xb4, 0x20, 0x00, 0x00, - 0x7d, 0x00, 0x00, 0x1d, 0x4c, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x01, 0x68, 0xce, 0x3c, 0x80}; + BYTE frameData[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00, 0x1e, 0xa9, 0x50, 0x14, 0x07, 0xb4, 0x20, 0x00, 0x00, + 0x7d, 0x00, 0x00, 0x1d, 0x4c, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x3c, 0x80}; UINT32 frameDataSize = SIZEOF(frameData); Frame frame; diff --git a/tst/client/StreamApiServiceCallsTest.cpp b/tst/client/StreamApiServiceCallsTest.cpp index 0a31e8685..e89c11187 100644 --- a/tst/client/StreamApiServiceCallsTest.cpp +++ b/tst/client/StreamApiServiceCallsTest.cpp @@ -1,7 +1,6 @@ #include "ClientTestFixture.h" -class StreamApiServiceCallsTest : public ClientTestBase { -}; +class StreamApiServiceCallsTest : public ClientTestBase {}; TEST_F(StreamApiServiceCallsTest, putFrame_DescribeStreamCreating) { diff --git a/tst/client/StreamApiTest.cpp b/tst/client/StreamApiTest.cpp index 9c8ff78b6..46fc89037 100644 --- a/tst/client/StreamApiTest.cpp +++ b/tst/client/StreamApiTest.cpp @@ -1,7 +1,6 @@ #include "ClientTestFixture.h" -class StreamApiTest : public ClientTestBase { -}; +class StreamApiTest : public ClientTestBase {}; TEST_F(StreamApiTest, createKinesisVideoStream_NullInput) { @@ -445,7 +444,6 @@ TEST_F(StreamApiTest, insertKinesisVideoEvent_Invalid_Length) Meta.imagePrefix = imagePrefixInvalid; MEMSET(imagePrefixInvalid, 'h', SIZEOF(imagePrefixInvalid) - 1); EXPECT_EQ(STATUS_INVALID_IMAGE_PREFIX_LENGTH, putKinesisVideoEventMetadata(mStreamHandle, STREAM_EVENT_TYPE_IMAGE_GENERATION, &Meta)); - } TEST_F(StreamApiTest, insertKinesisVideoEvent_Invalid_Name) diff --git a/tst/client/StreamDeviceTagsTest.cpp b/tst/client/StreamDeviceTagsTest.cpp index b14902205..83f4cd77d 100644 --- a/tst/client/StreamDeviceTagsTest.cpp +++ b/tst/client/StreamDeviceTagsTest.cpp @@ -1,7 +1,6 @@ #include "ClientTestFixture.h" -class StreamDeviceTagsTest : public ClientTestBase { -}; +class StreamDeviceTagsTest : public ClientTestBase {}; TEST_F(StreamDeviceTagsTest, createDeviceTagsValid) { @@ -9,7 +8,7 @@ TEST_F(StreamDeviceTagsTest, createDeviceTagsValid) CLIENT_HANDLE clientHandle = INVALID_CLIENT_HANDLE_VALUE; UINT32 tagCount = MAX_TAG_COUNT; PTag tags = (PTag) MEMALLOC(SIZEOF(Tag) * tagCount); - for(i = 0; i < tagCount; i++) { + for (i = 0; i < tagCount; i++) { tags[i].version = TAG_CURRENT_VERSION; tags[i].name = (PCHAR) MEMALLOC(MAX_TAG_NAME_LEN); STRCPY(tags[i].name, "TagName"); @@ -28,7 +27,7 @@ TEST_F(StreamDeviceTagsTest, createDeviceTagsValid) EXPECT_EQ(0, mTagCount); // Free the tags - for(i = 0; i < tagCount; i++) { + for (i = 0; i < tagCount; i++) { MEMFREE(tags[i].name); MEMFREE(tags[i].value); } @@ -45,7 +44,7 @@ TEST_F(StreamDeviceTagsTest, createDeviceTagsLongNameInvalid) UINT32 tagCount = MAX_TAG_COUNT; PTag tags = (PTag) MEMALLOC(SIZEOF(Tag) * tagCount); - for(i = 0; i < tagCount; i++) { + for (i = 0; i < tagCount; i++) { tags[i].version = TAG_CURRENT_VERSION; tags[i].name = (PCHAR) MEMALLOC(MAX_TAG_NAME_LEN + 2); MEMSET(tags[i].name, 'A', MAX_TAG_NAME_LEN + 1); @@ -62,7 +61,7 @@ TEST_F(StreamDeviceTagsTest, createDeviceTagsLongNameInvalid) EXPECT_EQ(0, mTagCount); // Free the tags - for(i = 0; i < tagCount; i++) { + for (i = 0; i < tagCount; i++) { MEMFREE(tags[i].name); MEMFREE(tags[i].value); } @@ -78,7 +77,7 @@ TEST_F(StreamDeviceTagsTest, createDeviceTagsLongValueInvalid) CLIENT_HANDLE clientHandle = INVALID_CLIENT_HANDLE_VALUE; UINT32 tagCount = MAX_TAG_COUNT; PTag tags = (PTag) MEMALLOC(SIZEOF(Tag) * tagCount); - for(i = 0; i < tagCount; i++) { + for (i = 0; i < tagCount; i++) { tags[i].version = TAG_CURRENT_VERSION; tags[i].name = (PCHAR) MEMALLOC(MAX_TAG_NAME_LEN + 1); MEMSET(tags[i].name, 'A', MAX_TAG_NAME_LEN); @@ -95,7 +94,7 @@ TEST_F(StreamDeviceTagsTest, createDeviceTagsLongValueInvalid) EXPECT_EQ(0, mTagCount); // Free the tags - for(i = 0; i < tagCount; i++) { + for (i = 0; i < tagCount; i++) { MEMFREE(tags[i].name); MEMFREE(tags[i].value); } @@ -113,7 +112,7 @@ TEST_F(StreamDeviceTagsTest, createStreamTagsValid) STREAM_HANDLE streamHandle = INVALID_STREAM_HANDLE_VALUE; PTag tags = (PTag) MEMALLOC(SIZEOF(Tag) * tagCount); - for(i = 0; i < tagCount; i++) { + for (i = 0; i < tagCount; i++) { tags[i].version = TAG_CURRENT_VERSION; tags[i].name = (PCHAR) MEMALLOC(MAX_TAG_NAME_LEN); STRCPY(tags[i].name, "TagName"); @@ -135,10 +134,12 @@ TEST_F(StreamDeviceTagsTest, createStreamTagsValid) EXPECT_EQ(STATUS_SUCCESS, createStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAM_ARN)); EXPECT_EQ(STATUS_SUCCESS, tagResourceResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK)); EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); // Free the tags - for(i = 0; i < tagCount; i++) { + for (i = 0; i < tagCount; i++) { MEMFREE(tags[i].name); MEMFREE(tags[i].value); } @@ -156,7 +157,7 @@ TEST_F(StreamDeviceTagsTest, createStreamTagsLongNameInvalid) STREAM_HANDLE streamHandle = INVALID_STREAM_HANDLE_VALUE; PTag tags = (PTag) MEMALLOC(SIZEOF(Tag) * tagCount); - for(i = 0; i < tagCount; i++) { + for (i = 0; i < tagCount; i++) { tags[i].version = TAG_CURRENT_VERSION; tags[i].name = (PCHAR) MEMALLOC(MAX_TAG_NAME_LEN + 2); MEMSET(tags[i].name, 'A', MAX_TAG_NAME_LEN + 1); @@ -176,7 +177,7 @@ TEST_F(StreamDeviceTagsTest, createStreamTagsLongNameInvalid) EXPECT_EQ(0, mTagCount); // Free the tags - for(i = 0; i < tagCount; i++) { + for (i = 0; i < tagCount; i++) { MEMFREE(tags[i].name); MEMFREE(tags[i].value); } @@ -194,7 +195,7 @@ TEST_F(StreamDeviceTagsTest, createStreamTagsLongValueInvalid) STREAM_HANDLE streamHandle = INVALID_STREAM_HANDLE_VALUE; PTag tags = (PTag) MEMALLOC(SIZEOF(Tag) * tagCount); - for(i = 0; i < tagCount; i++) { + for (i = 0; i < tagCount; i++) { tags[i].version = TAG_CURRENT_VERSION; tags[i].name = (PCHAR) MEMALLOC(MAX_TAG_NAME_LEN + 1); MEMSET(tags[i].name, 'A', MAX_TAG_NAME_LEN); @@ -214,7 +215,7 @@ TEST_F(StreamDeviceTagsTest, createStreamTagsLongValueInvalid) EXPECT_EQ(0, mTagCount); // Free the tags - for(i = 0; i < tagCount; i++) { + for (i = 0; i < tagCount; i++) { MEMFREE(tags[i].name); MEMFREE(tags[i].value); } diff --git a/tst/client/StreamFunctionalityTest.cpp b/tst/client/StreamFunctionalityTest.cpp index d894c481f..36d842c9e 100644 --- a/tst/client/StreamFunctionalityTest.cpp +++ b/tst/client/StreamFunctionalityTest.cpp @@ -1,15 +1,14 @@ #include "ClientTestFixture.h" -using ::testing::WithParamInterface; using ::testing::Bool; -using ::testing::Values; using ::testing::Combine; +using ::testing::Values; +using ::testing::WithParamInterface; -class StreamFunctionalityTest : public ClientTestBase, - public WithParamInterface< ::std::tuple > -{ -protected: - void SetUp() { +class StreamFunctionalityTest : public ClientTestBase, public WithParamInterface< ::std::tuple > { + protected: + void SetUp() + { ClientTestBase::SetUp(); STREAMING_TYPE streamingType; @@ -47,8 +46,8 @@ TEST_P(StreamFunctionalityTest, CreateSyncFreeSuccess) EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoStream(&mStreamHandle)); } - -TEST_P(StreamFunctionalityTest, CreateSyncStopSyncFreePutFrameFail) { +TEST_P(StreamFunctionalityTest, CreateSyncStopSyncFreePutFrameFail) +{ CreateScenarioTestClient(); PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); CreateStreamSync(); @@ -110,7 +109,8 @@ TEST_P(StreamFunctionalityTest, CreateSyncPutMultipleFramesFree) EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoStream(&mStreamHandle)); } -TEST_P(StreamFunctionalityTest, CreateSyncStopFreeSuccess) { +TEST_P(StreamFunctionalityTest, CreateSyncStopFreeSuccess) +{ CreateScenarioTestClient(); PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); CreateStreamSync(); @@ -118,7 +118,8 @@ TEST_P(StreamFunctionalityTest, CreateSyncStopFreeSuccess) { EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoStream(&mStreamHandle)); } -TEST_P(StreamFunctionalityTest, CreateSyncPutFrameStopSyncFreeSuccess) { +TEST_P(StreamFunctionalityTest, CreateSyncPutFrameStopSyncFreeSuccess) +{ CreateScenarioTestClient(); PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); CreateStreamSync(); @@ -128,7 +129,8 @@ TEST_P(StreamFunctionalityTest, CreateSyncPutFrameStopSyncFreeSuccess) { } // stopStreamSync should timeout since putStreamResult is never submitted. -TEST_P(StreamFunctionalityTest, CreateAwaitPutFrameStopSyncFreeSuccess) { +TEST_P(StreamFunctionalityTest, CreateAwaitPutFrameStopSyncFreeSuccess) +{ PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); // the test is meant to timeout, use a shorter timeout to reduce test running time. mDeviceInfo.clientInfo.stopStreamTimeout = TEST_STOP_STREAM_TIMEOUT_SHORT; @@ -139,7 +141,6 @@ TEST_P(StreamFunctionalityTest, CreateAwaitPutFrameStopSyncFreeSuccess) { VerifyStopStreamSyncAndFree(TRUE); } - TEST_P(StreamFunctionalityTest, CreateAwaitReadyFree) { PASS_TEST_FOR_ZERO_RETENTION_AND_OFFLINE(); @@ -178,7 +179,7 @@ TEST_P(StreamFunctionalityTest, CreateSyncPutFrameEoFR) { CreateScenarioTestClient(); BOOL submittedAck = FALSE, gotStreamData; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; UINT64 stopTime, currentTime; std::vector currentUploadHandles; STATUS retStatus; @@ -194,7 +195,7 @@ TEST_P(StreamFunctionalityTest, CreateSyncPutFrameEoFR) // Put a eofr frame EXPECT_EQ(STATUS_SUCCESS, producer.putFrame(TRUE)); - //give 5 seconds to get the single frame fragment + // give 5 seconds to get the single frame fragment stopTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) + 10 * HUNDREDS_OF_NANOS_IN_A_SECOND; do { currentTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); @@ -329,8 +330,11 @@ TEST_P(StreamFunctionalityTest, StreamDescription_V0_Test) EXPECT_EQ(0, pKinesisVideoStream->retention); EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); } INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, StreamFunctionalityTest, - Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); + Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), + Values(0, TEST_REPLAY_DURATION))); diff --git a/tst/client/StreamParallelTest.cpp b/tst/client/StreamParallelTest.cpp index 5b99c37c8..da1b3fe98 100644 --- a/tst/client/StreamParallelTest.cpp +++ b/tst/client/StreamParallelTest.cpp @@ -1,7 +1,6 @@ #include "ClientTestFixture.h" -class StreamParallelTest : public ClientTestBase { -}; +class StreamParallelTest : public ClientTestBase {}; StreamParallelTest* gParallelTest = NULL; @@ -83,10 +82,9 @@ PVOID ClientTestBase::basicConsumerRoutine(UINT64 streamId) while (!ATOMIC_LOAD_BOOL(&mTerminate)) { DLOGV("Consumer for stream %llu TID %016llx", streamId, GETTID()); // Consume frames - retStatus = getKinesisVideoStreamData(streamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize); - EXPECT_TRUE(retStatus == STATUS_SUCCESS || retStatus == STATUS_NO_MORE_DATA_AVAILABLE || - retStatus == STATUS_END_OF_STREAM || retStatus == STATUS_UPLOAD_HANDLE_ABORTED); + retStatus = getKinesisVideoStreamData(streamHandle, TEST_UPLOAD_HANDLE, getDataBuffer, SIZEOF(getDataBuffer), &filledSize); + EXPECT_TRUE(retStatus == STATUS_SUCCESS || retStatus == STATUS_NO_MORE_DATA_AVAILABLE || retStatus == STATUS_END_OF_STREAM || + retStatus == STATUS_UPLOAD_HANDLE_ABORTED); if (retStatus == STATUS_SUCCESS) { EXPECT_EQ(SIZEOF(getDataBuffer), filledSize); @@ -145,8 +143,7 @@ TEST_F(StreamParallelTest, putFrame_BasicParallelPutGet) // Move the next state // Reset the stream name mStreamName[0] = '\0'; - EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCustomDatas[mStreamCount], SERVICE_CALL_RESULT_OK, - TEST_STREAMING_ENDPOINT)); + EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCustomDatas[mStreamCount], SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); // Ensure the get token is called EXPECT_EQ(0, STRCMP(streamName, mStreamName)); @@ -155,11 +152,9 @@ TEST_F(StreamParallelTest, putFrame_BasicParallelPutGet) // Move to the next state // Reset the stream name mStreamName[0] = '\0'; - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCustomDatas[mStreamCount], - SERVICE_CALL_RESULT_OK, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCustomDatas[mStreamCount], SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); DLOGV("Creating the producer and consumer threads"); diff --git a/tst/client/StreamPutGetTest.cpp b/tst/client/StreamPutGetTest.cpp index ff84b9581..d35ba4026 100644 --- a/tst/client/StreamPutGetTest.cpp +++ b/tst/client/StreamPutGetTest.cpp @@ -1,7 +1,6 @@ #include "ClientTestFixture.h" -class StreamPutGetTest : public ClientTestBase { -}; +class StreamPutGetTest : public ClientTestBase {}; #ifdef ALIGNED_MEMORY_MODEL TEST_F(StreamPutGetTest, putFrame_PutGetFrameBoundary) { diff --git a/tst/client/StreamRecoveryFunctionalityTest.cpp b/tst/client/StreamRecoveryFunctionalityTest.cpp index 426a27de1..ccc0cf9c1 100644 --- a/tst/client/StreamRecoveryFunctionalityTest.cpp +++ b/tst/client/StreamRecoveryFunctionalityTest.cpp @@ -1,15 +1,14 @@ #include "ClientTestFixture.h" -using ::testing::WithParamInterface; using ::testing::Bool; -using ::testing::Values; using ::testing::Combine; +using ::testing::Values; +using ::testing::WithParamInterface; -class StreamRecoveryFunctionalityTest : public ClientTestBase, - public WithParamInterface< ::std::tuple >{ - -protected: - void SetUp() { +class StreamRecoveryFunctionalityTest : public ClientTestBase, public WithParamInterface< ::std::tuple > { + protected: + void SetUp() + { ClientTestBase::SetUp(); STREAMING_TYPE streamingType; @@ -26,7 +25,7 @@ class StreamRecoveryFunctionalityTest : public ClientTestBase, TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamResetConnectionEnsureRecovery) { std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; BOOL didPutFrame, gotStreamData, submittedAck; UINT64 currentTime, streamStopTime, resetConnectionTime; @@ -54,9 +53,7 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamResetConnectionEns if (IS_VALID_TIMESTAMP(resetConnectionTime) && currentTime >= resetConnectionTime) { // reset connection - EXPECT_EQ(STATUS_SUCCESS, kinesisVideoStreamTerminated(mStreamHandle, - INVALID_UPLOAD_HANDLE_VALUE, - SERVICE_CALL_RESULT_OK)); + EXPECT_EQ(STATUS_SUCCESS, kinesisVideoStreamTerminated(mStreamHandle, INVALID_UPLOAD_HANDLE_VALUE, SERVICE_CALL_RESULT_OK)); resetConnectionTime = INVALID_TIMESTAMP_VALUE; // reset connection only once. } @@ -65,9 +62,10 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamResetConnectionEns VerifyStopStreamSyncAndFree(); } -TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamResetConnectionAfterTokenRotationEnsureRecovery) { +TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamResetConnectionAfterTokenRotationEnsureRecovery) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; BOOL didPutFrame, gotStreamData, submittedAck; UINT64 currentTime, streamStopTime, resetConnectionTime; @@ -98,9 +96,7 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamResetConnectionAft if (IS_VALID_TIMESTAMP(resetConnectionTime) && currentTime >= resetConnectionTime) { // reset connection - EXPECT_EQ(STATUS_SUCCESS, kinesisVideoStreamTerminated(mStreamHandle, - INVALID_UPLOAD_HANDLE_VALUE, - SERVICE_CALL_RESULT_OK)); + EXPECT_EQ(STATUS_SUCCESS, kinesisVideoStreamTerminated(mStreamHandle, INVALID_UPLOAD_HANDLE_VALUE, SERVICE_CALL_RESULT_OK)); // restore slow speed after reset so all subsequent uploads are at normal speed mMockConsumerConfig.mUploadSpeedBytesPerSecond = 1000000; // restore speed for current active upload handles @@ -121,10 +117,11 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamResetConnectionAft // Create stream, stream, last persisted ACK is before the rollback duration, the received ACK is // after the rollback duration, inject a fault indicating not-dead host and terminate session. // Make sure the rollback is to the received ACK + next fragment -TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamRollbackToLastReceivedAckEnsureRecovery) { +TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamRollbackToLastReceivedAckEnsureRecovery) +{ std::vector currentUploadHandles; UPLOAD_HANDLE errorHandle = INVALID_UPLOAD_HANDLE_VALUE; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; BOOL didPutFrame, gotStreamData = FALSE, submittedAck; UINT64 currentTime, streamStopTime, rollbackTime, lastReceivedAckTime = 0, lastPersistedAckTime = 0; STATUS retStatus; @@ -157,20 +154,16 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamRollbackToLastRece // First getStreamData should trigger rollback if (IS_VALID_TIMESTAMP(lastReceivedAckTime) && uploadHandle != errorHandle) { UINT32 actualDataSize; - retStatus = getKinesisVideoStreamData(mStreamHandle, mockConsumer->mUploadHandle, - mockConsumer->mDataBuffer, 1, &actualDataSize); + retStatus = getKinesisVideoStreamData(mStreamHandle, mockConsumer->mUploadHandle, mockConsumer->mDataBuffer, 1, &actualDataSize); if (mStreamInfo.streamCaps.streamingType == STREAMING_TYPE_REALTIME) { // Rollback to last received ack in realtime mode - EXPECT_EQ( - lastReceivedAckTime * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, - FROM_STREAM_HANDLE(mStreamHandle)->curViewItem.viewItem.ackTimestamp); + EXPECT_EQ(lastReceivedAckTime * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, + FROM_STREAM_HANDLE(mStreamHandle)->curViewItem.viewItem.ackTimestamp); } else { // Rollback to the tail in offline mode - EXPECT_EQ( - lastPersistedAckTime * HUNDREDS_OF_NANOS_IN_A_MILLISECOND - + 1 * HUNDREDS_OF_NANOS_IN_A_SECOND * - mMockProducerConfig.mKeyFrameInterval / mMockProducerConfig.mFps, - FROM_STREAM_HANDLE(mStreamHandle)->curViewItem.viewItem.ackTimestamp); + EXPECT_EQ(lastPersistedAckTime * HUNDREDS_OF_NANOS_IN_A_MILLISECOND + + 1 * HUNDREDS_OF_NANOS_IN_A_SECOND * mMockProducerConfig.mKeyFrameInterval / mMockProducerConfig.mFps, + FROM_STREAM_HANDLE(mStreamHandle)->curViewItem.viewItem.ackTimestamp); } lastReceivedAckTime = INVALID_TIMESTAMP_VALUE; // only check when rollback happens } else { @@ -207,7 +200,8 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamRollbackToLastRece for (int i = 0; i < currentUploadHandles.size(); i++) { UPLOAD_HANDLE uploadHandle = currentUploadHandles[i]; mockConsumer = mStreamingSession.getConsumer(uploadHandle); - EXPECT_EQ(STATUS_SUCCESS, mockConsumer->submitErrorAck(SERVICE_CALL_RESULT_FRAGMENT_ARCHIVAL_ERROR, lastReceivedAckTime, &submittedAck)); + EXPECT_EQ(STATUS_SUCCESS, + mockConsumer->submitErrorAck(SERVICE_CALL_RESULT_FRAGMENT_ARCHIVAL_ERROR, lastReceivedAckTime, &submittedAck)); if (submittedAck) { rollbackTime = INVALID_TIMESTAMP_VALUE; // rollback only once. errorHandle = uploadHandle; @@ -223,9 +217,10 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamRollbackToLastRece * contentView: Frag1 | Frag2 | Frag3 ... * Send a non recoverable error ack to Frag1. Make sure that Frag1 is not streamed in the new connection */ -TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorThrowAwayBadFragmentNearTail) { +TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorThrowAwayBadFragmentNearTail) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer = nullptr; + MockConsumer* mockConsumer = nullptr; BOOL gotStreamData = FALSE, submittedAck; UINT64 currentTime, stopTime; TID thread; @@ -245,7 +240,7 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorThrowAwa MockProducer mockProducer(mMockProducerConfig, mStreamHandle); // need ack to count number of fragments streamed. No ack case should also work if with ack works. - for(i = 0; i < mMockProducerConfig.mKeyFrameInterval * totalFragmentPut; i++) { + for (i = 0; i < mMockProducerConfig.mKeyFrameInterval * totalFragmentPut; i++) { EXPECT_EQ(STATUS_SUCCESS, mockProducer.putFrame(FALSE)); } @@ -323,9 +318,10 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorThrowAwa * contentView: Frag1 | Frag2 | Frag3 ... * Send a non recoverable error ack to Frag2 with a timestamp. Make sure that ONLY Frag2 is not streamed in the new connection */ -TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorWithTimestampThrowAwayBadFragmentMiddle) { +TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorWithTimestampThrowAwayBadFragmentMiddle) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer = nullptr; + MockConsumer* mockConsumer = nullptr; BOOL gotStreamData = FALSE, submittedAck; UINT64 currentTime, stopTime, ackTime = 0, duration; TID thread; @@ -374,7 +370,9 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorWithTime // submit a fatal error ack to current upload handle at timestamp corresponding to the second fragment mStreamingSession.getActiveUploadHandles(currentUploadHandles); EXPECT_EQ(1, currentUploadHandles.size()); - EXPECT_EQ(STATUS_SUCCESS, mockConsumer->submitErrorAck(SERVICE_CALL_RESULT_FRAGMENT_DURATION_REACHED, ackTime / HUNDREDS_OF_NANOS_IN_A_MILLISECOND, &submittedAck)); + EXPECT_EQ( + STATUS_SUCCESS, + mockConsumer->submitErrorAck(SERVICE_CALL_RESULT_FRAGMENT_DURATION_REACHED, ackTime / HUNDREDS_OF_NANOS_IN_A_MILLISECOND, &submittedAck)); EXPECT_EQ(TRUE, submittedAck); errorHandle = mockConsumer->mUploadHandle; @@ -430,9 +428,10 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorWithTime * Send a non recoverable error ack on the 4th fragment ingestion without a timestamp. * Make sure that the earlier fragments are not streamed in the new connection. */ -TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorWithoutTimestampThrowAwayBadFragmentMiddle) { +TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorWithoutTimestampThrowAwayBadFragmentMiddle) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer = nullptr; + MockConsumer* mockConsumer = nullptr; BOOL gotStreamData = FALSE, submittedAck; UINT64 currentTime, stopTime; TID thread; @@ -533,9 +532,10 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorWithoutT * without a timestamp. Make sure that the first fragment is rolled back to and streamed whioe * the fragments from the persistent ACK till current are skipped in the new connection */ -TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorWithoutTimestampThrowAwayBadFromPersist) { +TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorWithoutTimestampThrowAwayBadFromPersist) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer = nullptr; + MockConsumer* mockConsumer = nullptr; BOOL gotStreamData = FALSE, submittedAck; UINT64 currentTime, stopTime; TID thread; @@ -651,9 +651,10 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorWithoutT * contentView: Frag1_Frame1 Frag1_Frame2 Frag1_Frame3 ... * Send a non recoverable error ack to Frag1 while it is not completed. Make sure that Frag1 is not streamed in the new connection */ -TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorThrowAwayBadFragmentAtHeadPartiallyStreamed) { +TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorThrowAwayBadFragmentAtHeadPartiallyStreamed) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer = nullptr; + MockConsumer* mockConsumer = nullptr; BOOL gotStreamData = FALSE, submittedAck; UINT64 currentTime, stopTime; TID thread; @@ -671,7 +672,7 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorThrowAwa MockProducer mockProducer(mMockProducerConfig, mStreamHandle); // put some frames but not all for the first fragment - for(i = 0; i < mMockProducerConfig.mKeyFrameInterval - 5; i++) { + for (i = 0; i < mMockProducerConfig.mKeyFrameInterval - 5; i++) { EXPECT_EQ(STATUS_SUCCESS, mockProducer.putFrame(FALSE)); } @@ -706,12 +707,12 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorThrowAwa } while (!gotStreamData); // finishing putting all frames for the first fragment. - for(i = 0; i < 5; i++) { + for (i = 0; i < 5; i++) { EXPECT_EQ(STATUS_SUCCESS, mockProducer.putFrame(FALSE)); } // put in more fragments. At the end we are expecting totalFragmentPut * 3 acks. - for(i = 0; i < mMockProducerConfig.mKeyFrameInterval * (totalFragmentPut-1); i++) { + for (i = 0; i < mMockProducerConfig.mKeyFrameInterval * (totalFragmentPut - 1); i++) { EXPECT_EQ(STATUS_SUCCESS, mockProducer.putFrame(FALSE)); } @@ -759,9 +760,10 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorThrowAwa * Send a non recoverable error ack to Frag1 while Frag1 is completed (next frame will be the start of Frag2). * Make sure that Frag1 is not streamed in the new connection */ -TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorThrowAwayBadFragmentAtHeadFullyStreamed) { +TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorThrowAwayBadFragmentAtHeadFullyStreamed) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer = nullptr; + MockConsumer* mockConsumer = nullptr; BOOL gotStreamData = FALSE, submittedAck; UINT64 currentTime, stopTime; TID thread; @@ -779,7 +781,7 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorThrowAwa MockProducer mockProducer(mMockProducerConfig, mStreamHandle); // put all frames for the first fragment - for(i = 0; i < mMockProducerConfig.mKeyFrameInterval; i++) { + for (i = 0; i < mMockProducerConfig.mKeyFrameInterval; i++) { EXPECT_EQ(STATUS_SUCCESS, mockProducer.putFrame(FALSE)); } @@ -814,7 +816,7 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorThrowAwa } while (!gotStreamData); // put in more fragments. At the end we are expecting totalFragmentPut * 3 acks. - for(i = 0; i < mMockProducerConfig.mKeyFrameInterval * (totalFragmentPut-1); i++) { + for (i = 0; i < mMockProducerConfig.mKeyFrameInterval * (totalFragmentPut - 1); i++) { EXPECT_EQ(STATUS_SUCCESS, mockProducer.putFrame(FALSE)); } @@ -861,9 +863,10 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamFatalErrorThrowAwa * contentView: Frag1_Frame1 Frag1_Frame2 Frag1_Frame3 ... Frag2_fram1,.... FragN_frameN * Timeout the upload handle with current view non-zero. Ensure immediate auto-recovery with rollback */ -TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamTimeoutWithBuffer) { +TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamTimeoutWithBuffer) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer = nullptr; + MockConsumer* mockConsumer = nullptr; BOOL gotStreamData = FALSE, submittedAck; UINT64 currentTime, stopTime; TID thread; @@ -915,7 +918,7 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamTimeoutWithBuffer) } while (!gotStreamData); // put in more fragments. At the end we are expecting totalFragmentPut * 3 acks. - for (i = 0; i < mMockProducerConfig.mKeyFrameInterval * (totalFragmentPut -1 ); i++) { + for (i = 0; i < mMockProducerConfig.mKeyFrameInterval * (totalFragmentPut - 1); i++) { EXPECT_EQ(STATUS_SUCCESS, mockProducer.putFrame(FALSE)); } @@ -959,9 +962,10 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamTimeoutWithBuffer) * contentView: Frag1_Frame1 Frag1_Frame2 Frag1_Frame3 ... Frag2_fram1,.... FragN_frameN * Timeout the upload handle with current view zero. Ensure no immediate auto-recovery */ -TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamTimeoutWithoutBuffer) { +TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamTimeoutWithoutBuffer) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer = nullptr; + MockConsumer* mockConsumer = nullptr; BOOL gotStreamData = FALSE, submittedAck; UINT64 currentTime, stopTime; TID thread; @@ -1059,9 +1063,7 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamTimeoutWithoutBuff EXPECT_TRUE(currentUploadHandles[0] != errorHandle); // Validate that the new upload handle has a rolled back proper start stream - EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, - currentUploadHandles[0], dataBuf, - dataBufSize, &retrievedSize)); + EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, currentUploadHandles[0], dataBuf, dataBufSize, &retrievedSize)); EXPECT_EQ(dataBufSize, retrievedSize); pKinesisVideoStream = FROM_STREAM_HANDLE(mStreamHandle); @@ -1075,11 +1077,9 @@ TEST_P(StreamRecoveryFunctionalityTest, CreateStreamThenStreamTimeoutWithoutBuff // until the next key frame which will become the stream start for (i = 0; i < TEST_DEFAULT_PRODUCER_CONFIG_FRAME_SIZE; i++) { if (mStreamInfo.streamCaps.replayDuration == 0) { - EXPECT_EQ((numFragments + 1) * mMockProducerConfig.mKeyFrameInterval, dataBuf[i + overhead]) - << "Failed on " << i; + EXPECT_EQ((numFragments + 1) * mMockProducerConfig.mKeyFrameInterval, dataBuf[i + overhead]) << "Failed on " << i; } else { - EXPECT_EQ(0, dataBuf[i + overhead]) - << "Failed on " << i; + EXPECT_EQ(0, dataBuf[i + overhead]) << "Failed on " << i; } } @@ -1122,7 +1122,7 @@ TEST_P(StreamRecoveryFunctionalityTest, streamStartViewDroppedBeforeFullyConsume BOOL didPutFrame, gotStreamData = FALSE, submittedAck; UINT32 tokenRotateCount = 0, i; std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; STATUS status = STATUS_SUCCESS; CreateScenarioTestClient(); @@ -1143,7 +1143,7 @@ TEST_P(StreamRecoveryFunctionalityTest, streamStartViewDroppedBeforeFullyConsume MockProducer mockProducer(mMockProducerConfig, mStreamHandle); /* fill the content view */ - for(i = 0; i < 40; ++i) { + for (i = 0; i < 40; ++i) { EXPECT_EQ(STATUS_SUCCESS, mockProducer.putFrame(FALSE)); } @@ -1162,7 +1162,7 @@ TEST_P(StreamRecoveryFunctionalityTest, streamStartViewDroppedBeforeFullyConsume } /* put 40 frames again. The first 40 frames are now all dropped */ - for(i = 0; i < 40; ++i) { + for (i = 0; i < 40; ++i) { EXPECT_EQ(STATUS_SUCCESS, mockProducer.putFrame(FALSE)); } @@ -1180,17 +1180,17 @@ TEST_P(StreamRecoveryFunctionalityTest, streamStartViewDroppedBeforeFullyConsume VerifyStopStreamSyncAndFree(); } -TEST_P(StreamRecoveryFunctionalityTest, FragmentMetadataStartStreamFailRecovery) { +TEST_P(StreamRecoveryFunctionalityTest, FragmentMetadataStartStreamFailRecovery) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer = nullptr; + MockConsumer* mockConsumer = nullptr; BOOL gotStreamData = FALSE, submittedAck, firstChunk = TRUE; UINT64 currentTime, stopTime; TID thread; STATUS retStatus = STATUS_SUCCESS; BYTE dataBuf[TEST_DEFAULT_PRODUCER_CONFIG_FRAME_SIZE + 1000]; BYTE storedDataBuf[SIZEOF(dataBuf)]; - UINT32 i, ackReceived = 0, dataBufSize = SIZEOF(dataBuf), retrievedSize, - storedRetrievedSize, overhead, numFragments = 1; + UINT32 i, ackReceived = 0, dataBufSize = SIZEOF(dataBuf), retrievedSize, storedRetrievedSize, overhead, numFragments = 1; UPLOAD_HANDLE errorHandle; PKinesisVideoStream pKinesisVideoStream; PStreamMkvGenerator pStreamMkvGenerator; @@ -1253,9 +1253,7 @@ TEST_P(StreamRecoveryFunctionalityTest, FragmentMetadataStartStreamFailRecovery) EXPECT_NE(errorHandle, currentUploadHandles[0]); // Get the data with the new handle - EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, - currentUploadHandles[0], dataBuf, - dataBufSize, &retrievedSize)); + EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, currentUploadHandles[0], dataBuf, dataBufSize, &retrievedSize)); EXPECT_EQ(storedRetrievedSize, retrievedSize); EXPECT_EQ(0, MEMCMP(dataBuf, storedDataBuf, storedRetrievedSize)); @@ -1263,17 +1261,17 @@ TEST_P(StreamRecoveryFunctionalityTest, FragmentMetadataStartStreamFailRecovery) EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoStream(&mStreamHandle)); } -TEST_P(StreamRecoveryFunctionalityTest, EventMetadataStartStreamFailRecovery) { +TEST_P(StreamRecoveryFunctionalityTest, EventMetadataStartStreamFailRecovery) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer = nullptr; + MockConsumer* mockConsumer = nullptr; BOOL gotStreamData = FALSE, submittedAck, firstChunk = TRUE; UINT64 currentTime, stopTime; TID thread; STATUS retStatus = STATUS_SUCCESS; BYTE dataBuf[TEST_DEFAULT_PRODUCER_CONFIG_FRAME_SIZE + 1000]; BYTE storedDataBuf[SIZEOF(dataBuf)]; - UINT32 i, ackReceived = 0, dataBufSize = SIZEOF(dataBuf), retrievedSize, - storedRetrievedSize, overhead, numFragments = 1; + UINT32 i, ackReceived = 0, dataBufSize = SIZEOF(dataBuf), retrievedSize, storedRetrievedSize, overhead, numFragments = 1; UPLOAD_HANDLE errorHandle; PKinesisVideoStream pKinesisVideoStream; PStreamMkvGenerator pStreamMkvGenerator; @@ -1337,9 +1335,7 @@ TEST_P(StreamRecoveryFunctionalityTest, EventMetadataStartStreamFailRecovery) { EXPECT_NE(errorHandle, currentUploadHandles[0]); // Get the data with the new handle - EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, - currentUploadHandles[0], dataBuf, - dataBufSize, &retrievedSize)); + EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamData(mStreamHandle, currentUploadHandles[0], dataBuf, dataBufSize, &retrievedSize)); EXPECT_EQ(storedRetrievedSize, retrievedSize); EXPECT_EQ(0, MEMCMP(dataBuf, storedDataBuf, storedRetrievedSize)); @@ -1348,6 +1344,7 @@ TEST_P(StreamRecoveryFunctionalityTest, EventMetadataStartStreamFailRecovery) { } INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, StreamRecoveryFunctionalityTest, - Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); + Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), + Values(0, TEST_REPLAY_DURATION))); #endif \ No newline at end of file diff --git a/tst/client/StreamStateTransitionsTest.cpp b/tst/client/StreamStateTransitionsTest.cpp index ba3ba8167..181ba0649 100644 --- a/tst/client/StreamStateTransitionsTest.cpp +++ b/tst/client/StreamStateTransitionsTest.cpp @@ -1,7 +1,6 @@ #include "ClientTestFixture.h" -class StreamStateTransitionsTest : public ClientTestBase { -}; +class StreamStateTransitionsTest : public ClientTestBase {}; TEST_F(StreamStateTransitionsTest, stopStateFromCreate) { @@ -67,7 +66,9 @@ TEST_F(StreamStateTransitionsTest, stopStateFromGetToken) mStreamDescription.creationTime = GETTIME(); EXPECT_EQ(STATUS_SUCCESS, describeStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, &mStreamDescription)); EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), TEST_AUTH_EXPIRATION)); EXPECT_EQ(STATUS_SUCCESS, kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_RESULT_OK)); } @@ -327,7 +328,8 @@ TEST_F(StreamStateTransitionsTest, stopStateFromStreamingLimitNoRecovery) mSubmitServiceCallResultMode = STOP_AT_PUT_STREAM; - EXPECT_EQ(STATUS_SERVICE_CALL_STREAM_LIMIT_ERROR, kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_STREAM_LIMIT)); + EXPECT_EQ(STATUS_SERVICE_CALL_STREAM_LIMIT_ERROR, + kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_STREAM_LIMIT)); // Validate that we have not restarted EXPECT_EQ(1, ATOMIC_LOAD(&mDescribeStreamFuncCount)); @@ -338,7 +340,8 @@ TEST_F(StreamStateTransitionsTest, stopStateFromStreamingLimitNoRecovery) EXPECT_EQ(1, ATOMIC_LOAD(&mStreamReadyFuncCount)); EXPECT_EQ(1, ATOMIC_LOAD(&mPutStreamFuncCount)); - EXPECT_EQ(STATUS_SERVICE_CALL_DEVICE_LIMIT_ERROR, kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_DEVICE_LIMIT)); + EXPECT_EQ(STATUS_SERVICE_CALL_DEVICE_LIMIT_ERROR, + kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_DEVICE_LIMIT)); // Validate that we have not restarted EXPECT_EQ(1, ATOMIC_LOAD(&mDescribeStreamFuncCount)); @@ -477,7 +480,8 @@ TEST_F(StreamStateTransitionsTest, stopStateFromStreamingNotAuthorizedNoRecovery mSubmitServiceCallResultMode = STOP_AT_PUT_STREAM; - EXPECT_EQ(STATUS_SERVICE_CALL_NOT_AUTHORIZED_ERROR, kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_NOT_AUTHORIZED)); + EXPECT_EQ(STATUS_SERVICE_CALL_NOT_AUTHORIZED_ERROR, + kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_NOT_AUTHORIZED)); // Validate that we have not restarted EXPECT_EQ(1, ATOMIC_LOAD(&mDescribeStreamFuncCount)); @@ -488,7 +492,8 @@ TEST_F(StreamStateTransitionsTest, stopStateFromStreamingNotAuthorizedNoRecovery EXPECT_EQ(1, ATOMIC_LOAD(&mStreamReadyFuncCount)); EXPECT_EQ(1, ATOMIC_LOAD(&mPutStreamFuncCount)); - EXPECT_EQ(STATUS_SERVICE_CALL_NOT_AUTHORIZED_ERROR, kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_FORBIDDEN)); + EXPECT_EQ(STATUS_SERVICE_CALL_NOT_AUTHORIZED_ERROR, + kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_FORBIDDEN)); // Validate that we have not restarted EXPECT_EQ(1, ATOMIC_LOAD(&mDescribeStreamFuncCount)); @@ -628,7 +633,8 @@ TEST_F(StreamStateTransitionsTest, stopStateFromStreamingResourceInUseNoRecovery mSubmitServiceCallResultMode = STOP_AT_PUT_STREAM; - EXPECT_EQ(STATUS_SERVICE_CALL_RESOURCE_IN_USE_ERROR, kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_RESOURCE_IN_USE)); + EXPECT_EQ(STATUS_SERVICE_CALL_RESOURCE_IN_USE_ERROR, + kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_RESOURCE_IN_USE)); // Validate that we have not restarted EXPECT_EQ(1, ATOMIC_LOAD(&mDescribeStreamFuncCount)); @@ -767,7 +773,8 @@ TEST_F(StreamStateTransitionsTest, stopStateFromStreamingInternalNoRecovery) mSubmitServiceCallResultMode = STOP_AT_PUT_STREAM; - EXPECT_EQ(STATUS_ACK_ERR_ACK_INTERNAL_ERROR, kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_RESULT_ACK_INTERNAL_ERROR)); + EXPECT_EQ(STATUS_ACK_ERR_ACK_INTERNAL_ERROR, + kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_RESULT_ACK_INTERNAL_ERROR)); // Validate that we have not restarted EXPECT_EQ(1, ATOMIC_LOAD(&mDescribeStreamFuncCount)); @@ -906,7 +913,8 @@ TEST_F(StreamStateTransitionsTest, stopStateFromStreamingResourceNotFoundNoRecov mSubmitServiceCallResultMode = STOP_AT_PUT_STREAM; - EXPECT_EQ(STATUS_SERVICE_CALL_RESOURCE_NOT_FOUND_ERROR, kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_RESOURCE_NOT_FOUND)); + EXPECT_EQ(STATUS_SERVICE_CALL_RESOURCE_NOT_FOUND_ERROR, + kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_RESOURCE_NOT_FOUND)); // Validate that we have not restarted EXPECT_EQ(1, ATOMIC_LOAD(&mDescribeStreamFuncCount)); @@ -917,7 +925,8 @@ TEST_F(StreamStateTransitionsTest, stopStateFromStreamingResourceNotFoundNoRecov EXPECT_EQ(1, ATOMIC_LOAD(&mStreamReadyFuncCount)); EXPECT_EQ(1, ATOMIC_LOAD(&mPutStreamFuncCount)); - EXPECT_EQ(STATUS_SERVICE_CALL_RESOURCE_DELETED_ERROR, kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_RESOURCE_DELETED)); + EXPECT_EQ(STATUS_SERVICE_CALL_RESOURCE_DELETED_ERROR, + kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_RESOURCE_DELETED)); // Validate that we have not restarted EXPECT_EQ(1, ATOMIC_LOAD(&mDescribeStreamFuncCount)); @@ -1045,6 +1054,7 @@ TEST_F(StreamStateTransitionsTest, stopStateFromStreamingOtherNoRecovery) mSubmitServiceCallResultMode = STOP_AT_PUT_STREAM; - EXPECT_EQ(STATUS_SERVICE_CALL_DEVICE_NOT_FOND_ERROR, kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_DEVICE_NOT_FOUND)); + EXPECT_EQ(STATUS_SERVICE_CALL_DEVICE_NOT_FOND_ERROR, + kinesisVideoStreamTerminated(mCallContext.customData, TEST_UPLOAD_HANDLE, SERVICE_CALL_DEVICE_NOT_FOUND)); } #endif \ No newline at end of file diff --git a/tst/client/StreamStoppingFunctionalityTest.cpp b/tst/client/StreamStoppingFunctionalityTest.cpp index b21f801db..baeadca79 100644 --- a/tst/client/StreamStoppingFunctionalityTest.cpp +++ b/tst/client/StreamStoppingFunctionalityTest.cpp @@ -1,15 +1,14 @@ #include "ClientTestFixture.h" -using ::testing::WithParamInterface; using ::testing::Bool; -using ::testing::Values; using ::testing::Combine; +using ::testing::Values; +using ::testing::WithParamInterface; -class StreamStoppingFunctionalityTest : public ClientTestBase, - public WithParamInterface< ::std::tuple >{ - -protected: - void SetUp() { +class StreamStoppingFunctionalityTest : public ClientTestBase, public WithParamInterface< ::std::tuple > { + protected: + void SetUp() + { ClientTestBase::SetUp(); STREAMING_TYPE streamingType; @@ -44,13 +43,13 @@ TEST_P(StreamStoppingFunctionalityTest, CreateSyncResetConnectionSuccess) #ifdef ALIGNED_MEMORY_MODEL -TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamWithTwoUploadHandlesStopSyncFreeSuccess) { - +TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamWithTwoUploadHandlesStopSyncFreeSuccess) +{ UINT64 currentTime, testTerminationTime; BOOL didPutFrame, gotStreamData, submittedAck; UINT32 tokenRotateCount = 0; std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; CreateScenarioTestClient(); @@ -58,8 +57,8 @@ TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamWithTwoUploadHandlesStop CreateStreamSync(); - testTerminationTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) - + 2 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 15 * HUNDREDS_OF_NANOS_IN_A_SECOND; + testTerminationTime = + mClientCallbacks.getCurrentTimeFn((UINT64) this) + 2 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 15 * HUNDREDS_OF_NANOS_IN_A_SECOND; MockProducer mockProducer(mMockProducerConfig, mStreamHandle); @@ -72,7 +71,7 @@ TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamWithTwoUploadHandlesStop for (int i = 0; i < currentUploadHandles.size(); i++) { UPLOAD_HANDLE uploadHandle = currentUploadHandles[i]; mockConsumer = mStreamingSession.getConsumer(uploadHandle); - //GetStreamedData and SubmitAck + // GetStreamedData and SubmitAck STATUS retStatus = mockConsumer->timedGetStreamData(currentTime, &gotStreamData); EXPECT_EQ(STATUS_SUCCESS, mockConsumer->timedSubmitNormalAck(currentTime, &submittedAck)); VerifyGetStreamDataResult(retStatus, gotStreamData, uploadHandle, ¤tTime, &mockConsumer); @@ -88,10 +87,10 @@ TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamWithTwoUploadHandlesStop VerifyStopStreamSyncAndFree(); } - -TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamHighDensityStopSyncTimeoutFreeSuccess) { +TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamHighDensityStopSyncTimeoutFreeSuccess) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; BOOL didPutFrame, gotStreamData, submittedAck; UINT64 currentTime, testTerminationTime; @@ -125,7 +124,7 @@ TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamHighDensityStopSyncTimeo TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamHighDensityStopSyncStreamOutRest) { std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; BOOL didPutFrame, gotStreamData, submittedAck; UINT64 currentTime, streamStopTime; StreamMetrics streamMetrics; @@ -160,7 +159,8 @@ TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamHighDensityStopSyncStrea } while (currentTime < streamStopTime); EXPECT_EQ(STATUS_SUCCESS, getKinesisVideoStreamMetrics(mStreamHandle, &streamMetrics)); - DLOGD("stream metric at stream stop: currentViewSize %llu byte, overallViewSize %llu byte", streamMetrics.currentViewSize, streamMetrics.overallViewSize); + DLOGD("stream metric at stream stop: currentViewSize %llu byte, overallViewSize %llu byte", streamMetrics.currentViewSize, + streamMetrics.overallViewSize); VerifyStopStreamSyncAndFree(); } @@ -168,7 +168,7 @@ TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamHighDensityStopSyncStrea TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamStopSyncFree) { std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; BOOL didPutFrame, gotStreamData, submittedAck; UINT64 currentTime, streamStopTime; @@ -200,7 +200,7 @@ TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamStopSyncFree) TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamStopSyncErrorAckWhileStreamingRemainingBits) { std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; BOOL didPutFrame, gotStreamData, submittedAck, submittedErrorAck = FALSE; UINT64 currentTime, streamStopTime; @@ -211,8 +211,8 @@ TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamStopSyncErrorAckWhileStr CreateStreamSync(); MockProducer mockProducer(mMockProducerConfig, mStreamHandle); - streamStopTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) + 1 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + - 5 * HUNDREDS_OF_NANOS_IN_A_SECOND; + streamStopTime = + mClientCallbacks.getCurrentTimeFn((UINT64) this) + 1 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 5 * HUNDREDS_OF_NANOS_IN_A_SECOND; do { currentTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); EXPECT_EQ(STATUS_SUCCESS, mockProducer.timedPutFrame(currentTime, &didPutFrame)); @@ -238,7 +238,7 @@ TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamStopSyncErrorAckWhileStr } while (!submittedErrorAck); // remaining buffer should be streamed out successfully and stream closed callback called. - consumeStream((STREAM_CLOSED_TIMEOUT_DURATION_IN_SECONDS) * HUNDREDS_OF_NANOS_IN_A_SECOND); + consumeStream((STREAM_CLOSED_TIMEOUT_DURATION_IN_SECONDS) *HUNDREDS_OF_NANOS_IN_A_SECOND); EXPECT_TRUE(mStreamingSession.mConsumerList.empty()); EXPECT_EQ(TRUE, ATOMIC_LOAD_BOOL(&mStreamClosed)); EXPECT_EQ(STATUS_SUCCESS, freeKinesisVideoStream(&mStreamHandle)); @@ -248,4 +248,5 @@ TEST_P(StreamStoppingFunctionalityTest, CreateSyncStreamStopSyncErrorAckWhileStr #endif INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, StreamStoppingFunctionalityTest, - Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); + Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), + Values(0, TEST_REPLAY_DURATION))); diff --git a/tst/client/StreamTokenRotationTest.cpp b/tst/client/StreamTokenRotationTest.cpp index 5cd1a773e..a71581af3 100644 --- a/tst/client/StreamTokenRotationTest.cpp +++ b/tst/client/StreamTokenRotationTest.cpp @@ -1,7 +1,6 @@ #include "ClientTestFixture.h" -class StreamTokenRotationTest : public ClientTestBase { -}; +class StreamTokenRotationTest : public ClientTestBase {}; UINT64 gPresetTimeValue = 0; UINT32 gPutStreamFuncCount = 0; @@ -17,14 +16,8 @@ UINT64 getCurrentTimePreset(UINT64 customData) return gPresetTimeValue; } -STATUS testPutStream(UINT64 customData, - PCHAR streamName, - PCHAR containerType, - UINT64 streamStartTime, - BOOL absoluteFragmentTimestamp, - BOOL ackRequired, - PCHAR streamingEndpoint, - PServiceCallContext pCallbackContext) +STATUS testPutStream(UINT64 customData, PCHAR streamName, PCHAR containerType, UINT64 streamStartTime, BOOL absoluteFragmentTimestamp, + BOOL ackRequired, PCHAR streamingEndpoint, PServiceCallContext pCallbackContext) { UNUSED_PARAM(customData); UNUSED_PARAM(streamName); @@ -98,12 +91,15 @@ TEST_F(StreamTokenRotationTest, basicTokenRotationNonPersistAwait) EXPECT_EQ(STATUS_SUCCESS, describeStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, &mStreamDescription)); EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); - EXPECT_EQ(STATUS_INVALID_TOKEN_EXPIRATION, getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) gStreamingToken, SIZEOF(gStreamingToken), MIN_STREAMING_TOKEN_EXPIRATION_DURATION - 1)); - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) gStreamingToken, SIZEOF(gStreamingToken), MIN_STREAMING_TOKEN_EXPIRATION_DURATION)); + EXPECT_EQ(STATUS_INVALID_TOKEN_EXPIRATION, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) gStreamingToken, SIZEOF(gStreamingToken), + MIN_STREAMING_TOKEN_EXPIRATION_DURATION - 1)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) gStreamingToken, SIZEOF(gStreamingToken), + MIN_STREAMING_TOKEN_EXPIRATION_DURATION)); // Produce and consume the buffer for (i = 0, timestamp = 0; timestamp <= runDuration; timestamp += TEST_LONG_FRAME_DURATION, i++) { - frame.index = i; frame.decodingTs = timestamp; frame.presentationTs = timestamp; @@ -120,22 +116,19 @@ TEST_F(StreamTokenRotationTest, basicTokenRotationNonPersistAwait) EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFrame(streamHandle, &frame)); // Check for rotation - if (timestamp > (UINT64)(rotation * MIN_STREAMING_TOKEN_EXPIRATION_DURATION - STREAMING_TOKEN_EXPIRATION_GRACE_PERIOD + TEST_LONG_FRAME_DURATION)) { + if (timestamp > + (UINT64) (rotation * MIN_STREAMING_TOKEN_EXPIRATION_DURATION - STREAMING_TOKEN_EXPIRATION_GRACE_PERIOD + TEST_LONG_FRAME_DURATION)) { EXPECT_EQ(rotation + 1, ATOMIC_LOAD(&mGetStreamingEndpointFuncCount)); EXPECT_EQ(rotation, ATOMIC_LOAD(&mGetStreamingTokenFuncCount)); EXPECT_EQ(rotation, gPutStreamFuncCount); - EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - TEST_STREAMING_ENDPOINT)); + EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); EXPECT_EQ(rotation + 1, ATOMIC_LOAD(&mGetStreamingEndpointFuncCount)); EXPECT_EQ(rotation + 1, ATOMIC_LOAD(&mGetStreamingTokenFuncCount)); EXPECT_EQ(rotation, gPutStreamFuncCount); - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) gStreamingToken, - SIZEOF(gStreamingToken), - (rotation + 1) * MIN_STREAMING_TOKEN_EXPIRATION_DURATION)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) gStreamingToken, SIZEOF(gStreamingToken), + (rotation + 1) * MIN_STREAMING_TOKEN_EXPIRATION_DURATION)); // Validate the put stream count EXPECT_EQ(rotation + 1, gPutStreamFuncCount); @@ -154,11 +147,8 @@ TEST_F(StreamTokenRotationTest, basicTokenRotationNonPersistAwait) if (i != 0 && (i % 10 == 0)) { iterate = TRUE; while (iterate) { - status = getKinesisVideoStreamData(streamHandle, uploadHandle, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize); - EXPECT_TRUE(status == STATUS_SUCCESS || - status == STATUS_END_OF_STREAM || - status == STATUS_NO_MORE_DATA_AVAILABLE); + status = getKinesisVideoStreamData(streamHandle, uploadHandle, getDataBuffer, SIZEOF(getDataBuffer), &filledSize); + EXPECT_TRUE(status == STATUS_SUCCESS || status == STATUS_END_OF_STREAM || status == STATUS_NO_MORE_DATA_AVAILABLE); switch (status) { case STATUS_SUCCESS: break; @@ -175,10 +165,9 @@ TEST_F(StreamTokenRotationTest, basicTokenRotationNonPersistAwait) } } - EXPECT_EQ(0, ATOMIC_LOAD(&mStreamErrorReportFuncCount)); EXPECT_EQ(STATUS_SUCCESS, mStatus); - EXPECT_TRUE(uploadHandle > TEST_UPLOAD_HANDLE); //upload handle rotated at least once. + EXPECT_TRUE(uploadHandle > TEST_UPLOAD_HANDLE); // upload handle rotated at least once. if (IS_VALID_CLIENT_HANDLE(clientHandle)) { freeKinesisVideoClient(&clientHandle); @@ -254,12 +243,15 @@ TEST_F(StreamTokenRotationTest, rotationWithAwaitingCheck) EXPECT_EQ(STATUS_SUCCESS, describeStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, &mStreamDescription)); EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); - EXPECT_EQ(STATUS_INVALID_TOKEN_EXPIRATION, getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) gStreamingToken, SIZEOF(gStreamingToken), MIN_STREAMING_TOKEN_EXPIRATION_DURATION - 1)); - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) gStreamingToken, SIZEOF(gStreamingToken), MIN_STREAMING_TOKEN_EXPIRATION_DURATION)); + EXPECT_EQ(STATUS_INVALID_TOKEN_EXPIRATION, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) gStreamingToken, SIZEOF(gStreamingToken), + MIN_STREAMING_TOKEN_EXPIRATION_DURATION - 1)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) gStreamingToken, SIZEOF(gStreamingToken), + MIN_STREAMING_TOKEN_EXPIRATION_DURATION)); // Produce and consume the buffer for (i = 0, timestamp = 0; timestamp <= runDuration; timestamp += TEST_LONG_FRAME_DURATION, i++) { - frame.index = i; frame.decodingTs = timestamp; frame.presentationTs = timestamp; @@ -276,22 +268,19 @@ TEST_F(StreamTokenRotationTest, rotationWithAwaitingCheck) EXPECT_EQ(STATUS_SUCCESS, putKinesisVideoFrame(streamHandle, &frame)); // Check for rotation - if ((INT64) timestamp > rotation * MIN_STREAMING_TOKEN_EXPIRATION_DURATION - STREAMING_TOKEN_EXPIRATION_GRACE_PERIOD + TEST_LONG_FRAME_DURATION) { + if ((INT64) timestamp > + rotation * MIN_STREAMING_TOKEN_EXPIRATION_DURATION - STREAMING_TOKEN_EXPIRATION_GRACE_PERIOD + TEST_LONG_FRAME_DURATION) { EXPECT_EQ(rotation + 1, ATOMIC_LOAD(&mGetStreamingEndpointFuncCount)); EXPECT_EQ(rotation, ATOMIC_LOAD(&mGetStreamingTokenFuncCount)); EXPECT_EQ(rotation, gPutStreamFuncCount); - EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - TEST_STREAMING_ENDPOINT)); + EXPECT_EQ(STATUS_SUCCESS, getStreamingEndpointResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, TEST_STREAMING_ENDPOINT)); EXPECT_EQ(rotation + 1, ATOMIC_LOAD(&mGetStreamingEndpointFuncCount)); EXPECT_EQ(rotation + 1, ATOMIC_LOAD(&mGetStreamingTokenFuncCount)); EXPECT_EQ(rotation, gPutStreamFuncCount); - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) gStreamingToken, - SIZEOF(gStreamingToken), - (rotation + 1) * MIN_STREAMING_TOKEN_EXPIRATION_DURATION)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) gStreamingToken, SIZEOF(gStreamingToken), + (rotation + 1) * MIN_STREAMING_TOKEN_EXPIRATION_DURATION)); // Validate the put stream count EXPECT_EQ(rotation + 1, gPutStreamFuncCount); @@ -311,11 +300,8 @@ TEST_F(StreamTokenRotationTest, rotationWithAwaitingCheck) if (i != 0 && (i % 10 == 0)) { iterate = TRUE; while (iterate) { - status = getKinesisVideoStreamData(streamHandle, uploadHandle, getDataBuffer, SIZEOF(getDataBuffer), - &filledSize); - EXPECT_TRUE(status == STATUS_SUCCESS || - status == STATUS_END_OF_STREAM || - status == STATUS_NO_MORE_DATA_AVAILABLE || + status = getKinesisVideoStreamData(streamHandle, uploadHandle, getDataBuffer, SIZEOF(getDataBuffer), &filledSize); + EXPECT_TRUE(status == STATUS_SUCCESS || status == STATUS_END_OF_STREAM || status == STATUS_NO_MORE_DATA_AVAILABLE || status == STATUS_AWAITING_PERSISTED_ACK); switch (status) { case STATUS_SUCCESS: @@ -330,8 +316,7 @@ TEST_F(StreamTokenRotationTest, rotationWithAwaitingCheck) // The last bits should be EOS tag. // We can check the EOS tag by checking the value part of the // tag which should be empty - EXPECT_EQ(0, MEMCMP(emptyTagValue, getDataBuffer + filledSize - gMkvTagStringBitsSize, - gMkvTagStringBitsSize)); + EXPECT_EQ(0, MEMCMP(emptyTagValue, getDataBuffer + filledSize - gMkvTagStringBitsSize, gMkvTagStringBitsSize)); // Send the ACK pUploadHandleInfo = getStreamUploadInfo(FROM_STREAM_HANDLE(streamHandle), uploadHandle); @@ -346,7 +331,7 @@ TEST_F(StreamTokenRotationTest, rotationWithAwaitingCheck) } EXPECT_EQ(0, ATOMIC_LOAD(&mStreamErrorReportFuncCount)); - EXPECT_TRUE(uploadHandle > TEST_UPLOAD_HANDLE); //upload handle rotated at least once. + EXPECT_TRUE(uploadHandle > TEST_UPLOAD_HANDLE); // upload handle rotated at least once. if (IS_VALID_CLIENT_HANDLE(clientHandle)) { freeKinesisVideoClient(&clientHandle); diff --git a/tst/client/StreamingSession.cpp b/tst/client/StreamingSession.cpp index 6cd04631e..6141f47f8 100644 --- a/tst/client/StreamingSession.cpp +++ b/tst/client/StreamingSession.cpp @@ -1,36 +1,37 @@ #include "ClientTestFixture.h" -UPLOAD_HANDLE StreamingSession::addNewConsumerSession(MockConsumerConfig consumerConfig, - STREAM_HANDLE mStreamHandle, - UPLOAD_HANDLE uploadHandleOverride) { +UPLOAD_HANDLE StreamingSession::addNewConsumerSession(MockConsumerConfig consumerConfig, STREAM_HANDLE mStreamHandle, + UPLOAD_HANDLE uploadHandleOverride) +{ if (IS_VALID_UPLOAD_HANDLE(uploadHandleOverride)) { mUploadHandleCounter = uploadHandleOverride; } UPLOAD_HANDLE currentHandle = mUploadHandleCounter; - MockConsumer *mockConsumer = new MockConsumer(consumerConfig, - (UPLOAD_HANDLE) currentHandle, - mStreamHandle); + MockConsumer* mockConsumer = new MockConsumer(consumerConfig, (UPLOAD_HANDLE) currentHandle, mStreamHandle); mConsumerList[currentHandle] = mockConsumer; mUploadHandleCounter++; return currentHandle; } -void StreamingSession::removeConsumerSession(UPLOAD_HANDLE uploadHandle) { +void StreamingSession::removeConsumerSession(UPLOAD_HANDLE uploadHandle) +{ if (mConsumerList.count(uploadHandle) != 0) { delete mConsumerList[uploadHandle]; mConsumerList.erase(uploadHandle); } } -void StreamingSession::clearSessions() { - for(std::map::iterator it = mConsumerList.begin(); it != mConsumerList.end(); it++) { +void StreamingSession::clearSessions() +{ + for (std::map::iterator it = mConsumerList.begin(); it != mConsumerList.end(); it++) { delete it->second; } mConsumerList.clear(); mUploadHandleCounter = 0; } -void StreamingSession::signalDataAvailable(UPLOAD_HANDLE uploadHandle) { +void StreamingSession::signalDataAvailable(UPLOAD_HANDLE uploadHandle) +{ if (mConsumerList.count(uploadHandle) != 0) { mConsumerList[uploadHandle]->dataAvailable(); } @@ -40,7 +41,8 @@ void StreamingSession::signalDataAvailable(UPLOAD_HANDLE uploadHandle) { * Fills a vector with active upload handles. If any upload handles' connection was closed due to error, * they will be removed and wont be returned. */ -void StreamingSession::getActiveUploadHandles(std::vector &activeUploadHandles) { +void StreamingSession::getActiveUploadHandles(std::vector& activeUploadHandles) +{ activeUploadHandles.clear(); UINT64 lastTransferDataTime = INVALID_TIMESTAMP_VALUE; std::map::iterator it = mConsumerList.begin(); @@ -54,8 +56,7 @@ void StreamingSession::getActiveUploadHandles(std::vector &active // The loop steps from oldest upload handle to the latest. The timestamp when upload handle // last received data should be monotonically increasing between upload handles. - if (IS_VALID_TIMESTAMP(lastTransferDataTime) && - IS_VALID_TIMESTAMP(curr->second->mLastGetStreamDataTime)) { + if (IS_VALID_TIMESTAMP(lastTransferDataTime) && IS_VALID_TIMESTAMP(curr->second->mLastGetStreamDataTime)) { EXPECT_TRUE(lastTransferDataTime < curr->second->mLastGetStreamDataTime); } @@ -64,8 +65,9 @@ void StreamingSession::getActiveUploadHandles(std::vector &active } } -MockConsumer *StreamingSession::getConsumer(UPLOAD_HANDLE uploadHandle) { - MockConsumer *mockConsumer = NULL; +MockConsumer* StreamingSession::getConsumer(UPLOAD_HANDLE uploadHandle) +{ + MockConsumer* mockConsumer = NULL; if (mConsumerList.count(uploadHandle) != 0) { mockConsumer = mConsumerList[uploadHandle]; } diff --git a/tst/client/TokenRotationFunctionalityTest.cpp b/tst/client/TokenRotationFunctionalityTest.cpp index f801e2307..8de78191f 100644 --- a/tst/client/TokenRotationFunctionalityTest.cpp +++ b/tst/client/TokenRotationFunctionalityTest.cpp @@ -1,15 +1,14 @@ #include "ClientTestFixture.h" -using ::testing::WithParamInterface; using ::testing::Bool; -using ::testing::Values; using ::testing::Combine; +using ::testing::Values; +using ::testing::WithParamInterface; -class TokenRotationFunctionalityTest : public ClientTestBase, - public WithParamInterface< ::std::tuple >{ - -protected: - void SetUp() { +class TokenRotationFunctionalityTest : public ClientTestBase, public WithParamInterface< ::std::tuple > { + protected: + void SetUp() + { ClientTestBase::SetUp(); STREAMING_TYPE streamingType; @@ -24,15 +23,14 @@ class TokenRotationFunctionalityTest : public ClientTestBase, }; #ifdef ALIGNED_MEMORY_MODEL -TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamWithResultEventAfterGracePeriodStopFreeSuccess) { - - UINT64 currentTime, testTerminationTime, startTestTime, stopPutFrameTime, - putStreamEventResultTime = INVALID_TIMESTAMP_VALUE; +TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamWithResultEventAfterGracePeriodStopFreeSuccess) +{ + UINT64 currentTime, testTerminationTime, startTestTime, stopPutFrameTime, putStreamEventResultTime = INVALID_TIMESTAMP_VALUE; BOOL didPutFrame, gotStreamData, submittedAck; UINT32 tokenRotateCount = 0; std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; STATUS retStatus; @@ -46,24 +44,21 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamWithResultEventAfterGrace mSubmitServiceCallResultMode = STOP_AT_GET_STREAMING_TOKEN; - UPLOAD_HANDLE localUploadHandle = mStreamingSession.addNewConsumerSession(mMockConsumerConfig, - mStreamHandle); - EXPECT_EQ(STATUS_SUCCESS, - putStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, localUploadHandle)); + UPLOAD_HANDLE localUploadHandle = mStreamingSession.addNewConsumerSession(mMockConsumerConfig, mStreamHandle); + EXPECT_EQ(STATUS_SUCCESS, putStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, localUploadHandle)); currentputStreamFuncCount = ATOMIC_LOAD(&mPutStreamFuncCount); MockProducer mockProducer(mMockProducerConfig, mStreamHandle); - testTerminationTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) - + 1 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 10 * HUNDREDS_OF_NANOS_IN_A_SECOND; + testTerminationTime = + mClientCallbacks.getCurrentTimeFn((UINT64) this) + 1 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 10 * HUNDREDS_OF_NANOS_IN_A_SECOND; startTestTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); stopPutFrameTime = startTestTime + MIN_STREAMING_TOKEN_EXPIRATION_DURATION; do { - currentTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); if (currentTime < stopPutFrameTime) { @@ -71,21 +66,15 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamWithResultEventAfterGrace } if (ATOMIC_LOAD(&mPutStreamFuncCount) > currentputStreamFuncCount) { - - putStreamEventResultTime = - currentTime + (STREAMING_TOKEN_EXPIRATION_GRACE_PERIOD - 1 * HUNDREDS_OF_NANOS_IN_A_SECOND); + putStreamEventResultTime = currentTime + (STREAMING_TOKEN_EXPIRATION_GRACE_PERIOD - 1 * HUNDREDS_OF_NANOS_IN_A_SECOND); currentputStreamFuncCount++; } if (IS_VALID_TIMESTAMP(putStreamEventResultTime) && currentTime >= putStreamEventResultTime) { - - UPLOAD_HANDLE localUploadHandle = mStreamingSession.addNewConsumerSession(mMockConsumerConfig, - mStreamHandle); - EXPECT_EQ(STATUS_SUCCESS, - putStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, localUploadHandle)); + UPLOAD_HANDLE localUploadHandle = mStreamingSession.addNewConsumerSession(mMockConsumerConfig, mStreamHandle); + EXPECT_EQ(STATUS_SUCCESS, putStreamResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, localUploadHandle)); putStreamEventResultTime = INVALID_TIMESTAMP_VALUE; - } mStreamingSession.getActiveUploadHandles(currentUploadHandles); @@ -95,8 +84,7 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamWithResultEventAfterGrace mockConsumer = mStreamingSession.getConsumer(uploadHandle); retStatus = mockConsumer->timedGetStreamData(currentTime, &gotStreamData); - EXPECT_EQ(STATUS_SUCCESS, - mockConsumer->timedSubmitNormalAck(currentTime, &submittedAck)); + EXPECT_EQ(STATUS_SUCCESS, mockConsumer->timedSubmitNormalAck(currentTime, &submittedAck)); VerifyGetStreamDataResult(retStatus, gotStreamData, uploadHandle, ¤tTime, &mockConsumer); if (retStatus == STATUS_END_OF_STREAM) { tokenRotateCount++; @@ -110,12 +98,13 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamWithResultEventAfterGrace VerifyStopStreamSyncAndFree(); } -TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamWithLargeBufferMultipleSessionsStopSyncFreeSuccess) { +TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamWithLargeBufferMultipleSessionsStopSyncFreeSuccess) +{ UINT64 currentTime, testTerminationTime, startTestTime, endPutFrameTime; BOOL didPutFrame, gotStreamData, submittedAck; UINT32 tokenRotateCount = 0; std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; STATUS retStatus; startTestTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); @@ -132,8 +121,8 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamWithLargeBufferMultipleSe endPutFrameTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) + 5 * HUNDREDS_OF_NANOS_IN_A_SECOND; - testTerminationTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) - + 1 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 5 * HUNDREDS_OF_NANOS_IN_A_SECOND; + testTerminationTime = + mClientCallbacks.getCurrentTimeFn((UINT64) this) + 1 * MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 5 * HUNDREDS_OF_NANOS_IN_A_SECOND; do { currentTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); @@ -143,7 +132,6 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamWithLargeBufferMultipleSe } while (currentTime < endPutFrameTime); do { - currentTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); mStreamingSession.getActiveUploadHandles(currentUploadHandles); @@ -151,10 +139,8 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamWithLargeBufferMultipleSe for (int i = 0; i < currentUploadHandles.size(); i++) { UPLOAD_HANDLE uploadHandle = currentUploadHandles[i]; - if (currentTime > - (startTestTime + MIN_STREAMING_TOKEN_EXPIRATION_DURATION - - STREAMING_TOKEN_EXPIRATION_GRACE_PERIOD) && - currentTime < (startTestTime + MIN_STREAMING_TOKEN_EXPIRATION_DURATION)) { + if (currentTime > (startTestTime + MIN_STREAMING_TOKEN_EXPIRATION_DURATION - STREAMING_TOKEN_EXPIRATION_GRACE_PERIOD) && + currentTime < (startTestTime + MIN_STREAMING_TOKEN_EXPIRATION_DURATION)) { DLOGV("Within Token expiration grace period"); } @@ -175,9 +161,10 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamWithLargeBufferMultipleSe VerifyStopStreamSyncAndFree(); } -TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamForMultipleRotationsStopSyncFreeSuccess) { +TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamForMultipleRotationsStopSyncFreeSuccess) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; BOOL didPutFrame, gotStreamData, submittedAck; UINT64 currentTime, testTerminationTime; @@ -206,9 +193,10 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamForMultipleRotationsStopS VerifyStopStreamSyncAndFree(); } -TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamNewPutStreamResultComesFastButExistingSessionFailsRollsbackRestartsStopSyncFreeSuccess) { +TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamNewPutStreamResultComesFastButExistingSessionFailsRollsbackRestartsStopSyncFreeSuccess) +{ std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; BOOL didPutFrame, gotStreamData, submittedAck; UINT64 currentTime, testTerminationTime; UINT64 newUploadHandle = 2; @@ -229,8 +217,7 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamNewPutStreamResultComesFa EXPECT_EQ(STATUS_SUCCESS, mockProducer.timedPutFrame(currentTime, &didPutFrame)); if (!eventReplied[ATOMIC_LOAD(&mPutStreamFuncCount)]) { - UPLOAD_HANDLE localUploadHandle = mStreamingSession.addNewConsumerSession(mMockConsumerConfig, - mStreamHandle); + UPLOAD_HANDLE localUploadHandle = mStreamingSession.addNewConsumerSession(mMockConsumerConfig, mStreamHandle); UINT32 putStreamFuncCount = ATOMIC_LOAD(&mPutStreamFuncCount); switch (putStreamFuncCount) { case 1: @@ -255,8 +242,7 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamNewPutStreamResultComesFa } else { mockConsumer = mStreamingSession.getConsumer(uploadHandle); STATUS retStatus = mockConsumer->timedGetStreamData(currentTime, &gotStreamData); - EXPECT_EQ(STATUS_SUCCESS, - mockConsumer->submitErrorAck(SERVICE_CALL_RESULT_ACK_INTERNAL_ERROR, &submittedAck)); + EXPECT_EQ(STATUS_SUCCESS, mockConsumer->submitErrorAck(SERVICE_CALL_RESULT_ACK_INTERNAL_ERROR, &submittedAck)); VerifyGetStreamDataResult(retStatus, gotStreamData, uploadHandle, ¤tTime, &mockConsumer); } } @@ -265,11 +251,11 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamNewPutStreamResultComesFa VerifyStopStreamSyncAndFree(); } -//CreateSync, Stream, at token rotation, getStreamingTokenResultEvent takes long time to return (after previous handle has hit eos.) +// CreateSync, Stream, at token rotation, getStreamingTokenResultEvent takes long time to return (after previous handle has hit eos.) TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamAtTokenRotationLongDelayForGetStreamingTokenResult) { std::vector currentUploadHandles; - MockConsumer *mockConsumer; + MockConsumer* mockConsumer; BOOL didPutFrame, gotStreamData, submittedAck, gotStatusAwaitingAck = FALSE; UINT64 currentTime, streamStopTime; @@ -279,8 +265,7 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamAtTokenRotationLongDelayF CreateStreamSync(); MockProducer mockProducer(mMockProducerConfig, mStreamHandle); - streamStopTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) + - MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 5 * HUNDREDS_OF_NANOS_IN_A_SECOND; + streamStopTime = mClientCallbacks.getCurrentTimeFn((UINT64) this) + MIN_STREAMING_TOKEN_EXPIRATION_DURATION + 5 * HUNDREDS_OF_NANOS_IN_A_SECOND; do { currentTime = mClientCallbacks.getCurrentTimeFn((UINT64) this); @@ -306,12 +291,10 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamAtTokenRotationLongDelayF // enable pic event chaining. mSubmitServiceCallResultMode = STOP_AT_PUT_STREAM; - EXPECT_EQ(STATUS_SUCCESS, getStreamingTokenResultEvent(mCallContext.customData, - SERVICE_CALL_RESULT_OK, - (PBYTE) TEST_STREAMING_TOKEN, - SIZEOF(TEST_STREAMING_TOKEN), - currentTime + HUNDREDS_OF_NANOS_IN_A_SECOND + - MIN_STREAMING_TOKEN_EXPIRATION_DURATION)); + EXPECT_EQ(STATUS_SUCCESS, + getStreamingTokenResultEvent(mCallContext.customData, SERVICE_CALL_RESULT_OK, (PBYTE) TEST_STREAMING_TOKEN, + SIZEOF(TEST_STREAMING_TOKEN), + currentTime + HUNDREDS_OF_NANOS_IN_A_SECOND + MIN_STREAMING_TOKEN_EXPIRATION_DURATION)); mockProducer.putFrame(); // put a frame to trigger putStreamResult // should stream out remaining buffer successfully. @@ -319,5 +302,6 @@ TEST_P(TokenRotationFunctionalityTest, CreateSyncStreamAtTokenRotationLongDelayF } INSTANTIATE_TEST_SUITE_P(PermutatedStreamInfo, TokenRotationFunctionalityTest, - Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), Values(0, TEST_REPLAY_DURATION))); + Combine(Values(STREAMING_TYPE_REALTIME, STREAMING_TYPE_OFFLINE), Values(0, 10 * HUNDREDS_OF_NANOS_IN_AN_HOUR), Bool(), + Values(0, TEST_REPLAY_DURATION))); #endif \ No newline at end of file diff --git a/tst/duration/DurationTest.cpp b/tst/duration/DurationTest.cpp index d8b6a6c16..9e80105b8 100644 --- a/tst/duration/DurationTest.cpp +++ b/tst/duration/DurationTest.cpp @@ -1,71 +1,83 @@ #include #include "src/duration/src/Duration.h" -TEST(InvalidInput, NullInput) { +TEST(InvalidInput, NullInput) +{ EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(NULL, NULL)); } -TEST(InvalidInput, EmptyInput) { +TEST(InvalidInput, EmptyInput) +{ PCHAR emptyStr = (PCHAR) ""; EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(emptyStr, NULL)); EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(emptyStr, emptyStr)); } -TEST(InvalidInput, NonPeriodInput) { +TEST(InvalidInput, NonPeriodInput) +{ PCHAR nonPeriodStr = (PCHAR) "23DT23H"; EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(nonPeriodStr, NULL)); EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(nonPeriodStr, nonPeriodStr + STRLEN(nonPeriodStr))); } -TEST(InvalidInput, TwoTimeInput) { +TEST(InvalidInput, TwoTimeInput) +{ PCHAR twoTimeStr = (PCHAR) "P23DT23HT23H"; EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(twoTimeStr, NULL)); EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(twoTimeStr, twoTimeStr + STRLEN(twoTimeStr))); } -TEST(InvalidInput, InvalidCharInput) { +TEST(InvalidInput, InvalidCharInput) +{ PCHAR invalidCharStr = (PCHAR) "P23DT23HX"; EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(invalidCharStr, NULL)); EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(invalidCharStr, invalidCharStr + STRLEN(invalidCharStr))); } -TEST(InvalidInput, TwoYearInput) { +TEST(InvalidInput, TwoYearInput) +{ PCHAR twoYearStr = (PCHAR) "P1Y23DT23H1Y"; EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(twoYearStr, NULL)); EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(twoYearStr, twoYearStr + STRLEN(twoYearStr))); } -TEST(InvalidInput, TwoDayInput) { +TEST(InvalidInput, TwoDayInput) +{ PCHAR twoDayStr = (PCHAR) "P1Y23DT23H2D"; EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(twoDayStr, NULL)); EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(twoDayStr, twoDayStr + STRLEN(twoDayStr))); } -TEST(InvalidInput, InvalidFractionInput1) { +TEST(InvalidInput, InvalidFractionInput1) +{ PCHAR invalidFractionStr = (PCHAR) "P1Y23.5.5DT23H"; EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(invalidFractionStr, NULL)); EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(invalidFractionStr, invalidFractionStr + STRLEN(invalidFractionStr))); } -TEST(InvalidInput, InvalidFractionInput2) { +TEST(InvalidInput, InvalidFractionInput2) +{ PCHAR invalidFractionStr = (PCHAR) "P1Y34.SDT23H"; EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(invalidFractionStr, NULL)); EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(invalidFractionStr, invalidFractionStr + STRLEN(invalidFractionStr))); } -TEST(InvalidInput, EarlyEndInput) { +TEST(InvalidInput, EarlyEndInput) +{ PCHAR earlyEndStr = (PCHAR) "P1Y23.5DT23"; EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(earlyEndStr, NULL)); EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(earlyEndStr, earlyEndStr + STRLEN(earlyEndStr))); } -TEST(InvalidInput, OverflowInput) { +TEST(InvalidInput, OverflowInput) +{ PCHAR overflowStr = (PCHAR) "P355000Y"; EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(overflowStr, NULL)); EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(overflowStr, overflowStr + STRLEN(overflowStr))); } -TEST(InvalidInput, SmallCaseInput) { +TEST(InvalidInput, SmallCaseInput) +{ PCHAR smallCaseInput = (PCHAR) "pT23.5H3M"; EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(smallCaseInput, NULL)); EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(smallCaseInput, smallCaseInput + STRLEN(smallCaseInput))); @@ -77,7 +89,8 @@ TEST(InvalidInput, SmallCaseInput) { EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(smallCaseInput, smallCaseInput + STRLEN(smallCaseInput))); } -TEST(InvalidInput, InputWithInvalidChar) { +TEST(InvalidInput, InputWithInvalidChar) +{ PCHAR inputWithSpace = (PCHAR) "PT23.5 H3M"; EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(inputWithSpace, NULL)); EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(inputWithSpace, inputWithSpace + STRLEN(inputWithSpace))); @@ -89,51 +102,58 @@ TEST(InvalidInput, InputWithInvalidChar) { EXPECT_EQ(INVALID_DURATION_VALUE, parseDuration(inputWithSpace, inputWithSpace + STRLEN(inputWithSpace))); } -TEST(ValidInput, CompleteInput) { +TEST(ValidInput, CompleteInput) +{ PCHAR completeStr = (PCHAR) "P1.2Y2.6M3.5W23.5DT23.2H12.5M6.7S"; - unsigned long long expectedValue = (unsigned long long)(((1.2 * 365 + 2.6 * 31 + 3.5 * 7 + 23.5 ) * 24 * 3600 - + 23.2 * 3600 + 12.5 * 60 + 6.7) * 10000000); + unsigned long long expectedValue = + (unsigned long long) (((1.2 * 365 + 2.6 * 31 + 3.5 * 7 + 23.5) * 24 * 3600 + 23.2 * 3600 + 12.5 * 60 + 6.7) * 10000000); EXPECT_EQ(expectedValue, parseDuration(completeStr, NULL)); EXPECT_EQ(expectedValue, parseDuration(completeStr, completeStr + STRLEN(completeStr))); } -TEST(ValidInput, InputWithZeros) { +TEST(ValidInput, InputWithZeros) +{ PCHAR withZerosStr = (PCHAR) "P1Y0M0.0W23DT23H"; - unsigned long long expectedValue = (unsigned long long)(((1.0 * 365 + 23) * 24 * 3600 + 23 * 3600) * 10000000); + unsigned long long expectedValue = (unsigned long long) (((1.0 * 365 + 23) * 24 * 3600 + 23 * 3600) * 10000000); EXPECT_EQ(expectedValue, parseDuration(withZerosStr, NULL)); EXPECT_EQ(expectedValue, parseDuration(withZerosStr, withZerosStr + STRLEN(withZerosStr))); } -TEST(ValidInput, InputWithoutTime) { +TEST(ValidInput, InputWithoutTime) +{ PCHAR withoutTimeStr = (PCHAR) "P1Y23D"; - unsigned long long expectedValue = (unsigned long long)(((1.0 * 365 + 23) * 24 * 3600) * 10000000); + unsigned long long expectedValue = (unsigned long long) (((1.0 * 365 + 23) * 24 * 3600) * 10000000); EXPECT_EQ(expectedValue, parseDuration(withoutTimeStr, NULL)); EXPECT_EQ(expectedValue, parseDuration(withoutTimeStr, withoutTimeStr + STRLEN(withoutTimeStr))); } -TEST(ValidInput, TimeOnlyInput) { +TEST(ValidInput, TimeOnlyInput) +{ PCHAR timeOnlyStr = (PCHAR) "PT23.5H3M"; - unsigned long long expectedValue = (unsigned long long)((23.5 * 3600 + 3 * 60) * 10000000); + unsigned long long expectedValue = (unsigned long long) ((23.5 * 3600 + 3 * 60) * 10000000); EXPECT_EQ(expectedValue, parseDuration(timeOnlyStr, NULL)); EXPECT_EQ(expectedValue, parseDuration(timeOnlyStr, timeOnlyStr + STRLEN(timeOnlyStr))); } -TEST(ValidInput, LargeIntegerInput) { +TEST(ValidInput, LargeIntegerInput) +{ PCHAR largeIntegerStr = (PCHAR) "P35500Y"; unsigned long long expectedValue = (unsigned long long) 35500 * 365 * 24 * 3600 * 10000000; EXPECT_EQ(expectedValue, parseDuration(largeIntegerStr, NULL)); EXPECT_EQ(expectedValue, parseDuration(largeIntegerStr, largeIntegerStr + STRLEN(largeIntegerStr))); } -TEST(ValidInput, PreciseFractionalInput) { +TEST(ValidInput, PreciseFractionalInput) +{ PCHAR preciseFractionStr = (PCHAR) "P1.2Y2.6M3.5W23.5DT23.2311H12.567122M6.712343S"; - unsigned long long expectedValue = (unsigned long long)(((1.2 * 365 + 2.6 * 31 + 3.5 * 7 + 23.5 ) * 24 * 3600 - + 23.2311 * 3600 + 12.567122 * 60 + 6.712343) * 10000000); + unsigned long long expectedValue = + (unsigned long long) (((1.2 * 365 + 2.6 * 31 + 3.5 * 7 + 23.5) * 24 * 3600 + 23.2311 * 3600 + 12.567122 * 60 + 6.712343) * 10000000); EXPECT_EQ(expectedValue, parseDuration(preciseFractionStr, NULL)); EXPECT_EQ(expectedValue, parseDuration(preciseFractionStr, preciseFractionStr + STRLEN(preciseFractionStr))); } -int main(int argc, char **argv) { +int main(int argc, char** argv) +{ ::testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); } diff --git a/tst/heap/HeapApiFunctionalityTest.cpp b/tst/heap/HeapApiFunctionalityTest.cpp index 7c44afd8b..11c4b33b9 100644 --- a/tst/heap/HeapApiFunctionalityTest.cpp +++ b/tst/heap/HeapApiFunctionalityTest.cpp @@ -1,7 +1,6 @@ #include "HeapTestFixture.h" -class HeapApiFunctionalityTest : public HeapTestBase { -}; +class HeapApiFunctionalityTest : public HeapTestBase {}; VOID zeroHandleArray(PALLOCATION_HANDLE handles, UINT32 count) { @@ -70,7 +69,7 @@ VOID multipleLargeAlloc(PHeap pHeap) handles[i] = handle; } - EXPECT_EQ(STATUS_SUCCESS,heapAlloc(pHeap, size, &handle)); + EXPECT_EQ(STATUS_SUCCESS, heapAlloc(pHeap, size, &handle)); EXPECT_FALSE(IS_VALID_ALLOCATION_HANDLE(handle)); // Free the allocations as in system heap mode we will leak @@ -78,7 +77,7 @@ VOID multipleLargeAlloc(PHeap pHeap) EXPECT_EQ(STATUS_SUCCESS, heapFree(pHeap, handles[i])); } - EXPECT_EQ(STATUS_SUCCESS,heapRelease(pHeap)); + EXPECT_EQ(STATUS_SUCCESS, heapRelease(pHeap)); } VOID minBlockFitAlloc(PHeap pHeap) @@ -433,7 +432,7 @@ TEST_F(HeapApiFunctionalityTest, AivHeapResizeEdgeCases) EXPECT_EQ(STATUS_SUCCESS, heapAlloc(pHeap, size, &handle)); EXPECT_TRUE(IS_VALID_ALLOCATION_HANDLE(handle)); EXPECT_EQ(STATUS_SUCCESS, heapMap(pHeap, handle, &pAlloc, &setSize)); - MEMSET(pAlloc, (BYTE)i, setSize); + MEMSET(pAlloc, (BYTE) i, setSize); EXPECT_EQ(STATUS_SUCCESS, heapUnmap(pHeap, pAlloc)); handles[i] = handle; } @@ -547,7 +546,7 @@ TEST_F(HeapApiFunctionalityTest, AivHeapResizeUpDownBottomUp) EXPECT_EQ(STATUS_SUCCESS, heapAlloc(pHeap, size, &handle)); EXPECT_TRUE(IS_VALID_ALLOCATION_HANDLE(handle)); EXPECT_EQ(STATUS_SUCCESS, heapMap(pHeap, handle, &pAlloc, &setSize)); - MEMSET(pAlloc, (BYTE)i, setSize); + MEMSET(pAlloc, (BYTE) i, setSize); EXPECT_EQ(STATUS_SUCCESS, heapUnmap(pHeap, pAlloc)); handles[i] = handle; } @@ -566,9 +565,9 @@ TEST_F(HeapApiFunctionalityTest, AivHeapResizeUpDownBottomUp) EXPECT_EQ(j, setSize); EXPECT_EQ(STATUS_SUCCESS, heapMap(pHeap, handle, &pAlloc, &setSize)); // Validate that the first, mid and last elements are correct - EXPECT_EQ((BYTE)i, ((PBYTE)pAlloc)[0]); - EXPECT_EQ((BYTE)i, ((PBYTE)pAlloc)[setSize - 1]); - EXPECT_EQ((BYTE)i, ((PBYTE)pAlloc)[(setSize - 1) / 2]); + EXPECT_EQ((BYTE) i, ((PBYTE) pAlloc)[0]); + EXPECT_EQ((BYTE) i, ((PBYTE) pAlloc)[setSize - 1]); + EXPECT_EQ((BYTE) i, ((PBYTE) pAlloc)[(setSize - 1) / 2]); EXPECT_EQ(STATUS_SUCCESS, heapUnmap(pHeap, pAlloc)); } } @@ -617,7 +616,7 @@ TEST_F(HeapApiFunctionalityTest, AivHeapResizeUpDownTopDown) EXPECT_EQ(STATUS_SUCCESS, heapAlloc(pHeap, size, &handle)); EXPECT_TRUE(IS_VALID_ALLOCATION_HANDLE(handle)); EXPECT_EQ(STATUS_SUCCESS, heapMap(pHeap, handle, &pAlloc, &setSize)); - MEMSET(pAlloc, (BYTE)i, setSize); + MEMSET(pAlloc, (BYTE) i, setSize); EXPECT_EQ(STATUS_SUCCESS, heapUnmap(pHeap, pAlloc)); handles[i] = handle; } @@ -636,9 +635,9 @@ TEST_F(HeapApiFunctionalityTest, AivHeapResizeUpDownTopDown) EXPECT_EQ(j, setSize); EXPECT_EQ(STATUS_SUCCESS, heapMap(pHeap, handle, &pAlloc, &setSize)); // Validate that the first, mid and last elements are correct - EXPECT_EQ((BYTE)(NUM_ITERATIONS - 2 - i), ((PBYTE)pAlloc)[0]); - EXPECT_EQ((BYTE)(NUM_ITERATIONS - 2 - i), ((PBYTE)pAlloc)[setSize - 1]); - EXPECT_EQ((BYTE)(NUM_ITERATIONS - 2 - i), ((PBYTE)pAlloc)[(setSize - 1) / 2]); + EXPECT_EQ((BYTE) (NUM_ITERATIONS - 2 - i), ((PBYTE) pAlloc)[0]); + EXPECT_EQ((BYTE) (NUM_ITERATIONS - 2 - i), ((PBYTE) pAlloc)[setSize - 1]); + EXPECT_EQ((BYTE) (NUM_ITERATIONS - 2 - i), ((PBYTE) pAlloc)[(setSize - 1) / 2]); EXPECT_EQ(STATUS_SUCCESS, heapUnmap(pHeap, pAlloc)); } } diff --git a/tst/heap/HeapApiTest.cpp b/tst/heap/HeapApiTest.cpp index fcc6f1e4f..3d02ae040 100644 --- a/tst/heap/HeapApiTest.cpp +++ b/tst/heap/HeapApiTest.cpp @@ -1,142 +1,66 @@ #include "HeapTestFixture.h" -class HeapApiTest : public HeapTestBase { -}; +class HeapApiTest : public HeapTestBase {}; -TEST_F(HeapApiTest, InvalidInputHeapInitialize_HeapPointerNull) { +TEST_F(HeapApiTest, InvalidInputHeapInitialize_HeapPointerNull) +{ EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_AIV_HEAP, NULL, NULL))); EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_SYSTEM_HEAP, NULL, NULL))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, - 20, - FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, - NULL, - NULL))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, - 20, - FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, - NULL, - NULL))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, - 20, - FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, - NULL, - NULL))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, - 20, - FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, - NULL, - NULL))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, - 20, - FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_FILE_HEAP, - NULL, - NULL))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, - 20, - FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_FILE_HEAP, - NULL, - NULL))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, NULL, NULL))); + EXPECT_TRUE( + STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, NULL, NULL))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, NULL, NULL))); + EXPECT_TRUE( + STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, NULL, NULL))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_FILE_HEAP, NULL, NULL))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_FILE_HEAP, NULL, NULL))); } -TEST_F(HeapApiTest, InvalidInputHeapInitialize_MinHeapSize) { +TEST_F(HeapApiTest, InvalidInputHeapInitialize_MinHeapSize) +{ PHeap pHeap; EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE - 1, 20, FLAGS_USE_AIV_HEAP, NULL, &pHeap))); EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE - 1, 20, FLAGS_USE_SYSTEM_HEAP, NULL, &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE - 1, - 20, - FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, - NULL, - &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE - 1, - 20, - FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, - NULL, - &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE - 1, - 20, - FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, - NULL, - &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE - 1, - 20, - FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, - NULL, - &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE - 1, - 20, - FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_FILE_HEAP, - NULL, - &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE - 1, - 20, - FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_FILE_HEAP, - NULL, - &pHeap))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE - 1, 20, FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, NULL, &pHeap))); + EXPECT_TRUE(STATUS_FAILED( + heapInitialize(MIN_HEAP_SIZE - 1, 20, FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, NULL, &pHeap))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE - 1, 20, FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, NULL, &pHeap))); + EXPECT_TRUE(STATUS_FAILED( + heapInitialize(MIN_HEAP_SIZE - 1, 20, FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, NULL, &pHeap))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE - 1, 20, FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_FILE_HEAP, NULL, &pHeap))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE - 1, 20, FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_FILE_HEAP, NULL, &pHeap))); } -TEST_F(HeapApiTest, InvalidInputHeapInitialize_MaxHeapSize) { +TEST_F(HeapApiTest, InvalidInputHeapInitialize_MaxHeapSize) +{ PHeap pHeap; EXPECT_TRUE(STATUS_FAILED(heapInitialize(MAX_HEAP_SIZE + 1, 20, FLAGS_USE_AIV_HEAP, NULL, &pHeap))); EXPECT_TRUE(STATUS_FAILED(heapInitialize(MAX_HEAP_SIZE + 1, 20, FLAGS_USE_SYSTEM_HEAP, NULL, &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MAX_HEAP_SIZE + 1, - 20, - FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, - NULL, - &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MAX_HEAP_SIZE + 1, - 20, - FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, - NULL, - &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MAX_HEAP_SIZE + 1, - 20, - FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, - NULL, - &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MAX_HEAP_SIZE + 1, - 20, - FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, - NULL, - &pHeap))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MAX_HEAP_SIZE + 1, 20, FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, NULL, &pHeap))); + EXPECT_TRUE(STATUS_FAILED( + heapInitialize(MAX_HEAP_SIZE + 1, 20, FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, NULL, &pHeap))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MAX_HEAP_SIZE + 1, 20, FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, NULL, &pHeap))); + EXPECT_TRUE(STATUS_FAILED( + heapInitialize(MAX_HEAP_SIZE + 1, 20, FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, NULL, &pHeap))); } -TEST_F(HeapApiTest, InvalidInputHeapInitialize_SpillRatio) { +TEST_F(HeapApiTest, InvalidInputHeapInitialize_SpillRatio) +{ PHeap pHeap; EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 101, FLAGS_USE_AIV_HEAP, NULL, &pHeap))); EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 101, FLAGS_USE_SYSTEM_HEAP, NULL, &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, - 101, - FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, - NULL, - &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, - 101, - FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, - NULL, - &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, - 101, - FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, - NULL, - &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, - 101, - FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, - NULL, - &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, - 101, - FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_FILE_HEAP, - NULL, - &pHeap))); - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, - 101, - FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_FILE_HEAP, - NULL, - &pHeap))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 101, FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, NULL, &pHeap))); + EXPECT_TRUE( + STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 101, FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, NULL, &pHeap))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 101, FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, NULL, &pHeap))); + EXPECT_TRUE(STATUS_FAILED( + heapInitialize(MIN_HEAP_SIZE, 101, FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, NULL, &pHeap))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 101, FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_FILE_HEAP, NULL, &pHeap))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 101, FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_FILE_HEAP, NULL, &pHeap))); } -TEST_F(HeapApiTest, InvalidInputHeapInitialize_HeapTypeFlags) { +TEST_F(HeapApiTest, InvalidInputHeapInitialize_HeapTypeFlags) +{ PHeap pHeap; EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 20, HEAP_FLAGS_NONE, NULL, &pHeap))); EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_HYBRID_VRAM_HEAP, NULL, &pHeap))); @@ -146,7 +70,8 @@ TEST_F(HeapApiTest, InvalidInputHeapInitialize_HeapTypeFlags) { EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_HYBRID_FILE_HEAP | FLAGS_REOPEN_VRAM_LIBRARY, NULL, &pHeap))); } -TEST_F(HeapApiTest, IdempotentHeapRelease_NullHeapRelease) { +TEST_F(HeapApiTest, IdempotentHeapRelease_NullHeapRelease) +{ PHeap pHeap; EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_AIV_HEAP, NULL, &pHeap))); EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); @@ -157,7 +82,8 @@ TEST_F(HeapApiTest, IdempotentHeapRelease_NullHeapRelease) { EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(NULL))); } -TEST_F(HeapApiTest, InvalidHeapGetSize_NullHeap) { +TEST_F(HeapApiTest, InvalidHeapGetSize_NullHeap) +{ PHeap pHeap = (PHeap) 12345; UINT64 size; @@ -166,12 +92,14 @@ TEST_F(HeapApiTest, InvalidHeapGetSize_NullHeap) { EXPECT_TRUE(STATUS_FAILED(heapGetSize(NULL, NULL))); } -TEST_F(HeapApiTest, InvalidHeapDebugCheckAllocator_NullHeapDebugCheckAllocator) { +TEST_F(HeapApiTest, InvalidHeapDebugCheckAllocator_NullHeapDebugCheckAllocator) +{ EXPECT_TRUE(STATUS_FAILED(heapDebugCheckAllocator(NULL, TRUE))); EXPECT_TRUE(STATUS_FAILED(heapDebugCheckAllocator(NULL, FALSE))); } -TEST_F(HeapApiTest, InvalidHeapAlloc_NullHeap) { +TEST_F(HeapApiTest, InvalidHeapAlloc_NullHeap) +{ PHeap pHeap; ALLOCATION_HANDLE handle; EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_AIV_HEAP, NULL, &pHeap))); @@ -183,7 +111,8 @@ TEST_F(HeapApiTest, InvalidHeapAlloc_NullHeap) { EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); } -TEST_F(HeapApiTest, InvalidHeapGetAllocSize_NullHeapHandle) { +TEST_F(HeapApiTest, InvalidHeapGetAllocSize_NullHeapHandle) +{ PHeap pHeap; UINT64 size; ALLOCATION_HANDLE handle; @@ -206,7 +135,8 @@ TEST_F(HeapApiTest, InvalidHeapGetAllocSize_NullHeapHandle) { EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); } -TEST_F(HeapApiTest, InvalidHeapAlloc_NullHandle) { +TEST_F(HeapApiTest, InvalidHeapAlloc_NullHandle) +{ PHeap pHeap; EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_AIV_HEAP, NULL, &pHeap))); @@ -218,7 +148,8 @@ TEST_F(HeapApiTest, InvalidHeapAlloc_NullHandle) { EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); } -TEST_F(HeapApiTest, InvalidHeapAlloc_ZeroAlloc) { +TEST_F(HeapApiTest, InvalidHeapAlloc_ZeroAlloc) +{ PHeap pHeap; ALLOCATION_HANDLE handle; @@ -231,7 +162,8 @@ TEST_F(HeapApiTest, InvalidHeapAlloc_ZeroAlloc) { EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); } -TEST_F(HeapApiTest, InvalidHeapAlloc_MaxAlloc) { +TEST_F(HeapApiTest, InvalidHeapAlloc_MaxAlloc) +{ PHeap pHeap; ALLOCATION_HANDLE handle; @@ -244,7 +176,8 @@ TEST_F(HeapApiTest, InvalidHeapAlloc_MaxAlloc) { EXPECT_EQ(STATUS_SUCCESS, heapRelease(pHeap)); } -TEST_F(HeapApiTest, InvalidHeapFree_NullHeap) { +TEST_F(HeapApiTest, InvalidHeapFree_NullHeap) +{ PHeap pHeap; ALLOCATION_HANDLE handle; EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_AIV_HEAP, NULL, &pHeap))); @@ -259,7 +192,8 @@ TEST_F(HeapApiTest, InvalidHeapFree_NullHeap) { EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); } -TEST_F(HeapApiTest, InvalidHeapFree_InvalidHandle) { +TEST_F(HeapApiTest, InvalidHeapFree_InvalidHandle) +{ PHeap pHeap; ALLOCATION_HANDLE handle; @@ -275,7 +209,8 @@ TEST_F(HeapApiTest, InvalidHeapFree_InvalidHandle) { EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); } -TEST_F(HeapApiTest, InvalidHeapMap_NullHeap) { +TEST_F(HeapApiTest, InvalidHeapMap_NullHeap) +{ PHeap pHeap; ALLOCATION_HANDLE handle; PVOID pAlloc; @@ -294,7 +229,8 @@ TEST_F(HeapApiTest, InvalidHeapMap_NullHeap) { EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); } -TEST_F(HeapApiTest, InvalidHeapMap_InvalidHandle) { +TEST_F(HeapApiTest, InvalidHeapMap_InvalidHandle) +{ PHeap pHeap; ALLOCATION_HANDLE handle; PVOID pAlloc; @@ -313,7 +249,8 @@ TEST_F(HeapApiTest, InvalidHeapMap_InvalidHandle) { EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); } -TEST_F(HeapApiTest, InvalidHeapMap_NullAllocation) { +TEST_F(HeapApiTest, InvalidHeapMap_NullAllocation) +{ PHeap pHeap; ALLOCATION_HANDLE handle; UINT64 size; @@ -331,7 +268,8 @@ TEST_F(HeapApiTest, InvalidHeapMap_NullAllocation) { EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); } -TEST_F(HeapApiTest, InvalidHeapMap_NullSize) { +TEST_F(HeapApiTest, InvalidHeapMap_NullSize) +{ PHeap pHeap = NULL; ALLOCATION_HANDLE handle; PVOID pAlloc = NULL; @@ -349,7 +287,8 @@ TEST_F(HeapApiTest, InvalidHeapMap_NullSize) { EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); } -TEST_F(HeapApiTest, InvalidHeapUnmap_NullHeap) { +TEST_F(HeapApiTest, InvalidHeapUnmap_NullHeap) +{ PHeap pHeap; PVOID pAlloc = (PVOID) 12345; @@ -362,7 +301,8 @@ TEST_F(HeapApiTest, InvalidHeapUnmap_NullHeap) { EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); } -TEST_F(HeapApiTest, InvalidHeapUnmap_InvalidAllocation) { +TEST_F(HeapApiTest, InvalidHeapUnmap_InvalidAllocation) +{ PHeap pHeap; EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(MIN_HEAP_SIZE, 20, FLAGS_USE_AIV_HEAP, NULL, &pHeap))); @@ -374,7 +314,8 @@ TEST_F(HeapApiTest, InvalidHeapUnmap_InvalidAllocation) { EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); } -TEST_F(HeapApiTest, InvalidFileHeapCreate_InvalidParams) { +TEST_F(HeapApiTest, InvalidFileHeapCreate_InvalidParams) +{ PHeap pHeap = NULL; CHAR filePath[MAX_PATH_LEN + 2]; @@ -393,16 +334,17 @@ TEST_F(HeapApiTest, InvalidFileHeapCreate_InvalidParams) { EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(pHeap))); } -TEST_F(HeapApiTest, InvalidHeapResize_InvalidValues) { +TEST_F(HeapApiTest, InvalidHeapResize_InvalidValues) +{ PHeap pHeap; ALLOCATION_HANDLE handle, storedHandle, invalidHandle = INVALID_ALLOCATION_HANDLE_VALUE; UINT64 heapSize = MIN_HEAP_SIZE * 2 + 100000; UINT32 heapTypes[] = {FLAGS_USE_AIV_HEAP, - FLAGS_USE_SYSTEM_HEAP, - FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, - FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, - FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_FILE_HEAP, - FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_FILE_HEAP}; + FLAGS_USE_SYSTEM_HEAP, + FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, + FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_VRAM_HEAP, + FLAGS_USE_AIV_HEAP | FLAGS_USE_HYBRID_FILE_HEAP, + FLAGS_USE_SYSTEM_HEAP | FLAGS_USE_HYBRID_FILE_HEAP}; for (UINT32 heapType = 0; heapType < ARRAY_SIZE(heapTypes); heapType++) { EXPECT_EQ(STATUS_SUCCESS, heapInitialize(heapSize, 50, heapTypes[heapType], NULL, &pHeap)); diff --git a/tst/heap/HeapPerfTest.cpp b/tst/heap/HeapPerfTest.cpp index 1374939f8..db85e15cc 100644 --- a/tst/heap/HeapPerfTest.cpp +++ b/tst/heap/HeapPerfTest.cpp @@ -1,16 +1,15 @@ #include "HeapTestFixture.h" -class HeapPerfTest : public HeapTestBase { -}; - -#define HEAP_PERF_TEST_VIEW_ITEM_COUNT 1500 -#define HEAP_PERF_TEST_MULTI_VIEW_ITEM_COUNT 1500 * 1000 -#define HEAP_PERF_TEST_MIN_ALLOCATION 2000 -#define HEAP_PERF_TEST_MULTI_VIEW_MIN_ALLOCATION 64 -#define HEAP_PERF_TEST_ALLOCATION_DELTA 50 -#define HEAP_PERF_TEST_ITERATION_COUNT 1000000 -#define HEAP_PERF_TEST_MULTI_VIEW_ITERATION_COUNT 10000000 -#define HEAP_PERF_TEST_SIZE 256 * 1024 * 1024 +class HeapPerfTest : public HeapTestBase {}; + +#define HEAP_PERF_TEST_VIEW_ITEM_COUNT 1500 +#define HEAP_PERF_TEST_MULTI_VIEW_ITEM_COUNT 1500 * 1000 +#define HEAP_PERF_TEST_MIN_ALLOCATION 2000 +#define HEAP_PERF_TEST_MULTI_VIEW_MIN_ALLOCATION 64 +#define HEAP_PERF_TEST_ALLOCATION_DELTA 50 +#define HEAP_PERF_TEST_ITERATION_COUNT 1000000 +#define HEAP_PERF_TEST_MULTI_VIEW_ITERATION_COUNT 10000000 +#define HEAP_PERF_TEST_SIZE 256 * 1024 * 1024 VOID randomAllocFree(PHeap pHeap, UINT32 itemCount, UINT32 iterationCount, UINT32 allocSize) { @@ -30,7 +29,6 @@ VOID randomAllocFree(PHeap pHeap, UINT32 itemCount, UINT32 iterationCount, UINT3 EXPECT_EQ(STATUS_SUCCESS, heapFree(pHeap, handles[(i - itemCount) % itemCount])); } } - } VOID singleAllocFree(PHeap pHeap) @@ -41,7 +39,6 @@ VOID singleAllocFree(PHeap pHeap) EXPECT_EQ(STATUS_SUCCESS, heapAlloc(pHeap, 10000, &handle)); EXPECT_EQ(STATUS_SUCCESS, heapFree(pHeap, handle)); } - } /////////////////////////////////////////////////////////////// @@ -66,7 +63,8 @@ TEST_F(HeapPerfTest, randomAllocFreeWindowedPerf) durationSystem = endTime - time; iterationDurationSystem = (DOUBLE) durationSystem / HEAP_PERF_TEST_ITERATION_COUNT; - DLOGI("System Allocator perf time: %lf seconds, time per iteration: %lf nanos", (DOUBLE) durationSystem / HUNDREDS_OF_NANOS_IN_A_SECOND, iterationDurationSystem * DEFAULT_TIME_UNIT_IN_NANOS); + DLOGI("System Allocator perf time: %lf seconds, time per iteration: %lf nanos", (DOUBLE) durationSystem / HUNDREDS_OF_NANOS_IN_A_SECOND, + iterationDurationSystem * DEFAULT_TIME_UNIT_IN_NANOS); EXPECT_EQ(STATUS_SUCCESS, heapInitialize(HEAP_PERF_TEST_SIZE, 20, FLAGS_USE_AIV_HEAP, NULL, &pHeap)); time = GETTIME(); @@ -76,7 +74,8 @@ TEST_F(HeapPerfTest, randomAllocFreeWindowedPerf) duration = endTime - time; iterationDuration = (DOUBLE) duration / HEAP_PERF_TEST_ITERATION_COUNT; - DLOGI("Allocator perf time: %lf seconds, time per iteration: %lf nanos", (DOUBLE) duration / HUNDREDS_OF_NANOS_IN_A_SECOND, iterationDuration * DEFAULT_TIME_UNIT_IN_NANOS); + DLOGI("Allocator perf time: %lf seconds, time per iteration: %lf nanos", (DOUBLE) duration / HUNDREDS_OF_NANOS_IN_A_SECOND, + iterationDuration * DEFAULT_TIME_UNIT_IN_NANOS); // check if we are within 20% of the system heap speed if ((DOUBLE) duration <= (DOUBLE) durationSystem * 1.2 && iterationDuration <= iterationDurationSystem * 1.2) { @@ -103,23 +102,27 @@ TEST_F(HeapPerfTest, randomAllocFreeMultiStreamWindowedPerf) for (; i < totalIteration; i++) { EXPECT_EQ(STATUS_SUCCESS, heapInitialize(HEAP_PERF_TEST_SIZE, 20, FLAGS_USE_SYSTEM_HEAP, NULL, &pHeap)); time = GETTIME(); - randomAllocFree(pHeap, HEAP_PERF_TEST_MULTI_VIEW_ITEM_COUNT, HEAP_PERF_TEST_MULTI_VIEW_ITERATION_COUNT, HEAP_PERF_TEST_MULTI_VIEW_MIN_ALLOCATION); + randomAllocFree(pHeap, HEAP_PERF_TEST_MULTI_VIEW_ITEM_COUNT, HEAP_PERF_TEST_MULTI_VIEW_ITERATION_COUNT, + HEAP_PERF_TEST_MULTI_VIEW_MIN_ALLOCATION); endTime = GETTIME(); EXPECT_EQ(STATUS_SUCCESS, heapRelease(pHeap)); durationSystem = endTime - time; iterationDurationSystem = (DOUBLE) durationSystem / HEAP_PERF_TEST_MULTI_VIEW_ITERATION_COUNT; - DLOGI("System Allocator perf time: %lf seconds, time per iteration: %lf nanos", (DOUBLE) durationSystem / HUNDREDS_OF_NANOS_IN_A_SECOND, iterationDurationSystem * DEFAULT_TIME_UNIT_IN_NANOS); + DLOGI("System Allocator perf time: %lf seconds, time per iteration: %lf nanos", (DOUBLE) durationSystem / HUNDREDS_OF_NANOS_IN_A_SECOND, + iterationDurationSystem * DEFAULT_TIME_UNIT_IN_NANOS); EXPECT_EQ(STATUS_SUCCESS, heapInitialize(HEAP_PERF_TEST_SIZE, 20, FLAGS_USE_AIV_HEAP, NULL, &pHeap)); time = GETTIME(); - randomAllocFree(pHeap, HEAP_PERF_TEST_MULTI_VIEW_ITEM_COUNT, HEAP_PERF_TEST_MULTI_VIEW_ITERATION_COUNT, HEAP_PERF_TEST_MULTI_VIEW_MIN_ALLOCATION); + randomAllocFree(pHeap, HEAP_PERF_TEST_MULTI_VIEW_ITEM_COUNT, HEAP_PERF_TEST_MULTI_VIEW_ITERATION_COUNT, + HEAP_PERF_TEST_MULTI_VIEW_MIN_ALLOCATION); endTime = GETTIME(); EXPECT_EQ(STATUS_SUCCESS, heapRelease(pHeap)); duration = endTime - time; iterationDuration = (DOUBLE) duration / HEAP_PERF_TEST_MULTI_VIEW_ITERATION_COUNT; - DLOGI("Allocator perf time: %lf seconds, time per iteration: %lf nanos", (DOUBLE) duration / HUNDREDS_OF_NANOS_IN_A_SECOND, iterationDuration * DEFAULT_TIME_UNIT_IN_NANOS); + DLOGI("Allocator perf time: %lf seconds, time per iteration: %lf nanos", (DOUBLE) duration / HUNDREDS_OF_NANOS_IN_A_SECOND, + iterationDuration * DEFAULT_TIME_UNIT_IN_NANOS); // check if we are within 20% of the system heap speed if ((DOUBLE) duration <= (DOUBLE) durationSystem * 1.2 && iterationDuration <= iterationDurationSystem * 1.2) { @@ -152,7 +155,8 @@ TEST_F(HeapPerfTest, singleAllocFreePerf) durationSystem = endTime - time; iterationDurationSystem = (DOUBLE) durationSystem / HEAP_PERF_TEST_ITERATION_COUNT; - DLOGI("System Allocator perf time: %lf seconds, time per iteration: %lf nanos", (DOUBLE) durationSystem / HUNDREDS_OF_NANOS_IN_A_SECOND, iterationDurationSystem * DEFAULT_TIME_UNIT_IN_NANOS); + DLOGI("System Allocator perf time: %lf seconds, time per iteration: %lf nanos", (DOUBLE) durationSystem / HUNDREDS_OF_NANOS_IN_A_SECOND, + iterationDurationSystem * DEFAULT_TIME_UNIT_IN_NANOS); EXPECT_EQ(STATUS_SUCCESS, heapInitialize(HEAP_PERF_TEST_SIZE, 20, FLAGS_USE_AIV_HEAP, NULL, &pHeap)); time = GETTIME(); @@ -162,7 +166,8 @@ TEST_F(HeapPerfTest, singleAllocFreePerf) duration = endTime - time; iterationDuration = (DOUBLE) duration / HEAP_PERF_TEST_ITERATION_COUNT; - DLOGI("Allocator perf time: %lf seconds, time per iteration: %lf nanos", (DOUBLE) duration / HUNDREDS_OF_NANOS_IN_A_SECOND, iterationDuration * DEFAULT_TIME_UNIT_IN_NANOS); + DLOGI("Allocator perf time: %lf seconds, time per iteration: %lf nanos", (DOUBLE) duration / HUNDREDS_OF_NANOS_IN_A_SECOND, + iterationDuration * DEFAULT_TIME_UNIT_IN_NANOS); // check if we are within 20% of the system heap speed if ((DOUBLE) duration <= (DOUBLE) durationSystem * 1.2 && iterationDuration <= iterationDurationSystem * 1.2) { diff --git a/tst/heap/HeapTestFixture.cpp b/tst/heap/HeapTestFixture.cpp index 7f764b647..ea6a37160 100644 --- a/tst/heap/HeapTestFixture.cpp +++ b/tst/heap/HeapTestFixture.cpp @@ -52,7 +52,7 @@ VOID HeapTestBase::SetUpInternal() mVramUnlockCount = 0; mVramUninitCount = 0; - mDlOpen = (PVOID)(UINT64)MOCK_LIB_HANDLE; + mDlOpen = (PVOID) (UINT64) MOCK_LIB_HANDLE; mDlClose = 0; mDlSym = TRUE; diff --git a/tst/heap/HybridFileHeapTest.cpp b/tst/heap/HybridFileHeapTest.cpp index d28265723..6a2639c2d 100644 --- a/tst/heap/HybridFileHeapTest.cpp +++ b/tst/heap/HybridFileHeapTest.cpp @@ -1,15 +1,14 @@ #include "HeapTestFixture.h" -using ::testing::WithParamInterface; using ::testing::Bool; -using ::testing::Values; using ::testing::Combine; +using ::testing::Values; +using ::testing::WithParamInterface; -class HybridFileHeapTest : public HeapTestBase, - public WithParamInterface<::std::tuple> -{ -protected: - VOID SetUp() { +class HybridFileHeapTest : public HeapTestBase, public WithParamInterface<::std::tuple> { + protected: + VOID SetUp() + { HeapTestBase::SetUp(); HEAP_BEHAVIOR_FLAGS primaryHeapType; @@ -45,7 +44,7 @@ TEST_P(HybridFileHeapTest, hybridFileHeapOperationsAivPrimaryHeap) PVOID pAlloc; // Split the 50% and allocate half from ram and half from file heap - memHeapLimit = (UINT32)(heapSize * ((DOUBLE)spillRatio / 100)); + memHeapLimit = (UINT32) (heapSize * ((DOUBLE) spillRatio / 100)); fileHeapLimit = heapSize - memHeapLimit; fileAllocSize = fileHeapLimit / numAlloc; ramAllocSize = memHeapLimit / numAlloc; @@ -56,17 +55,13 @@ TEST_P(HybridFileHeapTest, hybridFileHeapOperationsAivPrimaryHeap) } // Initialize - EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, - spillRatio, - mHeapType, - NULL, - &pHeap))); + EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, spillRatio, mHeapType, NULL, &pHeap))); DLOGV("Allocating from RAM"); // Allocate from ram - should be 1 less due to service structs for (i = 0; i < numAlloc - 1; i++) { - EXPECT_TRUE(STATUS_SUCCEEDED(heapAlloc(pHeap, ramAllocSize, &handle))) << "Failed allocating from direct heap with index: " << i; + EXPECT_TRUE(STATUS_SUCCEEDED(heapAlloc(pHeap, ramAllocSize, &handle))) << "Failed allocating from direct heap with index: " << i; EXPECT_TRUE(IS_VALID_ALLOCATION_HANDLE(handle)) << "Invalid direct allocation handle at index: " << i; // Store the handle for later processing @@ -166,12 +161,7 @@ TEST_P(HybridFileHeapTest, hybridFileCreateHeapMemHeapSmall) PHeap pHeap; // Initialize should fail as MIN_HEAP_SIZE will be smaller for the mem heap with 20% reduction - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, - 20, - mHeapType, - NULL, - &pHeap))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 20, mHeapType, NULL, &pHeap))); } -INSTANTIATE_TEST_SUITE_P(PermutatedHeapType, HybridFileHeapTest, - Values(FLAGS_USE_AIV_HEAP, FLAGS_USE_SYSTEM_HEAP)); +INSTANTIATE_TEST_SUITE_P(PermutatedHeapType, HybridFileHeapTest, Values(FLAGS_USE_AIV_HEAP, FLAGS_USE_SYSTEM_HEAP)); diff --git a/tst/heap/HybridHeapTest.cpp b/tst/heap/HybridHeapTest.cpp index 41e01d2ed..1e5ae08c7 100644 --- a/tst/heap/HybridHeapTest.cpp +++ b/tst/heap/HybridHeapTest.cpp @@ -1,17 +1,16 @@ #include "HeapTestFixture.h" -using ::testing::WithParamInterface; using ::testing::Bool; -using ::testing::Values; using ::testing::Combine; +using ::testing::Values; +using ::testing::WithParamInterface; -class HybridHeapTest : public HeapTestBase, - public WithParamInterface<::std::tuple> -{ -protected: +class HybridHeapTest : public HeapTestBase, public WithParamInterface<::std::tuple> { + protected: static const UINT32 AllocationCount = 100; - VOID SetUp() { + VOID SetUp() + { HeapTestBase::SetUp(); HEAP_BEHAVIOR_FLAGS primaryHeapType; @@ -31,7 +30,8 @@ class HybridHeapTest : public HeapTestBase, mHeap = NULL; } - VOID freeAllocations() { + VOID freeAllocations() + { // Release the allocations in case of the system heap usage as heap release doesn't free allocations if (mHeap != NULL && (mHeapType & FLAGS_USE_SYSTEM_HEAP) != HEAP_FLAGS_NONE) { for (UINT32 i = 0; i < AllocationCount; i++) { @@ -59,17 +59,13 @@ TEST_P(HybridHeapTest, hybridCreateHeap) UINT32 numAlloc = AllocationCount / 2; // Split the 50% and allocate half from ram and half from vram - memHeapLimit = (UINT32)(heapSize * ((DOUBLE)spillRatio / 100)); + memHeapLimit = (UINT32) (heapSize * ((DOUBLE) spillRatio / 100)); vramHeapLimit = heapSize - memHeapLimit; vramAllocSize = vramHeapLimit / numAlloc; ramAllocSize = memHeapLimit / numAlloc; // Initialize - EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, - spillRatio, - mHeapType, - NULL, - &mHeap))); + EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, spillRatio, mHeapType, NULL, &mHeap))); // Validate internal calls EXPECT_EQ(mVramGetMaxCount, 1); @@ -84,8 +80,7 @@ TEST_P(HybridHeapTest, hybridCreateHeap) EXPECT_EQ(mDlErrorCount, 0); EXPECT_EQ(mDlSymCount, 7); - DLOGV("Allocating from RAM type %s", - (mHeapType & FLAGS_USE_AIV_HEAP) != HEAP_FLAGS_NONE ? "AIV heap" : "System heap"); + DLOGV("Allocating from RAM type %s", (mHeapType & FLAGS_USE_AIV_HEAP) != HEAP_FLAGS_NONE ? "AIV heap" : "System heap"); // Allocate from ram - should be 1 less due to service structs for (UINT32 i = 0; i < numAlloc - 1; i++) { @@ -149,11 +144,7 @@ TEST_P(HybridHeapTest, hybridCreateHeap) TEST_P(HybridHeapTest, hybridCreateHeapMemHeapSmall) { // Initialize should fail as MIN_HEAP_SIZE will be smaller for the mem heap with 20% reduction - EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, - 20, - mHeapType, - NULL, - &mHeap))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(MIN_HEAP_SIZE, 20, mHeapType, NULL, &mHeap))); } TEST_P(HybridHeapTest, hybridCreateHeapDlOpenCount) @@ -161,21 +152,13 @@ TEST_P(HybridHeapTest, hybridCreateHeapDlOpenCount) UINT32 heapSize = MIN_HEAP_SIZE * 2 + 100000; // Initialize with one time opening - EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, - 50, - mHeapType, - NULL, - &mHeap))); + EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, 50, mHeapType, NULL, &mHeap))); EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(mHeap))); EXPECT_EQ(mDlCloseCount, 1); EXPECT_EQ(mDlOpenCount, 1); // Initialize with reopen - EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, - 50, - mHeapType | FLAGS_REOPEN_VRAM_LIBRARY, - NULL, - &mHeap))); + EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, 50, mHeapType | FLAGS_REOPEN_VRAM_LIBRARY, NULL, &mHeap))); EXPECT_TRUE(STATUS_SUCCEEDED(heapRelease(mHeap))); EXPECT_EQ(mDlCloseCount, 2); EXPECT_EQ(mDlOpenCount, 3); @@ -188,11 +171,7 @@ TEST_P(HybridHeapTest, hybridCreateHeapDlOpenError) // Set to produce an error mDlOpen = NULL; - EXPECT_TRUE(STATUS_FAILED(heapInitialize(heapSize, - 50, - mHeapType, - NULL, - &mHeap))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(heapSize, 50, mHeapType, NULL, &mHeap))); // Validate the on error we don't attempt to close the library as the handle is NULL EXPECT_EQ(mDlCloseCount, 0); @@ -205,12 +184,7 @@ TEST_P(HybridHeapTest, hybridCreateHeapDlSymError) // Set to produce an error mDlSym = FALSE; - EXPECT_TRUE(STATUS_FAILED(heapInitialize(heapSize, - 50, - mHeapType, - NULL, - &mHeap))); - + EXPECT_TRUE(STATUS_FAILED(heapInitialize(heapSize, 50, mHeapType, NULL, &mHeap))); // Validate the on error we close the library EXPECT_EQ(mDlCloseCount, 1); @@ -223,11 +197,7 @@ TEST_P(HybridHeapTest, hybridCreateHeapDlCloseError) // Set to produce an error mDlClose = 1; - EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, - 50, - mHeapType, - NULL, - &mHeap))); + EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, 50, mHeapType, NULL, &mHeap))); EXPECT_TRUE(STATUS_FAILED(heapRelease(mHeap))); // Validate the on error we close the library @@ -242,11 +212,7 @@ TEST_P(HybridHeapTest, hybridCreateHeapVRamInitError) mVramInit = 1; // Initialize should fail as we will fail to vram init - EXPECT_TRUE(STATUS_FAILED(heapInitialize(heapSize, - 50, - mHeapType, - NULL, - &mHeap))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(heapSize, 50, mHeapType, NULL, &mHeap))); } TEST_P(HybridHeapTest, hybridCreateHeapGetMaxVramSmall) @@ -257,11 +223,7 @@ TEST_P(HybridHeapTest, hybridCreateHeapGetMaxVramSmall) mVramGetMax = MIN_HEAP_SIZE; // Initialize should fail as requested vram size will be smaller than the max vram - EXPECT_TRUE(STATUS_FAILED(heapInitialize(heapSize, - 50, - mHeapType, - NULL, - &mHeap))); + EXPECT_TRUE(STATUS_FAILED(heapInitialize(heapSize, 50, mHeapType, NULL, &mHeap))); } TEST_P(HybridHeapTest, hybridCreateHeapVRamReleaseError) @@ -271,11 +233,7 @@ TEST_P(HybridHeapTest, hybridCreateHeapVRamReleaseError) // Set to produce an error mVramUninit = 1; - EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, - 50, - mHeapType, - NULL, - &mHeap))); + EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, 50, mHeapType, NULL, &mHeap))); EXPECT_TRUE(STATUS_FAILED(heapRelease(mHeap))); } @@ -292,7 +250,7 @@ TEST_P(HybridHeapTest, hybridCreateHeapVRamAllocError) UINT32 numAlloc = AllocationCount / 2; // Split the 50% and allocate half from ram and half from vram - memHeapLimit = (UINT32)(heapSize * ((DOUBLE)spillRatio / 100)); + memHeapLimit = (UINT32) (heapSize * ((DOUBLE) spillRatio / 100)); vramHeapLimit = heapSize - memHeapLimit; vramAllocSize = vramHeapLimit / numAlloc; ramAllocSize = memHeapLimit / numAlloc; @@ -300,11 +258,7 @@ TEST_P(HybridHeapTest, hybridCreateHeapVRamAllocError) // Set to produce an error mVramAlloc = 0; - EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, - spillRatio, - mHeapType, - NULL, - &mHeap))); + EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, spillRatio, mHeapType, NULL, &mHeap))); DLOGV("Allocating from RAM"); @@ -338,7 +292,7 @@ TEST_P(HybridHeapTest, hybridCreateHeapVRamMapError) UINT32 spillRatio = 50; UINT32 numAlloc = AllocationCount / 2; // Split the 50% and allocate half from ram and half from vram - memHeapLimit = (UINT32)(heapSize * ((DOUBLE)spillRatio / 100)); + memHeapLimit = (UINT32) (heapSize * ((DOUBLE) spillRatio / 100)); vramHeapLimit = heapSize - memHeapLimit; vramAllocSize = vramHeapLimit / numAlloc; ramAllocSize = memHeapLimit / numAlloc; @@ -346,11 +300,7 @@ TEST_P(HybridHeapTest, hybridCreateHeapVRamMapError) // Set to produce an error mVramLock = NULL; - EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, - spillRatio, - mHeapType, - NULL, - &mHeap))); + EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, spillRatio, mHeapType, NULL, &mHeap))); DLOGV("Allocating from RAM"); @@ -387,7 +337,7 @@ TEST_P(HybridHeapTest, hybridCreateHeapVRamUnmapError) UINT32 spillRatio = 50; UINT32 numAlloc = AllocationCount / 2; // Split the 50% and allocate half from ram and half from vram - memHeapLimit = (UINT32)(heapSize * ((DOUBLE)spillRatio / 100)); + memHeapLimit = (UINT32) (heapSize * ((DOUBLE) spillRatio / 100)); vramHeapLimit = heapSize - memHeapLimit; vramAllocSize = vramHeapLimit / numAlloc; ramAllocSize = memHeapLimit / numAlloc; @@ -395,11 +345,7 @@ TEST_P(HybridHeapTest, hybridCreateHeapVRamUnmapError) // Set to produce an error mVramUnlock = 1; - EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, - spillRatio, - mHeapType, - NULL, - &mHeap))); + EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, spillRatio, mHeapType, NULL, &mHeap))); DLOGV("Allocating from RAM"); @@ -444,7 +390,7 @@ TEST_P(HybridHeapTest, hybridCreateHeapVRamFreeError) UINT32 spillRatio = 50; UINT32 numAlloc = AllocationCount / 2; // Split the 50% and allocate half from ram and half from vram - memHeapLimit = (UINT32)(heapSize * ((DOUBLE)spillRatio / 100)); + memHeapLimit = (UINT32) (heapSize * ((DOUBLE) spillRatio / 100)); vramHeapLimit = heapSize - memHeapLimit; vramAllocSize = vramHeapLimit / numAlloc; ramAllocSize = memHeapLimit / numAlloc; @@ -452,11 +398,7 @@ TEST_P(HybridHeapTest, hybridCreateHeapVRamFreeError) // Set to produce an error mVramFree = 1; - EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, - spillRatio, - mHeapType, - NULL, - &mHeap))); + EXPECT_TRUE(STATUS_SUCCEEDED(heapInitialize(heapSize, spillRatio, mHeapType, NULL, &mHeap))); DLOGV("Allocating from RAM"); @@ -501,16 +443,12 @@ TEST_P(HybridHeapTest, hybridFillResizeAlloc) UINT32 numAlloc = AllocationCount / 2; // Split the 50% and allocate half from ram and half from vram - memHeapLimit = (UINT32)(heapSize * ((DOUBLE)spillRatio / 100)); + memHeapLimit = (UINT32) (heapSize * ((DOUBLE) spillRatio / 100)); vramHeapLimit = heapSize - memHeapLimit; vramAllocSize = vramHeapLimit / numAlloc; ramAllocSize = memHeapLimit / numAlloc; - EXPECT_EQ(STATUS_SUCCESS, heapInitialize(heapSize, - spillRatio, - mHeapType, - NULL, - &mHeap)); + EXPECT_EQ(STATUS_SUCCESS, heapInitialize(heapSize, spillRatio, mHeapType, NULL, &mHeap)); // Allocate from ram - account for the service structs // Store an allocation handle somewhere in the middle @@ -548,5 +486,4 @@ TEST_P(HybridHeapTest, hybridFillResizeAlloc) EXPECT_EQ(STATUS_SUCCESS, heapRelease(mHeap)); } -INSTANTIATE_TEST_SUITE_P(PermutatedHeapType, HybridHeapTest, - Values(FLAGS_USE_AIV_HEAP, FLAGS_USE_SYSTEM_HEAP)); +INSTANTIATE_TEST_SUITE_P(PermutatedHeapType, HybridHeapTest, Values(FLAGS_USE_AIV_HEAP, FLAGS_USE_SYSTEM_HEAP)); diff --git a/tst/mkvgen/AnnexBCpdNalAdapterTest.cpp b/tst/mkvgen/AnnexBCpdNalAdapterTest.cpp index 5acc32c69..4f587470e 100644 --- a/tst/mkvgen/AnnexBCpdNalAdapterTest.cpp +++ b/tst/mkvgen/AnnexBCpdNalAdapterTest.cpp @@ -1,7 +1,6 @@ #include "MkvgenTestFixture.h" -class AnnexBCpdNalAdapterTest : public MkvgenTestBase { -}; +class AnnexBCpdNalAdapterTest : public MkvgenTestBase {}; #ifdef FIXUP_ANNEX_B_TRAILING_NALU_ZERO TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_InvalidInput) @@ -16,8 +15,7 @@ TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_InvalidInput) EXPECT_NE(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(pCpd, cpdSize, pAdaptedCpd, NULL)); EXPECT_NE(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(pCpd, 0, pAdaptedCpd, &adaptedCpdSize)); EXPECT_NE(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(pCpd, 1, pAdaptedCpd, &adaptedCpdSize)); - EXPECT_NE(STATUS_SUCCESS, - adaptH264CpdNalsFromAnnexBToAvcc(pCpd, MIN_H264_ANNEXB_CPD_SIZE - 1, pAdaptedCpd, &adaptedCpdSize)); + EXPECT_NE(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(pCpd, MIN_H264_ANNEXB_CPD_SIZE - 1, pAdaptedCpd, &adaptedCpdSize)); } #endif @@ -39,16 +37,16 @@ TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_InvalidNoStartCode) TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_ValidZerosInStream) { BYTE cpds[][21] = { - {0, 0, 1, 0x67, 2, 3, 4, 10, 11, 12, 13, 14, 15, 0, 0, 1, 0x68, 3, 4, 5, 6}, // 0 - {0, 0, 0, 1, 0x67, 2, 3, 4, 10, 11, 12, 13, 14, 15, 0, 0, 0, 1, 0x68, 3, 4}, // 1 + {0, 0, 1, 0x67, 2, 3, 4, 10, 11, 12, 13, 14, 15, 0, 0, 1, 0x68, 3, 4, 5, 6}, // 0 + {0, 0, 0, 1, 0x67, 2, 3, 4, 10, 11, 12, 13, 14, 15, 0, 0, 0, 1, 0x68, 3, 4}, // 1 }; UINT32 adaptedSizes[] = {26, 26}; UINT32 actualAdaptedSizes[] = {26, 24}; BYTE adaptedCpds[][26] = { - {1, 2, 3, 4, 0xff, 0xE1, 0, 10, 0x67, 2, 3, 4, 10, 11, 12, 13, 14, 15, 1, 0, 5, 0x68, 3, 4, 5, 6}, // 0 - {1, 2, 3, 4, 0xff, 0xE1, 0, 10, 0x67, 2, 3, 4, 10, 11, 12, 13, 14, 15, 1, 0, 3, 0x68, 3, 4, 0, 0}, // 1 + {1, 2, 3, 4, 0xff, 0xE1, 0, 10, 0x67, 2, 3, 4, 10, 11, 12, 13, 14, 15, 1, 0, 5, 0x68, 3, 4, 5, 6}, // 0 + {1, 2, 3, 4, 0xff, 0xE1, 0, 10, 0x67, 2, 3, 4, 10, 11, 12, 13, 14, 15, 1, 0, 3, 0x68, 3, 4, 0, 0}, // 1 }; UINT32 cpdSize; @@ -68,10 +66,8 @@ TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_ValidZerosInStream) TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_ValidSpsPps) { - BYTE cpd[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00, 0x1e, - 0xa9, 0x50, 0x14, 0x07, 0xb4, 0x20, 0x00, 0x00, - 0x7d, 0x00, 0x00, 0x1d, 0x4c, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x01, 0x68, 0xce, 0x3c, 0x80}; + BYTE cpd[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00, 0x1e, 0xa9, 0x50, 0x14, 0x07, 0xb4, 0x20, 0x00, 0x00, + 0x7d, 0x00, 0x00, 0x1d, 0x4c, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x3c, 0x80}; UINT32 cpdSize = SIZEOF(cpd); BYTE adaptedCpd[1000]; UINT32 adaptedCpdSize = SIZEOF(adaptedCpd); @@ -79,11 +75,8 @@ TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_ValidSpsPps) EXPECT_EQ(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, NULL, &adaptedCpdSize)); EXPECT_EQ(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(cpd, cpdSize, adaptedCpd, &adaptedCpdSize)); - BYTE cpd2[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x34, - 0xAC, 0x2B, 0x40, 0x1E, 0x00, 0x78, 0xD8, 0x08, - 0x80, 0x00, 0x01, 0xF4, 0x00, 0x00, 0xEA, 0x60, - 0x47, 0xA5, 0x50, 0x00, 0x00, 0x00, 0x01, 0x68, - 0xEE, 0x3C, 0xB0}; + BYTE cpd2[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x34, 0xAC, 0x2B, 0x40, 0x1E, 0x00, 0x78, 0xD8, 0x08, 0x80, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0xEA, 0x60, 0x47, 0xA5, 0x50, 0x00, 0x00, 0x00, 0x01, 0x68, 0xEE, 0x3C, 0xB0}; cpdSize = SIZEOF(cpd2); EXPECT_EQ(STATUS_SUCCESS, adaptH264CpdNalsFromAnnexBToAvcc(cpd2, cpdSize, NULL, &adaptedCpdSize)); @@ -94,13 +87,13 @@ TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_FixedUpValidSpsPps) { // This is taken from a real encoder that generates bad NALUs with zeroes at the end. // It also has SEI and AUD NALus - BYTE cpd[] = {0x00, 0x00, 0x00, 0x01, 0x09, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x1E, 0xAC, - 0x1B, 0x1A, 0x80, 0xB0, 0x3D, 0xFF, 0xFF, 0x00, 0x28, 0x00, 0x21, 0x6E, 0x0C, 0x0C, 0x0C, 0x80, - 0x00, 0x01, 0xF4, 0x00, 0x00, 0x75, 0x30, 0x74, 0x30, 0x07, 0xD0, 0x00, 0x01, 0x31, 0x2D, 0x5D, - 0xE5, 0xC6, 0x86, 0x00, 0xFA, 0x00, 0x00, 0x26, 0x25, 0xAB, 0xBC, 0xB8, 0x50, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x68, 0xEE, 0x38, 0x30, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0x0D, 0xBC, 0xFF, - 0x87, 0x49, 0xB5, 0x16, 0x3C, 0xFF, 0x87, 0x49, 0xB5, 0x16, 0x40, 0x01, 0x04, 0x00, 0x78, 0x08, - 0x10, 0x06, 0x01, 0xC4, 0x80,}; + BYTE cpd[] = { + 0x00, 0x00, 0x00, 0x01, 0x09, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x1E, 0xAC, 0x1B, 0x1A, 0x80, 0xB0, 0x3D, + 0xFF, 0xFF, 0x00, 0x28, 0x00, 0x21, 0x6E, 0x0C, 0x0C, 0x0C, 0x80, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x75, 0x30, 0x74, 0x30, 0x07, + 0xD0, 0x00, 0x01, 0x31, 0x2D, 0x5D, 0xE5, 0xC6, 0x86, 0x00, 0xFA, 0x00, 0x00, 0x26, 0x25, 0xAB, 0xBC, 0xB8, 0x50, 0x00, 0x00, + 0x00, 0x00, 0x01, 0x68, 0xEE, 0x38, 0x30, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0x0D, 0xBC, 0xFF, 0x87, 0x49, 0xB5, 0x16, + 0x3C, 0xFF, 0x87, 0x49, 0xB5, 0x16, 0x40, 0x01, 0x04, 0x00, 0x78, 0x08, 0x10, 0x06, 0x01, 0xC4, 0x80, + }; UINT32 cpdSize = SIZEOF(cpd); BYTE adaptedCpd[1000]; @@ -114,59 +107,51 @@ TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_FixedUpValidSpsPps) #endif } -TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_ValidH265) { +TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_ValidH265) +{ BYTE adaptedCpd[1000]; UINT32 adaptedCpdSize = SIZEOF(adaptedCpd); // These are series of codec private data bits extracted from an // Android device for H265 for various resolutions BYTE cpd[8][1000] = { - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x3c, 0xa0, 0x18, 0x20, 0x28, 0x71, 0x31, 0x39, 0x6b, 0xb9, 0x32, 0x4b, 0xb9, 0x48, 0x28, 0x10, - 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x3c, 0xa0, 0x0a, 0x08, 0x04, 0x07, 0xc4, 0xe5, 0xae, 0xe4, 0xc9, 0x2e, 0xe5, 0x20, 0xa0, 0x40, - 0x40, 0x5d, 0xa1, 0x42, 0x50, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5a, 0xa0, 0x05, 0x02, 0x01, 0xe1, 0x65, 0xae, 0xe4, 0xc9, 0x2e, 0xe5, 0x20, 0xa0, 0x40, 0x40}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5a, 0xa0, 0x06, 0x02, 0x01, 0xc1, 0xf1, 0x39, 0x6b, 0xb9, 0x32, 0x4b, 0xb9, 0x48, 0x28, 0x10, - 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5a, 0xa0, 0x05, 0xc2, 0x01, 0xe1, 0xc4, 0xf9, 0x6b, 0xb9, 0x32, 0x4b, 0xb9, 0x48, 0x28, 0x10, - 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5d, 0xa0, 0x07, 0x82, 0x00, 0xb8, 0x7c, 0x4e, 0x5a, 0xee, 0x4c, 0x92, 0xee, 0x52, 0x0a, 0x04, - 0x04, 0x05, 0xda, 0x14, 0x25, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5d, 0xa0, 0x02, 0x80, 0x80, 0x2e, 0x1f, 0x13, 0x96, 0xbb, 0x93, 0x24, 0xbb, 0x94, 0x82, 0x81, - 0x01, 0x01, 0x76, 0x85, 0x09, 0x40, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5d, 0xa0, 0x02, 0x80, 0x80, 0x3c, 0x16, 0x5a, 0xee, 0x4c, 0x92, 0xee, 0x52, 0x0a, 0x04, 0x04} - }; + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xa0, 0x18, 0x20, 0x28, 0x71, 0x31, 0x39, 0x6b, 0xb9, 0x32, 0x4b, + 0xb9, 0x48, 0x28, 0x10, 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xa0, 0x0a, 0x08, 0x04, 0x07, 0xc4, 0xe5, 0xae, 0xe4, 0xc9, 0x2e, + 0xe5, 0x20, 0xa0, 0x40, 0x40, 0x5d, 0xa1, 0x42, 0x50, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5a, 0xa0, 0x05, 0x02, 0x01, 0xe1, 0x65, 0xae, 0xe4, 0xc9, 0x2e, 0xe5, 0x20, 0xa0, 0x40, 0x40}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xa0, 0x06, 0x02, 0x01, 0xc1, 0xf1, 0x39, 0x6b, 0xb9, 0x32, 0x4b, + 0xb9, 0x48, 0x28, 0x10, 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xa0, 0x05, 0xc2, 0x01, 0xe1, 0xc4, 0xf9, 0x6b, 0xb9, 0x32, 0x4b, + 0xb9, 0x48, 0x28, 0x10, 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xa0, 0x07, 0x82, 0x00, 0xb8, 0x7c, 0x4e, 0x5a, 0xee, 0x4c, 0x92, + 0xee, 0x52, 0x0a, 0x04, 0x04, 0x05, 0xda, 0x14, 0x25, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xa0, 0x02, 0x80, 0x80, 0x2e, 0x1f, 0x13, 0x96, 0xbb, 0x93, 0x24, + 0xbb, 0x94, 0x82, 0x81, 0x01, 0x01, 0x76, 0x85, 0x09, 0x40, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5d, 0xa0, 0x02, 0x80, 0x80, 0x3c, 0x16, 0x5a, 0xee, 0x4c, 0x92, 0xee, 0x52, 0x0a, 0x04, 0x04}}; UINT32 cpdSizes[8] = {80, 80, 64, 80, 80, 80, 80, 64}; UINT32 naluCounts[8] = {3, 3, 2, 3, 3, 3, 3, 2}; @@ -174,18 +159,13 @@ TEST_F(AnnexBCpdNalAdapterTest, nalAdapter_ValidH265) { UINT16 i; for (i = 0; i < 8; i++) { - EXPECT_EQ(STATUS_SUCCESS, adaptH265CpdNalsFromAnnexBToHvcc(cpd[i], cpdSizes[i], NULL, &adaptedCpdSize)) - << "Failed on iteration " << i; - EXPECT_EQ(STATUS_SUCCESS, adaptH265CpdNalsFromAnnexBToHvcc(cpd[i], cpdSizes[i], adaptedCpd, &adaptedCpdSize)) - << "Failed on iteration " << i; + EXPECT_EQ(STATUS_SUCCESS, adaptH265CpdNalsFromAnnexBToHvcc(cpd[i], cpdSizes[i], NULL, &adaptedCpdSize)) << "Failed on iteration " << i; + EXPECT_EQ(STATUS_SUCCESS, adaptH265CpdNalsFromAnnexBToHvcc(cpd[i], cpdSizes[i], adaptedCpd, &adaptedCpdSize)) << "Failed on iteration " << i; - EXPECT_EQ(naluCounts[i], adaptedCpd[HEVC_CPD_HEADER_OVERHEAD - 1]) - << "Failed on iteration " << i; + EXPECT_EQ(naluCounts[i], adaptedCpd[HEVC_CPD_HEADER_OVERHEAD - 1]) << "Failed on iteration " << i; // The avgFrameRate should be 0 = two bytes - EXPECT_EQ(0, adaptedCpd[HEVC_CPD_HEADER_OVERHEAD - 3]) - << "Failed on iteration " << i; - EXPECT_EQ(0, adaptedCpd[HEVC_CPD_HEADER_OVERHEAD - 4]) - << "Failed on iteration " << i; + EXPECT_EQ(0, adaptedCpd[HEVC_CPD_HEADER_OVERHEAD - 3]) << "Failed on iteration " << i; + EXPECT_EQ(0, adaptedCpd[HEVC_CPD_HEADER_OVERHEAD - 4]) << "Failed on iteration " << i; } } diff --git a/tst/mkvgen/AnnexBNalAdapterTest.cpp b/tst/mkvgen/AnnexBNalAdapterTest.cpp index 18b9b35b1..56467f3ed 100644 --- a/tst/mkvgen/AnnexBNalAdapterTest.cpp +++ b/tst/mkvgen/AnnexBNalAdapterTest.cpp @@ -1,7 +1,6 @@ #include "MkvgenTestFixture.h" -class AnnexBNalAdapterTest : public MkvgenTestBase { -}; +class AnnexBNalAdapterTest : public MkvgenTestBase {}; #ifdef FIXUP_ANNEX_B_TRAILING_NALU_ZERO TEST_F(AnnexBNalAdapterTest, nalAdapter_InvalidInput) @@ -227,41 +226,41 @@ TEST_F(AnnexBNalAdapterTest, nalAdapter_ValidTrailingZeros) TEST_F(AnnexBNalAdapterTest, nalAdapter_ValidZerosInStream) { BYTE frameDatas[][10] = { - {1, 0, 0, 0, 2, 2, 2, 2, 2, 2}, // 0 - {0, 1, 0, 0, 2, 2, 2, 2, 2, 2}, // 1 - {0, 0, 1, 0, 2, 2, 2, 2, 2, 2}, // 2 - {0, 0, 0, 2, 2, 2, 2, 2, 2, 2}, // 3 - {0, 0, 0, 1, 2, 2, 2, 2, 2, 2}, // 4 - {1, 0, 0, 0, 1, 2, 2, 2, 2, 2}, // 5 - {1, 0, 0, 1, 0, 1, 2, 2, 2, 2}, // 6 - {1, 0, 0, 0, 1, 1, 2, 2, 0, 0}, // 7 - {1, 0, 0, 0, 1, 0, 0, 0, 1, 0}, // 8 - {1, 0, 0, 1, 1, 0, 0, 0, 1, 0}, // 9 - {1, 0, 0, 1, 1, 0, 0, 1, 1, 0}, // 10 - {0, 0, 1, 2, 2, 2, 2, 2, 2, 2}, // 11 - {1, 2, 3, 4, 5, 6, 7, 0, 0, 1}, // 12 - {1, 0, 0, 1, 5, 6, 7, 0, 0, 1}, // 13 - {0, 0, 1, 2, 5, 6, 7, 0, 0, 1}, // 14 + {1, 0, 0, 0, 2, 2, 2, 2, 2, 2}, // 0 + {0, 1, 0, 0, 2, 2, 2, 2, 2, 2}, // 1 + {0, 0, 1, 0, 2, 2, 2, 2, 2, 2}, // 2 + {0, 0, 0, 2, 2, 2, 2, 2, 2, 2}, // 3 + {0, 0, 0, 1, 2, 2, 2, 2, 2, 2}, // 4 + {1, 0, 0, 0, 1, 2, 2, 2, 2, 2}, // 5 + {1, 0, 0, 1, 0, 1, 2, 2, 2, 2}, // 6 + {1, 0, 0, 0, 1, 1, 2, 2, 0, 0}, // 7 + {1, 0, 0, 0, 1, 0, 0, 0, 1, 0}, // 8 + {1, 0, 0, 1, 1, 0, 0, 0, 1, 0}, // 9 + {1, 0, 0, 1, 1, 0, 0, 1, 1, 0}, // 10 + {0, 0, 1, 2, 2, 2, 2, 2, 2, 2}, // 11 + {1, 2, 3, 4, 5, 6, 7, 0, 0, 1}, // 12 + {1, 0, 0, 1, 5, 6, 7, 0, 0, 1}, // 13 + {0, 0, 1, 2, 5, 6, 7, 0, 0, 1}, // 14 }; UINT32 adaptedSizes[] = {10, 10, 11, 10, 10, 10, 11, 10, 10, 11, 12, 11, 11, 12, 12}; BYTE adaptedFrameDatas[][12] = { - {1, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0}, // 0 - {0, 1, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0}, // 1 - {0, 0, 0, 7, 0, 2, 2, 2, 2, 2, 2, 0}, // 2 - {0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0}, // 3 - {0, 0, 0, 6, 2, 2, 2, 2, 2, 2, 0, 0}, // 4 - {1, 0, 0, 0, 5, 2, 2, 2, 2, 2, 0, 0}, // 5 - {1, 0, 0, 0, 6, 0, 1, 2, 2, 2, 2, 0}, // 6 - {1, 0, 0, 0, 5, 1, 2, 2, 0, 0, 0, 0}, // 7 - {1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, // 8 - {1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0}, // 9 - {1, 0, 0, 0, 1, 1, 0, 0, 0, 2, 1, 0}, // 10 - {0, 0, 0, 7, 2, 2, 2, 2, 2, 2, 2, 0}, // 11 - {1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0}, // 12 - {1, 0, 0, 0, 3, 5, 6, 7, 0, 0, 0, 0}, // 13 - {0, 0, 0, 4, 2, 5, 6, 7, 0, 0, 0, 0}, // 14 + {1, 0, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0}, // 0 + {0, 1, 0, 0, 2, 2, 2, 2, 2, 2, 0, 0}, // 1 + {0, 0, 0, 7, 0, 2, 2, 2, 2, 2, 2, 0}, // 2 + {0, 0, 0, 2, 2, 2, 2, 2, 2, 2, 0, 0}, // 3 + {0, 0, 0, 6, 2, 2, 2, 2, 2, 2, 0, 0}, // 4 + {1, 0, 0, 0, 5, 2, 2, 2, 2, 2, 0, 0}, // 5 + {1, 0, 0, 0, 6, 0, 1, 2, 2, 2, 2, 0}, // 6 + {1, 0, 0, 0, 5, 1, 2, 2, 0, 0, 0, 0}, // 7 + {1, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0}, // 8 + {1, 0, 0, 0, 1, 1, 0, 0, 0, 1, 0, 0}, // 9 + {1, 0, 0, 0, 1, 1, 0, 0, 0, 2, 1, 0}, // 10 + {0, 0, 0, 7, 2, 2, 2, 2, 2, 2, 2, 0}, // 11 + {1, 2, 3, 4, 5, 6, 7, 0, 0, 0, 0, 0}, // 12 + {1, 0, 0, 0, 3, 5, 6, 7, 0, 0, 0, 0}, // 13 + {0, 0, 0, 4, 2, 5, 6, 7, 0, 0, 0, 0}, // 14 }; UINT32 frameDataSize; @@ -283,14 +282,11 @@ TEST_F(AnnexBNalAdapterTest, nalAdapter_ValidZerosInStream) TEST_F(AnnexBNalAdapterTest, nalAdapter_ValidSpsPpsOnly) { - BYTE frameData1[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x40, 0x1f, - 0x96, 0x54, 0x02, 0x80, 0x2d, 0xc8, 0x00, 0x00, - 0x00, 0x01, 0x68, 0xce, 0x38, 0x80}; - - BYTE frameData2[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00, 0x1e, - 0xa9, 0x50, 0x14, 0x07, 0xb4, 0x20, 0x00, 0x00, - 0x7d, 0x00, 0x00, 0x1d, 0x4c, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x01, 0x68, 0xce, 0x3c, 0x80}; + BYTE frameData1[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x40, 0x1f, 0x96, 0x54, 0x02, + 0x80, 0x2d, 0xc8, 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x38, 0x80}; + + BYTE frameData2[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00, 0x1e, 0xa9, 0x50, 0x14, 0x07, 0xb4, 0x20, 0x00, 0x00, + 0x7d, 0x00, 0x00, 0x1d, 0x4c, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x3c, 0x80}; BYTE adaptedFrameData[1000]; UINT32 adaptedFrameDataSize = SIZEOF(adaptedFrameData); @@ -313,51 +309,43 @@ TEST_F(AnnexBNalAdapterTest, nalAdapter_ValidEPB) // These are series of codec private data bits extracted from an // Android device for H265 for various resolutions BYTE frames[8][1000] = { - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x3c, 0xa0, 0x18, 0x20, 0x28, 0x71, 0x31, 0x39, 0x6b, 0xb9, 0x32, 0x4b, 0xb9, 0x48, 0x28, 0x10, - 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x3c, 0xa0, 0x0a, 0x08, 0x04, 0x07, 0xc4, 0xe5, 0xae, 0xe4, 0xc9, 0x2e, 0xe5, 0x20, 0xa0, 0x40, - 0x40, 0x5d, 0xa1, 0x42, 0x50, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5a, 0xa0, 0x05, 0x02, 0x01, 0xe1, 0x65, 0xae, 0xe4, 0xc9, 0x2e, 0xe5, 0x20, 0xa0, 0x40, 0x40}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5a, 0xa0, 0x06, 0x02, 0x01, 0xc1, 0xf1, 0x39, 0x6b, 0xb9, 0x32, 0x4b, 0xb9, 0x48, 0x28, 0x10, - 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5a, 0xa0, 0x05, 0xc2, 0x01, 0xe1, 0xc4, 0xf9, 0x6b, 0xb9, 0x32, 0x4b, 0xb9, 0x48, 0x28, 0x10, - 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5d, 0xa0, 0x07, 0x82, 0x00, 0xb8, 0x7c, 0x4e, 0x5a, 0xee, 0x4c, 0x92, 0xee, 0x52, 0x0a, 0x04, - 0x04, 0x05, 0xda, 0x14, 0x25, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5d, 0xa0, 0x02, 0x80, 0x80, 0x2e, 0x1f, 0x13, 0x96, 0xbb, 0x93, 0x24, 0xbb, 0x94, 0x82, 0x81, - 0x01, 0x01, 0x76, 0x85, 0x09, 0x40, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5d, 0xa0, 0x02, 0x80, 0x80, 0x3c, 0x16, 0x5a, 0xee, 0x4c, 0x92, 0xee, 0x52, 0x0a, 0x04, 0x04}, + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xa0, 0x18, 0x20, 0x28, 0x71, 0x31, 0x39, 0x6b, 0xb9, 0x32, 0x4b, + 0xb9, 0x48, 0x28, 0x10, 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xa0, 0x0a, 0x08, 0x04, 0x07, 0xc4, 0xe5, 0xae, 0xe4, 0xc9, 0x2e, + 0xe5, 0x20, 0xa0, 0x40, 0x40, 0x5d, 0xa1, 0x42, 0x50, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5a, 0xa0, 0x05, 0x02, 0x01, 0xe1, 0x65, 0xae, 0xe4, 0xc9, 0x2e, 0xe5, 0x20, 0xa0, 0x40, 0x40}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xa0, 0x06, 0x02, 0x01, 0xc1, 0xf1, 0x39, 0x6b, 0xb9, 0x32, 0x4b, + 0xb9, 0x48, 0x28, 0x10, 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xa0, 0x05, 0xc2, 0x01, 0xe1, 0xc4, 0xf9, 0x6b, 0xb9, 0x32, 0x4b, + 0xb9, 0x48, 0x28, 0x10, 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xa0, 0x07, 0x82, 0x00, 0xb8, 0x7c, 0x4e, 0x5a, 0xee, 0x4c, 0x92, + 0xee, 0x52, 0x0a, 0x04, 0x04, 0x05, 0xda, 0x14, 0x25, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xa0, 0x02, 0x80, 0x80, 0x2e, 0x1f, 0x13, 0x96, 0xbb, 0x93, 0x24, + 0xbb, 0x94, 0x82, 0x81, 0x01, 0x01, 0x76, 0x85, 0x09, 0x40, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5d, 0xa0, 0x02, 0x80, 0x80, 0x3c, 0x16, 0x5a, 0xee, 0x4c, 0x92, 0xee, 0x52, 0x0a, 0x04, 0x04}, }; UINT32 frameSizes[8] = {80, 80, 64, 80, 80, 80, 80, 64}; @@ -366,12 +354,16 @@ TEST_F(AnnexBNalAdapterTest, nalAdapter_ValidEPB) for (i = 0; i < ARRAY_SIZE(frameSizes); i++) { adaptedFrameDataSize = 0; - EXPECT_EQ(STATUS_SUCCESS, adaptFrameNalsFromAnnexBToAvcc(frames[i], frameSizes[i], TRUE, NULL, &adaptedFrameDataSize)) << "Failed on iteration " << i; - EXPECT_EQ(STATUS_SUCCESS, adaptFrameNalsFromAnnexBToAvcc(frames[i], frameSizes[i], TRUE, adaptedFrameData, &adaptedFrameDataSize)) << "Failed on iteration " << i; + EXPECT_EQ(STATUS_SUCCESS, adaptFrameNalsFromAnnexBToAvcc(frames[i], frameSizes[i], TRUE, NULL, &adaptedFrameDataSize)) + << "Failed on iteration " << i; + EXPECT_EQ(STATUS_SUCCESS, adaptFrameNalsFromAnnexBToAvcc(frames[i], frameSizes[i], TRUE, adaptedFrameData, &adaptedFrameDataSize)) + << "Failed on iteration " << i; adaptedFrameDataSize = 0; - EXPECT_EQ(STATUS_SUCCESS, adaptFrameNalsFromAnnexBToAvcc(frames[i], frameSizes[i], FALSE, NULL, &adaptedFrameDataSize)) << "Failed on iteration " << i; - EXPECT_EQ(STATUS_SUCCESS, adaptFrameNalsFromAnnexBToAvcc(frames[i], frameSizes[i], FALSE, adaptedFrameData, &adaptedFrameDataSize)) << "Failed on iteration " << i; + EXPECT_EQ(STATUS_SUCCESS, adaptFrameNalsFromAnnexBToAvcc(frames[i], frameSizes[i], FALSE, NULL, &adaptedFrameDataSize)) + << "Failed on iteration " << i; + EXPECT_EQ(STATUS_SUCCESS, adaptFrameNalsFromAnnexBToAvcc(frames[i], frameSizes[i], FALSE, adaptedFrameData, &adaptedFrameDataSize)) + << "Failed on iteration " << i; } } @@ -379,14 +371,14 @@ TEST_F(AnnexBNalAdapterTest, nalAdapter_ValidEPB) TEST_F(AnnexBNalAdapterTest, nalAdapter_badRealLifeEncoderSampleWithFix) { // I-frame from a real-life encoder output which is actually invalid Annex-B format (shortened after a few bytes of the actual frame) - BYTE frameData[] = {0x00, 0x00, 0x00, 0x01, 0x09, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x1E, 0xAC, - 0x1B, 0x1A, 0x80, 0xB0, 0x3D, 0xFF, 0xFF, 0x00, 0x28, 0x00, 0x21, 0x6E, 0x0C, 0x0C, 0x0C, 0x80, - 0x00, 0x01, 0xF4, 0x00, 0x00, 0x75, 0x30, 0x74, 0x30, 0x07, 0xD0, 0x00, 0x01, 0x31, 0x2D, 0x5D, - 0xE5, 0xC6, 0x86, 0x00, 0xFA, 0x00, 0x00, 0x26, 0x25, 0xAB, 0xBC, 0xB8, 0x50, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x68, 0xEE, 0x38, 0x30, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0x0D, 0xBC, 0xFF, - 0x87, 0x49, 0xB5, 0x16, 0x3C, 0xFF, 0x87, 0x49, 0xB5, 0x16, 0x40, 0x01, 0x04, 0x00, 0x78, 0x08, - 0x10, 0x06, 0x01, 0xC4, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x65, 0xB8, 0x00, 0x02, 0x00, 0x00, - 0x03, 0x02, 0x7F, 0xEC, 0x0E, 0xD0, 0xE1, 0xA7, 0x9D, 0xA3, 0x7C, 0x49, 0x42, 0xC2, 0x23, 0x59,}; + BYTE frameData[] = { + 0x00, 0x00, 0x00, 0x01, 0x09, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x1E, 0xAC, 0x1B, 0x1A, 0x80, 0xB0, 0x3D, 0xFF, + 0xFF, 0x00, 0x28, 0x00, 0x21, 0x6E, 0x0C, 0x0C, 0x0C, 0x80, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x75, 0x30, 0x74, 0x30, 0x07, 0xD0, 0x00, + 0x01, 0x31, 0x2D, 0x5D, 0xE5, 0xC6, 0x86, 0x00, 0xFA, 0x00, 0x00, 0x26, 0x25, 0xAB, 0xBC, 0xB8, 0x50, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x68, 0xEE, 0x38, 0x30, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0x0D, 0xBC, 0xFF, 0x87, 0x49, 0xB5, 0x16, 0x3C, 0xFF, 0x87, 0x49, + 0xB5, 0x16, 0x40, 0x01, 0x04, 0x00, 0x78, 0x08, 0x10, 0x06, 0x01, 0xC4, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x65, 0xB8, 0x00, 0x02, + 0x00, 0x00, 0x03, 0x02, 0x7F, 0xEC, 0x0E, 0xD0, 0xE1, 0xA7, 0x9D, 0xA3, 0x7C, 0x49, 0x42, 0xC2, 0x23, 0x59, + }; BYTE adaptedFrameData[1000]; UINT32 adaptedFrameDataSize = SIZEOF(adaptedFrameData); @@ -418,8 +410,7 @@ TEST_F(AnnexBNalAdapterTest, nalAdapter_badRealLifeEncoderSampleWithFix) // Extract the SPS and PPS PBYTE pSps, pPps; UINT32 spsSize, ppsSize; - EXPECT_EQ(STATUS_SUCCESS, - getH264SpsPpsNalusFromAvccNalus(adaptedFrameData, adaptedFrameDataSize, &pSps, &spsSize, &pPps, &ppsSize)); + EXPECT_EQ(STATUS_SUCCESS, getH264SpsPpsNalusFromAvccNalus(adaptedFrameData, adaptedFrameDataSize, &pSps, &spsSize, &pPps, &ppsSize)); EXPECT_TRUE(pSps != NULL); EXPECT_EQ(50, spsSize); diff --git a/tst/mkvgen/AudioCpdParserTest.cpp b/tst/mkvgen/AudioCpdParserTest.cpp index b36baa975..846e127e7 100644 --- a/tst/mkvgen/AudioCpdParserTest.cpp +++ b/tst/mkvgen/AudioCpdParserTest.cpp @@ -1,7 +1,6 @@ #include "MkvgenTestFixture.h" -class AudioCpdParserTest : public MkvgenTestBase { -}; +class AudioCpdParserTest : public MkvgenTestBase {}; TEST_F(AudioCpdParserTest, audioCpdParser_InvalidInput) { @@ -52,7 +51,8 @@ TEST_F(AudioCpdParserTest, audioCpdParser_invalidSamplingFrequencyIndex) DOUBLE samplingFrequency; UINT16 channelConfig; - EXPECT_EQ(STATUS_MKV_INVALID_AAC_CPD_SAMPLING_FREQUENCY_INDEX, getSamplingFreqAndChannelFromAacCpd(cpd, cpdSize, &samplingFrequency, &channelConfig)); + EXPECT_EQ(STATUS_MKV_INVALID_AAC_CPD_SAMPLING_FREQUENCY_INDEX, + getSamplingFreqAndChannelFromAacCpd(cpd, cpdSize, &samplingFrequency, &channelConfig)); } TEST_F(AudioCpdParserTest, audioCpdParser_invalidChannelConfig) @@ -65,7 +65,8 @@ TEST_F(AudioCpdParserTest, audioCpdParser_invalidChannelConfig) EXPECT_EQ(STATUS_MKV_INVALID_AAC_CPD_CHANNEL_CONFIG, getSamplingFreqAndChannelFromAacCpd(cpd, cpdSize, &samplingFrequency, &channelConfig)); } -TEST_F(AudioCpdParserTest, generateAacCpdTest) { +TEST_F(AudioCpdParserTest, generateAacCpdTest) +{ BYTE cpd[] = {0x11, 0x90}; UINT32 samplingFrequency = 48000; UINT16 channelConfig = 2; @@ -74,14 +75,12 @@ TEST_F(AudioCpdParserTest, generateAacCpdTest) { EXPECT_EQ(STATUS_NULL_ARG, mkvgenGenerateAacCpd(AAC_LC, samplingFrequency, channelConfig, NULL, cpdSize)); // invalid cpd size - EXPECT_EQ(STATUS_INVALID_ARG, - mkvgenGenerateAacCpd(AAC_LC, samplingFrequency, channelConfig, buffer, KVS_AAC_CPD_SIZE_BYTE - 1)); + EXPECT_EQ(STATUS_INVALID_ARG, mkvgenGenerateAacCpd(AAC_LC, samplingFrequency, channelConfig, buffer, KVS_AAC_CPD_SIZE_BYTE - 1)); // invalid sampling frequency EXPECT_EQ(STATUS_INVALID_ARG, mkvgenGenerateAacCpd(AAC_LC, 12345, channelConfig, buffer, cpdSize)); // invalid channel config EXPECT_EQ(STATUS_INVALID_ARG, mkvgenGenerateAacCpd(AAC_LC, samplingFrequency, 0, buffer, cpdSize)); - EXPECT_EQ(STATUS_INVALID_ARG, - mkvgenGenerateAacCpd(AAC_LC, samplingFrequency, MKV_AAC_CHANNEL_CONFIG_MAX, buffer, cpdSize)); + EXPECT_EQ(STATUS_INVALID_ARG, mkvgenGenerateAacCpd(AAC_LC, samplingFrequency, MKV_AAC_CHANNEL_CONFIG_MAX, buffer, cpdSize)); EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateAacCpd(AAC_LC, samplingFrequency, channelConfig, buffer, cpdSize)); EXPECT_EQ(0, MEMCMP(cpd, buffer, cpdSize)); @@ -103,8 +102,10 @@ TEST_F(AudioCpdParserTest, generatePcmCpdTest) // NULL buffer EXPECT_EQ(STATUS_NULL_ARG, mkvgenGeneratePcmCpd(KVS_PCM_FORMAT_CODE_ALAW, samplingFrequency, channelConfig, NULL, 0)); // invalid sampling frequency - EXPECT_EQ(STATUS_INVALID_ARG, mkvgenGeneratePcmCpd(KVS_PCM_FORMAT_CODE_ALAW, MIN_PCM_SAMPLING_RATE - 1, channelConfig, buffer, ARRAY_SIZE(buffer))); - EXPECT_EQ(STATUS_INVALID_ARG, mkvgenGeneratePcmCpd(KVS_PCM_FORMAT_CODE_ALAW, MAX_PCM_SAMPLING_RATE + 1, channelConfig, buffer, ARRAY_SIZE(buffer))); + EXPECT_EQ(STATUS_INVALID_ARG, + mkvgenGeneratePcmCpd(KVS_PCM_FORMAT_CODE_ALAW, MIN_PCM_SAMPLING_RATE - 1, channelConfig, buffer, ARRAY_SIZE(buffer))); + EXPECT_EQ(STATUS_INVALID_ARG, + mkvgenGeneratePcmCpd(KVS_PCM_FORMAT_CODE_ALAW, MAX_PCM_SAMPLING_RATE + 1, channelConfig, buffer, ARRAY_SIZE(buffer))); // invalid channel config EXPECT_EQ(STATUS_INVALID_ARG, mkvgenGeneratePcmCpd(KVS_PCM_FORMAT_CODE_ALAW, samplingFrequency, 0, buffer, ARRAY_SIZE(buffer))); EXPECT_EQ(STATUS_INVALID_ARG, mkvgenGeneratePcmCpd(KVS_PCM_FORMAT_CODE_ALAW, samplingFrequency, 3, buffer, ARRAY_SIZE(buffer))); @@ -123,4 +124,3 @@ TEST_F(AudioCpdParserTest, generatePcmCpdTest) EXPECT_EQ(STATUS_SUCCESS, mkvgenGeneratePcmCpd(KVS_PCM_FORMAT_CODE_ALAW, samplingFrequency, 1, buffer, ARRAY_SIZE(buffer))); EXPECT_EQ(STATUS_SUCCESS, mkvgenGeneratePcmCpd(KVS_PCM_FORMAT_CODE_ALAW, samplingFrequency, 2, buffer, ARRAY_SIZE(buffer))); } - diff --git a/tst/mkvgen/AvccNalAdapterTest.cpp b/tst/mkvgen/AvccNalAdapterTest.cpp index e4ca04d54..9ec15524f 100644 --- a/tst/mkvgen/AvccNalAdapterTest.cpp +++ b/tst/mkvgen/AvccNalAdapterTest.cpp @@ -1,7 +1,6 @@ #include "MkvgenTestFixture.h" -class AvccNalAdapterTest : public MkvgenTestBase { -}; +class AvccNalAdapterTest : public MkvgenTestBase {}; TEST_F(AvccNalAdapterTest, nalAdapter_InvalidInput) { @@ -113,10 +112,10 @@ TEST_F(AvccNalAdapterTest, nalAdapter_OutOfBounds) { UINT32 frameDataSize; BYTE frameDatas[][21] = { - {0, 0, 0, 4, 2, 3, 4, 5, 0, 0, 0, 10, 0, 0, 0, 1, 6, 0, 0, 0, 0}, // 0 - {0, 0, 0, 4, 2, 3, 4, 5, 0, 0, 0, 8, 0, 0, 0, 1, 6, 0, 0, 0, 0}, // 1 - {0, 0, 0, 4, 2, 3, 4, 5, 0, 0, 0, 7, 0, 0, 0, 1, 6, 0, 0, 0, 0}, // 1 - {0, 0, 0, 4, 2, 3, 4, 5, 0, 0, 0, 6, 0, 0, 0, 1, 6, 0, 0, 0, 0}, // 1 + {0, 0, 0, 4, 2, 3, 4, 5, 0, 0, 0, 10, 0, 0, 0, 1, 6, 0, 0, 0, 0}, // 0 + {0, 0, 0, 4, 2, 3, 4, 5, 0, 0, 0, 8, 0, 0, 0, 1, 6, 0, 0, 0, 0}, // 1 + {0, 0, 0, 4, 2, 3, 4, 5, 0, 0, 0, 7, 0, 0, 0, 1, 6, 0, 0, 0, 0}, // 1 + {0, 0, 0, 4, 2, 3, 4, 5, 0, 0, 0, 6, 0, 0, 0, 1, 6, 0, 0, 0, 0}, // 1 }; for (UINT32 i = 0; i < SIZEOF(frameDatas) / SIZEOF(frameDatas[0]); i++) { diff --git a/tst/mkvgen/MkvgenApiFunctionalityTest.cpp b/tst/mkvgen/MkvgenApiFunctionalityTest.cpp index 66c735c0c..dbb85711f 100644 --- a/tst/mkvgen/MkvgenApiFunctionalityTest.cpp +++ b/tst/mkvgen/MkvgenApiFunctionalityTest.cpp @@ -1,7 +1,6 @@ #include "MkvgenTestFixture.h" -class MkvgenApiFunctionalityTest : public MkvgenTestBase { -}; +class MkvgenApiFunctionalityTest : public MkvgenTestBase {}; TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_ClusterBoundaryKeyFrame) { @@ -14,8 +13,9 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_ClusterBoundaryKeyFrame) TrackInfo trackInfo; trackInfo.trackId = MKV_TEST_TRACKID; - EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator))); + EXPECT_TRUE( + STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator))); // Add a Non-key frame EXPECT_TRUE(STATUS_SUCCEEDED(mkvgenPackageFrame(mkvGenerator, &frame, &trackInfo, mBuffer, &size, &encodedFrameInfo))); @@ -68,9 +68,9 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_LargeFrameTimecode) TrackInfo trackInfo; trackInfo.trackId = MKV_TEST_TRACKID; - EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MIN_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, - mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator))); + EXPECT_TRUE( + STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MIN_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator))); // Add a Non-key frame EXPECT_TRUE(STATUS_SUCCEEDED(mkvgenPackageFrame(mkvGenerator, &frame, &trackInfo, mBuffer, &size, &encodedFrameInfo))); @@ -99,7 +99,8 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvFromJpegAsH2 Frame frame = {FRAME_CURRENT_VERSION, 0, FRAME_FLAG_KEY_FRAME, 0, 0, frameDuration, 0, frameBuf, MKV_TEST_TRACKID}; UINT32 i, cpdSize, index; UINT64 fileSize; - BYTE cpd[] = {0x01, 0x42, 0x40, 0x15, 0xFF, 0xE1, 0x00, 0x09, 0x67, 0x42, 0x40, 0x28, 0x96, 0x54, 0x0a, 0x0f, 0xc8, 0x01, 0x00, 0x04, 0x68, 0xce, 0x3c, 0x80}; + BYTE cpd[] = {0x01, 0x42, 0x40, 0x15, 0xFF, 0xE1, 0x00, 0x09, 0x67, 0x42, 0x40, 0x28, + 0x96, 0x54, 0x0a, 0x0f, 0xc8, 0x01, 0x00, 0x04, 0x68, 0xce, 0x3c, 0x80}; CHAR tagName[MKV_MAX_TAG_NAME_LEN]; CHAR tagVal[MKV_MAX_TAG_VALUE_LEN]; TrackInfo trackInfo; @@ -111,9 +112,9 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvFromJpegAsH2 mTrackInfo.codecPrivateData = cpd; // Pretend it's h264 to enforce the video width and height inclusion in the track info - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H264_CONTENT_TYPE, MKV_GEN_IN_STREAM_TIME, MKV_TEST_TIMECODE_SCALE, - 2 * HUNDREDS_OF_NANOS_IN_A_SECOND, MKV_TEST_SEGMENT_UUID, &mTrackInfo, - mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H264_CONTENT_TYPE, MKV_GEN_IN_STREAM_TIME, MKV_TEST_TIMECODE_SCALE, 2 * HUNDREDS_OF_NANOS_IN_A_SECOND, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator)); for (i = 0, index = 0; i < 100; i++) { SNPRINTF(fileName, MAX_PATH_LEN, (PCHAR) "samples" FPATHSEPARATOR_STR "gif%03d.jpg", i); fileSize = MKV_TEST_BUFFER_SIZE; @@ -127,15 +128,13 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvFromJpegAsH2 frame.index = i; frame.presentationTs = frameDuration * i; frame.decodingTs = frameDuration * i; - frame.size = (UINT32)fileSize; + frame.size = (UINT32) fileSize; // Add a frame packagedSize = size; EXPECT_EQ(STATUS_SUCCESS, mkvgenPackageFrame(mkvGenerator, &frame, &trackInfo, mkvBuffer + index, &packagedSize, NULL)); index += packagedSize; size -= packagedSize; - - } // Add tags @@ -143,11 +142,7 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvFromJpegAsH2 packagedSize = size; SNPRINTF(tagName, MKV_MAX_TAG_NAME_LEN, "testTag_%d", i); SNPRINTF(tagVal, MKV_MAX_TAG_VALUE_LEN, "testTag_%d_Value", i); - EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTag(mkvGenerator, - mkvBuffer + index, - tagName, - tagVal, - &packagedSize)); + EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTag(mkvGenerator, mkvBuffer + index, tagName, tagVal, &packagedSize)); index += packagedSize; size -= packagedSize; } @@ -171,11 +166,8 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvFromJpegAsFo Frame frame = {FRAME_CURRENT_VERSION, 0, FRAME_FLAG_KEY_FRAME, 0, 0, frameDuration, 0, frameBuf, MKV_TEST_TRACKID}; UINT32 i, cpdSize, index; UINT64 fileSize; - BYTE cpd[] = {0x28, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, - 0xe0, 0x01, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, - 0x4d, 0x4a, 0x50, 0x47, 0x00, 0x10, 0x0e, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + BYTE cpd[] = {0x28, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x4d, 0x4a, 0x50, 0x47, + 0x00, 0x10, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; CHAR tagName[MKV_MAX_TAG_NAME_LEN]; CHAR tagVal[MKV_MAX_TAG_VALUE_LEN]; TrackInfo trackInfo; @@ -187,9 +179,9 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvFromJpegAsFo mTrackInfo.codecPrivateData = cpd; // This is a M-JPG to enforce the video width and height inclusion in the track info - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_X_MKV_VIDEO_CONTENT_TYPE, MKV_GEN_IN_STREAM_TIME, MKV_TEST_TIMECODE_SCALE, - 2 * HUNDREDS_OF_NANOS_IN_A_SECOND, MKV_TEST_SEGMENT_UUID, &mTrackInfo, - mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_X_MKV_VIDEO_CONTENT_TYPE, MKV_GEN_IN_STREAM_TIME, MKV_TEST_TIMECODE_SCALE, 2 * HUNDREDS_OF_NANOS_IN_A_SECOND, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator)); for (i = 0, index = 0; i < 100; i++) { SNPRINTF(fileName, 24, (PCHAR) "samples" FPATHSEPARATOR_STR "gif%03d.jpg", i); @@ -203,7 +195,7 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvFromJpegAsFo frame.index = i; frame.presentationTs = frameDuration * i; frame.decodingTs = frameDuration * i; - frame.size = (UINT32)fileSize; + frame.size = (UINT32) fileSize; // Add a frame packagedSize = size; @@ -217,11 +209,7 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvFromJpegAsFo packagedSize = size; SNPRINTF(tagName, 16, (PCHAR) "testTag_%d", i); SNPRINTF(tagVal, 16, (PCHAR) "testTag_%d_Value", i); - EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTag(mkvGenerator, - mkvBuffer + index, - tagName, - tagVal, - &packagedSize)); + EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTag(mkvGenerator, mkvBuffer + index, tagName, tagVal, &packagedSize)); index += packagedSize; size -= packagedSize; } @@ -244,28 +232,16 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvTagsOnly) STRCPY(mTrackInfo.codecId, (PCHAR) "V_MJPEG"); // Pretend it's h264 to enforce the video width and height inclusion in the track info - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H264_CONTENT_TYPE, - MKV_GEN_IN_STREAM_TIME, - MKV_TEST_TIMECODE_SCALE, - 2 * HUNDREDS_OF_NANOS_IN_A_SECOND, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &mkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H264_CONTENT_TYPE, MKV_GEN_IN_STREAM_TIME, MKV_TEST_TIMECODE_SCALE, 2 * HUNDREDS_OF_NANOS_IN_A_SECOND, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator)); // Add tags for (i = 0; i < MKV_TEST_TAG_COUNT; i++) { packagedSize = size; SNPRINTF(tagName, 16, (PCHAR) "testTag_%d", i); SNPRINTF(tagVal, 24, (PCHAR) "testTag_%d_Value", i); - EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTag(mkvGenerator, - mkvBuffer + index, - tagName, - tagVal, - &packagedSize)); + EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTag(mkvGenerator, mkvBuffer + index, tagName, tagVal, &packagedSize)); index += packagedSize; size -= packagedSize; } @@ -275,7 +251,8 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvTagsOnly) EXPECT_EQ(STATUS_SUCCESS, freeMkvGenerator(mkvGenerator)); } -TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvMixedTags) { +TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvMixedTags) +{ PMkvGenerator mkvGenerator; BYTE frameBuf[100]; UINT32 size = 5000000, packagedSize; @@ -283,11 +260,8 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvMixedTags) { UINT64 frameDuration = 500 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND; Frame frame = {FRAME_CURRENT_VERSION, 0, FRAME_FLAG_NONE, 0, 0, frameDuration, SIZEOF(frameBuf), frameBuf, MKV_TEST_TRACKID}; UINT32 frameIndex, i, cpdSize, index = 0; - BYTE cpd[] = {0x28, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, - 0xe0, 0x01, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, - 0x4d, 0x4a, 0x50, 0x47, 0x00, 0x10, 0x0e, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + BYTE cpd[] = {0x28, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x4d, 0x4a, 0x50, 0x47, + 0x00, 0x10, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; CHAR tagName[MKV_MAX_TAG_NAME_LEN]; CHAR tagVal[MKV_MAX_TAG_VALUE_LEN]; TrackInfo trackInfo; @@ -299,11 +273,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvMixedTags) { mTrackInfo.codecPrivateDataSize = cpdSize; mTrackInfo.codecPrivateData = cpd; - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_X_MKV_VIDEO_CONTENT_TYPE, - MKV_GEN_IN_STREAM_TIME | MKV_GEN_KEY_FRAME_PROCESSING, - MKV_TEST_TIMECODE_SCALE, 2 * HUNDREDS_OF_NANOS_IN_A_SECOND, - MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, - MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_X_MKV_VIDEO_CONTENT_TYPE, MKV_GEN_IN_STREAM_TIME | MKV_GEN_KEY_FRAME_PROCESSING, MKV_TEST_TIMECODE_SCALE, + 2 * HUNDREDS_OF_NANOS_IN_A_SECOND, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &mkvGenerator)); // Generate a key-frame every 10th frame for (frameIndex = 0; frameIndex < 100; frameIndex++) { @@ -318,11 +291,7 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvMixedTags) { packagedSize = size; SNPRINTF(tagName, 16, (PCHAR) "testTag_%d", i); SNPRINTF(tagVal, 24, "(PCHAR) testTag_%d_Value", i); - EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTag(mkvGenerator, - mkvBuffer + index, - tagName, - tagVal, - &packagedSize)); + EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTag(mkvGenerator, mkvBuffer + index, tagName, tagVal, &packagedSize)); index += packagedSize; size -= packagedSize; } @@ -330,12 +299,7 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvMixedTags) { // Add a frame packagedSize = size; - EXPECT_EQ(STATUS_SUCCESS, mkvgenPackageFrame(mkvGenerator, - &frame, - &trackInfo, - mkvBuffer + index, - &packagedSize, - NULL)); + EXPECT_EQ(STATUS_SUCCESS, mkvgenPackageFrame(mkvGenerator, &frame, &trackInfo, mkvBuffer + index, &packagedSize, NULL)); index += packagedSize; size -= packagedSize; } @@ -345,11 +309,7 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CreateStoreMkvMixedTags) { packagedSize = size; SNPRINTF(tagName, 16, (PCHAR) "testTag_%d", i); SNPRINTF(tagVal, 24, (PCHAR) "testTag_%d_Value", i); - EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTag(mkvGenerator, - mkvBuffer + index, - tagName, - tagVal, - &packagedSize)); + EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTag(mkvGenerator, mkvBuffer + index, tagName, tagVal, &packagedSize)); index += packagedSize; size -= packagedSize; } @@ -377,17 +337,9 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_CodecPrivateData) cpdSize = cpdSizes[i]; mTrackInfo.codecPrivateDataSize = cpdSize; mTrackInfo.codecPrivateData = tempBuffer; - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_TEST_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &mkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator)); // Add a frame size = MKV_TEST_BUFFER_SIZE; @@ -426,17 +378,9 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_ClusterBoundaryNonKeyFrame TrackInfo trackInfo; trackInfo.trackId = MKV_TEST_TRACKID; - EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, - MKV_GEN_IN_STREAM_TIME, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &mkvGenerator))); + EXPECT_TRUE( + STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_GEN_IN_STREAM_TIME, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator))); // Add a Non-key frame EXPECT_TRUE(STATUS_SUCCEEDED(mkvgenPackageFrame(mkvGenerator, &frame, &trackInfo, NULL, &size, &encodedFrameInfo))); @@ -541,10 +485,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_TimeCallbackCalls) TrackInfo trackInfo; trackInfo.trackId = MKV_TEST_TRACKID; - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_GEN_KEY_FRAME_PROCESSING, MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, - mTrackInfoCount, MKV_TEST_CLIENT_ID, getTimeCallback, - MKV_TEST_CUSTOM_DATA, &mkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_GEN_KEY_FRAME_PROCESSING, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, getTimeCallback, MKV_TEST_CUSTOM_DATA, + &mkvGenerator)); // Add a key frame - get size first EXPECT_EQ(STATUS_SUCCESS, mkvgenPackageFrame(mkvGenerator, &frame, &trackInfo, NULL, &size, NULL)); @@ -581,11 +525,9 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenPackageFrame_TimeCallbackCallsNotCalled TrackInfo trackInfo; trackInfo.trackId = MKV_TEST_TRACKID; - EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, - MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, - MKV_TEST_CLIENT_ID, getTimeCallback, - MKV_TEST_CUSTOM_DATA, &mkvGenerator))); + EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, + MKV_TEST_CLIENT_ID, getTimeCallback, MKV_TEST_CUSTOM_DATA, &mkvGenerator))); // Add a key frame - get size first EXPECT_TRUE(STATUS_SUCCEEDED(mkvgenPackageFrame(mkvGenerator, &frame, &trackInfo, NULL, &size, NULL))); @@ -619,10 +561,9 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenResetGenerator_Variations) TrackInfo trackInfo; trackInfo.trackId = MKV_TEST_TRACKID; - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, - MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, - MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator)); // Add a Non-key frame EXPECT_EQ(STATUS_SUCCESS, mkvgenPackageFrame(mkvGenerator, &frame, &trackInfo, mBuffer, &size, &encodedFrameInfo)); @@ -695,17 +636,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenResetGeneratorWithAvccAdaptation_Variat putInt32((PINT32) (frame.frameData + i), runSize); } - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_TEST_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_AVCC_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &mkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_AVCC_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &mkvGenerator)); // Add a Non-key frame EXPECT_EQ(STATUS_SUCCESS, mkvgenPackageFrame(mkvGenerator, &frame, &trackInfo, mBuffer, &size, &encodedFrameInfo)); @@ -785,17 +719,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenResetGeneratorWithAnnexBAdaptation_Vari adaptedSize = SIZEOF(frameBuf) / 100 + SIZEOF(frameBuf); // Try for non-video track type. The frame shouldn't get adapted - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_TEST_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &mkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &mkvGenerator)); // Add a Non-key frame EXPECT_EQ(STATUS_SUCCESS, mkvgenPackageFrame(mkvGenerator, &frame, &trackInfo, mBuffer, &size, &encodedFrameInfo)); @@ -807,17 +734,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenResetGeneratorWithAnnexBAdaptation_Vari trackInfo.trackType = MKV_TRACK_INFO_TYPE_VIDEO; // Try for non-video track type. The frame shouldn't get adapted - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_TEST_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &mkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &mkvGenerator)); size = MKV_TEST_BUFFER_SIZE; // Add a Non-key frame @@ -878,8 +798,8 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenMkvTracksHeaderWithMultipleTrack) PMkvGenerator pMkvGenerator; UINT32 size = MKV_TEST_BUFFER_SIZE; BYTE videoCpd[] = {0x01, 0x4d, 0x00, 0x20, 0xff, 0xe1, 0x00, 0x23, 0x27, 0x4d, 0x00, 0x20, 0x89, 0x8b, 0x60, 0x28, 0x02, - 0xdd, 0x80, 0x9e, 0x00, 0x00, 0x4e, 0x20, 0x00, 0x0f, 0x42, 0x41, 0xc0, 0xc0, 0x01, 0x77, 0x00, 0x00, - 0x5d, 0xc1, 0x7b, 0xdf, 0x07, 0xc2, 0x21, 0x1b, 0x80, 0x01, 0x00, 0x04, 0x28, 0xee, 0x1f, 0x20}; + 0xdd, 0x80, 0x9e, 0x00, 0x00, 0x4e, 0x20, 0x00, 0x0f, 0x42, 0x41, 0xc0, 0xc0, 0x01, 0x77, 0x00, 0x00, + 0x5d, 0xc1, 0x7b, 0xdf, 0x07, 0xc2, 0x21, 0x1b, 0x80, 0x01, 0x00, 0x04, 0x28, 0xee, 0x1f, 0x20}; UINT32 videoCpdSize = SIZEOF(videoCpd); BYTE audioCpd[] = {0x12, 0x10, 0x56, 0xe5, 0x00}; UINT32 audioCpdSize = SIZEOF(audioCpd); @@ -917,17 +837,9 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenMkvTracksHeaderWithMultipleTrack) UINT32 mkvTracksElementSize = 0; UINT32 encodedCpdLen = 0; - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H264_AAC_MULTI_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - testTrackInfo, - testTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H264_AAC_MULTI_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, testTrackInfo, testTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); UINT32 encodedLen; mkvgenEbmlEncodeSegmentInfo((PStreamMkvGenerator) pMkvGenerator, NULL, 0, &encodedLen); EXPECT_EQ(STATUS_SUCCESS, mkvgenPackageFrame(pMkvGenerator, &frame, &trackInfo, mBuffer, &size, &encodedFrameInfo)); @@ -951,10 +863,7 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenMkvTracksHeaderWithMultipleTrack) pCurrentPnt += 4; // Calculate the EBML encoded cpd size for video cpd - mkvgenEbmlEncodeNumber(videoCpdSize, - NULL, - 0, - &encodedCpdLen); + mkvgenEbmlEncodeNumber(videoCpdSize, NULL, 0, &encodedCpdLen); // Jump to the beginning of video cpd bits. mkvgenGetMkvTrackHeaderSize includes MKV_TRACKS_ELEM_BITS_SIZE but we just // want the track entry size, therefore subtract MKV_TRACKS_ELEM_BITS_SIZE @@ -966,10 +875,7 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenMkvTracksHeaderWithMultipleTrack) // Jump to the beginning of audio cpd bits pCurrentPnt += videoCpdSize; - mkvgenEbmlEncodeNumber(audioCpdSize, - NULL, - 0, - &encodedCpdLen); + mkvgenEbmlEncodeNumber(audioCpdSize, NULL, 0, &encodedCpdLen); // Jump to the beginning of audio cpd bits. mkvgenGetMkvTrackHeaderSize includes MKV_TRACKS_ELEM_BITS_SIZE but we just // want the track entry size, therefore subtract MKV_TRACKS_ELEM_BITS_SIZE @@ -990,50 +896,40 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) PStreamMkvGenerator pStreamMkvGenerator; PTrackInfo pTrackInfo; - BYTE cpdH264[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x34, 0xAC, 0x2B, 0x40, 0x1E, 0x00, 0x78, 0xD8, 0x08, - 0x80, 0x00, 0x01, 0xF4, 0x00, 0x00, 0xEA, 0x60, 0x47, 0xA5, 0x50, 0x00, 0x00, 0x00, 0x01, 0x68, - 0xEE, 0x3C, 0xB0}; - BYTE cpdH264Aud[] = {0x00, 0x00, 0x00, 0x01, 0x09, 0x10, - 0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x34, 0xAC, 0x2B, 0x40, 0x1E, 0x00, 0x78, 0xD8, 0x08, - 0x80, 0x00, 0x01, 0xF4, 0x00, 0x00, 0xEA, 0x60, 0x47, 0xA5, 0x50, 0x00, 0x00, 0x00, 0x01, 0x68, - 0xEE, 0x3C, 0xB0}; - BYTE cpdH264_2[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00, 0x1e, - 0xa9, 0x50, 0x14, 0x07, 0xb4, 0x20, 0x00, 0x00, - 0x7d, 0x00, 0x00, 0x1d, 0x4c, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x01, 0x68, 0xce, 0x3c, 0x80}; - BYTE cpdH265[] = {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x3c, 0xa0, 0x18, 0x20, 0x28, 0x71, 0x31, 0x39, 0x6b, 0xb9, 0x32, 0x4b, 0xb9, 0x48, 0x28, 0x10, - 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}; - BYTE cpdH265Aud[] = {0x00, 0x00, 0x00, 0x01, 0x09, 0x10, - 0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x3c, 0xa0, 0x18, 0x20, 0x28, 0x71, 0x31, 0x39, 0x6b, 0xb9, 0x32, 0x4b, 0xb9, 0x48, 0x28, 0x10, - 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}; + BYTE cpdH264[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x34, 0xAC, 0x2B, 0x40, 0x1E, 0x00, 0x78, 0xD8, 0x08, 0x80, 0x00, + 0x01, 0xF4, 0x00, 0x00, 0xEA, 0x60, 0x47, 0xA5, 0x50, 0x00, 0x00, 0x00, 0x01, 0x68, 0xEE, 0x3C, 0xB0}; + BYTE cpdH264Aud[] = {0x00, 0x00, 0x00, 0x01, 0x09, 0x10, 0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x34, 0xAC, 0x2B, 0x40, 0x1E, 0x00, 0x78, 0xD8, + 0x08, 0x80, 0x00, 0x01, 0xF4, 0x00, 0x00, 0xEA, 0x60, 0x47, 0xA5, 0x50, 0x00, 0x00, 0x00, 0x01, 0x68, 0xEE, 0x3C, 0xB0}; + BYTE cpdH264_2[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00, 0x1e, 0xa9, 0x50, 0x14, 0x07, 0xb4, 0x20, 0x00, 0x00, + 0x7d, 0x00, 0x00, 0x1d, 0x4c, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x3c, 0x80}; + BYTE cpdH265[] = {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xa0, 0x18, 0x20, 0x28, 0x71, 0x31, 0x39, 0x6b, 0xb9, 0x32, 0x4b, + 0xb9, 0x48, 0x28, 0x10, 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}; + BYTE cpdH265Aud[] = {0x00, 0x00, 0x00, 0x01, 0x09, 0x10, 0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, + 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, + 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, + 0x3c, 0xa0, 0x18, 0x20, 0x28, 0x71, 0x31, 0x39, 0x6b, 0xb9, 0x32, 0x4b, 0xb9, 0x48, 0x28, 0x10, 0x10, 0x17, + 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}; // I-frame from a real-life encoder output which is actually invalid Annex-B format (shortened after a few bytes of the actual frame) - BYTE cpdH264AudSeiExtra0[] = {0x00, 0x00, 0x00, 0x01, 0x09, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x1E, 0xAC, - 0x1B, 0x1A, 0x80, 0xB0, 0x3D, 0xFF, 0xFF, 0x00, 0x28, 0x00, 0x21, 0x6E, 0x0C, 0x0C, 0x0C, 0x80, - 0x00, 0x01, 0xF4, 0x00, 0x00, 0x75, 0x30, 0x74, 0x30, 0x07, 0xD0, 0x00, 0x01, 0x31, 0x2D, 0x5D, - 0xE5, 0xC6, 0x86, 0x00, 0xFA, 0x00, 0x00, 0x26, 0x25, 0xAB, 0xBC, 0xB8, 0x50, 0x00, 0x00, 0x00, - 0x00, 0x01, 0x68, 0xEE, 0x38, 0x30, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0x0D, 0xBC, 0xFF, - 0x87, 0x49, 0xB5, 0x16, 0x3C, 0xFF, 0x87, 0x49, 0xB5, 0x16, 0x40, 0x01, 0x04, 0x00, 0x78, 0x08, - 0x10, 0x06, 0x01, 0xC4, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x65, 0xB8, 0x00, 0x02, 0x00, 0x00, - 0x03, 0x02, 0x7F, 0xEC, 0x0E, 0xD0, 0xE1, 0xA7, 0x9D, 0xA3, 0x7C, 0x49, 0x42, 0xC2, 0x23, 0x59,}; - - BYTE cpdH265WithIdr_N_Lp[] = {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, - 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5a, 0x95, 0x98, 0x09, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, - 0x60, 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, - 0x00, 0x5a, 0xa0, 0x05, 0x02, 0x01, 0xe1, 0x65, 0x95, 0x9a, 0x49, 0x32, - 0xbf, 0xfc, 0x00, 0x04, 0x00, 0x04, 0x04, 0x00, 0x00, 0x03, 0x00, 0x04, - 0x00, 0x00, 0x03, 0x00, 0x64, 0x20, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, - 0xc1, 0x72, 0xb4, 0x62, 0x40, 0x00, 0x00, 0x00, 0x01, 0x28, 0x01, 0xaf, - 0x3c, 0x40, 0xeb, 0x4d, 0x2b, 0x2c, 0x9a, 0x4a, 0x2f, 0x09, 0x56, 0xe0, - 0xdd, 0x7b, 0x56, 0xe5, 0x00, 0xc5, 0xb4, 0xbc, 0x5c, 0x27, 0x8a, 0xc0, - 0x7e, 0xaa, 0x7d, 0xc6, 0xbf, 0xec, 0xc1, 0xb0, 0x8a, 0xfd, 0x07, 0x3a,}; + BYTE cpdH264AudSeiExtra0[] = { + 0x00, 0x00, 0x00, 0x01, 0x09, 0x10, 0x00, 0x00, 0x00, 0x00, 0x01, 0x67, 0x64, 0x00, 0x1E, 0xAC, 0x1B, 0x1A, 0x80, 0xB0, 0x3D, 0xFF, + 0xFF, 0x00, 0x28, 0x00, 0x21, 0x6E, 0x0C, 0x0C, 0x0C, 0x80, 0x00, 0x01, 0xF4, 0x00, 0x00, 0x75, 0x30, 0x74, 0x30, 0x07, 0xD0, 0x00, + 0x01, 0x31, 0x2D, 0x5D, 0xE5, 0xC6, 0x86, 0x00, 0xFA, 0x00, 0x00, 0x26, 0x25, 0xAB, 0xBC, 0xB8, 0x50, 0x00, 0x00, 0x00, 0x00, 0x01, + 0x68, 0xEE, 0x38, 0x30, 0x00, 0x00, 0x00, 0x00, 0x01, 0x06, 0x00, 0x0D, 0xBC, 0xFF, 0x87, 0x49, 0xB5, 0x16, 0x3C, 0xFF, 0x87, 0x49, + 0xB5, 0x16, 0x40, 0x01, 0x04, 0x00, 0x78, 0x08, 0x10, 0x06, 0x01, 0xC4, 0x80, 0x00, 0x00, 0x00, 0x00, 0x01, 0x65, 0xB8, 0x00, 0x02, + 0x00, 0x00, 0x03, 0x02, 0x7F, 0xEC, 0x0E, 0xD0, 0xE1, 0xA7, 0x9D, 0xA3, 0x7C, 0x49, 0x42, 0xC2, 0x23, 0x59, + }; + + BYTE cpdH265WithIdr_N_Lp[] = { + 0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x03, 0x00, 0x5a, 0x95, 0x98, 0x09, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xa0, 0x05, 0x02, 0x01, 0xe1, 0x65, 0x95, 0x9a, 0x49, 0x32, 0xbf, 0xfc, 0x00, 0x04, 0x00, 0x04, + 0x04, 0x00, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0x64, 0x20, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc1, 0x72, 0xb4, 0x62, + 0x40, 0x00, 0x00, 0x00, 0x01, 0x28, 0x01, 0xaf, 0x3c, 0x40, 0xeb, 0x4d, 0x2b, 0x2c, 0x9a, 0x4a, 0x2f, 0x09, 0x56, 0xe0, 0xdd, 0x7b, + 0x56, 0xe5, 0x00, 0xc5, 0xb4, 0xbc, 0x5c, 0x27, 0x8a, 0xc0, 0x7e, 0xaa, 0x7d, 0xc6, 0xbf, 0xec, 0xc1, 0xb0, 0x8a, 0xfd, 0x07, 0x3a, + }; BYTE annexBStart[] = {0x00, 0x00, 0x00, 0x01}; @@ -1048,17 +944,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // // Non-key frame scenario // - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H264_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H264_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1084,17 +973,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // // Non-H264 frame scenario // - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator((PCHAR) "abc", - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator((PCHAR) "abc", MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1121,17 +1003,9 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // // No adaptation specified // - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H264_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H264_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1159,17 +1033,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // // CPD already specified // - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H264_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H264_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1194,17 +1061,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // // Invalid CPD - no I-frame bits // - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H264_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H264_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1232,17 +1092,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // // Invalid CPD // - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H264_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H264_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1271,17 +1124,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // // Invalid - H265 with invalid H264 content type // - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H264_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H264_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1315,17 +1161,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // // Valid H264 // - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H264_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H264_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1359,17 +1198,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // // Valid H264 with AUD // - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H264_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H264_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1401,17 +1233,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // // Valid H265 with content type of H265 // - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H265_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H265_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1443,17 +1268,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // // Valid H265 with content type of H265 with AUD // - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H265_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H265_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1487,17 +1305,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // mTrackInfo.codecPrivateDataSize = SIZEOF(cpdH264); mTrackInfo.codecPrivateData = cpdH264; - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H264_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H264_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1530,17 +1341,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // mTrackInfo.codecPrivateDataSize = 0; mTrackInfo.codecPrivateData = NULL; - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H264_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H264_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1634,17 +1438,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // // InValid H264 getting fixed up with content type of H264 // - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H264_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H264_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS, MKV_TEST_TIMECODE_SCALE, + MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1675,17 +1472,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // // InValid H264 getting fixed up with content type of H264 with CPD adaptation // - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H264_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS | MKV_GEN_ADAPT_ANNEXB_CPD_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H264_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS | MKV_GEN_ADAPT_ANNEXB_CPD_NALS, + MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, + MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1715,17 +1505,10 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_Variations) // // Valid H265 with IDR_N_LP in Annex-B format // - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_H265_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS | MKV_GEN_ADAPT_ANNEXB_CPD_NALS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_H265_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS | MKV_GEN_ADAPT_ANNEXB_CPD_NALS, + MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, + MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; pTrackInfo = &pStreamMkvGenerator->trackInfoList[0]; @@ -1769,17 +1552,9 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_G711Alaw) STRCPY(trackInfo.codecId, (PCHAR) "audio/teststream"); STRCPY(trackInfo.trackName, MKV_TEST_TRACK_NAME); - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_ALAW_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &trackInfo, - 1, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_ALAW_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &trackInfo, 1, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; EXPECT_TRUE((DOUBLE) 8000 == pStreamMkvGenerator->trackInfoList->trackCustomData.trackAudioConfig.samplingFrequency); @@ -1803,17 +1578,9 @@ TEST_F(MkvgenApiFunctionalityTest, mkvgenExtractCpd_G711Mulaw) STRCPY(trackInfo.codecId, (PCHAR) "audio/teststream"); STRCPY(trackInfo.trackName, MKV_TEST_TRACK_NAME); - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_MULAW_CONTENT_TYPE, - MKV_TEST_BEHAVIOR_FLAGS, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &trackInfo, - 1, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &pMkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_MULAW_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &trackInfo, 1, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); pStreamMkvGenerator = (PStreamMkvGenerator) pMkvGenerator; EXPECT_TRUE((DOUBLE) 8000 == pStreamMkvGenerator->trackInfoList->trackCustomData.trackAudioConfig.samplingFrequency); diff --git a/tst/mkvgen/MkvgenApiTest.cpp b/tst/mkvgen/MkvgenApiTest.cpp index 86c6b9e45..c912ae759 100644 --- a/tst/mkvgen/MkvgenApiTest.cpp +++ b/tst/mkvgen/MkvgenApiTest.cpp @@ -2,8 +2,7 @@ BOOL gTimeCallbackCalled = FALSE; -class MkvgenApiTest : public MkvgenTestBase { -}; +class MkvgenApiTest : public MkvgenTestBase {}; TEST_F(MkvgenApiTest, createMkvGenerator_InvalidInput) { @@ -15,53 +14,90 @@ TEST_F(MkvgenApiTest, createMkvGenerator_InvalidInput) BYTE zeroSegmentUUID[MKV_SEGMENT_UUID_LEN]; MEMSET(zeroSegmentUUID, 0, MKV_SEGMENT_UUID_LEN); - EXPECT_EQ(STATUS_MKV_INVALID_CONTENT_TYPE_LENGTH, createMkvGenerator(contentTypeExceedMaxLen, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); - EXPECT_EQ(STATUS_MKV_INVALID_TIMECODE_SCALE, createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MIN_TIMECODE_SCALE - 1, MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); - EXPECT_EQ(STATUS_MKV_INVALID_TIMECODE_SCALE, createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MAX_TIMECODE_SCALE + 1, MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); - EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MIN_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator))); + EXPECT_EQ(STATUS_MKV_INVALID_CONTENT_TYPE_LENGTH, + createMkvGenerator(contentTypeExceedMaxLen, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); + EXPECT_EQ(STATUS_MKV_INVALID_TIMECODE_SCALE, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MIN_TIMECODE_SCALE - 1, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); + EXPECT_EQ(STATUS_MKV_INVALID_TIMECODE_SCALE, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MAX_TIMECODE_SCALE + 1, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); + EXPECT_TRUE( + STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MIN_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator))); EXPECT_TRUE(STATUS_SUCCEEDED(freeMkvGenerator(pMkvGenerator))); - EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MIN_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, NULL, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator))); + EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MIN_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + NULL, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator))); EXPECT_TRUE(STATUS_SUCCEEDED(freeMkvGenerator(pMkvGenerator))); - EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MAX_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator))); + EXPECT_TRUE( + STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MAX_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator))); EXPECT_TRUE(STATUS_SUCCEEDED(freeMkvGenerator(pMkvGenerator))); - EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MAX_CLUSTER_DURATION + 1, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator))); + EXPECT_TRUE( + STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MAX_CLUSTER_DURATION + 1, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator))); EXPECT_TRUE(STATUS_SUCCEEDED(freeMkvGenerator(pMkvGenerator))); - EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION - 1, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator))); + EXPECT_TRUE( + STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION - 1, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator))); EXPECT_TRUE(STATUS_SUCCEEDED(freeMkvGenerator(pMkvGenerator))); - EXPECT_EQ(STATUS_MKV_INVALID_CLUSTER_DURATION, createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_GEN_FLAG_NONE, MKV_TEST_TIMECODE_SCALE, MAX_CLUSTER_DURATION + 1, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); - EXPECT_EQ(STATUS_MKV_INVALID_CLUSTER_DURATION, createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_GEN_FLAG_NONE, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION - 1, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); + EXPECT_EQ(STATUS_MKV_INVALID_CLUSTER_DURATION, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_GEN_FLAG_NONE, MKV_TEST_TIMECODE_SCALE, MAX_CLUSTER_DURATION + 1, MKV_TEST_SEGMENT_UUID, + &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); + EXPECT_EQ(STATUS_MKV_INVALID_CLUSTER_DURATION, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_GEN_FLAG_NONE, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION - 1, MKV_TEST_SEGMENT_UUID, + &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); MEMSET(mTrackInfo.codecId, 'a', MKV_MAX_CODEC_ID_LEN + 1); // codecId is not null terminated - EXPECT_EQ(STATUS_MKV_INVALID_CODEC_ID_LENGTH, createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); + EXPECT_EQ(STATUS_MKV_INVALID_CODEC_ID_LENGTH, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); STRCPY(mTrackInfo.codecId, MKV_TEST_CODEC_ID); MEMSET(mTrackInfo.trackName, 'a', MKV_MAX_TRACK_NAME_LEN + 1); // trackName is not null terminated - EXPECT_EQ(STATUS_MKV_INVALID_TRACK_NAME_LENGTH, createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); + EXPECT_EQ(STATUS_MKV_INVALID_TRACK_NAME_LENGTH, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); STRCPY(mTrackInfo.trackName, MKV_TEST_TRACK_NAME); - EXPECT_TRUE(STATUS_FAILED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, NULL))); + EXPECT_TRUE(STATUS_FAILED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, NULL))); // invalid cpd buffer being NULL mTrackInfo.codecPrivateDataSize = 1; - EXPECT_EQ(STATUS_MKV_CODEC_PRIVATE_NULL, createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); + EXPECT_EQ(STATUS_MKV_CODEC_PRIVATE_NULL, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, + &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); // invalid cpd size mTrackInfo.codecPrivateDataSize = MKV_MAX_CODEC_PRIVATE_LEN + 1; mTrackInfo.codecPrivateData = (PBYTE) 0x11; - EXPECT_EQ(STATUS_MKV_INVALID_CODEC_PRIVATE_LENGTH, createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); + EXPECT_EQ(STATUS_MKV_INVALID_CODEC_PRIVATE_LENGTH, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, + &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); mTrackInfo.codecPrivateDataSize = 0; mTrackInfo.codecPrivateData = NULL; - EXPECT_EQ(STATUS_MKV_BOTH_ANNEXB_AND_AVCC_SPECIFIED, createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS | MKV_GEN_ADAPT_AVCC_NALS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, NULL, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); + EXPECT_EQ(STATUS_MKV_BOTH_ANNEXB_AND_AVCC_SPECIFIED, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS | MKV_GEN_ADAPT_ANNEXB_NALS | MKV_GEN_ADAPT_AVCC_NALS, + MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, NULL, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, + &pMkvGenerator)); // zero segmentUUID - EXPECT_EQ(STATUS_MKV_INVALID_SEGMENT_UUID, createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, zeroSegmentUUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); + EXPECT_EQ(STATUS_MKV_INVALID_SEGMENT_UUID, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, zeroSegmentUUID, + &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator)); - EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator))); + EXPECT_TRUE( + STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator))); EXPECT_TRUE(STATUS_SUCCEEDED(freeMkvGenerator(pMkvGenerator))); - EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, NULL, NULL, 0, &pMkvGenerator))); + EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, NULL, NULL, 0, &pMkvGenerator))); EXPECT_TRUE(STATUS_SUCCEEDED(freeMkvGenerator(pMkvGenerator))); - EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, EMPTY_STRING, NULL, 0, &pMkvGenerator))); + EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, EMPTY_STRING, NULL, 0, &pMkvGenerator))); EXPECT_TRUE(STATUS_SUCCEEDED(freeMkvGenerator(pMkvGenerator))); } @@ -70,7 +106,9 @@ TEST_F(MkvgenApiTest, freeMkvGenerator_Idempotency) PMkvGenerator pMkvGenerator = NULL; // Create a valid generator - EXPECT_TRUE(STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator))); + EXPECT_TRUE( + STATUS_SUCCEEDED(createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_TEST_BEHAVIOR_FLAGS, MKV_TEST_TIMECODE_SCALE, MIN_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &pMkvGenerator))); // Free the generator EXPECT_TRUE(STATUS_SUCCEEDED(freeMkvGenerator(pMkvGenerator))); @@ -235,49 +273,25 @@ TEST_F(MkvgenApiTest, mkvgenGenerateHeader_TrackNameCodecIdGenerationTest) mTrackInfo.trackCustomData.trackVideoConfig.videoWidth = 1280; mTrackInfo.trackCustomData.trackVideoConfig.videoHeight = 720; - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_TEST_CONTENT_TYPE, - MKV_GEN_IN_STREAM_TIME, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &mkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_GEN_IN_STREAM_TIME, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator)); storedSize = mkvgenGetMkvHeaderSize((PStreamMkvGenerator) mkvGenerator); EXPECT_EQ(STATUS_SUCCESS, freeMkvGenerator(mkvGenerator)); mkvGenerator = NULL; // Same but client id = NULL - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_TEST_CONTENT_TYPE, - MKV_GEN_IN_STREAM_TIME, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - NULL, - NULL, - 0, - &mkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_GEN_IN_STREAM_TIME, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, NULL, NULL, 0, &mkvGenerator)); storedSizeNull = mkvgenGetMkvHeaderSize((PStreamMkvGenerator) mkvGenerator); EXPECT_EQ(STATUS_SUCCESS, freeMkvGenerator(mkvGenerator)); mkvGenerator = NULL; // Same but client id = EMPTY - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_TEST_CONTENT_TYPE, - MKV_GEN_IN_STREAM_TIME, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - EMPTY_STRING, - NULL, - 0, - &mkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_GEN_IN_STREAM_TIME, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, EMPTY_STRING, NULL, 0, &mkvGenerator)); storedSizeEmpty = mkvgenGetMkvHeaderSize((PStreamMkvGenerator) mkvGenerator); EXPECT_EQ(STATUS_SUCCESS, freeMkvGenerator(mkvGenerator)); mkvGenerator = NULL; @@ -290,38 +304,21 @@ TEST_F(MkvgenApiTest, mkvgenGenerateHeader_TrackNameCodecIdGenerationTest) STRCPY(mTrackInfo.codecId, longCodecId); STRCPY(mTrackInfo.trackName, longTrackName); - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_TEST_CONTENT_TYPE, - MKV_GEN_IN_STREAM_TIME, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &mkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_GEN_IN_STREAM_TIME, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator)); size = mkvgenGetMkvHeaderSize((PStreamMkvGenerator) mkvGenerator); EXPECT_EQ(STATUS_SUCCESS, freeMkvGenerator(mkvGenerator)); mkvGenerator = NULL; - EXPECT_EQ(STRLEN(longTrackName) - STRLEN(shortTrackName) + STRLEN(longCodecId) - STRLEN(shortCodecId), - size - storedSize); + EXPECT_EQ(STRLEN(longTrackName) - STRLEN(shortTrackName) + STRLEN(longCodecId) - STRLEN(shortCodecId), size - storedSize); // empty trackname and codec id mTrackInfo.codecId[0] = '\0'; mTrackInfo.trackName[0] = '\0'; - EXPECT_EQ(STATUS_SUCCESS, createMkvGenerator(MKV_TEST_CONTENT_TYPE, - MKV_GEN_IN_STREAM_TIME, - MKV_TEST_TIMECODE_SCALE, - MKV_TEST_CLUSTER_DURATION, - MKV_TEST_SEGMENT_UUID, - &mTrackInfo, - mTrackInfoCount, - MKV_TEST_CLIENT_ID, - NULL, - 0, - &mkvGenerator)); + EXPECT_EQ(STATUS_SUCCESS, + createMkvGenerator(MKV_TEST_CONTENT_TYPE, MKV_GEN_IN_STREAM_TIME, MKV_TEST_TIMECODE_SCALE, MKV_TEST_CLUSTER_DURATION, + MKV_TEST_SEGMENT_UUID, &mTrackInfo, mTrackInfoCount, MKV_TEST_CLIENT_ID, NULL, 0, &mkvGenerator)); size = mkvgenGetMkvHeaderSize((PStreamMkvGenerator) mkvGenerator); EXPECT_EQ(STATUS_SUCCESS, freeMkvGenerator(mkvGenerator)); mkvGenerator = NULL; @@ -417,8 +414,7 @@ TEST_F(MkvgenApiTest, mkvgenGenerateTagsChain_PositiveAndNegativeTest) STRCPY(tagValue, "TestTagValue"); tempBuffer = (PBYTE) MEMALLOC(size); - for(int i = 0; static_cast(i) < MKV_TREE_LAST; i++) - { + for (int i = 0; static_cast(i) < MKV_TREE_LAST; i++) { EXPECT_NE(STATUS_SUCCESS, mkvgenGenerateTagsChain(tempBuffer, NULL, tagValue, &size, static_cast(i))); EXPECT_NE(STATUS_SUCCESS, mkvgenGenerateTagsChain(tempBuffer, tagName, NULL, &size, static_cast(i))); EXPECT_NE(STATUS_SUCCESS, mkvgenGenerateTagsChain(tempBuffer, tagName, tagValue, NULL, static_cast(i))); @@ -464,15 +460,15 @@ TEST_F(MkvgenApiTest, mkvgenGenerateTagsChain_OriginalAPICheck) EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTag(mMkvGenerator, originalAPIBuffer, tagName, tagValue, &size)); EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTagsChain(tagsChainAPIBuffer, tagName, tagValue, &size, MKV_TREE_TAGS)); - //TAGS equal check + // TAGS equal check EXPECT_EQ(0, MEMCMP(tagsChainAPIBuffer, originalAPIBuffer, size)); - //reset and check TAG + // reset and check TAG MEMSET(tagsChainAPIBuffer, 0, size); EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTagsChain(tagsChainAPIBuffer, tagName, tagValue, &size, MKV_TREE_TAG)); EXPECT_EQ(0, MEMCMP(tagsChainAPIBuffer, originalAPIBuffer + MKV_TAG_ELEMENT_OFFSET, size)); - //reset and check SIMPLE + // reset and check SIMPLE MEMSET(tagsChainAPIBuffer, 0, size); EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTagsChain(tagsChainAPIBuffer, tagName, tagValue, &size, MKV_TREE_SIMPLE)); EXPECT_EQ(0, MEMCMP(tagsChainAPIBuffer, originalAPIBuffer + MKV_SIMPLE_TAG_ELEMENT_OFFSET, size)); @@ -490,25 +486,25 @@ TEST_F(MkvgenApiTest, mkvgenGenerateTagsChain_MaxStringsCheck) CHAR temp; PBYTE tagsChainAPIBuffer = (PBYTE) MEMCALLOC(1, size); - //randomize the name - for(int i = 0; i < MKV_MAX_TAG_NAME_LEN; i++) { - //generate random ascii character - temp = ( rand()%223 ) + 32; + // randomize the name + for (int i = 0; i < MKV_MAX_TAG_NAME_LEN; i++) { + // generate random ascii character + temp = (rand() % 223) + 32; - //no delete character - if(temp == 127) { + // no delete character + if (temp == 127) { temp++; } tagName[i] = temp; } - //randomize the value - for(int i = 0; i < MKV_MAX_TAG_VALUE_LEN; i++) { - //generate random ascii character - temp = ( rand()%223 ) + 32; + // randomize the value + for (int i = 0; i < MKV_MAX_TAG_VALUE_LEN; i++) { + // generate random ascii character + temp = (rand() % 223) + 32; - //no delete character - if(temp == 127) { + // no delete character + if (temp == 127) { temp++; } tagValue[i] = temp; @@ -516,11 +512,13 @@ TEST_F(MkvgenApiTest, mkvgenGenerateTagsChain_MaxStringsCheck) EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTagsChain(tagsChainAPIBuffer, tagName, tagValue, &size, MKV_TREE_SIMPLE)); - //Check name - EXPECT_EQ(0, MEMCMP(tagName, tagsChainAPIBuffer + 2*(MKV_GENERIC_ELEMENT_SIZE_OFFSET + MKV_GENERIC_ELEMENT_OFFSET), MKV_MAX_TAG_NAME_LEN)); + // Check name + EXPECT_EQ(0, MEMCMP(tagName, tagsChainAPIBuffer + 2 * (MKV_GENERIC_ELEMENT_SIZE_OFFSET + MKV_GENERIC_ELEMENT_OFFSET), MKV_MAX_TAG_NAME_LEN)); - //Check string - EXPECT_EQ(0, MEMCMP(tagValue, tagsChainAPIBuffer + 3*(MKV_GENERIC_ELEMENT_SIZE_OFFSET + MKV_GENERIC_ELEMENT_OFFSET) + MKV_MAX_TAG_NAME_LEN, MKV_MAX_TAG_VALUE_LEN)); + // Check string + EXPECT_EQ(0, + MEMCMP(tagValue, tagsChainAPIBuffer + 3 * (MKV_GENERIC_ELEMENT_SIZE_OFFSET + MKV_GENERIC_ELEMENT_OFFSET) + MKV_MAX_TAG_NAME_LEN, + MKV_MAX_TAG_VALUE_LEN)); MEMFREE(tagsChainAPIBuffer); } @@ -534,16 +532,16 @@ TEST_F(MkvgenApiTest, mkvgenIncreaseTagsTagSize_FunctionalityTest) EXPECT_EQ(STATUS_INVALID_ARG, mkvgenIncreaseTagsTagSize(NULL, 0)); /*** RANDOMIZATION TESTING ***/ - randomSize = rand()%(0x000fffffffffffff); //UINT64, first byte is occupied, + randomSize = rand() % (0x000fffffffffffff); // UINT64, first byte is occupied, EXPECT_EQ(STATUS_SUCCESS, mkvgenGenerateTagsChain(tagsMkvHolder, (PCHAR) "TEST_NAME", (PCHAR) "TEST_VALUE", &size, MKV_TREE_TAGS)); EXPECT_EQ(STATUS_SUCCESS, mkvgenIncreaseTagsTagSize(tagsMkvHolder, randomSize)); - //grab size, and verify it increase by the expected amount. - encodedSize = GET_UNALIGNED_BIG_ENDIAN((PUINT64)(tagsMkvHolder + MKV_TAGS_ELEMENT_SIZE_OFFSET)); + // grab size, and verify it increase by the expected amount. + encodedSize = GET_UNALIGNED_BIG_ENDIAN((PUINT64) (tagsMkvHolder + MKV_TAGS_ELEMENT_SIZE_OFFSET)); EXPECT_EQ(encodedSize, randomSize + size - MKV_TAG_ELEMENT_OFFSET); - //check TAG size as well. - encodedSize = GET_UNALIGNED_BIG_ENDIAN((PUINT64)(tagsMkvHolder + MKV_TAG_ELEMENT_SIZE_OFFSET)); + // check TAG size as well. + encodedSize = GET_UNALIGNED_BIG_ENDIAN((PUINT64) (tagsMkvHolder + MKV_TAG_ELEMENT_SIZE_OFFSET)); EXPECT_EQ(encodedSize, randomSize + size - MKV_SIMPLE_TAG_ELEMENT_OFFSET); SAFE_MEMFREE(tagsMkvHolder); @@ -574,11 +572,10 @@ TEST_F(MkvgenApiTest, mkvgenContentType_GetContentType) EXPECT_EQ(MKV_CONTENT_TYPE_H264, mkvgenGetContentTypeFromContentTypeString((PCHAR) "video/h264,")); EXPECT_EQ(MKV_CONTENT_TYPE_H264 | MKV_CONTENT_TYPE_UNKNOWN, mkvgenGetContentTypeFromContentTypeString((PCHAR) "video/h264, video/h265")); EXPECT_EQ(MKV_CONTENT_TYPE_UNKNOWN | MKV_CONTENT_TYPE_H265, mkvgenGetContentTypeFromContentTypeString((PCHAR) "video/h264 ,video/h265")); - EXPECT_EQ(MKV_CONTENT_TYPE_H264 | MKV_CONTENT_TYPE_H265 | MKV_CONTENT_TYPE_AAC | - MKV_CONTENT_TYPE_X_MKV_VIDEO | MKV_CONTENT_TYPE_X_MKV_AUDIO, + EXPECT_EQ(MKV_CONTENT_TYPE_H264 | MKV_CONTENT_TYPE_H265 | MKV_CONTENT_TYPE_AAC | MKV_CONTENT_TYPE_X_MKV_VIDEO | MKV_CONTENT_TYPE_X_MKV_AUDIO, mkvgenGetContentTypeFromContentTypeString((PCHAR) "video/h264,video/h265,audio/aac,video/x-matroska,audio/x-matroska")); - EXPECT_EQ(MKV_CONTENT_TYPE_H264 | MKV_CONTENT_TYPE_H265 | MKV_CONTENT_TYPE_AAC | - MKV_CONTENT_TYPE_X_MKV_VIDEO | MKV_CONTENT_TYPE_X_MKV_AUDIO | MKV_CONTENT_TYPE_UNKNOWN, + EXPECT_EQ(MKV_CONTENT_TYPE_H264 | MKV_CONTENT_TYPE_H265 | MKV_CONTENT_TYPE_AAC | MKV_CONTENT_TYPE_X_MKV_VIDEO | MKV_CONTENT_TYPE_X_MKV_AUDIO | + MKV_CONTENT_TYPE_UNKNOWN, mkvgenGetContentTypeFromContentTypeString((PCHAR) "video/h264,video/h265,audio/aac,blah,video/x-matroska,audio/x-matroska")); } @@ -602,27 +599,17 @@ TEST_F(MkvgenApiTest, mkvGenGetAudioConfigFromAmsAcmCpdNegativeCase) BYTE cpdTooShort[] = {0x07, 0x00, 0x01, 0x00, 0x40}; TrackCustomData audioData; - EXPECT_EQ(STATUS_MKV_INVALID_AMS_ACM_CPD, getAudioConfigFromAmsAcmCpd(cpdWrongFormatCode, - SIZEOF(cpdWrongFormatCode), - &audioData.trackAudioConfig.samplingFrequency, - &audioData.trackAudioConfig.channelConfig, - &audioData.trackAudioConfig.bitDepth)); - - EXPECT_EQ(STATUS_MKV_INVALID_AMS_ACM_CPD, getAudioConfigFromAmsAcmCpd(cpdTooShort, - SIZEOF(cpdTooShort), - &audioData.trackAudioConfig.samplingFrequency, - &audioData.trackAudioConfig.channelConfig, - &audioData.trackAudioConfig.bitDepth)); - - EXPECT_EQ(STATUS_NULL_ARG, getAudioConfigFromAmsAcmCpd(cpdTooShort, - SIZEOF(cpdTooShort), - NULL, - NULL, - NULL)); - - EXPECT_EQ(STATUS_NULL_ARG, getAudioConfigFromAmsAcmCpd(NULL, - SIZEOF(cpdTooShort), - &audioData.trackAudioConfig.samplingFrequency, - &audioData.trackAudioConfig.channelConfig, - &audioData.trackAudioConfig.bitDepth)); + EXPECT_EQ(STATUS_MKV_INVALID_AMS_ACM_CPD, + getAudioConfigFromAmsAcmCpd(cpdWrongFormatCode, SIZEOF(cpdWrongFormatCode), &audioData.trackAudioConfig.samplingFrequency, + &audioData.trackAudioConfig.channelConfig, &audioData.trackAudioConfig.bitDepth)); + + EXPECT_EQ(STATUS_MKV_INVALID_AMS_ACM_CPD, + getAudioConfigFromAmsAcmCpd(cpdTooShort, SIZEOF(cpdTooShort), &audioData.trackAudioConfig.samplingFrequency, + &audioData.trackAudioConfig.channelConfig, &audioData.trackAudioConfig.bitDepth)); + + EXPECT_EQ(STATUS_NULL_ARG, getAudioConfigFromAmsAcmCpd(cpdTooShort, SIZEOF(cpdTooShort), NULL, NULL, NULL)); + + EXPECT_EQ(STATUS_NULL_ARG, + getAudioConfigFromAmsAcmCpd(NULL, SIZEOF(cpdTooShort), &audioData.trackAudioConfig.samplingFrequency, + &audioData.trackAudioConfig.channelConfig, &audioData.trackAudioConfig.bitDepth)); } diff --git a/tst/mkvgen/SpsParserTest.cpp b/tst/mkvgen/SpsParserTest.cpp index a58c82cd3..3f170460b 100644 --- a/tst/mkvgen/SpsParserTest.cpp +++ b/tst/mkvgen/SpsParserTest.cpp @@ -1,7 +1,6 @@ #include "MkvgenTestFixture.h" -class SpsParserTest : public MkvgenTestBase { -}; +class SpsParserTest : public MkvgenTestBase {}; TEST_F(SpsParserTest, spsParser_InvalidInput) { @@ -24,8 +23,7 @@ TEST_F(SpsParserTest, spsParser_InvalidInput) TEST_F(SpsParserTest, spsParser_Raw_Sps) { - BYTE cpd[] = {0x67, 0x42, 0x40, 0x1f, 0x96, 0x54, 0x02, 0x80, - 0x2d, 0xc8, 0x68, 0xce, 0x38, 0x80}; + BYTE cpd[] = {0x67, 0x42, 0x40, 0x1f, 0x96, 0x54, 0x02, 0x80, 0x2d, 0xc8, 0x68, 0xce, 0x38, 0x80}; UINT32 cpdSize = SIZEOF(cpd); UINT16 width, height; @@ -36,13 +34,10 @@ TEST_F(SpsParserTest, spsParser_Raw_Sps) TEST_F(SpsParserTest, spsParser_AnnexB) { - BYTE cpd1[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x40, 0x1f, - 0x96, 0x54, 0x02, 0x80, 0x2d, 0xc8, 0x00, 0x00, - 0x00, 0x01, 0x68, 0xce, 0x38, 0x80}; - BYTE cpd2[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00, 0x1e, - 0xa9, 0x50, 0x14, 0x07, 0xb4, 0x20, 0x00, 0x00, - 0x7d, 0x00, 0x00, 0x1d, 0x4c, 0x00, 0x80, 0x00, - 0x00, 0x00, 0x01, 0x68, 0xce, 0x3c, 0x80}; + BYTE cpd1[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x40, 0x1f, 0x96, 0x54, 0x02, + 0x80, 0x2d, 0xc8, 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x38, 0x80}; + BYTE cpd2[] = {0x00, 0x00, 0x00, 0x01, 0x67, 0x42, 0x00, 0x1e, 0xa9, 0x50, 0x14, 0x07, 0xb4, 0x20, 0x00, 0x00, + 0x7d, 0x00, 0x00, 0x1d, 0x4c, 0x00, 0x80, 0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x3c, 0x80}; UINT16 width, height; @@ -55,44 +50,29 @@ TEST_F(SpsParserTest, spsParser_AnnexB) EXPECT_EQ(480, height); } -TEST_F(SpsParserTest, spsParser_Avcc) { - BYTE cpd1[] = {0x01, 0x64, 0x00, 0x28, 0xff, 0xe1, 0x00, 0x2e, - 0x67, 0x64, 0x00, 0x28, 0xac, 0x2c, 0xa4, 0x01, - 0xe0, 0x08, 0x9f, 0x97, 0xff, 0x00, 0x01, 0x00, - 0x01, 0x52, 0x02, 0x02, 0x02, 0x80, 0x00, 0x01, - 0xf4, 0x80, 0x00, 0x75, 0x30, 0x70, 0x10, 0x00, - 0x16, 0xe3, 0x60, 0x00, 0x08, 0x95, 0x45, 0xf8, - 0xc7, 0x07, 0x68, 0x58, 0xb4, 0x48, 0x01, 0x00, - 0x05, 0x68, 0xeb, 0x73, 0x52, 0x50, 0xfd, 0xf8, - 0xf8, 0x00}; - BYTE cpd2[] = {0x01, 0x42, 0x40, 0x15, 0xFF, 0xE1, 0x00, 0x0a, - 0x67, 0x42, 0x40, 0x33, 0x95, 0xa0, 0x1e, 0x00, - 0xb5, 0x90, 0x01, 0x00, 0x04, 0x68, 0xce, 0x3c, - 0x80}; +TEST_F(SpsParserTest, spsParser_Avcc) +{ + BYTE cpd1[] = {0x01, 0x64, 0x00, 0x28, 0xff, 0xe1, 0x00, 0x2e, 0x67, 0x64, 0x00, 0x28, 0xac, 0x2c, 0xa4, 0x01, 0xe0, + 0x08, 0x9f, 0x97, 0xff, 0x00, 0x01, 0x00, 0x01, 0x52, 0x02, 0x02, 0x02, 0x80, 0x00, 0x01, 0xf4, 0x80, + 0x00, 0x75, 0x30, 0x70, 0x10, 0x00, 0x16, 0xe3, 0x60, 0x00, 0x08, 0x95, 0x45, 0xf8, 0xc7, 0x07, 0x68, + 0x58, 0xb4, 0x48, 0x01, 0x00, 0x05, 0x68, 0xeb, 0x73, 0x52, 0x50, 0xfd, 0xf8, 0xf8, 0x00}; + BYTE cpd2[] = {0x01, 0x42, 0x40, 0x15, 0xFF, 0xE1, 0x00, 0x0a, 0x67, 0x42, 0x40, 0x33, 0x95, + 0xa0, 0x1e, 0x00, 0xb5, 0x90, 0x01, 0x00, 0x04, 0x68, 0xce, 0x3c, 0x80}; BYTE cpd3[] = {0x01, 0x42, 0xC0, 0x0D, 0xFF, 0xE1, 0x00, 0x21, 0x67, 0x42, 0xC0, 0x0D, 0xAB, 0x40, 0xA0, 0xFD, 0x08, 0x00, 0x00, 0x03, 0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x47, 0x02, 0x00, 0x0C, 0x00, 0x00, 0x06, 0x00, 0x16, 0xB1, 0xB0, 0x3C, 0x50, 0xAA, 0x80, 0x01, 0x00, 0x04, 0x28, 0xCE, 0x3C, 0x80}; // From https://t.corp.amazon.com/V200428039 // Profile 244 and Chroma Format 4:4:4 - BYTE cpd4[] = {0x01,0xf4,0x00,0x28, - 0xff,0xe1,0x00,0x1e,0x67,0xf4,0x00,0x28, - 0x91,0x96,0x80,0x78,0x02,0x27,0xe2,0x70, - 0x16,0xa0,0x20,0x20,0x28,0x00,0x00,0x03, - 0x00,0x08,0x00,0x00,0x03,0x01,0xb4,0x78, - 0xc1,0x95,0x01,0x00,0x04,0x68,0xef,0x31, - 0x92}; + BYTE cpd4[] = {0x01, 0xf4, 0x00, 0x28, 0xff, 0xe1, 0x00, 0x1e, 0x67, 0xf4, 0x00, 0x28, 0x91, 0x96, 0x80, + 0x78, 0x02, 0x27, 0xe2, 0x70, 0x16, 0xa0, 0x20, 0x20, 0x28, 0x00, 0x00, 0x03, 0x00, 0x08, + 0x00, 0x00, 0x03, 0x01, 0xb4, 0x78, 0xc1, 0x95, 0x01, 0x00, 0x04, 0x68, 0xef, 0x31, 0x92}; // From http://jell.yfish.us/ 3Mbps H.264 1080p - BYTE cpd5[] = {0x01,0x64,0x00,0x28, - 0xff,0xe1,0x00,0x2e,0x67,0x64,0x00,0x28, - 0xac,0x2c,0xa4,0x01,0xe0,0x08,0x9f,0x97, - 0xff,0x00,0x01,0x00,0x01,0x52,0x02,0x02, - 0x02,0x80,0x00,0x01,0xf4,0x80,0x00,0x75, - 0x30,0x70,0x10,0x00,0x16,0xe3,0x60,0x00, - 0x08,0x95,0x45,0xf8,0xc7,0x07,0x68,0x58, - 0xb4,0x48,0x01,0x00,0x05,0x68,0xeb,0x73, - 0x52,0x50,0xfd,0xf8,0xf8,0x00}; + BYTE cpd5[] = {0x01, 0x64, 0x00, 0x28, 0xff, 0xe1, 0x00, 0x2e, 0x67, 0x64, 0x00, 0x28, 0xac, 0x2c, 0xa4, 0x01, 0xe0, + 0x08, 0x9f, 0x97, 0xff, 0x00, 0x01, 0x00, 0x01, 0x52, 0x02, 0x02, 0x02, 0x80, 0x00, 0x01, 0xf4, 0x80, + 0x00, 0x75, 0x30, 0x70, 0x10, 0x00, 0x16, 0xe3, 0x60, 0x00, 0x08, 0x95, 0x45, 0xf8, 0xc7, 0x07, 0x68, + 0x58, 0xb4, 0x48, 0x01, 0x00, 0x05, 0x68, 0xeb, 0x73, 0x52, 0x50, 0xfd, 0xf8, 0xf8, 0x00}; UINT16 width, height; @@ -117,12 +97,10 @@ TEST_F(SpsParserTest, spsParser_Avcc) { EXPECT_EQ(1080, height); } -TEST_F(SpsParserTest, spsParser_Mjpg) { - BYTE cpd[] = {0x28, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, - 0xe0, 0x01, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, - 0x4d, 0x4a, 0x50, 0x47, 0x00, 0x10, 0x0e, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +TEST_F(SpsParserTest, spsParser_Mjpg) +{ + BYTE cpd[] = {0x28, 0x00, 0x00, 0x00, 0x80, 0x02, 0x00, 0x00, 0xe0, 0x01, 0x00, 0x00, 0x01, 0x00, 0x18, 0x00, 0x4d, 0x4a, 0x50, 0x47, + 0x00, 0x10, 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; UINT16 width, height; @@ -133,46 +111,34 @@ TEST_F(SpsParserTest, spsParser_Mjpg) { EXPECT_EQ(STATUS_MKV_INVALID_BIH_CPD, getVideoWidthAndHeightFromBih(cpd, SIZEOF(cpd) - 1, &width, &height)); } -TEST_F(SpsParserTest, spsParser_Hevc) { +TEST_F(SpsParserTest, spsParser_Hevc) +{ // These are series of codec private data bits extracted from an // GStreamer pipeline for H265 for various resolutions BYTE cpd[4][1000] = { - {0x01, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0xf0, - 0x00, 0xfc, 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, 0x03, 0x20, 0x00, 0x01, 0x00, 0x18, - 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x7b, 0xac, 0x09, 0x21, 0x00, 0x01, 0x00, - 0x23, 0x42, 0x01, 0x01, 0x01, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x03, 0x00, 0x7b, 0xa0, 0x01, 0x98, 0x20, 0x02, 0x68, 0x7c, 0x4e, - 0x5a, 0xee, 0x42, 0x11, 0x12, 0xe2, 0x6c, 0x01, 0x22, 0x00, 0x01, 0x00, 0x07, 0x44, - 0x01, 0xc0, 0x77, 0xc0, 0xcc, 0x90, 0x00, 0x00, 0x00}, - - {0x01, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0xf0, - 0x00, 0xfc, 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, 0x03, 0x20, 0x00, 0x01, 0x00, 0x18, - 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x7b, 0xac, 0x09, 0x21, 0x00, 0x01, 0x00, - 0x22, 0x42, 0x01, 0x01, 0x01, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x03, 0x00, 0x7b, 0xa0, 0x03, 0xc0, 0x80, 0x16, 0x85, 0x96, 0xbb, - 0x90, 0x84, 0x44, 0xb8, 0x9b, 0x00, 0x40, 0x22, 0x00, 0x01, 0x00, 0x07, 0x44, 0x01, - 0xc0, 0x77, 0xc0, 0xcc, 0x90, 0x00, 0x00, 0x00, 0xff}, - - {0x01, 0x21, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0xf0, - 0x00, 0xfc, 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, 0x03, 0x20, 0x00, 0x01, 0x00, 0x18, - 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x21, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x96, 0xac, 0x09, 0x21, 0x00, 0x01, 0x00, - 0x21, 0x42, 0x01, 0x01, 0x21, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x03, 0x00, 0x96, 0xa0, 0x0c, 0x08, 0x04, 0x85, 0x96, 0xbb, 0x90, - 0x84, 0x44, 0xb8, 0x9b, 0x00, 0x40, 0x22, 0x00, 0x01, 0x00, 0x07, 0x44, 0x01, 0xc0, - 0x77, 0xc0, 0xcc, 0x90, 0x00, 0x00, 0x00, 0xff, 0xff}, - - {0x01, 0x21, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0xf0, - 0x00, 0xfc, 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, 0x03, 0x20, 0x00, 0x01, 0x00, 0x18, - 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x21, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, - 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x96, 0xac, 0x09, 0x21, 0x00, 0x01, 0x00, - 0x22, 0x42, 0x01, 0x01, 0x21, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x03, 0x00, 0x96, 0xa0, 0x0a, 0x08, 0x04, 0x07, 0xc4, 0xe5, 0xae, - 0xe4, 0x21, 0x11, 0x2e, 0x26, 0xc0, 0x10, 0x22, 0x00, 0x01, 0x00, 0x07, 0x44, 0x01, - 0xc0, 0x77, 0xc0, 0xcc, 0x90, 0x00, 0x00, 0x00, 0xff} - }; + {0x01, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0xf0, 0x00, 0xfc, 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, + 0x03, 0x20, 0x00, 0x01, 0x00, 0x18, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x03, 0x00, 0x7b, 0xac, 0x09, 0x21, 0x00, 0x01, 0x00, 0x23, 0x42, 0x01, 0x01, 0x01, 0x40, 0x00, 0x00, 0x03, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x7b, 0xa0, 0x01, 0x98, 0x20, 0x02, 0x68, 0x7c, 0x4e, 0x5a, 0xee, 0x42, 0x11, + 0x12, 0xe2, 0x6c, 0x01, 0x22, 0x00, 0x01, 0x00, 0x07, 0x44, 0x01, 0xc0, 0x77, 0xc0, 0xcc, 0x90, 0x00, 0x00, 0x00}, + + {0x01, 0x01, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0xf0, 0x00, 0xfc, 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, + 0x03, 0x20, 0x00, 0x01, 0x00, 0x18, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x03, 0x00, 0x7b, 0xac, 0x09, 0x21, 0x00, 0x01, 0x00, 0x22, 0x42, 0x01, 0x01, 0x01, 0x40, 0x00, 0x00, 0x03, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x7b, 0xa0, 0x03, 0xc0, 0x80, 0x16, 0x85, 0x96, 0xbb, 0x90, 0x84, 0x44, 0xb8, + 0x9b, 0x00, 0x40, 0x22, 0x00, 0x01, 0x00, 0x07, 0x44, 0x01, 0xc0, 0x77, 0xc0, 0xcc, 0x90, 0x00, 0x00, 0x00, 0xff}, + + {0x01, 0x21, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0xf0, 0x00, 0xfc, 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, + 0x03, 0x20, 0x00, 0x01, 0x00, 0x18, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x21, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x03, 0x00, 0x96, 0xac, 0x09, 0x21, 0x00, 0x01, 0x00, 0x21, 0x42, 0x01, 0x01, 0x21, 0x40, 0x00, 0x00, 0x03, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x96, 0xa0, 0x0c, 0x08, 0x04, 0x85, 0x96, 0xbb, 0x90, 0x84, 0x44, 0xb8, 0x9b, + 0x00, 0x40, 0x22, 0x00, 0x01, 0x00, 0x07, 0x44, 0x01, 0xc0, 0x77, 0xc0, 0xcc, 0x90, 0x00, 0x00, 0x00, 0xff, 0xff}, + + {0x01, 0x21, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0xf0, 0x00, 0xfc, 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, + 0x03, 0x20, 0x00, 0x01, 0x00, 0x18, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x21, 0x40, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x03, 0x00, 0x96, 0xac, 0x09, 0x21, 0x00, 0x01, 0x00, 0x22, 0x42, 0x01, 0x01, 0x21, 0x40, 0x00, 0x00, 0x03, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x96, 0xa0, 0x0a, 0x08, 0x04, 0x07, 0xc4, 0xe5, 0xae, 0xe4, 0x21, 0x11, 0x2e, + 0x26, 0xc0, 0x10, 0x22, 0x00, 0x01, 0x00, 0x07, 0x44, 0x01, 0xc0, 0x77, 0xc0, 0xcc, 0x90, 0x00, 0x00, 0x00, 0xff}}; UINT32 cpdSizes[4] = {107, 106, 105, 106}; @@ -189,7 +155,8 @@ TEST_F(SpsParserTest, spsParser_Hevc) { } } -TEST_F(SpsParserTest, spsParser_AnnexB_H265) { +TEST_F(SpsParserTest, spsParser_AnnexB_H265) +{ // These are series of codec private data bits extracted from an // Android device for H265 for various resolutions // Some are from other samples @@ -198,100 +165,80 @@ TEST_F(SpsParserTest, spsParser_AnnexB_H265) { const UINT32 NUMBER_OF_H265_CPDS = 13; BYTE cpd[NUMBER_OF_H265_CPDS][1000] = { - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x3c, 0xa0, 0x18, 0x20, 0x28, 0x71, 0x31, 0x39, 0x6b, 0xb9, 0x32, 0x4b, 0xb9, 0x48, 0x28, 0x10, - 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x3c, 0xa0, 0x0a, 0x08, 0x04, 0x07, 0xc4, 0xe5, 0xae, 0xe4, 0xc9, 0x2e, 0xe5, 0x20, 0xa0, 0x40, - 0x40, 0x5d, 0xa1, 0x42, 0x50, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5a, 0xa0, 0x05, 0x02, 0x01, 0xe1, 0x65, 0xae, 0xe4, 0xc9, 0x2e, 0xe5, 0x20, 0xa0, 0x40, 0x40}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5a, 0xa0, 0x06, 0x02, 0x01, 0xc1, 0xf1, 0x39, 0x6b, 0xb9, 0x32, 0x4b, 0xb9, 0x48, 0x28, 0x10, - 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5a, 0xa0, 0x05, 0xc2, 0x01, 0xe1, 0xc4, 0xf9, 0x6b, 0xb9, 0x32, 0x4b, 0xb9, 0x48, 0x28, 0x10, - 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5d, 0xa0, 0x07, 0x82, 0x00, 0xb8, 0x7c, 0x4e, 0x5a, 0xee, 0x4c, 0x92, 0xee, 0x52, 0x0a, 0x04, - 0x04, 0x05, 0xda, 0x14, 0x25, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5d, 0xa0, 0x02, 0x80, 0x80, 0x2e, 0x1f, 0x13, 0x96, 0xbb, 0x93, 0x24, 0xbb, 0x94, 0x82, 0x81, - 0x01, 0x01, 0x76, 0x85, 0x09, 0x40, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04}, - - {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, - 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, - 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5d, 0xa0, 0x02, 0x80, 0x80, 0x3c, 0x16, 0x5a, 0xee, 0x4c, 0x92, 0xee, 0x52, 0x0a, 0x04, 0x04}, - - // From http://jell.yfish.us/ jellyfish-3-mbps-hd-hevc.mkv sample - {0x01, 0x01, 0x60, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xf0, 0x00, 0xff, - 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, 0x03, 0xa0, 0x00, 0x01, 0x00, 0x18, 0x40, 0x01, 0x0c, 0x01, - 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x78, 0x99, 0x98, 0x09, 0xa1, 0x00, 0x01, 0x00, 0x29, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, - 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x78, 0xa0, 0x03, 0xc0, 0x80, 0x10, - 0xe5, 0x96, 0x66, 0x69, 0x24, 0xca, 0xf0, 0x10, 0x10, 0x00, 0x00, 0x06, 0x40, 0x00, 0x00, 0xbb, - 0x50, 0x80, 0xa2, 0x00, 0x01, 0x00, 0x07, 0x44, 0x01, 0xc1, 0x72, 0xb4, 0x62, 0x40}, - - // From http://jell.yfish.us/ jellyfish-3-mbps-hd-hevc-10bit.mkv sample - {0x01, 0x02, 0x20, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xf0, 0x00, 0xff, - 0xfd, 0xfa, 0xfa, 0x00, 0x00, 0x0f, 0x03, 0xa0, 0x00, 0x01, 0x00, 0x19, 0x40, 0x01, 0x0c, 0x01, - 0xff, 0xff, 0x02, 0x20, 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x78, 0x99, 0x8a, 0x02, 0x40, 0xa1, 0x00, 0x01, 0x00, 0x2b, 0x42, 0x01, 0x01, 0x02, 0x20, 0x00, - 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x78, 0xa0, 0x03, 0xc0, 0x80, - 0x10, 0xe4, 0xd9, 0x66, 0x62, 0xa4, 0x90, 0x84, 0x6b, 0xc0, 0x40, 0x40, 0x00, 0x00, 0x19, 0x00, - 0x00, 0x03, 0x02, 0xed, 0x42, 0xa2, 0x00, 0x01, 0x00, 0x07, 0x44, 0x01, 0xc1, 0x76, 0xb6, 0x62, - 0x40}, - - // From https://developer.apple.com/streaming/examples/advanced-stream-hevc.html - {0x01, 0x02, 0x00, 0x00, 0x00, 0x04, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0xf0, 0x00, 0xfc, - 0xfd, 0xfa, 0xfa, 0x00, 0x00, 0x0f, 0x03, 0xa0, 0x00, 0x01, 0x00, 0x18, 0x40, 0x01, 0x0c, 0x01, - 0xff, 0xff, 0x02, 0x20, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x7b, 0x18, 0xb0, 0x24, 0xa1, 0x00, 0x01, 0x00, 0x3c, 0x42, 0x01, 0x01, 0x02, 0x20, 0x00, 0x00, - 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x7b, 0xa0, 0x02, 0x80, 0x80, 0x2d, - 0x13, 0x67, 0x18, 0xb9, 0x24, 0x48, 0x05, 0x38, 0x88, 0x89, 0x2c, 0xf2, 0x4a, 0x69, 0x27, 0x2c, - 0x91, 0x24, 0x92, 0x2d, 0xc9, 0x1a, 0xa4, 0x8f, 0xca, 0x22, 0x3f, 0xf0, 0x00, 0x10, 0x00, 0x16, - 0xa0, 0x20, 0x20, 0x20, 0x10, 0xa2, 0x00, 0x01, 0x00, 0x08, 0x44, 0x01, 0xc0, 0x25, 0x2f, 0x05, - 0x32, 0x40}, - - // From https://bitmovin.com/demos/multi-codec-streaming - {0x01, 0x01, 0x60, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d, 0xf0, 0x00, 0xff, - 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, 0x03, 0xa0, 0x00, 0x01, 0x00, 0x18, 0x40, 0x01, 0x0c, 0x01, - 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, - 0x5d, 0x99, 0x98, 0x09, 0xa1, 0x00, 0x01, 0x00, 0x28, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, - 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xa0, 0x02, 0x80, 0x80, 0x2d, - 0x16, 0x59, 0x99, 0xa4, 0x93, 0x0b, 0x80, 0x40, 0x00, 0x00, 0x03, 0x00, 0x40, 0x00, 0x00, 0x06, - 0x42, 0xa2, 0x00, 0x01, 0x00, 0x07, 0x44, 0x01, 0xc1, 0x72, 0xb0, 0x62, 0x40}, - - // From http://dash.akamaized.net/dash264/TestCasesHEVC/1a/5/video_10M_init.mp4 - {0x01, 0x02, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, 0xf0, 0x00, 0xfc, - 0xfd, 0xfa, 0xfa, 0x00, 0x00, 0x0f, 0x03, 0x20, 0x00, 0x01, 0x00, 0x19, 0x40, 0x01, 0x0c, 0x01, - 0xff, 0xff, 0x02, 0x60, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, - 0x00, 0xba, 0x98, 0x90, 0x24, 0x21, 0x00, 0x01, 0x00, 0x37, 0x42, 0x01, 0x01, 0x02, 0x60, 0x00, - 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0xba, 0xa0, 0x01, 0xe0, - 0x20, 0x02, 0x1c, 0x4d, 0x96, 0x62, 0x64, 0x93, 0x21, 0x4e, 0x22, 0x22, 0x48, 0x92, 0x49, 0xaa, - 0x92, 0x44, 0xf5, 0x24, 0xde, 0xb9, 0x26, 0x94, 0x95, 0x37, 0x93, 0xa9, 0xac, 0xdc, 0xa2, 0x2c, - 0x80, 0x22, 0x00, 0x01, 0x00, 0x07, 0x44, 0x01, 0xc0, 0x71, 0x82, 0xd9, 0x20}, + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xa0, 0x18, 0x20, 0x28, 0x71, 0x31, 0x39, 0x6b, 0xb9, 0x32, 0x4b, + 0xb9, 0x48, 0x28, 0x10, 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x3c, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x3c, 0xa0, 0x0a, 0x08, 0x04, 0x07, 0xc4, 0xe5, 0xae, 0xe4, 0xc9, 0x2e, + 0xe5, 0x20, 0xa0, 0x40, 0x40, 0x5d, 0xa1, 0x42, 0x50, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5a, 0xa0, 0x05, 0x02, 0x01, 0xe1, 0x65, 0xae, 0xe4, 0xc9, 0x2e, 0xe5, 0x20, 0xa0, 0x40, 0x40}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xa0, 0x06, 0x02, 0x01, 0xc1, 0xf1, 0x39, 0x6b, 0xb9, 0x32, 0x4b, + 0xb9, 0x48, 0x28, 0x10, 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5a, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5a, 0xa0, 0x05, 0xc2, 0x01, 0xe1, 0xc4, 0xf9, 0x6b, 0xb9, 0x32, 0x4b, + 0xb9, 0x48, 0x28, 0x10, 0x10, 0x17, 0x68, 0x50, 0x94, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xa0, 0x07, 0x82, 0x00, 0xb8, 0x7c, 0x4e, 0x5a, 0xee, 0x4c, 0x92, + 0xee, 0x52, 0x0a, 0x04, 0x04, 0x05, 0xda, 0x14, 0x25, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04, 0x20}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xa0, 0x02, 0x80, 0x80, 0x2e, 0x1f, 0x13, 0x96, 0xbb, 0x93, 0x24, + 0xbb, 0x94, 0x82, 0x81, 0x01, 0x01, 0x76, 0x85, 0x09, 0x40, 0x00, 0x00, 0x00, 0x01, 0x44, 0x01, 0xc0, 0xf1, 0x80, 0x04}, + + {0x00, 0x00, 0x00, 0x01, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x03, 0x00, 0x5d, 0xac, 0x59, 0x00, 0x00, 0x00, 0x01, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5d, 0xa0, 0x02, 0x80, 0x80, 0x3c, 0x16, 0x5a, 0xee, 0x4c, 0x92, 0xee, 0x52, 0x0a, 0x04, 0x04}, + + // From http://jell.yfish.us/ jellyfish-3-mbps-hd-hevc.mkv sample + {0x01, 0x01, 0x60, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xf0, 0x00, 0xff, 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, + 0x03, 0xa0, 0x00, 0x01, 0x00, 0x18, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x78, 0x99, 0x98, 0x09, 0xa1, 0x00, 0x01, 0x00, 0x29, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x78, 0xa0, 0x03, 0xc0, 0x80, 0x10, 0xe5, 0x96, 0x66, 0x69, 0x24, 0xca, 0xf0, 0x10, + 0x10, 0x00, 0x00, 0x06, 0x40, 0x00, 0x00, 0xbb, 0x50, 0x80, 0xa2, 0x00, 0x01, 0x00, 0x07, 0x44, 0x01, 0xc1, 0x72, 0xb4, 0x62, 0x40}, + + // From http://jell.yfish.us/ jellyfish-3-mbps-hd-hevc-10bit.mkv sample + {0x01, 0x02, 0x20, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x78, 0xf0, 0x00, 0xff, 0xfd, 0xfa, 0xfa, 0x00, 0x00, 0x0f, 0x03, + 0xa0, 0x00, 0x01, 0x00, 0x19, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x02, 0x20, 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, + 0x03, 0x00, 0x78, 0x99, 0x8a, 0x02, 0x40, 0xa1, 0x00, 0x01, 0x00, 0x2b, 0x42, 0x01, 0x01, 0x02, 0x20, 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, + 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x78, 0xa0, 0x03, 0xc0, 0x80, 0x10, 0xe4, 0xd9, 0x66, 0x62, 0xa4, 0x90, 0x84, 0x6b, 0xc0, 0x40, 0x40, + 0x00, 0x00, 0x19, 0x00, 0x00, 0x03, 0x02, 0xed, 0x42, 0xa2, 0x00, 0x01, 0x00, 0x07, 0x44, 0x01, 0xc1, 0x76, 0xb6, 0x62, 0x40}, + + // From https://developer.apple.com/streaming/examples/advanced-stream-hevc.html + {0x01, 0x02, 0x00, 0x00, 0x00, 0x04, 0xb0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7b, 0xf0, 0x00, 0xfc, 0xfd, 0xfa, 0xfa, 0x00, 0x00, 0x0f, + 0x03, 0xa0, 0x00, 0x01, 0x00, 0x18, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x02, 0x20, 0x00, 0x00, 0x03, 0x00, 0xb0, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x7b, 0x18, 0xb0, 0x24, 0xa1, 0x00, 0x01, 0x00, 0x3c, 0x42, 0x01, 0x01, 0x02, 0x20, 0x00, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x7b, 0xa0, 0x02, 0x80, 0x80, 0x2d, 0x13, 0x67, 0x18, 0xb9, 0x24, 0x48, 0x05, 0x38, + 0x88, 0x89, 0x2c, 0xf2, 0x4a, 0x69, 0x27, 0x2c, 0x91, 0x24, 0x92, 0x2d, 0xc9, 0x1a, 0xa4, 0x8f, 0xca, 0x22, 0x3f, 0xf0, 0x00, 0x10, + 0x00, 0x16, 0xa0, 0x20, 0x20, 0x20, 0x10, 0xa2, 0x00, 0x01, 0x00, 0x08, 0x44, 0x01, 0xc0, 0x25, 0x2f, 0x05, 0x32, 0x40}, + + // From https://bitmovin.com/demos/multi-codec-streaming + {0x01, 0x01, 0x60, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5d, 0xf0, 0x00, 0xff, 0xfd, 0xf8, 0xf8, 0x00, 0x00, 0x0f, + 0x03, 0xa0, 0x00, 0x01, 0x00, 0x18, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, 0x90, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x5d, 0x99, 0x98, 0x09, 0xa1, 0x00, 0x01, 0x00, 0x28, 0x42, 0x01, 0x01, 0x01, 0x60, 0x00, 0x00, 0x03, 0x00, + 0x90, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x5d, 0xa0, 0x02, 0x80, 0x80, 0x2d, 0x16, 0x59, 0x99, 0xa4, 0x93, 0x0b, 0x80, 0x40, + 0x00, 0x00, 0x03, 0x00, 0x40, 0x00, 0x00, 0x06, 0x42, 0xa2, 0x00, 0x01, 0x00, 0x07, 0x44, 0x01, 0xc1, 0x72, 0xb0, 0x62, 0x40}, + + // From http://dash.akamaized.net/dash264/TestCasesHEVC/1a/5/video_10M_init.mp4 + {0x01, 0x02, 0x60, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xba, 0xf0, 0x00, 0xfc, 0xfd, 0xfa, 0xfa, 0x00, 0x00, + 0x0f, 0x03, 0x20, 0x00, 0x01, 0x00, 0x19, 0x40, 0x01, 0x0c, 0x01, 0xff, 0xff, 0x02, 0x60, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, + 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0xba, 0x98, 0x90, 0x24, 0x21, 0x00, 0x01, 0x00, 0x37, 0x42, 0x01, 0x01, 0x02, 0x60, + 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x00, 0xba, 0xa0, 0x01, 0xe0, 0x20, 0x02, 0x1c, 0x4d, + 0x96, 0x62, 0x64, 0x93, 0x21, 0x4e, 0x22, 0x22, 0x48, 0x92, 0x49, 0xaa, 0x92, 0x44, 0xf5, 0x24, 0xde, 0xb9, 0x26, 0x94, 0x95, + 0x37, 0x93, 0xa9, 0xac, 0xdc, 0xa2, 0x2c, 0x80, 0x22, 0x00, 0x01, 0x00, 0x07, 0x44, 0x01, 0xc0, 0x71, 0x82, 0xd9, 0x20}, }; UINT32 cpdSizes[NUMBER_OF_H265_CPDS] = {80, 80, 64, 80, 80, 80, 80, 64, 110, 113, 130, 109, 125}; @@ -303,8 +250,7 @@ TEST_F(SpsParserTest, spsParser_AnnexB_H265) { for (i = 0; i < NUMBER_OF_H265_CPDS; i++) { width = height = 0; - EXPECT_EQ(STATUS_SUCCESS, getVideoWidthAndHeightFromH265Sps(cpd[i], cpdSizes[i], &width, &height)) - << "Failed on iteration " << i; + EXPECT_EQ(STATUS_SUCCESS, getVideoWidthAndHeightFromH265Sps(cpd[i], cpdSizes[i], &width, &height)) << "Failed on iteration " << i; EXPECT_EQ(widths[i], width) << "Failed on iteration " << i; EXPECT_EQ(heights[i], height) << "Failed on iteration " << i; } diff --git a/tst/state/StateApiFunctionalityTest.cpp b/tst/state/StateApiFunctionalityTest.cpp index ac9e9e64e..90afc9b69 100644 --- a/tst/state/StateApiFunctionalityTest.cpp +++ b/tst/state/StateApiFunctionalityTest.cpp @@ -1,8 +1,10 @@ #include "StateTestFixture.h" class StateApiFunctionalityTest : public StateTestBase { -public: - StateApiFunctionalityTest() : mTestStateCount(0) {} + public: + StateApiFunctionalityTest() : mTestStateCount(0) + { + } UINT32 mTestStateCount; }; @@ -86,7 +88,6 @@ STATUS executeFunctionalityTestState(UINT64 customData, UINT64 time) return retStatus; } - TEST_F(StateApiFunctionalityTest, nullExecuteFn) { PStateMachine pStateMachine; @@ -104,12 +105,9 @@ TEST_F(StateApiFunctionalityTest, nullExecuteFn) // Set the state 1 execute function to null states[1].executeStateFn = NULL; - EXPECT_EQ(STATUS_SUCCESS, createStateMachine(states, - TEST_STATE_MACHINE_STATE_COUNT, - (UINT64) this, - kinesisVideoStreamDefaultGetCurrentTime, - (UINT64) this, - &pStateMachine)); + EXPECT_EQ(STATUS_SUCCESS, + createStateMachine(states, TEST_STATE_MACHINE_STATE_COUNT, (UINT64) this, kinesisVideoStreamDefaultGetCurrentTime, (UINT64) this, + &pStateMachine)); EXPECT_EQ(STATUS_SUCCESS, stepStateMachine(pStateMachine)); @@ -130,12 +128,9 @@ TEST_F(StateApiFunctionalityTest, nullGetNextStateFn) // Set the state 0 execute function to null states[0].getNextStateFn = NULL; - EXPECT_EQ(STATUS_SUCCESS, createStateMachine(states, - TEST_STATE_MACHINE_STATE_COUNT, - (UINT64) this, - kinesisVideoStreamDefaultGetCurrentTime, - (UINT64) this, - &pStateMachine)); + EXPECT_EQ(STATUS_SUCCESS, + createStateMachine(states, TEST_STATE_MACHINE_STATE_COUNT, (UINT64) this, kinesisVideoStreamDefaultGetCurrentTime, (UINT64) this, + &pStateMachine)); EXPECT_NE(STATUS_SUCCESS, stepStateMachine(pStateMachine)); @@ -248,4 +243,3 @@ TEST_F(StateApiFunctionalityTest, checkForStateMachineTransitionBasicTest) EXPECT_EQ(STATUS_SUCCESS, checkForStateTransition(mStateMachine, &transition)); EXPECT_EQ(TRUE, transition); } - diff --git a/tst/state/StateApiTest.cpp b/tst/state/StateApiTest.cpp index 320aac3c4..f6a31e1f2 100644 --- a/tst/state/StateApiTest.cpp +++ b/tst/state/StateApiTest.cpp @@ -3,32 +3,30 @@ extern StateMachineState TEST_STATE_MACHINE_STATES[]; extern UINT32 TEST_STATE_MACHINE_STATE_COUNT; -class StateApiTest : public StateTestBase { -}; +class StateApiTest : public StateTestBase {}; TEST_F(StateApiTest, createStateMachine_InvalidInput) { PStateMachine pStateMachine; - EXPECT_NE(STATUS_SUCCESS, createStateMachine(NULL, TEST_STATE_MACHINE_STATE_COUNT, (UINT64) this, - kinesisVideoStreamDefaultGetCurrentTime, (UINT64) this, - &pStateMachine)); + EXPECT_NE(STATUS_SUCCESS, + createStateMachine(NULL, TEST_STATE_MACHINE_STATE_COUNT, (UINT64) this, kinesisVideoStreamDefaultGetCurrentTime, (UINT64) this, + &pStateMachine)); - EXPECT_NE(STATUS_SUCCESS, createStateMachine(TEST_STATE_MACHINE_STATES, 0, (UINT64) this, - kinesisVideoStreamDefaultGetCurrentTime, (UINT64) this, - &pStateMachine)); + EXPECT_NE( + STATUS_SUCCESS, + createStateMachine(TEST_STATE_MACHINE_STATES, 0, (UINT64) this, kinesisVideoStreamDefaultGetCurrentTime, (UINT64) this, &pStateMachine)); - EXPECT_NE(STATUS_SUCCESS, createStateMachine(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, - (UINT64) this, kinesisVideoStreamDefaultGetCurrentTime, - (UINT64) this, NULL)); + EXPECT_NE(STATUS_SUCCESS, + createStateMachine(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, (UINT64) this, kinesisVideoStreamDefaultGetCurrentTime, + (UINT64) this, NULL)); - EXPECT_NE(STATUS_SUCCESS, createStateMachine(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, - (UINT64) this, NULL, - (UINT64) this, &pStateMachine)); + EXPECT_NE(STATUS_SUCCESS, + createStateMachine(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, (UINT64) this, NULL, (UINT64) this, &pStateMachine)); - EXPECT_EQ(STATUS_SUCCESS, createStateMachine(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, - (UINT64) this, kinesisVideoStreamDefaultGetCurrentTime, - (UINT64) this, &pStateMachine)); + EXPECT_EQ(STATUS_SUCCESS, + createStateMachine(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, (UINT64) this, kinesisVideoStreamDefaultGetCurrentTime, + (UINT64) this, &pStateMachine)); EXPECT_EQ(STATUS_SUCCESS, freeStateMachine(pStateMachine)); EXPECT_EQ(STATUS_SUCCESS, freeStateMachine(NULL)); @@ -75,9 +73,9 @@ TEST_F(StateApiTest, resetStateMachineRetryCount_InvalidInput) TEST_F(StateApiTest, checkForStateTransition_InvalidInput) { BOOL testBool = FALSE; - EXPECT_NE(STATUS_SUCCESS, checkForStateTransition(NULL,NULL)); - EXPECT_NE(STATUS_SUCCESS, checkForStateTransition(NULL,&testBool)); - EXPECT_NE(STATUS_SUCCESS, checkForStateTransition(mStateMachine,NULL)); + EXPECT_NE(STATUS_SUCCESS, checkForStateTransition(NULL, NULL)); + EXPECT_NE(STATUS_SUCCESS, checkForStateTransition(NULL, &testBool)); + EXPECT_NE(STATUS_SUCCESS, checkForStateTransition(mStateMachine, NULL)); EXPECT_EQ(STATUS_SUCCESS, checkForStateTransition(mStateMachine, &testBool)); } @@ -86,17 +84,17 @@ TEST_F(StateApiTest, createStateMachineWithName_InvalidArg) { PStateMachine pStateMachine = NULL; CHAR longRandomName[34] = "abcdefghijklmnopqrstuvwxyzABCDEFG"; - EXPECT_EQ(STATUS_NULL_ARG, createStateMachineWithName(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, - (UINT64) this, kinesisVideoStreamDefaultGetCurrentTime, - (UINT64) this, NULL, &pStateMachine)); + EXPECT_EQ(STATUS_NULL_ARG, + createStateMachineWithName(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, (UINT64) this, + kinesisVideoStreamDefaultGetCurrentTime, (UINT64) this, NULL, &pStateMachine)); EXPECT_EQ(NULL, getStateMachineName(pStateMachine)); - EXPECT_EQ(STATUS_STATE_MACHINE_NAME_LEN_INVALID, createStateMachineWithName(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, - (UINT64) this, kinesisVideoStreamDefaultGetCurrentTime, - (UINT64) this, (PCHAR)"", &pStateMachine)); + EXPECT_EQ(STATUS_STATE_MACHINE_NAME_LEN_INVALID, + createStateMachineWithName(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, (UINT64) this, + kinesisVideoStreamDefaultGetCurrentTime, (UINT64) this, (PCHAR) "", &pStateMachine)); EXPECT_EQ(NULL, getStateMachineName(pStateMachine)); - EXPECT_EQ(STATUS_STATE_MACHINE_NAME_LEN_INVALID, createStateMachineWithName(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, - (UINT64) this, kinesisVideoStreamDefaultGetCurrentTime, - (UINT64) this, longRandomName, &pStateMachine)); + EXPECT_EQ(STATUS_STATE_MACHINE_NAME_LEN_INVALID, + createStateMachineWithName(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, (UINT64) this, + kinesisVideoStreamDefaultGetCurrentTime, (UINT64) this, longRandomName, &pStateMachine)); EXPECT_EQ(STATUS_SUCCESS, freeStateMachine(pStateMachine)); } @@ -104,14 +102,14 @@ TEST_F(StateApiTest, createStateMachineWithName_ValidArg) { PStateMachine pStateMachine; CHAR maxLengthRandomName[33] = "abcdefghijklmnopqrstuvwxyzABCDEF"; - EXPECT_EQ(STATUS_SUCCESS, createStateMachineWithName(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, - (UINT64) this, kinesisVideoStreamDefaultGetCurrentTime, - (UINT64) this, (PCHAR) "Test", &pStateMachine)); + EXPECT_EQ(STATUS_SUCCESS, + createStateMachineWithName(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, (UINT64) this, + kinesisVideoStreamDefaultGetCurrentTime, (UINT64) this, (PCHAR) "Test", &pStateMachine)); EXPECT_STREQ("Test", getStateMachineName(pStateMachine)); EXPECT_EQ(STATUS_SUCCESS, freeStateMachine(pStateMachine)); - EXPECT_EQ(STATUS_SUCCESS, createStateMachineWithName(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, - (UINT64) this, kinesisVideoStreamDefaultGetCurrentTime, - (UINT64) this, maxLengthRandomName, &pStateMachine)); + EXPECT_EQ(STATUS_SUCCESS, + createStateMachineWithName(TEST_STATE_MACHINE_STATES, TEST_STATE_MACHINE_STATE_COUNT, (UINT64) this, + kinesisVideoStreamDefaultGetCurrentTime, (UINT64) this, maxLengthRandomName, &pStateMachine)); EXPECT_STREQ(maxLengthRandomName, getStateMachineName(pStateMachine)); EXPECT_EQ(STATUS_SUCCESS, freeStateMachine(pStateMachine)); } \ No newline at end of file diff --git a/tst/state/StateTestFixture.cpp b/tst/state/StateTestFixture.cpp index 7d10721d3..9f9526c82 100644 --- a/tst/state/StateTestFixture.cpp +++ b/tst/state/StateTestFixture.cpp @@ -1,12 +1,17 @@ #include "StateTestFixture.h" StateMachineState TEST_STATE_MACHINE_STATES[] = { - {TEST_STATE_0, TEST_STATE_0 | TEST_STATE_1, fromTestState, executeTestState, stateTransitionHook, INFINITE_RETRY_COUNT_SENTINEL, STATUS_INVALID_OPERATION}, + {TEST_STATE_0, TEST_STATE_0 | TEST_STATE_1, fromTestState, executeTestState, stateTransitionHook, INFINITE_RETRY_COUNT_SENTINEL, + STATUS_INVALID_OPERATION}, {TEST_STATE_1, TEST_STATE_0, fromTestState, executeTestState, stateTransitionHook, SERVICE_CALL_MAX_RETRY_COUNT, STATUS_INVALID_OPERATION}, - {TEST_STATE_2, TEST_STATE_0 | TEST_STATE_1 | TEST_STATE_2 | TEST_STATE_3 | TEST_STATE_4 | TEST_STATE_5, fromTestState, executeTestState, stateTransitionHook, SERVICE_CALL_MAX_RETRY_COUNT, STATUS_INVALID_OPERATION}, - {TEST_STATE_3, TEST_STATE_2 | TEST_STATE_3, fromTestState, executeTestState, stateTransitionHook, SERVICE_CALL_MAX_RETRY_COUNT, STATUS_INVALID_OPERATION}, - {TEST_STATE_4, TEST_STATE_3 | TEST_STATE_4, fromTestState, executeTestState, stateTransitionHook, INFINITE_RETRY_COUNT_SENTINEL, STATUS_INVALID_OPERATION}, - {TEST_STATE_5, TEST_STATE_4 | TEST_STATE_5, fromTestState, executeTestState, stateTransitionHook, SERVICE_CALL_MAX_RETRY_COUNT, STATUS_INVALID_OPERATION}, + {TEST_STATE_2, TEST_STATE_0 | TEST_STATE_1 | TEST_STATE_2 | TEST_STATE_3 | TEST_STATE_4 | TEST_STATE_5, fromTestState, executeTestState, + stateTransitionHook, SERVICE_CALL_MAX_RETRY_COUNT, STATUS_INVALID_OPERATION}, + {TEST_STATE_3, TEST_STATE_2 | TEST_STATE_3, fromTestState, executeTestState, stateTransitionHook, SERVICE_CALL_MAX_RETRY_COUNT, + STATUS_INVALID_OPERATION}, + {TEST_STATE_4, TEST_STATE_3 | TEST_STATE_4, fromTestState, executeTestState, stateTransitionHook, INFINITE_RETRY_COUNT_SENTINEL, + STATUS_INVALID_OPERATION}, + {TEST_STATE_5, TEST_STATE_4 | TEST_STATE_5, fromTestState, executeTestState, stateTransitionHook, SERVICE_CALL_MAX_RETRY_COUNT, + STATUS_INVALID_OPERATION}, }; UINT32 TEST_STATE_MACHINE_STATE_COUNT = SIZEOF(TEST_STATE_MACHINE_STATES) / SIZEOF(StateMachineState); diff --git a/tst/trace/TraceApiFunctionalityTest.cpp b/tst/trace/TraceApiFunctionalityTest.cpp index 170ffb1c6..ab206c439 100644 --- a/tst/trace/TraceApiFunctionalityTest.cpp +++ b/tst/trace/TraceApiFunctionalityTest.cpp @@ -1,7 +1,6 @@ #include "TraceTestFixture.h" -class TraceApiFunctionalityTest : public TraceTestBase { -}; +class TraceApiFunctionalityTest : public TraceTestBase {}; TEST_F(TraceApiFunctionalityTest, OverflowTest_StartStop) { @@ -10,7 +9,8 @@ TEST_F(TraceApiFunctionalityTest, OverflowTest_StartStop) UINT32 traceCount = 200; UINT32 index; - EXPECT_TRUE(STATUS_SUCCEEDED(profilerInitialize(SIZEOF(TraceProfiler) + traceCount * SIZEOF(Trace), TRACE_LEVEL_REPORT_ALWAYS, FLAGS_USE_AIV_TRACE_PROFILER_FORMAT, &handle))); + EXPECT_TRUE(STATUS_SUCCEEDED(profilerInitialize(SIZEOF(TraceProfiler) + traceCount * SIZEOF(Trace), TRACE_LEVEL_REPORT_ALWAYS, + FLAGS_USE_AIV_TRACE_PROFILER_FORMAT, &handle))); // // Set the trace levels to INFO @@ -51,7 +51,8 @@ TEST_F(TraceApiFunctionalityTest, OverflowTest_StartOnly) UINT32 traceCount = 200; UINT32 index; - EXPECT_TRUE(STATUS_SUCCEEDED(profilerInitialize(SIZEOF(TraceProfiler) + traceCount * SIZEOF(Trace), TRACE_LEVEL_REPORT_ALWAYS, FLAGS_USE_AIV_TRACE_PROFILER_FORMAT, &handle))); + EXPECT_TRUE(STATUS_SUCCEEDED(profilerInitialize(SIZEOF(TraceProfiler) + traceCount * SIZEOF(Trace), TRACE_LEVEL_REPORT_ALWAYS, + FLAGS_USE_AIV_TRACE_PROFILER_FORMAT, &handle))); // // Set the trace levels to INFO @@ -91,7 +92,8 @@ TEST_F(TraceApiFunctionalityTest, OverflowTest_StartStopNoop) UINT32 traceCount = 200; UINT32 index; - EXPECT_TRUE(STATUS_SUCCEEDED(profilerInitialize(SIZEOF(TraceProfiler) + traceCount * SIZEOF(Trace), TRACE_LEVEL_REPORT_ALWAYS, FLAGS_USE_AIV_TRACE_PROFILER_FORMAT, &handle))); + EXPECT_TRUE(STATUS_SUCCEEDED(profilerInitialize(SIZEOF(TraceProfiler) + traceCount * SIZEOF(Trace), TRACE_LEVEL_REPORT_ALWAYS, + FLAGS_USE_AIV_TRACE_PROFILER_FORMAT, &handle))); // // Set the trace levels to INFO @@ -152,7 +154,8 @@ TEST_F(TraceApiFunctionalityTest, GetFormattedBuffer) UINT64 currentTime = 10000000000L; PCHAR pBuffer = NULL; - EXPECT_TRUE(STATUS_SUCCEEDED(profilerInitialize(SIZEOF(TraceProfiler) + traceCount * SIZEOF(Trace), TRACE_LEVEL_REPORT_ALWAYS, FLAGS_USE_AIV_TRACE_PROFILER_FORMAT, &handle))); + EXPECT_TRUE(STATUS_SUCCEEDED(profilerInitialize(SIZEOF(TraceProfiler) + traceCount * SIZEOF(Trace), TRACE_LEVEL_REPORT_ALWAYS, + FLAGS_USE_AIV_TRACE_PROFILER_FORMAT, &handle))); // // Set the trace levels to INFO @@ -160,7 +163,8 @@ TEST_F(TraceApiFunctionalityTest, GetFormattedBuffer) EXPECT_TRUE(STATUS_SUCCEEDED(setProfilerLevel(handle, TRACE_LEVEL_INFO))); for (index = 0; index < traceCount + overflowCount; index++) { - EXPECT_TRUE(STATUS_SUCCEEDED(traceStartInternalWorker(handle, TEST_TRACE_NAME, TRACE_LEVEL_CRITICAL, &traceHandle, 100 + index, (PCHAR) "ThreadName", currentTime))); + EXPECT_TRUE(STATUS_SUCCEEDED( + traceStartInternalWorker(handle, TEST_TRACE_NAME, TRACE_LEVEL_CRITICAL, &traceHandle, 100 + index, (PCHAR) "ThreadName", currentTime))); EXPECT_TRUE(traceHandle != INVALID_TRACE_HANDLE_VALUE); currentTime += 200000; EXPECT_TRUE(STATUS_SUCCEEDED(traceStopInternalWorker(handle, traceHandle, currentTime))); @@ -189,7 +193,8 @@ TEST_F(TraceApiFunctionalityTest, GetFormattedBuffer) EXPECT_TRUE(STATUS_SUCCEEDED(profilerRelease(handle))); // Create again for the noop operations - EXPECT_TRUE(STATUS_SUCCEEDED(profilerInitialize(SIZEOF(TraceProfiler) + traceCount * SIZEOF(Trace), TRACE_LEVEL_INFO, FLAGS_USE_AIV_TRACE_PROFILER_FORMAT, &handle))); + EXPECT_TRUE(STATUS_SUCCEEDED( + profilerInitialize(SIZEOF(TraceProfiler) + traceCount * SIZEOF(Trace), TRACE_LEVEL_INFO, FLAGS_USE_AIV_TRACE_PROFILER_FORMAT, &handle))); pTraceProfiler = TRACE_PROFILER_HANDLE_TO_POINTER(handle); EXPECT_TRUE(pTraceProfiler->traceLevel == TRACE_LEVEL_INFO); @@ -197,7 +202,8 @@ TEST_F(TraceApiFunctionalityTest, GetFormattedBuffer) // Lower priority trace // for (index = 0; index < traceCount + overflowCount; index++) { - EXPECT_TRUE(STATUS_SUCCEEDED(traceStartInternalWorker(handle, TEST_TRACE_NAME, TRACE_LEVEL_VERBOSE, &traceHandle, 100 + index, (PCHAR) "ThreadName", currentTime))); + EXPECT_TRUE(STATUS_SUCCEEDED( + traceStartInternalWorker(handle, TEST_TRACE_NAME, TRACE_LEVEL_VERBOSE, &traceHandle, 100 + index, (PCHAR) "ThreadName", currentTime))); EXPECT_TRUE(traceHandle == INVALID_TRACE_HANDLE_VALUE); currentTime += 200000; EXPECT_TRUE(STATUS_SUCCEEDED(traceStopInternalWorker(handle, traceHandle, currentTime))); diff --git a/tst/trace/TraceApiTest.cpp b/tst/trace/TraceApiTest.cpp index 33c53197a..22a78c2d8 100644 --- a/tst/trace/TraceApiTest.cpp +++ b/tst/trace/TraceApiTest.cpp @@ -1,18 +1,20 @@ #include "TraceTestFixture.h" -class TraceApiTest : public TraceTestBase { -}; +class TraceApiTest : public TraceTestBase {}; -TEST_F(TraceApiTest, InvalidInputProfilerInitialize_NullPointer) { +TEST_F(TraceApiTest, InvalidInputProfilerInitialize_NullPointer) +{ EXPECT_TRUE(STATUS_FAILED(profilerInitialize(1000000, TRACE_LEVEL_REPORT_ALWAYS, FLAGS_USE_AIV_TRACE_PROFILER_FORMAT, NULL))); } -TEST_F(TraceApiTest, InvalidInputProfilerInitialize_SmallBuffer) { +TEST_F(TraceApiTest, InvalidInputProfilerInitialize_SmallBuffer) +{ TRACE_PROFILER_HANDLE handle; EXPECT_TRUE(STATUS_FAILED(profilerInitialize(100, TRACE_LEVEL_REPORT_ALWAYS, FLAGS_USE_AIV_TRACE_PROFILER_FORMAT, &handle))); } -TEST_F(TraceApiTest, InvalidInputProfilerRelease_InvalidHandleRelease) { +TEST_F(TraceApiTest, InvalidInputProfilerRelease_InvalidHandleRelease) +{ TRACE_PROFILER_HANDLE handle; EXPECT_TRUE(STATUS_SUCCEEDED(profilerInitialize(1000000, TRACE_LEVEL_REPORT_ALWAYS, FLAGS_USE_AIV_TRACE_PROFILER_FORMAT, &handle))); @@ -23,7 +25,8 @@ TEST_F(TraceApiTest, InvalidInputProfilerRelease_InvalidHandleRelease) { EXPECT_TRUE(STATUS_SUCCEEDED(profilerRelease(INVALID_TRACE_PROFILER_HANDLE))); } -TEST_F(TraceApiTest, InvalidInputSetLevel_InvalidHandleRelease) { +TEST_F(TraceApiTest, InvalidInputSetLevel_InvalidHandleRelease) +{ TRACE_PROFILER_HANDLE handle; EXPECT_TRUE(STATUS_SUCCEEDED(profilerInitialize(1000000, TRACE_LEVEL_REPORT_ALWAYS, FLAGS_USE_AIV_TRACE_PROFILER_FORMAT, &handle))); @@ -44,7 +47,6 @@ TEST_F(TraceApiTest, InvalidInputSetLevel_InvalidHandleRelease) { EXPECT_TRUE(pTraceProfiler->traceStartFn == traceStartInternal); EXPECT_TRUE(pTraceProfiler->traceStopFn == traceStopInternal); - EXPECT_TRUE(STATUS_SUCCEEDED(setProfilerLevel(handle, TRACE_LEVEL_DISABLED))); EXPECT_TRUE(STATUS_SUCCEEDED(setProfilerLevel(handle, TRACE_LEVEL_DISABLED))); @@ -59,8 +61,8 @@ TEST_F(TraceApiTest, InvalidInputSetLevel_InvalidHandleRelease) { EXPECT_TRUE(STATUS_SUCCEEDED(profilerRelease(handle))); } - -TEST_F(TraceApiTest, InvalidInputGetBuffer_InvalidInput) { +TEST_F(TraceApiTest, InvalidInputGetBuffer_InvalidInput) +{ TRACE_PROFILER_HANDLE handle; PCHAR pBuffer; UINT32 bufferSize; @@ -83,12 +85,13 @@ TEST_F(TraceApiTest, InvalidInputGetBuffer_InvalidInput) { EXPECT_TRUE(STATUS_SUCCEEDED(profilerRelease(handle))); } -TEST_F(TraceApiTest, InvalidInputFreeBuffer_NullPointer) { +TEST_F(TraceApiTest, InvalidInputFreeBuffer_NullPointer) +{ EXPECT_TRUE(STATUS_SUCCEEDED(freeTraceBuffer(NULL))); } - -TEST_F(TraceApiTest, InvalidInputSetLevel_InvalidInputTraceStartStop) { +TEST_F(TraceApiTest, InvalidInputSetLevel_InvalidInputTraceStartStop) +{ TRACE_PROFILER_HANDLE handle; TRACE_HANDLE traceHandle; diff --git a/tst/utils/BitField.cpp b/tst/utils/BitField.cpp index f4d0e8f44..df5ace37b 100644 --- a/tst/utils/BitField.cpp +++ b/tst/utils/BitField.cpp @@ -1,7 +1,6 @@ #include "UtilTestFixture.h" -class BitfieldFunctionalityTest : public UtilTestBase { -}; +class BitfieldFunctionalityTest : public UtilTestBase {}; TEST_F(BitfieldFunctionalityTest, NegativeInvalidInput_BitFieldCreate) { @@ -112,7 +111,6 @@ TEST_F(BitfieldFunctionalityTest, GetPutResetSubByteItemBitField) EXPECT_EQ(STATUS_SUCCESS, bitFieldGet(pBitField, 0, &isSet)); EXPECT_FALSE(isSet); - EXPECT_EQ(STATUS_SUCCESS, bitFieldGet(pBitField, 7, &isSet)); EXPECT_FALSE(isSet); diff --git a/tst/utils/BitReader.cpp b/tst/utils/BitReader.cpp index cee4971b1..3ca1f836f 100644 --- a/tst/utils/BitReader.cpp +++ b/tst/utils/BitReader.cpp @@ -1,7 +1,6 @@ #include "UtilTestFixture.h" -class BitReaderFunctionalityTest : public UtilTestBase { -}; +class BitReaderFunctionalityTest : public UtilTestBase {}; TEST_F(BitReaderFunctionalityTest, NegativeInvalidInput_BitReaderReset) { diff --git a/tst/utils/Crc32Test.cpp b/tst/utils/Crc32Test.cpp index ca1a30127..7ef6f61cb 100644 --- a/tst/utils/Crc32Test.cpp +++ b/tst/utils/Crc32Test.cpp @@ -1,7 +1,6 @@ #include "UtilTestFixture.h" -class Crc32Test : public UtilTestBase { -}; +class Crc32Test : public UtilTestBase {}; TEST_F(Crc32Test, crc32FunctionalityTest) { diff --git a/tst/utils/Directory.cpp b/tst/utils/Directory.cpp index 8ffa70974..424eade38 100644 --- a/tst/utils/Directory.cpp +++ b/tst/utils/Directory.cpp @@ -1,7 +1,6 @@ #include "UtilTestFixture.h" -class DirectoryFunctionalityTest : public UtilTestBase { -}; +class DirectoryFunctionalityTest : public UtilTestBase {}; #if 0 #pragma GCC diagnostic ignored "-Wwrite-strings" @@ -62,7 +61,7 @@ STATUS createSubDirStruct(PCHAR dirPath, UINT32 depth, UINT32 numberOfFiles, UIN return STATUS_SUCCESS; } - UINT32 strLen = (UINT32)STRLEN(dirPath); + UINT32 strLen = (UINT32) STRLEN(dirPath); // Create the files first for (UINT32 i = 0; i < numberOfFiles; i++) { @@ -155,7 +154,7 @@ TEST_F(DirectoryFunctionalityTest, CreateTraverseRemoveDirs) count = 0; EXPECT_EQ(STATUS_SUCCESS, traverseDirectory((PCHAR) TEMP_TEST_DIRECTORY_PATH, (UINT64) &count, TRUE, printDirInfo)); - EXPECT_EQ((3 + 3 + 3 * (3 + 3 + 3 * (3 + 3))), count); + EXPECT_EQ((3 + 3 + 3 * (3 + 3 + 3 * (3 + 3))), count); count = 0; EXPECT_EQ(STATUS_SUCCESS, traverseDirectory((PCHAR) TEMP_TEST_DIRECTORY_PATH, (UINT64) &count, FALSE, printDirInfo)); @@ -168,7 +167,7 @@ TEST_F(DirectoryFunctionalityTest, CreateTraverseRemoveDirs) count = 0; EXPECT_EQ(STATUS_SUCCESS, traverseDirectory((PCHAR) (TEMP_TEST_DIRECTORY_PATH FPATHSEPARATOR_STR), (UINT64) &count, TRUE, printDirInfo)); - EXPECT_EQ((3 + 3 + 3 * (3 + 3 + 3 * (3 + 3))), count); + EXPECT_EQ((3 + 3 + 3 * (3 + 3 + 3 * (3 + 3))), count); count = 0; EXPECT_EQ(STATUS_SUCCESS, traverseDirectory((PCHAR) (TEMP_TEST_DIRECTORY_PATH FPATHSEPARATOR_STR), (UINT64) &count, FALSE, printDirInfo)); diff --git a/tst/utils/DoubleLinkedList.cpp b/tst/utils/DoubleLinkedList.cpp index 758931cac..3f052b1f4 100644 --- a/tst/utils/DoubleLinkedList.cpp +++ b/tst/utils/DoubleLinkedList.cpp @@ -1,7 +1,6 @@ #include "UtilTestFixture.h" -class DoubleListFunctionalityTest : public UtilTestBase { -}; +class DoubleListFunctionalityTest : public UtilTestBase {}; TEST_F(DoubleListFunctionalityTest, NegativeInvalidInput_DoubleListCreate) { @@ -193,7 +192,7 @@ TEST_F(DoubleListFunctionalityTest, NegativeInvalidInput_DoubleListGetNodeCount) EXPECT_NE(STATUS_SUCCESS, doubleListGetNodeCount(pList, NULL)); } -TEST_F(DoubleListFunctionalityTest, DoubleListClear) +TEST_F(DoubleListFunctionalityTest, DoubleListClear) { PDoubleList pList; UINT64 count = 10; @@ -487,7 +486,8 @@ TEST_F(DoubleListFunctionalityTest, DoubleListInsertBeforeAfter) EXPECT_EQ(STATUS_SUCCESS, doubleListFree(pList)); } -TEST_F(DoubleListFunctionalityTest, DoubleListAppendNonEmptyList) { +TEST_F(DoubleListFunctionalityTest, DoubleListAppendNonEmptyList) +{ PDoubleList pListDst, pListToAppend; PDoubleListNode pNode; @@ -519,34 +519,34 @@ TEST_F(DoubleListFunctionalityTest, DoubleListAppendNonEmptyList) { EXPECT_NE(NULL, (UINT64) pNode); EXPECT_EQ(pNode->data, 10); EXPECT_EQ(STATUS_SUCCESS, doubleListGetNextNode(pNode, &pNode)); - EXPECT_NE(NULL, (UINT64) pNode); + EXPECT_NE(NULL, (UINT64) pNode); EXPECT_EQ(pNode->data, 20); EXPECT_EQ(STATUS_SUCCESS, doubleListGetNextNode(pNode, &pNode)); - EXPECT_NE(NULL, (UINT64) pNode); + EXPECT_NE(NULL, (UINT64) pNode); EXPECT_EQ(pNode->data, 30); EXPECT_EQ(STATUS_SUCCESS, doubleListGetNextNode(pNode, &pNode)); - EXPECT_NE(NULL, (UINT64) pNode); + EXPECT_NE(NULL, (UINT64) pNode); EXPECT_EQ(pNode->data, 40); EXPECT_EQ(STATUS_SUCCESS, doubleListGetNextNode(pNode, &pNode)); - EXPECT_NE(NULL, (UINT64) pNode); + EXPECT_NE(NULL, (UINT64) pNode); EXPECT_EQ(pNode->data, 50); EXPECT_EQ(STATUS_SUCCESS, doubleListGetNextNode(pNode, &pNode)); EXPECT_EQ(NULL, pNode); EXPECT_EQ(STATUS_SUCCESS, doubleListGetTailNode(pListDst, &pNode)); - EXPECT_NE(NULL, (UINT64) pNode); + EXPECT_NE(NULL, (UINT64) pNode); EXPECT_EQ(pNode->data, 50); EXPECT_EQ(STATUS_SUCCESS, doubleListGetPrevNode(pNode, &pNode)); - EXPECT_NE(NULL, (UINT64) pNode); + EXPECT_NE(NULL, (UINT64) pNode); EXPECT_EQ(pNode->data, 40); EXPECT_EQ(STATUS_SUCCESS, doubleListGetPrevNode(pNode, &pNode)); - EXPECT_NE(NULL, (UINT64) pNode); + EXPECT_NE(NULL, (UINT64) pNode); EXPECT_EQ(pNode->data, 30); EXPECT_EQ(STATUS_SUCCESS, doubleListGetPrevNode(pNode, &pNode)); - EXPECT_NE(NULL, (UINT64) pNode); + EXPECT_NE(NULL, (UINT64) pNode); EXPECT_EQ(pNode->data, 20); EXPECT_EQ(STATUS_SUCCESS, doubleListGetPrevNode(pNode, &pNode)); - EXPECT_NE(NULL, (UINT64) pNode); + EXPECT_NE(NULL, (UINT64) pNode); EXPECT_EQ(pNode->data, 10); EXPECT_EQ(STATUS_SUCCESS, doubleListGetPrevNode(pNode, &pNode)); EXPECT_EQ(NULL, pNode); @@ -555,7 +555,8 @@ TEST_F(DoubleListFunctionalityTest, DoubleListAppendNonEmptyList) { EXPECT_EQ(STATUS_SUCCESS, doubleListFree(pListDst)); } -TEST_F(DoubleListFunctionalityTest, DoubleListAppendEmptyListOrNull) { +TEST_F(DoubleListFunctionalityTest, DoubleListAppendEmptyListOrNull) +{ PDoubleList pListDst, pListToAppend; UINT64 data; diff --git a/tst/utils/Endianness.cpp b/tst/utils/Endianness.cpp index f7a8426e2..a900da5ab 100644 --- a/tst/utils/Endianness.cpp +++ b/tst/utils/Endianness.cpp @@ -1,7 +1,6 @@ #include "UtilTestFixture.h" -class EndiannessFunctionalityTest : public UtilTestBase { -}; +class EndiannessFunctionalityTest : public UtilTestBase {}; TEST_F(EndiannessFunctionalityTest, InitializeEndianness) { @@ -82,7 +81,7 @@ TEST_F(EndiannessFunctionalityTest, UnalignedPut) if (isBigEndian()) { EXPECT_EQ(data[0], 0x01); EXPECT_EQ(data[1], 0x02); - }else { + } else { EXPECT_EQ(data[0], 0x02); EXPECT_EQ(data[1], 0x01); } @@ -94,7 +93,7 @@ TEST_F(EndiannessFunctionalityTest, UnalignedPut) EXPECT_EQ(data[1], 0x02); EXPECT_EQ(data[2], 0x03); EXPECT_EQ(data[3], 0x04); - }else { + } else { EXPECT_EQ(data[0], 0x04); EXPECT_EQ(data[1], 0x03); EXPECT_EQ(data[2], 0x02); @@ -112,7 +111,7 @@ TEST_F(EndiannessFunctionalityTest, UnalignedPut) EXPECT_EQ(data[5], 0x06); EXPECT_EQ(data[6], 0x07); EXPECT_EQ(data[7], 0x08); - }else { + } else { EXPECT_EQ(data[0], 0x08); EXPECT_EQ(data[1], 0x07); EXPECT_EQ(data[2], 0x06); @@ -143,7 +142,7 @@ TEST_F(EndiannessFunctionalityTest, UnalignedPut) if (isBigEndian()) { EXPECT_EQ(data[1], 0x01); EXPECT_EQ(data[2], 0x02); - }else { + } else { EXPECT_EQ(data[1], 0x02); EXPECT_EQ(data[2], 0x01); } @@ -156,7 +155,7 @@ TEST_F(EndiannessFunctionalityTest, UnalignedPut) EXPECT_EQ(data[2], 0x02); EXPECT_EQ(data[3], 0x03); EXPECT_EQ(data[4], 0x04); - }else { + } else { EXPECT_EQ(data[1], 0x04); EXPECT_EQ(data[2], 0x03); EXPECT_EQ(data[3], 0x02); @@ -175,7 +174,7 @@ TEST_F(EndiannessFunctionalityTest, UnalignedPut) EXPECT_EQ(data[6], 0x06); EXPECT_EQ(data[7], 0x07); EXPECT_EQ(data[8], 0x08); - }else { + } else { EXPECT_EQ(data[1], 0x08); EXPECT_EQ(data[2], 0x07); EXPECT_EQ(data[3], 0x06); diff --git a/tst/utils/ExponentialBackoffUtilsTest.cpp b/tst/utils/ExponentialBackoffUtilsTest.cpp index afb835689..3b00405d1 100644 --- a/tst/utils/ExponentialBackoffUtilsTest.cpp +++ b/tst/utils/ExponentialBackoffUtilsTest.cpp @@ -9,12 +9,14 @@ typedef struct __Range { } Range; class ExponentialBackoffUtilsTest : public UtilTestBase { -public: - bool inRange(double number, Range& range) { + public: + bool inRange(double number, Range& range) + { return (range.low <= number && number <= range.high); } - void getTestRetryConfiguration(PExponentialBackoffRetryStrategyConfig pExponentialBackoffRetryStrategyConfig) { + void getTestRetryConfiguration(PExponentialBackoffRetryStrategyConfig pExponentialBackoffRetryStrategyConfig) + { // Set time to reset state to 5 seconds pExponentialBackoffRetryStrategyConfig->minTimeToResetRetryState = 5000 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND; // If testing bounded retries, set max retry count to 5 @@ -38,31 +40,25 @@ class ExponentialBackoffUtilsTest : public UtilTestBase { "minTimeToResetRetryState: [%lu], " "jitterType: [%lu], " "jitterFactor: [%lu], ", - GETTID(), - pExponentialBackoffRetryStrategyConfig->maxRetryCount, - pExponentialBackoffRetryStrategyConfig->maxRetryWaitTime, - pExponentialBackoffRetryStrategyConfig->retryFactorTime, - pExponentialBackoffRetryStrategyConfig->minTimeToResetRetryState, - pExponentialBackoffRetryStrategyConfig->jitterType, - pExponentialBackoffRetryStrategyConfig->jitterFactor); + GETTID(), pExponentialBackoffRetryStrategyConfig->maxRetryCount, pExponentialBackoffRetryStrategyConfig->maxRetryWaitTime, + pExponentialBackoffRetryStrategyConfig->retryFactorTime, pExponentialBackoffRetryStrategyConfig->minTimeToResetRetryState, + pExponentialBackoffRetryStrategyConfig->jitterType, pExponentialBackoffRetryStrategyConfig->jitterFactor); } - void validateExponentialBackoffWaitTime( - PExponentialBackoffRetryStrategyState pExponentialBackoffRetryStrategyState, - UINT64 retryWaitTimeToVerify, - int expectedRetryCount, - ExponentialBackoffStatus expectedExponentialBackoffStatus, - Range& acceptableWaitTimeRange) { + void validateExponentialBackoffWaitTime(PExponentialBackoffRetryStrategyState pExponentialBackoffRetryStrategyState, UINT64 retryWaitTimeToVerify, + int expectedRetryCount, ExponentialBackoffStatus expectedExponentialBackoffStatus, + Range& acceptableWaitTimeRange) + { // Validate retry count is correctly incremented in ExponentialBackoffState EXPECT_EQ(expectedRetryCount, pExponentialBackoffRetryStrategyState->currentRetryCount); // validate that the status is still "In Progress" EXPECT_EQ(expectedExponentialBackoffStatus, pExponentialBackoffRetryStrategyState->status); // Record the actual wait time for validation EXPECT_EQ(retryWaitTimeToVerify, pExponentialBackoffRetryStrategyState->lastRetryWaitTime); - EXPECT_TRUE(inRange(retryWaitTimeToVerify/HUNDREDS_OF_NANOS_IN_A_MILLISECOND, acceptableWaitTimeRange)); + EXPECT_TRUE(inRange(retryWaitTimeToVerify / HUNDREDS_OF_NANOS_IN_A_MILLISECOND, acceptableWaitTimeRange)); - UINT64 lastRetrySystemTimeMilliSec = pExponentialBackoffRetryStrategyState->lastRetrySystemTime/(HUNDREDS_OF_NANOS_IN_A_MILLISECOND * 1.0); - UINT64 currentTimeMilliSec = GETTIME()/HUNDREDS_OF_NANOS_IN_A_MILLISECOND; + UINT64 lastRetrySystemTimeMilliSec = pExponentialBackoffRetryStrategyState->lastRetrySystemTime / (HUNDREDS_OF_NANOS_IN_A_MILLISECOND * 1.0); + UINT64 currentTimeMilliSec = GETTIME() / HUNDREDS_OF_NANOS_IN_A_MILLISECOND; UINT64 diffInMilliSec = currentTimeMilliSec - lastRetrySystemTimeMilliSec; EXPECT_TRUE(currentTimeMilliSec >= lastRetrySystemTimeMilliSec); @@ -111,7 +107,7 @@ TEST_F(ExponentialBackoffUtilsTest, testInitializeExponentialBackoffState) EXPECT_EQ(STATUS_NULL_ARG, exponentialBackoffRetryStrategyCreate(NULL)); - pRetryStrategyConfig = (PRetryStrategyConfig)&exponentialBackoffRetryStrategyConfig; + pRetryStrategyConfig = (PRetryStrategyConfig) &exponentialBackoffRetryStrategyConfig; exponentialBackoffRetryStrategyConfig.minTimeToResetRetryState = 25; exponentialBackoffRetryStrategyConfig.maxRetryCount = 5; exponentialBackoffRetryStrategyConfig.maxRetryWaitTime = 10; @@ -139,10 +135,13 @@ TEST_F(ExponentialBackoffUtilsTest, testInitializeExponentialBackoffState) pExponentialBackoffRetryStrategyState = TO_EXPONENTIAL_BACKOFF_STATE(kvsRetryStrategy.pRetryStrategy); EXPECT_TRUE(pExponentialBackoffRetryStrategyState != NULL); - EXPECT_EQ(90000 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.minTimeToResetRetryState); + EXPECT_EQ(90000 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, + pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.minTimeToResetRetryState); EXPECT_EQ(5, pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.maxRetryCount); - EXPECT_EQ(20000 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.maxRetryWaitTime); - EXPECT_EQ(1000 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.retryFactorTime); + EXPECT_EQ(20000 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, + pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.maxRetryWaitTime); + EXPECT_EQ(1000 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, + pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.retryFactorTime); EXPECT_EQ(FIXED_JITTER, pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.jitterType); EXPECT_EQ(600, pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.jitterFactor); @@ -172,14 +171,14 @@ TEST_F(ExponentialBackoffUtilsTest, testExponentialBackoffBlockingWait_Unbounded getTestRetryConfiguration(&(pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig)); std::vector actualRetryWaitTime; - std::vector acceptableRetryWaitTimeRangeMilliSec { - {200.0, 300.0}, // 1st retry 200ms + jitter - {400.0, 500.0}, // 2st retry 400ms + jitter - {800.0, 900.0}, // 3st retry 800ms + jitter - {1600.0, 1700.0}, // 4st retry 1600ms + jitter - {3000.0, 3100.0}, // 5st retry 3000ms + jitter - {3000.0, 3100.0}, // 6st retry 3000ms + jitter - {3000.0, 3100.0} // 7st retry 3000ms + jitter + std::vector acceptableRetryWaitTimeRangeMilliSec{ + {200.0, 300.0}, // 1st retry 200ms + jitter + {400.0, 500.0}, // 2st retry 400ms + jitter + {800.0, 900.0}, // 3st retry 800ms + jitter + {1600.0, 1700.0}, // 4st retry 1600ms + jitter + {3000.0, 3100.0}, // 5st retry 3000ms + jitter + {3000.0, 3100.0}, // 6st retry 3000ms + jitter + {3000.0, 3100.0} // 7st retry 3000ms + jitter }; UINT64 retryWaitTimeToVerify; @@ -190,12 +189,8 @@ TEST_F(ExponentialBackoffUtilsTest, testExponentialBackoffBlockingWait_Unbounded EXPECT_EQ(STATUS_SUCCESS, getExponentialBackoffRetryCount(&kvsRetryStrategy, &actualRetryCount)); EXPECT_EQ(retryCount + 1, actualRetryCount); - validateExponentialBackoffWaitTime( - pExponentialBackoffRetryStrategyState, - retryWaitTimeToVerify, - retryCount+1, - BACKOFF_IN_PROGRESS, - acceptableRetryWaitTimeRangeMilliSec.at(retryCount)); + validateExponentialBackoffWaitTime(pExponentialBackoffRetryStrategyState, retryWaitTimeToVerify, retryCount + 1, BACKOFF_IN_PROGRESS, + acceptableRetryWaitTimeRangeMilliSec.at(retryCount)); } // We have configured minTimeToResetRetryState as 5 seconds. So sleep for just over 5 seconds @@ -203,12 +198,10 @@ TEST_F(ExponentialBackoffUtilsTest, testExponentialBackoffBlockingWait_Unbounded std::this_thread::sleep_for(std::chrono::milliseconds(5100)); retryWaitTimeToVerify = 0; EXPECT_EQ(STATUS_SUCCESS, getExponentialBackoffRetryStrategyWaitTime(&kvsRetryStrategy, &retryWaitTimeToVerify)); - validateExponentialBackoffWaitTime( - pExponentialBackoffRetryStrategyState, - retryWaitTimeToVerify, - 1, // expected current retry count (1st retry) - BACKOFF_IN_PROGRESS, // expected retry state - acceptableRetryWaitTimeRangeMilliSec.at(0)); + validateExponentialBackoffWaitTime(pExponentialBackoffRetryStrategyState, retryWaitTimeToVerify, + 1, // expected current retry count (1st retry) + BACKOFF_IN_PROGRESS, // expected retry state + acceptableRetryWaitTimeRangeMilliSec.at(0)); EXPECT_EQ(STATUS_SUCCESS, exponentialBackoffRetryStrategyFree(&kvsRetryStrategy)); EXPECT_TRUE(kvsRetryStrategy.pRetryStrategy == NULL); @@ -235,12 +228,12 @@ TEST_F(ExponentialBackoffUtilsTest, testExponentialBackoffBlockingWait_Bounded) pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.maxRetryCount = maxTestRetryCount; std::vector actualRetryWaitTime; - std::vector acceptableRetryWaitTimeRangeMilliSec { - {200.0, 300.0}, // 1st retry 200ms + jitter - {400.0, 500.0}, // 2st retry 400ms + jitter - {800.0, 900.0}, // 3st retry 800ms + jitter - {1600.0, 1700.0}, // 4st retry 1600ms + jitter - {3000.0, 3100.0}, // 5st retry 3000ms + jitter + std::vector acceptableRetryWaitTimeRangeMilliSec{ + {200.0, 300.0}, // 1st retry 200ms + jitter + {400.0, 500.0}, // 2st retry 400ms + jitter + {800.0, 900.0}, // 3st retry 800ms + jitter + {1600.0, 1700.0}, // 4st retry 1600ms + jitter + {3000.0, 3100.0}, // 5st retry 3000ms + jitter }; UINT64 retryWaitTimeToVerify; @@ -251,12 +244,8 @@ TEST_F(ExponentialBackoffUtilsTest, testExponentialBackoffBlockingWait_Bounded) EXPECT_EQ(STATUS_SUCCESS, getExponentialBackoffRetryCount(&kvsRetryStrategy, &actualRetryCount)); EXPECT_EQ(retryCount + 1, actualRetryCount); - validateExponentialBackoffWaitTime( - pExponentialBackoffRetryStrategyState, - retryWaitTimeToVerify, - retryCount+1, - BACKOFF_IN_PROGRESS, - acceptableRetryWaitTimeRangeMilliSec.at(retryCount)); + validateExponentialBackoffWaitTime(pExponentialBackoffRetryStrategyState, retryWaitTimeToVerify, retryCount + 1, BACKOFF_IN_PROGRESS, + acceptableRetryWaitTimeRangeMilliSec.at(retryCount)); } // After the retries are exhausted, subsequent call to getExponentialBackoffRetryStrategyWaitTime should return an error @@ -292,12 +281,12 @@ TEST_F(ExponentialBackoffUtilsTest, testExponentialBackoffBlockingWait_FullJitte pExponentialBackoffRetryStrategyState->exponentialBackoffRetryStrategyConfig.jitterType = FULL_JITTER; std::vector actualRetryWaitTime; - std::vector acceptableRetryWaitTimeRangeMilliSec { - {200.0, 399.0}, // 1st retry 200ms + jitter - {400.0, 799.0}, // 2st retry 400ms + jitter - {800.0, 1599.0}, // 3st retry 800ms + jitter - {1600.0, 3199.0}, // 4st retry 1600ms + jitter - {3000.0, 5999.0}, // 5st retry 3000ms + jitter + std::vector acceptableRetryWaitTimeRangeMilliSec{ + {200.0, 399.0}, // 1st retry 200ms + jitter + {400.0, 799.0}, // 2st retry 400ms + jitter + {800.0, 1599.0}, // 3st retry 800ms + jitter + {1600.0, 3199.0}, // 4st retry 1600ms + jitter + {3000.0, 5999.0}, // 5st retry 3000ms + jitter }; UINT64 retryWaitTimeToVerify; @@ -308,12 +297,8 @@ TEST_F(ExponentialBackoffUtilsTest, testExponentialBackoffBlockingWait_FullJitte EXPECT_EQ(STATUS_SUCCESS, getExponentialBackoffRetryCount(&kvsRetryStrategy, &actualRetryCount)); EXPECT_EQ(retryCount + 1, actualRetryCount); - validateExponentialBackoffWaitTime( - pExponentialBackoffRetryStrategyState, - retryWaitTimeToVerify, - retryCount+1, - BACKOFF_IN_PROGRESS, - acceptableRetryWaitTimeRangeMilliSec.at(retryCount)); + validateExponentialBackoffWaitTime(pExponentialBackoffRetryStrategyState, retryWaitTimeToVerify, retryCount + 1, BACKOFF_IN_PROGRESS, + acceptableRetryWaitTimeRangeMilliSec.at(retryCount)); } // After the retries are exhausted, subsequent call to getExponentialBackoffRetryStrategyWaitTime should return an error diff --git a/tst/utils/FileIo.cpp b/tst/utils/FileIo.cpp index f8514e4f5..d4049cc44 100644 --- a/tst/utils/FileIo.cpp +++ b/tst/utils/FileIo.cpp @@ -1,31 +1,32 @@ #include "UtilTestFixture.h" #ifdef _WIN32 -#define TEST_TEMP_DIR_PATH (PCHAR) "C:\\Windows\\Temp\\" -#define TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR (PCHAR) "C:\\Windows\\Temp" +#define TEST_TEMP_DIR_PATH (PCHAR) "C:\\Windows\\Temp\\" +#define TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR (PCHAR) "C:\\Windows\\Temp" #else -#define TEST_TEMP_DIR_PATH (PCHAR) "/tmp/" -#define TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR (PCHAR) "/tmp" +#define TEST_TEMP_DIR_PATH (PCHAR) "/tmp/" +#define TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR (PCHAR) "/tmp" #endif -class FileIoFunctionalityTest : public UtilTestBase { -}; +class FileIoFunctionalityTest : public UtilTestBase {}; -class FileIoUnitTest : public UtilTestBase { -}; +class FileIoUnitTest : public UtilTestBase {}; -TEST_F(FileIoUnitTest, readFile_filePathNull) { +TEST_F(FileIoUnitTest, readFile_filePathNull) +{ EXPECT_EQ(STATUS_NULL_ARG, readFile(NULL, TRUE, NULL, NULL)); EXPECT_EQ(STATUS_NULL_ARG, readFile(NULL, FALSE, NULL, NULL)); } -TEST_F(FileIoUnitTest, readFile_sizeNull) { +TEST_F(FileIoUnitTest, readFile_sizeNull) +{ EXPECT_EQ(STATUS_NULL_ARG, readFile((PCHAR) (TEST_TEMP_DIR_PATH "test"), TRUE, NULL, NULL)); EXPECT_EQ(STATUS_NULL_ARG, readFile((PCHAR) (TEST_TEMP_DIR_PATH "test"), FALSE, NULL, NULL)); } -TEST_F(FileIoUnitTest, readFile_asciiBufferTooSmall) { - FILE *file = FOPEN((PCHAR) (TEST_TEMP_DIR_PATH "asciitest"), "w"); +TEST_F(FileIoUnitTest, readFile_asciiBufferTooSmall) +{ + FILE* file = FOPEN((PCHAR) (TEST_TEMP_DIR_PATH "asciitest"), "w"); UINT64 fileSize = 43; PCHAR fileBuffer = NULL; @@ -34,10 +35,10 @@ TEST_F(FileIoUnitTest, readFile_asciiBufferTooSmall) { EXPECT_EQ(STATUS_SUCCESS, readFile((PCHAR) (TEST_TEMP_DIR_PATH "asciitest"), FALSE, NULL, &fileSize)); -// In Windows systems, the newline character is represented by a combination of -// two characters: Carriage Return (CR) followed by Line Feed (LF), written as \r\n. +// In Windows systems, the newline character is represented by a combination of +// two characters: Carriage Return (CR) followed by Line Feed (LF), written as \r\n. // So, each newline character in a text file on Windows contributes two bytes to the file size. -#if defined _WIN32 || defined _WIN64 +#if defined _WIN32 || defined _WIN64 EXPECT_EQ(48, fileSize); #else EXPECT_EQ(45, fileSize); @@ -52,12 +53,13 @@ TEST_F(FileIoUnitTest, readFile_asciiBufferTooSmall) { SAFE_MEMFREE(fileBuffer); } -TEST_F(FileIoUnitTest, readFile_binaryBufferTooSmall) { - FILE *file = fopen((PCHAR) (TEST_TEMP_DIR_PATH "binarytest"), "wb"); +TEST_F(FileIoUnitTest, readFile_binaryBufferTooSmall) +{ + FILE* file = fopen((PCHAR) (TEST_TEMP_DIR_PATH "binarytest"), "wb"); UINT64 fileSize = 43; PCHAR fileBuffer = NULL; CHAR data[100] = "This is line 1\nThis is line 2\nThis is line 3\n"; - + FWRITE(data, SIZEOF(CHAR), STRLEN(data), file); FCLOSE(file); @@ -73,8 +75,9 @@ TEST_F(FileIoUnitTest, readFile_binaryBufferTooSmall) { SAFE_MEMFREE(fileBuffer); } -TEST_F(FileIoFunctionalityTest, readFile_asciiFileSize) { - FILE *file = FOPEN((PCHAR) (TEST_TEMP_DIR_PATH "asciitest"), "w"); +TEST_F(FileIoFunctionalityTest, readFile_asciiFileSize) +{ + FILE* file = FOPEN((PCHAR) (TEST_TEMP_DIR_PATH "asciitest"), "w"); CHAR fileBuffer[256]; UINT64 fileSize = ARRAY_SIZE(fileBuffer); @@ -83,10 +86,10 @@ TEST_F(FileIoFunctionalityTest, readFile_asciiFileSize) { EXPECT_EQ(STATUS_SUCCESS, readFile((PCHAR) (TEST_TEMP_DIR_PATH "asciitest"), FALSE, NULL, &fileSize)); -// In Windows systems, the newline character is represented by a combination of -// two characters: Carriage Return (CR) followed by Line Feed (LF), written as \r\n. +// In Windows systems, the newline character is represented by a combination of +// two characters: Carriage Return (CR) followed by Line Feed (LF), written as \r\n. // So, each newline character in a text file on Windows contributes two bytes to the file size. -#if defined _WIN32 || defined _WIN64 +#if defined _WIN32 || defined _WIN64 EXPECT_EQ(48, fileSize); #else EXPECT_EQ(45, fileSize); @@ -95,8 +98,9 @@ TEST_F(FileIoFunctionalityTest, readFile_asciiFileSize) { remove((PCHAR) (TEST_TEMP_DIR_PATH "asciitest")); } -TEST_F(FileIoFunctionalityTest, readFile_binaryFileSize) { - FILE *file = fopen((PCHAR) (TEST_TEMP_DIR_PATH "binarytest"), "wb"); +TEST_F(FileIoFunctionalityTest, readFile_binaryFileSize) +{ + FILE* file = fopen((PCHAR) (TEST_TEMP_DIR_PATH "binarytest"), "wb"); CHAR fileBuffer[256]; CHAR data[100] = "This is line 1\nThis is line 2\nThis is line 3\n"; UINT64 fileSize = ARRAY_SIZE(fileBuffer); @@ -104,18 +108,19 @@ TEST_F(FileIoFunctionalityTest, readFile_binaryFileSize) { FWRITE(data, SIZEOF(CHAR), STRLEN(data), file); FCLOSE(file); - EXPECT_EQ(STATUS_SUCCESS, readFile((PCHAR)(TEST_TEMP_DIR_PATH "binarytest"), TRUE, NULL, &fileSize)); + EXPECT_EQ(STATUS_SUCCESS, readFile((PCHAR) (TEST_TEMP_DIR_PATH "binarytest"), TRUE, NULL, &fileSize)); EXPECT_EQ(45, fileSize); remove((PCHAR) (TEST_TEMP_DIR_PATH "binarytest")); } -TEST_F(FileIoFunctionalityTest, readFile_binary) { - FILE *file = fopen((PCHAR) (TEST_TEMP_DIR_PATH "binarytest"), "wb"); +TEST_F(FileIoFunctionalityTest, readFile_binary) +{ + FILE* file = fopen((PCHAR) (TEST_TEMP_DIR_PATH "binarytest"), "wb"); UINT64 fileSize; PCHAR fileBuffer = NULL; CHAR data[100] = "This is line 1\nThis is line 2\nThis is line 3\n"; - + FWRITE(data, SIZEOF(CHAR), STRLEN(data), file); FCLOSE(file); @@ -130,21 +135,22 @@ TEST_F(FileIoFunctionalityTest, readFile_binary) { SAFE_MEMFREE(fileBuffer); } -TEST_F(FileIoFunctionalityTest, readFile_ascii) { - FILE *file = fopen((PCHAR) (TEST_TEMP_DIR_PATH "asciitest"), "w"); +TEST_F(FileIoFunctionalityTest, readFile_ascii) +{ + FILE* file = fopen((PCHAR) (TEST_TEMP_DIR_PATH "asciitest"), "w"); UINT64 fileSize; PCHAR fileBuffer = NULL; CHAR data[100] = "This is line 1\nThis is line 2\nThis is line 3\n"; - + FWRITE(data, SIZEOF(CHAR), STRLEN(data), file); FCLOSE(file); EXPECT_EQ(STATUS_SUCCESS, readFile((PCHAR) (TEST_TEMP_DIR_PATH "asciitest"), FALSE, NULL, &fileSize)); -// In Windows systems, the newline character is represented by a combination of -// two characters: Carriage Return (CR) followed by Line Feed (LF), written as \r\n. +// In Windows systems, the newline character is represented by a combination of +// two characters: Carriage Return (CR) followed by Line Feed (LF), written as \r\n. // So, each newline character in a text file on Windows contributes two bytes to the file size. -#if defined _WIN32 || defined _WIN64 +#if defined _WIN32 || defined _WIN64 EXPECT_EQ(48, fileSize); #else EXPECT_EQ(45, fileSize); diff --git a/tst/utils/FileLogger.cpp b/tst/utils/FileLogger.cpp index 2f0d62434..d6aa9ba73 100644 --- a/tst/utils/FileLogger.cpp +++ b/tst/utils/FileLogger.cpp @@ -1,22 +1,24 @@ #include "UtilTestFixture.h" // length of time and log level string in log: "2019-11-09 19:11:16.xxx VERBOSE " -#define TIMESTRING_OFFSET 32 +#define TIMESTRING_OFFSET 32 #ifdef _WIN32 -#define TEST_TEMP_DIR_PATH (PCHAR) "C:\\Windows\\Temp\\" -#define TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR (PCHAR) "C:\\Windows\\Temp" +#define TEST_TEMP_DIR_PATH (PCHAR) "C:\\Windows\\Temp\\" +#define TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR (PCHAR) "C:\\Windows\\Temp" #else -#define TEST_TEMP_DIR_PATH (PCHAR) "/tmp/" -#define TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR (PCHAR) "/tmp" +#define TEST_TEMP_DIR_PATH (PCHAR) "/tmp/" +#define TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR (PCHAR) "/tmp" #endif -class FileLoggerTest : public UtilTestBase -{ -public: - FileLoggerTest() : UtilTestBase() {} +class FileLoggerTest : public UtilTestBase { + public: + FileLoggerTest() : UtilTestBase() + { + } - void SetUp() { + void SetUp() + { UtilTestBase::SetUp(); // Tests will fail if log level is not warn @@ -43,10 +45,7 @@ TEST_F(FileLoggerTest, basicFileLoggerUsage) FREMOVE(TEST_TEMP_DIR_PATH "kvsFileLog.2"); DLOGW("Testing log line"); - createFileLogger(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, - 5, - (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, - FALSE, TRUE, &logFunc); + createFileLogger(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, 5, (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, FALSE, TRUE, &logFunc); logFunc(LOG_LEVEL_VERBOSE, NULL, (PCHAR) "%s", logMessage); logFunc(LOG_LEVEL_VERBOSE, NULL, (PCHAR) "%s", logMessage); // low log level logs have no effect @@ -97,24 +96,21 @@ TEST_F(FileLoggerTest, checkFileRotation) // make sure the files dont exist FREMOVE(TEST_TEMP_DIR_PATH "kvsFileLogIndex"); - for(; i < logIterationCount; ++i) { + for (; i < logIterationCount; ++i) { SNPRINTF(filePath, 1024, TEST_TEMP_DIR_PATH "kvsFileLog.%u", i); FREMOVE(filePath); } - createFileLogger(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, - maxLogFileCount, - (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, - FALSE, TRUE, &logFunc); + createFileLogger(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, maxLogFileCount, (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, FALSE, TRUE, &logFunc); // should create 12 files if limit allows - for(i = 0; i < logIterationCount; ++i) { + for (i = 0; i < logIterationCount; ++i) { logFunc(LOG_LEVEL_ERROR, NULL, (PCHAR) "%s", logMessage); } RELEASE_FILE_LOGGER(); - for(i = 0; i < logIterationCount; ++i) { + for (i = 0; i < logIterationCount; ++i) { SNPRINTF(filePath, 1024, TEST_TEMP_DIR_PATH "kvsFileLog.%u", i); EXPECT_EQ(STATUS_SUCCESS, fileExists(filePath, &fileFound)); // only log file with index from 6 to 11 should remain. The rest are rotated out. @@ -148,12 +144,11 @@ TEST_F(FileLoggerTest, fileLoggerPicksUpFromLastFileIndex) FREMOVE(TEST_TEMP_DIR_PATH "kvsFileLogIndex"); ULLTOSTR(128, fileIndexBuffer, ARRAY_SIZE(fileIndexBuffer), 10, &fileIndexStrSize); - EXPECT_EQ(STATUS_SUCCESS, writeFile((PCHAR) (TEST_TEMP_DIR_PATH "kvsFileLogIndex"), TRUE, FALSE, (PBYTE) fileIndexBuffer, STRLEN(fileIndexBuffer) * SIZEOF(CHAR))); + EXPECT_EQ( + STATUS_SUCCESS, + writeFile((PCHAR) (TEST_TEMP_DIR_PATH "kvsFileLogIndex"), TRUE, FALSE, (PBYTE) fileIndexBuffer, STRLEN(fileIndexBuffer) * SIZEOF(CHAR))); - createFileLogger(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, - 5, - (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, - FALSE, TRUE, &logFunc); + createFileLogger(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, 5, (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, FALSE, TRUE, &logFunc); // Cause a log flush. logFunc(LOG_LEVEL_ERROR, NULL, (PCHAR) "%s", logMessage); @@ -201,10 +196,7 @@ TEST_F(FileLoggerTest, logMessageLongerThanStringBuffer) logMessage[i] = 'b'; } - createFileLogger(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, - 5, - (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, - FALSE, TRUE, &logFunc); + createFileLogger(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, 5, (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, FALSE, TRUE, &logFunc); logFunc(LOG_LEVEL_ERROR, NULL, (PCHAR) "%s", logMessage); @@ -246,10 +238,7 @@ TEST_F(FileLoggerTest, oldLogFileOverrittenByFlushTriggerredByNewLog) MEMSET(logMessage, 'a', logMessageSize); logMessage[logMessageSize] = '\0'; - createFileLogger(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, - 3, - (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, - FALSE, TRUE, &logFunc); + createFileLogger(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, 3, (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, FALSE, TRUE, &logFunc); logFunc(LOG_LEVEL_ERROR, NULL, (PCHAR) "%s", logMessage); logFunc(LOG_LEVEL_ERROR, NULL, (PCHAR) "%s", logMessage); @@ -308,10 +297,7 @@ TEST_F(FileLoggerTest, oldLogFileOverrittenByFlushTriggerredByFreeCallbacks) MEMSET(logMessage, 'a', logMessageSize); logMessage[logMessageSize] = '\0'; - createFileLogger(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, - 1, - (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, - FALSE, TRUE, &logFunc); + createFileLogger(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, 1, (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, FALSE, TRUE, &logFunc); logFunc(LOG_LEVEL_ERROR, NULL, (PCHAR) "%s", logMessage); @@ -365,12 +351,8 @@ TEST_F(FileLoggerTest, basicFilterFileLoggerUsage) FREMOVE(TEST_TEMP_DIR_PATH "kvsFileFilterLogIndex"); // Test disabling all permitted levels and the filtered level - in short, no log files would be generated - createFileLoggerWithLevelFiltering(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, - 5, - (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, - FALSE, - FALSE, - FALSE, 0, &logFunc); + createFileLoggerWithLevelFiltering(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, 5, (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, FALSE, FALSE, FALSE, 0, + &logFunc); logFunc(LOG_LEVEL_VERBOSE, NULL, (PCHAR) "%s", logMessage); logFunc(LOG_LEVEL_VERBOSE, NULL, (PCHAR) "%s", logMessage); @@ -388,12 +370,8 @@ TEST_F(FileLoggerTest, basicFilterFileLoggerUsage) RELEASE_FILE_LOGGER(); // Test disabling all permitted levels and allow log files generated only for the filtered level - createFileLoggerWithLevelFiltering(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, - 5, - (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, - FALSE, - FALSE, - FALSE, LOG_LEVEL_WARN, &logFunc); + createFileLoggerWithLevelFiltering(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, 5, (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, FALSE, FALSE, FALSE, + LOG_LEVEL_WARN, &logFunc); logFunc(LOG_LEVEL_WARN, NULL, (PCHAR) "%s", logMessage); @@ -406,7 +384,6 @@ TEST_F(FileLoggerTest, basicFilterFileLoggerUsage) RELEASE_FILE_LOGGER(); // This ensures the file is closed before running other checks - EXPECT_EQ(STATUS_SUCCESS, fileExists((PCHAR) (TEST_TEMP_DIR_PATH "kvsFileLogFilter.0"), &fileFound)); EXPECT_EQ(TRUE, fileFound); @@ -425,12 +402,8 @@ TEST_F(FileLoggerTest, basicFilterFileLoggerUsage) FREMOVE(TEST_TEMP_DIR_PATH "kvsFileFilterLogIndex"); // Test enabling all permitted levels and the filtered level - createFileLoggerWithLevelFiltering(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, - 5, - (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, - FALSE, - FALSE, - TRUE, LOG_LEVEL_WARN, &logFunc); + createFileLoggerWithLevelFiltering(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, 5, (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, FALSE, FALSE, TRUE, + LOG_LEVEL_WARN, &logFunc); logFunc(LOG_LEVEL_WARN, NULL, (PCHAR) "%s", logMessage); logFunc(LOG_LEVEL_ERROR, NULL, (PCHAR) "%s", logMessage); @@ -470,7 +443,6 @@ TEST_F(FileLoggerTest, basicFilterFileLoggerUsage) MEMFREE(fileBuffer); } - TEST_F(FileLoggerTest, FileRotationFilterFileLoggerUsage) { UINT32 logMessageSize = MIN_FILE_LOGGER_STRING_BUFFER_SIZE / 2; @@ -489,12 +461,8 @@ TEST_F(FileLoggerTest, FileRotationFilterFileLoggerUsage) FREMOVE(TEST_TEMP_DIR_PATH "kvsFileFilterLogIndex"); // Test disabling all permitted levels and allow log files generated only for the filtered level - createFileLoggerWithLevelFiltering(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, - 2, - (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, - FALSE, - FALSE, - FALSE, LOG_LEVEL_WARN, &logFunc); + createFileLoggerWithLevelFiltering(MIN_FILE_LOGGER_STRING_BUFFER_SIZE, 2, (PCHAR) TEST_TEMP_DIR_PATH_NO_ENDING_SEPARTOR, FALSE, FALSE, FALSE, + LOG_LEVEL_WARN, &logFunc); logFunc(LOG_LEVEL_WARN, NULL, (PCHAR) "%s", logMessage); logMessage[logMessageSize] = '\0'; @@ -542,4 +510,4 @@ TEST_F(FileLoggerTest, FileRotationFilterFileLoggerUsage) MEMFREE(logMessage); MEMFREE(fileBuffer); - } \ No newline at end of file +} \ No newline at end of file diff --git a/tst/utils/FindStringTest.cpp b/tst/utils/FindStringTest.cpp index ac1700c31..435b64c86 100644 --- a/tst/utils/FindStringTest.cpp +++ b/tst/utils/FindStringTest.cpp @@ -1,7 +1,6 @@ #include "UtilTestFixture.h" -class FindStringFunctionalityTest : public UtilTestBase { -}; +class FindStringFunctionalityTest : public UtilTestBase {}; TEST_F(FindStringFunctionalityTest, Negative_Positive_Variations) { diff --git a/tst/utils/HashTable.cpp b/tst/utils/HashTable.cpp index 2c4bf5985..7f5c3acc6 100644 --- a/tst/utils/HashTable.cpp +++ b/tst/utils/HashTable.cpp @@ -1,7 +1,6 @@ #include "UtilTestFixture.h" -class HashTableFunctionalityTest : public UtilTestBase { -}; +class HashTableFunctionalityTest : public UtilTestBase {}; /** * Static variable for using later in the tests with callbacks @@ -343,11 +342,11 @@ TEST_F(HashTableFunctionalityTest, HashTableGetAllEntries) } EXPECT_EQ(STATUS_SUCCESS, hashTableGetAllEntries(pHashTable, NULL, &retCount)); - EXPECT_EQ((UINT32)count, retCount); + EXPECT_EQ((UINT32) count, retCount); retCount = (UINT32) (count + 1); EXPECT_EQ(STATUS_SUCCESS, hashTableGetAllEntries(pHashTable, gEntries, &retCount)); - EXPECT_EQ((UINT32)count, retCount); + EXPECT_EQ((UINT32) count, retCount); // Validate all are present for (UINT64 i = 0; i < count; i++) { diff --git a/tst/utils/InstrumentedAllocators.cpp b/tst/utils/InstrumentedAllocators.cpp index 00be950a0..2db16a9c4 100644 --- a/tst/utils/InstrumentedAllocators.cpp +++ b/tst/utils/InstrumentedAllocators.cpp @@ -1,8 +1,9 @@ #include "UtilTestFixture.h" class InstrumentedAllocatorsTest : public UtilTestBase { -protected: - InstrumentedAllocatorsTest() : UtilTestBase(FALSE) { + protected: + InstrumentedAllocatorsTest() : UtilTestBase(FALSE) + { SRAND(12345); } diff --git a/tst/utils/IntegerToString.cpp b/tst/utils/IntegerToString.cpp index c69e374f3..3ce5173e7 100644 --- a/tst/utils/IntegerToString.cpp +++ b/tst/utils/IntegerToString.cpp @@ -1,15 +1,16 @@ #include "UtilTestFixture.h" -class ItoEFunctionalityTest : public UtilTestBase { -}; +class ItoEFunctionalityTest : public UtilTestBase {}; -TEST_F(ItoEFunctionalityTest, InvalidInput_NullStrInput) { +TEST_F(ItoEFunctionalityTest, InvalidInput_NullStrInput) +{ UINT32 size; EXPECT_NE(STATUS_SUCCESS, ULLTOSTR(1, NULL, 100, 10, &size)); EXPECT_NE(STATUS_SUCCESS, ULTOSTR(1, NULL, 100, 10, &size)); } -TEST_F(ItoEFunctionalityTest, InvalidInput_ZeroSizeInput) { +TEST_F(ItoEFunctionalityTest, InvalidInput_ZeroSizeInput) +{ UINT32 size; PCHAR pStr = (PCHAR) 1; EXPECT_NE(STATUS_SUCCESS, ULLTOSTR(1, pStr, 0, 10, &size)); @@ -19,8 +20,8 @@ TEST_F(ItoEFunctionalityTest, InvalidInput_ZeroSizeInput) { EXPECT_NE(STATUS_SUCCESS, ULTOSTR(1, pStr, 1, 10, &size)); } - -TEST_F(ItoEFunctionalityTest, InvalidInput_InvalidBase) { +TEST_F(ItoEFunctionalityTest, InvalidInput_InvalidBase) +{ UINT32 size; PCHAR pStr = (PCHAR) 1; EXPECT_NE(STATUS_SUCCESS, ULLTOSTR(1, pStr, 100, 0, &size)); @@ -33,14 +34,16 @@ TEST_F(ItoEFunctionalityTest, InvalidInput_InvalidBase) { EXPECT_NE(STATUS_SUCCESS, ULTOSTR(1, pStr, 100, 37, &size)); } -TEST_F(ItoEFunctionalityTest, InvalidInput_BufferTooSmall) { +TEST_F(ItoEFunctionalityTest, InvalidInput_BufferTooSmall) +{ UINT32 size; CHAR temp[256]; EXPECT_NE(STATUS_SUCCESS, ULLTOSTR(100, temp, 3, 10, &size)); EXPECT_NE(STATUS_SUCCESS, ULTOSTR(100, temp, 3, 10, &size)); } -TEST_F(ItoEFunctionalityTest, ValidInput_SizeNotSpecified) { +TEST_F(ItoEFunctionalityTest, ValidInput_SizeNotSpecified) +{ UINT32 size; CHAR temp[256]; @@ -63,7 +66,8 @@ TEST_F(ItoEFunctionalityTest, ValidInput_SizeNotSpecified) { EXPECT_TRUE(STRCMP(temp, "100") == 0); } -TEST_F(ItoEFunctionalityTest, ValidInput_MinMaxValues) { +TEST_F(ItoEFunctionalityTest, ValidInput_MinMaxValues) +{ CHAR temp[256]; temp[0] = '\0'; @@ -83,7 +87,8 @@ TEST_F(ItoEFunctionalityTest, ValidInput_MinMaxValues) { EXPECT_TRUE(STRCMP(temp, "0") == 0); } -TEST_F(ItoEFunctionalityTest, ValidInput_VariousBases) { +TEST_F(ItoEFunctionalityTest, ValidInput_VariousBases) +{ CHAR temp[256]; UINT32 value = 255; diff --git a/tst/utils/MathTest.cpp b/tst/utils/MathTest.cpp index 88bdee680..575572a23 100644 --- a/tst/utils/MathTest.cpp +++ b/tst/utils/MathTest.cpp @@ -1,7 +1,6 @@ #include "UtilTestFixture.h" -class MathTest : public UtilTestBase { -}; +class MathTest : public UtilTestBase {}; TEST_F(MathTest, testPowerAPI) { diff --git a/tst/utils/Semaphore.cpp b/tst/utils/Semaphore.cpp index 51a11e1c8..a3eb5f094 100644 --- a/tst/utils/Semaphore.cpp +++ b/tst/utils/Semaphore.cpp @@ -1,9 +1,9 @@ #include "UtilTestFixture.h" class SemaphoreFunctionalityTest : public UtilTestBase { -public: - SemaphoreFunctionalityTest() : - handle(INVALID_SEMAPHORE_HANDLE_VALUE) { + public: + SemaphoreFunctionalityTest() : handle(INVALID_SEMAPHORE_HANDLE_VALUE) + { ATOMIC_STORE_BOOL(&acquired, FALSE); ATOMIC_STORE_BOOL(&shutdown, FALSE); ATOMIC_STORE(&threadCount, 0); @@ -22,10 +22,9 @@ class SemaphoreFunctionalityTest : public UtilTestBase { SemaphoreFunctionalityTest* pThis = (SemaphoreFunctionalityTest*) arg; ATOMIC_INCREMENT(&pThis->threadCount); retStatus = semaphoreAcquire(pThis->handle, INFINITE_TIME_VALUE); - if(ATOMIC_LOAD_BOOL(&pThis->shutdown)) { + if (ATOMIC_LOAD_BOOL(&pThis->shutdown)) { EXPECT_EQ(STATUS_SEMAPHORE_OPERATION_AFTER_SHUTDOWN, retStatus); - } - else { + } else { EXPECT_EQ(STATUS_SUCCESS, retStatus); } ATOMIC_DECREMENT(&pThis->threadCount); @@ -346,7 +345,8 @@ TEST_F(SemaphoreFunctionalityTest, emptySemaphoreAcquireFreeTest) THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); } -TEST_F(SemaphoreFunctionalityTest, avoidLossySignalsTest) { +TEST_F(SemaphoreFunctionalityTest, avoidLossySignalsTest) +{ UINT32 i; TID threadId; EXPECT_EQ(STATUS_SUCCESS, semaphoreEmptyCreate(100, &handle)); diff --git a/tst/utils/SingleLinkedList.cpp b/tst/utils/SingleLinkedList.cpp index 50bb3f77f..e306fdd06 100644 --- a/tst/utils/SingleLinkedList.cpp +++ b/tst/utils/SingleLinkedList.cpp @@ -1,7 +1,6 @@ #include "UtilTestFixture.h" -class SingleListFunctionalityTest : public UtilTestBase { -}; +class SingleListFunctionalityTest : public UtilTestBase {}; TEST_F(SingleListFunctionalityTest, NegativeInvalidInput_SingleListCreate) { @@ -245,7 +244,7 @@ TEST_F(SingleListFunctionalityTest, SingleListBasicOperationsCreateInsertGetDele for (UINT64 i = 0; i < count; i++) { EXPECT_EQ(STATUS_SUCCESS, singleListGetNodeDataAt(pList, (UINT32) i, &data)); EXPECT_EQ(data, count - i - 1); - EXPECT_EQ(STATUS_SUCCESS, singleListGetNodeAt(pList, (UINT32)i, &pNode)); + EXPECT_EQ(STATUS_SUCCESS, singleListGetNodeAt(pList, (UINT32) i, &pNode)); EXPECT_EQ(pNode->data, count - i - 1); } @@ -505,7 +504,8 @@ TEST_F(SingleListFunctionalityTest, SingleListInsertAfter) EXPECT_EQ(STATUS_SUCCESS, singleListFree(pList)); } -TEST_F(SingleListFunctionalityTest, SingleListAppendNonEmptyList) { +TEST_F(SingleListFunctionalityTest, SingleListAppendNonEmptyList) +{ PSingleList pListDst, pListToAppend; UINT64 data; @@ -548,7 +548,8 @@ TEST_F(SingleListFunctionalityTest, SingleListAppendNonEmptyList) { EXPECT_EQ(STATUS_SUCCESS, singleListFree(pListDst)); } -TEST_F(SingleListFunctionalityTest, SingleListAppendEmptyListOrNull) { +TEST_F(SingleListFunctionalityTest, SingleListAppendEmptyListOrNull) +{ PSingleList pListDst, pListToAppend; UINT64 data; diff --git a/tst/utils/StackQueue.cpp b/tst/utils/StackQueue.cpp index cfe2e058f..4fbd047b6 100644 --- a/tst/utils/StackQueue.cpp +++ b/tst/utils/StackQueue.cpp @@ -1,8 +1,6 @@ #include "UtilTestFixture.h" -class StackQueueFunctionalityTest : public UtilTestBase { -}; - +class StackQueueFunctionalityTest : public UtilTestBase {}; TEST_F(StackQueueFunctionalityTest, NegativeInvalidInput_StackQueueCreate) { @@ -126,7 +124,6 @@ TEST_F(StackQueueFunctionalityTest, StackQueueBasicOperations) EXPECT_EQ(STATUS_SUCCESS, stackQueueIsEmpty(pStackQueue, &isEmpty)); EXPECT_TRUE(isEmpty); - // Enqueue/push for (UINT64 i = 0; i < count; i++) { EXPECT_EQ(STATUS_SUCCESS, stackQueueEnqueue(pStackQueue, i)); @@ -146,7 +143,7 @@ TEST_F(StackQueueFunctionalityTest, StackQueueBasicOperations) for (UINT64 i = 0; i < count; i++) { EXPECT_EQ(STATUS_SUCCESS, stackQueueEnqueue(pStackQueue, i)); EXPECT_EQ(STATUS_SUCCESS, stackQueuePush(pStackQueue, i)); - EXPECT_EQ(STATUS_SUCCESS, stackQueueEnqueueAfterIndex(pStackQueue, rand()%(i+1), i)); + EXPECT_EQ(STATUS_SUCCESS, stackQueueEnqueueAfterIndex(pStackQueue, rand() % (i + 1), i)); } // Validate the count EXPECT_EQ(STATUS_SUCCESS, stackQueueGetCount(pStackQueue, &retCount)); @@ -194,15 +191,15 @@ TEST_F(StackQueueFunctionalityTest, StackQueueEnqueueAfterValidation) } for (UINT64 j = 0; j < 5; j++) { - checkIndex[j] = rand()%count; + checkIndex[j] = rand() % count; EXPECT_EQ(STATUS_SUCCESS, stackQueueEnqueueAfterIndex(pStackQueue, checkIndex[j], j)); } for (UINT64 init = 0; init < 5; init++) { - //placed AFTER the index, so always shifted at least 1 spot after + // placed AFTER the index, so always shifted at least 1 spot after indexShift[init]++; - for (UINT64 b = init+1; b < 5; b++) { - if((checkIndex[init] + indexShift[init]) > checkIndex[b]) { + for (UINT64 b = init + 1; b < 5; b++) { + if ((checkIndex[init] + indexShift[init]) > checkIndex[b]) { indexShift[init]++; } } @@ -260,7 +257,7 @@ TEST_F(StackQueueFunctionalityTest, StackQueuePutGetRemoveOperations) // Get at for (UINT64 i = 0; i < count; i++) { - EXPECT_EQ(STATUS_SUCCESS, stackQueueGetAt(pStackQueue, (UINT32)i, &data)); + EXPECT_EQ(STATUS_SUCCESS, stackQueueGetAt(pStackQueue, (UINT32) i, &data)); EXPECT_EQ(count - i - 1, data); EXPECT_EQ(STATUS_SUCCESS, stackQueueGetIndexOf(pStackQueue, data, &index)); EXPECT_EQ(i, index); @@ -269,7 +266,7 @@ TEST_F(StackQueueFunctionalityTest, StackQueuePutGetRemoveOperations) // Remove at from the middle for (UINT64 i = 0; i < count / 2; i++) { // Peek first - EXPECT_EQ(STATUS_SUCCESS, stackQueueRemoveAt(pStackQueue, (UINT32)(count / 2))); + EXPECT_EQ(STATUS_SUCCESS, stackQueueRemoveAt(pStackQueue, (UINT32) (count / 2))); } // Validate the count @@ -280,7 +277,7 @@ TEST_F(StackQueueFunctionalityTest, StackQueuePutGetRemoveOperations) // Validate the half for (UINT64 i = 0; i < count / 2; i++) { - EXPECT_EQ(STATUS_SUCCESS, stackQueueGetAt(pStackQueue, (UINT32)i, &data)); + EXPECT_EQ(STATUS_SUCCESS, stackQueueGetAt(pStackQueue, (UINT32) i, &data)); EXPECT_EQ(count - i - 1, data); } @@ -334,7 +331,7 @@ TEST_F(StackQueueFunctionalityTest, StackQueuePutGetSetOperations) // Get at for (UINT64 i = 0; i < count; i++) { - EXPECT_EQ(STATUS_SUCCESS, stackQueueGetAt(pStackQueue, (UINT32)i, &data)); + EXPECT_EQ(STATUS_SUCCESS, stackQueueGetAt(pStackQueue, (UINT32) i, &data)); EXPECT_EQ(count - i - 1, data); EXPECT_EQ(STATUS_SUCCESS, stackQueueGetIndexOf(pStackQueue, data, &index)); EXPECT_EQ(i, index); @@ -342,12 +339,12 @@ TEST_F(StackQueueFunctionalityTest, StackQueuePutGetSetOperations) // Set at for (UINT64 i = 0; i < count; i++) { - EXPECT_EQ(STATUS_SUCCESS, stackQueueSetAt(pStackQueue, (UINT32)i, 1000 + i)); + EXPECT_EQ(STATUS_SUCCESS, stackQueueSetAt(pStackQueue, (UINT32) i, 1000 + i)); } // Get at - verify for (UINT64 i = 0; i < count; i++) { - EXPECT_EQ(STATUS_SUCCESS, stackQueueGetAt(pStackQueue, (UINT32)i, &data)); + EXPECT_EQ(STATUS_SUCCESS, stackQueueGetAt(pStackQueue, (UINT32) i, &data)); EXPECT_EQ(i + 1000, data); EXPECT_EQ(STATUS_SUCCESS, stackQueueGetIndexOf(pStackQueue, data, &index)); EXPECT_EQ(i, index); diff --git a/tst/utils/StringSearch.cpp b/tst/utils/StringSearch.cpp index b209c580f..56b47a94a 100644 --- a/tst/utils/StringSearch.cpp +++ b/tst/utils/StringSearch.cpp @@ -1,9 +1,9 @@ #include "UtilTestFixture.h" -class StringSearchFunctionalityTest : public UtilTestBase { -}; +class StringSearchFunctionalityTest : public UtilTestBase {}; -TEST_F(StringSearchFunctionalityTest, NegativeInvalidInput) { +TEST_F(StringSearchFunctionalityTest, NegativeInvalidInput) +{ CHAR str[] = "this is a test"; EXPECT_EQ(NULL, defaultStrnstr(NULL, NULL, 0)); EXPECT_EQ(str, defaultStrnstr(str, NULL, 0)); @@ -14,12 +14,14 @@ TEST_F(StringSearchFunctionalityTest, NegativeInvalidInput) { EXPECT_EQ(NULL, defaultStrnstr(str, (PCHAR) "this is a test with extra length", ARRAY_SIZE(str) - 1)); } -TEST_F(StringSearchFunctionalityTest, ExactMatch_WithoutLen) { +TEST_F(StringSearchFunctionalityTest, ExactMatch_WithoutLen) +{ CHAR str[] = "this is a test"; EXPECT_EQ(str, defaultStrnstr(str, str, ARRAY_SIZE(str) - 1)); } -TEST_F(StringSearchFunctionalityTest, ExactMatch_WithLen) { +TEST_F(StringSearchFunctionalityTest, ExactMatch_WithLen) +{ CHAR str1[] = "this is a test"; CHAR str2[] = "this is"; EXPECT_EQ(str1, defaultStrnstr(str1, str2, ARRAY_SIZE(str2) - 1)); @@ -32,13 +34,14 @@ auto randStr = [](SIZE_T n) -> std::string { SRAND(GETTIME()); for (int i = 0; i < n; i++) { // 8 bits contain 255 characters + 1 null character - s += (CHAR)(RAND() % 255) + 1; + s += (CHAR) (RAND() % 255) + 1; } return s; }; -TEST_F(StringSearchFunctionalityTest, BigString_BigHaystack) { +TEST_F(StringSearchFunctionalityTest, BigString_BigHaystack) +{ std::string str1; std::string str2; @@ -50,7 +53,8 @@ TEST_F(StringSearchFunctionalityTest, BigString_BigHaystack) { EXPECT_EQ(STRSTR(str1.c_str(), str2.c_str()), defaultStrnstr((PCHAR) str1.c_str(), (PCHAR) str2.c_str(), str1.size())); } -TEST_F(StringSearchFunctionalityTest, BigString_BigNeedle) { +TEST_F(StringSearchFunctionalityTest, BigString_BigNeedle) +{ std::string str1; std::string str2; diff --git a/tst/utils/StringToInteger.cpp b/tst/utils/StringToInteger.cpp index bbe924cb0..82e4175e1 100644 --- a/tst/utils/StringToInteger.cpp +++ b/tst/utils/StringToInteger.cpp @@ -1,9 +1,9 @@ #include "UtilTestFixture.h" -class StoIFunctionalityTest : public UtilTestBase { -}; +class StoIFunctionalityTest : public UtilTestBase {}; -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_NullStrInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_NullStrInput) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -14,7 +14,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_NullStrInput) { EXPECT_NE(STATUS_SUCCESS, STRTOUI32(NULL, NULL, 10, &ui32)); } -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_NullRetInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_NullRetInput) +{ CHAR str[] = "123"; EXPECT_NE(STATUS_SUCCESS, STRTOI64(str, NULL, 10, NULL)); EXPECT_NE(STATUS_SUCCESS, STRTOUI64(str, NULL, 10, NULL)); @@ -22,7 +23,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_NullRetInput) { EXPECT_NE(STATUS_SUCCESS, STRTOUI32(str, NULL, 10, NULL)); } -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_EmptyStrInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_EmptyStrInput) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -34,7 +36,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_EmptyStrInput) { EXPECT_NE(STATUS_SUCCESS, STRTOUI32(str, NULL, 10, &ui32)); } -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_WhitespaceStrInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_WhitespaceStrInput) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -46,7 +49,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_WhitespaceStrInput) { EXPECT_NE(STATUS_SUCCESS, STRTOUI32(str, NULL, 10, &ui32)); } -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_WhitespaceStrAfterInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_WhitespaceStrAfterInput) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -58,7 +62,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_WhitespaceStrAfterInput) { EXPECT_NE(STATUS_SUCCESS, STRTOUI32(str, NULL, 10, &ui32)); } -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_PlusSignOnlyStrInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_PlusSignOnlyStrInput) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -70,7 +75,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_PlusSignOnlyStrInput) { EXPECT_NE(STATUS_SUCCESS, STRTOUI32(str, NULL, 10, &ui32)); } -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_MultiplePlusSignsStrInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_MultiplePlusSignsStrInput) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -82,7 +88,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_MultiplePlusSignsStrInput) { EXPECT_NE(STATUS_SUCCESS, STRTOUI32(str, NULL, 10, &ui32)); } -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_MinusSignOnlyStrInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_MinusSignOnlyStrInput) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -94,7 +101,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_MinusSignOnlyStrInput) { EXPECT_NE(STATUS_SUCCESS, STRTOUI32(str, NULL, 10, &ui32)); } -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_MultipleMinusSignsStrInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_MultipleMinusSignsStrInput) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -106,7 +114,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_MultipleMinusSignsStrInput) { EXPECT_NE(STATUS_SUCCESS, STRTOUI32(str, NULL, 10, &ui32)); } -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_MinusInputWithUnsignedInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_MinusInputWithUnsignedInput) +{ UINT64 ui64; UINT32 ui32; CHAR str[] = "-123"; @@ -117,7 +126,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_MinusInputWithUnsignedInput) EXPECT_NE(STATUS_SUCCESS, STRTOUI32(strZero, NULL, 10, &ui32)); } -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_SignInStringInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_SignInStringInput) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -134,7 +144,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_SignInStringInput) { EXPECT_NE(STATUS_SUCCESS, STRTOUI32(strMinus, NULL, 10, &ui32)); } -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_SameEndInputInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_SameEndInputInput) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -146,7 +157,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_SameEndInputInput) { EXPECT_NE(STATUS_SUCCESS, STRTOUI32(str, str, 10, &ui32)); } -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_InvalidSmallBaseInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_InvalidSmallBaseInput) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -162,7 +174,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_InvalidSmallBaseInput) { EXPECT_NE(STATUS_SUCCESS, STRTOUI32(str, NULL, 1, &ui32)); } -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_InvalidBigBaseInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_InvalidBigBaseInput) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -174,7 +187,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_InvalidBigBaseInput) { EXPECT_NE(STATUS_SUCCESS, STRTOUI32(str, NULL, 37, &ui32)); } -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_InvalidDigitBaseInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_InvalidDigitBaseInput) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -191,7 +205,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_InvalidDigitBaseInput) { EXPECT_NE(STATUS_SUCCESS, STRTOUI32(str2, NULL, 2, &ui32)); } -TEST_F(StoIFunctionalityTest, NegativeInvalidInput_OverflowUnderflowInput) { +TEST_F(StoIFunctionalityTest, NegativeInvalidInput_OverflowUnderflowInput) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -220,7 +235,8 @@ TEST_F(StoIFunctionalityTest, NegativeInvalidInput_OverflowUnderflowInput) { EXPECT_NE(STATUS_SUCCESS, STRTOI64(s7, NULL, 16, &i64)); } -TEST_F(StoIFunctionalityTest, PreceedingZeros) { +TEST_F(StoIFunctionalityTest, PreceedingZeros) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -237,7 +253,8 @@ TEST_F(StoIFunctionalityTest, PreceedingZeros) { EXPECT_EQ(0, ui32); } -TEST_F(StoIFunctionalityTest, UpperLowerCase) { +TEST_F(StoIFunctionalityTest, UpperLowerCase) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -254,7 +271,8 @@ TEST_F(StoIFunctionalityTest, UpperLowerCase) { EXPECT_EQ(0xabcdef, ui32); } -TEST_F(StoIFunctionalityTest, EndPointerBeforeStringEnd) { +TEST_F(StoIFunctionalityTest, EndPointerBeforeStringEnd) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -271,7 +289,8 @@ TEST_F(StoIFunctionalityTest, EndPointerBeforeStringEnd) { EXPECT_EQ(1000000000, ui32); } -TEST_F(StoIFunctionalityTest, EndOfStringBeforeEndPointer) { +TEST_F(StoIFunctionalityTest, EndOfStringBeforeEndPointer) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -288,7 +307,8 @@ TEST_F(StoIFunctionalityTest, EndOfStringBeforeEndPointer) { EXPECT_EQ(1000000000, ui32); } -TEST_F(StoIFunctionalityTest, PreceedingZerosWithSign) { +TEST_F(StoIFunctionalityTest, PreceedingZerosWithSign) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -316,7 +336,8 @@ TEST_F(StoIFunctionalityTest, PreceedingZerosWithSign) { #if !defined(__MINGW64__) && !defined(__MINGW32__) -TEST_F(StoIFunctionalityTest, CheckLimits) { +TEST_F(StoIFunctionalityTest, CheckLimits) +{ UINT64 ui64; INT64 i64; UINT32 ui32; @@ -343,7 +364,8 @@ TEST_F(StoIFunctionalityTest, CheckLimits) { EXPECT_EQ(-9223372036854775807LL - 1, i64); } -TEST_F(StoIFunctionalityTest, CheckSSCANFSupport) { +TEST_F(StoIFunctionalityTest, CheckSSCANFSupport) +{ INT32 i32; UINT32 ui32; EXPECT_EQ(1, SSCANF("20", "%x", &i32)); diff --git a/tst/utils/Tags.cpp b/tst/utils/Tags.cpp index 000be3e4b..97b4853ac 100644 --- a/tst/utils/Tags.cpp +++ b/tst/utils/Tags.cpp @@ -1,7 +1,6 @@ #include "UtilTestFixture.h" -class TagsFunctionalityTest : public UtilTestBase { -}; +class TagsFunctionalityTest : public UtilTestBase {}; TEST_F(TagsFunctionalityTest, basisTagsFunctionality) { diff --git a/tst/utils/Thread.cpp b/tst/utils/Thread.cpp index 196d28811..229065d79 100644 --- a/tst/utils/Thread.cpp +++ b/tst/utils/Thread.cpp @@ -1,9 +1,8 @@ #include "UtilTestFixture.h" -class ThreadFunctionalityTest : public UtilTestBase { -}; +class ThreadFunctionalityTest : public UtilTestBase {}; -#define TEST_THREAD_COUNT 500 +#define TEST_THREAD_COUNT 500 MUTEX gThreadMutex; UINT64 gThreadCount; @@ -24,7 +23,6 @@ PVOID testThreadRoutine(PVOID arg) st->threadVisited = TRUE; MUTEX_UNLOCK(gThreadMutex); - UINT64 sleepTime = st->threadSleepTime; // Just sleep for some time THREAD_SLEEP(sleepTime); @@ -51,7 +49,7 @@ TEST_F(ThreadFunctionalityTest, ThreadCreateAndReleaseSimpleCheck) st[index].threadVisited = FALSE; st[index].threadCleared = FALSE; st[index].threadSleepTime = index * HUNDREDS_OF_NANOS_IN_A_MILLISECOND; - EXPECT_EQ(STATUS_SUCCESS, THREAD_CREATE(&threads[index], testThreadRoutine, (PVOID)&st[index])); + EXPECT_EQ(STATUS_SUCCESS, THREAD_CREATE(&threads[index], testThreadRoutine, (PVOID) &st[index])); } // Await for the threads to finish @@ -80,13 +78,12 @@ TEST_F(ThreadFunctionalityTest, ThreadCreateAndCancel) // Create the threads for (index = 0; index < TEST_THREAD_COUNT; index++) { - st[index].threadVisited = FALSE; st[index].threadCleared = FALSE; // Long sleep st[index].threadSleepTime = 20 * HUNDREDS_OF_NANOS_IN_A_SECOND; - EXPECT_EQ(STATUS_SUCCESS, THREAD_CREATE(&threads[index], testThreadRoutine, (PVOID)&st[index])); + EXPECT_EQ(STATUS_SUCCESS, THREAD_CREATE(&threads[index], testThreadRoutine, (PVOID) &st[index])); #if !(defined _WIN32 || defined _WIN64 || defined __CYGWIN__) // We should detach thread for non-windows platforms only // Windows implementation would cancel the handle and the @@ -103,7 +100,6 @@ TEST_F(ThreadFunctionalityTest, ThreadCreateAndCancel) EXPECT_EQ(STATUS_SUCCESS, THREAD_CANCEL(threads[index])); } - // Validate that threads have been killed and didn't finish successfully MUTEX_LOCK(gThreadMutex); EXPECT_EQ(TEST_THREAD_COUNT, gThreadCount); diff --git a/tst/utils/Threadpool.cpp b/tst/utils/Threadpool.cpp index 2b6959ccc..9374f2c16 100644 --- a/tst/utils/Threadpool.cpp +++ b/tst/utils/Threadpool.cpp @@ -2,14 +2,12 @@ #include #include -class ThreadpoolFunctionalityTest : public UtilTestBase { -}; +class ThreadpoolFunctionalityTest : public UtilTestBase {}; MUTEX gTerminateMutex; SEMAPHORE_HANDLE gTerminateSemaphore; UINT8 gTerminateCount = 0; - PVOID randomishTask(PVOID customData) { THREAD_SLEEP((rand() % 20 + 100) * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); @@ -28,7 +26,7 @@ PVOID exitOnTeardownTask(PVOID customData) MUTEX_LOCK(gTerminateMutex); terminate = *pTerminate; MUTEX_UNLOCK(gTerminateMutex); - } while(!terminate); + } while (!terminate); semaphoreRelease(gTerminateSemaphore); @@ -84,7 +82,7 @@ TEST_F(ThreadpoolFunctionalityTest, BasicTryAddTest) MUTEX_UNLOCK(gTerminateMutex); // wait for threads to exit before test ends - for(auto i = 0; i < count; i++) { + for (auto i = 0; i < count; i++) { EXPECT_EQ(STATUS_SUCCESS, semaphoreAcquire(gTerminateSemaphore, INFINITE_TIME_VALUE)); } EXPECT_EQ(STATUS_SUCCESS, semaphoreFree(&gTerminateSemaphore)); @@ -117,7 +115,7 @@ TEST_F(ThreadpoolFunctionalityTest, BasicPushTest) MUTEX_UNLOCK(gTerminateMutex); // wait for threads to exit before test ends - for(auto i = 0; i < enteredThreadCount; i++) { + for (auto i = 0; i < enteredThreadCount; i++) { EXPECT_EQ(STATUS_SUCCESS, semaphoreAcquire(gTerminateSemaphore, INFINITE_TIME_VALUE)); } EXPECT_EQ(STATUS_SUCCESS, semaphoreFree(&gTerminateSemaphore)); @@ -171,7 +169,7 @@ TEST_F(ThreadpoolFunctionalityTest, GetThreadCountTest) MUTEX_UNLOCK(gTerminateMutex); // wait for threads to exit before test ends - for(auto i = 0; i < enteredThreadCount; i++) { + for (auto i = 0; i < enteredThreadCount; i++) { EXPECT_EQ(STATUS_SUCCESS, semaphoreAcquire(gTerminateSemaphore, INFINITE_TIME_VALUE)); } EXPECT_EQ(STATUS_SUCCESS, semaphoreFree(&gTerminateSemaphore)); @@ -209,7 +207,7 @@ TEST_F(ThreadpoolFunctionalityTest, ThreadsExitGracefullyAfterThreadpoolFreeTest MUTEX_UNLOCK(gTerminateMutex); // wait for threads to exit before test ends - for(auto i = 0; i < enteredThreadCount; i++) { + for (auto i = 0; i < enteredThreadCount; i++) { EXPECT_EQ(STATUS_SUCCESS, semaphoreAcquire(gTerminateSemaphore, INFINITE_TIME_VALUE)); } EXPECT_EQ(STATUS_SUCCESS, semaphoreFree(&gTerminateSemaphore)); @@ -217,8 +215,6 @@ TEST_F(ThreadpoolFunctionalityTest, ThreadsExitGracefullyAfterThreadpoolFreeTest THREAD_SLEEP(1 * HUNDREDS_OF_NANOS_IN_A_SECOND); } - - typedef struct __ThreadpoolUser { PThreadpool pThreadpool; volatile ATOMIC_BOOL usable; diff --git a/tst/utils/ThreadsafeBlockingQueue.cpp b/tst/utils/ThreadsafeBlockingQueue.cpp index b2579e3aa..c09ad4655 100644 --- a/tst/utils/ThreadsafeBlockingQueue.cpp +++ b/tst/utils/ThreadsafeBlockingQueue.cpp @@ -2,8 +2,7 @@ #include #include -class ThreadsafeBlockingQueueFunctionalityTest : public UtilTestBase { -}; +class ThreadsafeBlockingQueueFunctionalityTest : public UtilTestBase {}; TEST_F(ThreadsafeBlockingQueueFunctionalityTest, createDestroyTest) { @@ -17,9 +16,9 @@ TEST_F(ThreadsafeBlockingQueueFunctionalityTest, createEnqueueDestroyTest) PSafeBlockingQueue pSafeQueue = NULL; UINT64 totalItems = 0; srand(GETTIME()); - totalItems = rand()%(UINT16_MAX) + 1; + totalItems = rand() % (UINT16_MAX) + 1; EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueCreate(&pSafeQueue)); - for(UINT64 i = 0; i < totalItems; i++) { + for (UINT64 i = 0; i < totalItems; i++) { EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueEnqueue(pSafeQueue, i)); } EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueFree(pSafeQueue)); @@ -31,23 +30,22 @@ TEST_F(ThreadsafeBlockingQueueFunctionalityTest, queueIsEmptyTest) UINT64 totalItems = 0, totalLoops = 0, item = 0; BOOL empty = FALSE; srand(GETTIME()); - totalItems = rand()%(UINT16_MAX) + 1; - totalLoops = rand()%64; + totalItems = rand() % (UINT16_MAX) + 1; + totalLoops = rand() % 64; EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueCreate(&pSafeQueue)); - for(UINT64 j = 0; j < totalLoops; j++) { + for (UINT64 j = 0; j < totalLoops; j++) { EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueIsEmpty(pSafeQueue, &empty)); EXPECT_TRUE(empty); - for(UINT64 i = 0; i < totalItems; i++) { + for (UINT64 i = 0; i < totalItems; i++) { EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueEnqueue(pSafeQueue, i)); } EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueIsEmpty(pSafeQueue, &empty)); EXPECT_TRUE(!empty); EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueDequeue(pSafeQueue, &item)); EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueIsEmpty(pSafeQueue, &empty)); - if(totalItems > 1) { + if (totalItems > 1) { EXPECT_TRUE(!empty); - } - else { + } else { EXPECT_TRUE(empty); } EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueClear(pSafeQueue, FALSE)); @@ -59,16 +57,17 @@ TEST_F(ThreadsafeBlockingQueueFunctionalityTest, queueIsEmptyTest) TEST_F(ThreadsafeBlockingQueueFunctionalityTest, queueCountCorrectTest) { PSafeBlockingQueue pSafeQueue = NULL; - UINT64 totalItems = 0, totalLoops = 0, item = 0, itemsToQueue = 0;; + UINT64 totalItems = 0, totalLoops = 0, item = 0, itemsToQueue = 0; + ; UINT32 items = 0; BOOL empty = FALSE; srand(GETTIME()); - totalLoops = rand()%64; + totalLoops = rand() % 64; EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueCreate(&pSafeQueue)); - //queue and dequeue a random number of items in a loop, and check the value - for(UINT64 j = 0; j < totalLoops; j++) { - itemsToQueue = rand()%(UINT16_MAX-totalItems) + 1; - for(UINT64 i = 0; i < itemsToQueue; i++) { + // queue and dequeue a random number of items in a loop, and check the value + for (UINT64 j = 0; j < totalLoops; j++) { + itemsToQueue = rand() % (UINT16_MAX - totalItems) + 1; + for (UINT64 i = 0; i < itemsToQueue; i++) { EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueEnqueue(pSafeQueue, i)); } @@ -76,8 +75,8 @@ TEST_F(ThreadsafeBlockingQueueFunctionalityTest, queueCountCorrectTest) EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueGetCount(pSafeQueue, &items)); EXPECT_EQ(totalItems, items); - itemsToQueue = rand()%(totalItems); - for(UINT64 i = 0; i < itemsToQueue; i++) { + itemsToQueue = rand() % (totalItems); + for (UINT64 i = 0; i < itemsToQueue; i++) { EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueDequeue(pSafeQueue, &item)); } @@ -94,35 +93,35 @@ typedef struct __SafeQueueUser { volatile ATOMIC_BOOL usable; } SafeQueueUser; -void* writingThread(void* ptr) { - SafeQueueUser * user = (SafeQueueUser*)ptr; +void* writingThread(void* ptr) +{ + SafeQueueUser* user = (SafeQueueUser*) ptr; PSafeBlockingQueue pSafeQueue = user->pSafeQueue; - for(int i = 0; i < STATIC_NUMBER_OF_ITEMS; i++) { - std::this_thread::sleep_for(std::chrono::milliseconds(rand()%50)); - if(ATOMIC_LOAD_BOOL(&user->usable)) { + for (int i = 0; i < STATIC_NUMBER_OF_ITEMS; i++) { + std::this_thread::sleep_for(std::chrono::milliseconds(rand() % 50)); + if (ATOMIC_LOAD_BOOL(&user->usable)) { safeBlockingQueueEnqueue(pSafeQueue, i); - } - else { + } else { break; } } return 0; } -void* readingThread(void* ptr) { - SafeQueueUser * user = (SafeQueueUser*)ptr; +void* readingThread(void* ptr) +{ + SafeQueueUser* user = (SafeQueueUser*) ptr; PSafeBlockingQueue pSafeQueue = user->pSafeQueue; UINT64 item = 0; - for(int i = 0; i < STATIC_NUMBER_OF_ITEMS; i++) { - std::this_thread::sleep_for(std::chrono::milliseconds(rand()%50)); - if(ATOMIC_LOAD_BOOL(&user->usable)) { - if(safeBlockingQueueDequeue(pSafeQueue, &item) != STATUS_SUCCESS) { + for (int i = 0; i < STATIC_NUMBER_OF_ITEMS; i++) { + std::this_thread::sleep_for(std::chrono::milliseconds(rand() % 50)); + if (ATOMIC_LOAD_BOOL(&user->usable)) { + if (safeBlockingQueueDequeue(pSafeQueue, &item) != STATUS_SUCCESS) { break; } - } - else { + } else { break; } } @@ -137,19 +136,19 @@ TEST_F(ThreadsafeBlockingQueueFunctionalityTest, multithreadQueueDequeueTest) BOOL empty = FALSE; TID threads[8] = {0}; srand(GETTIME()); - totalThreads = rand()%7 + 2; - //make it even - totalThreads -= totalThreads%2; + totalThreads = rand() % 7 + 2; + // make it even + totalThreads -= totalThreads % 2; EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueCreate(&pSafeQueue)); user.pSafeQueue = pSafeQueue; ATOMIC_STORE_BOOL(&user.usable, TRUE); - for(UINT64 i = 0; i < totalThreads/2; i++) { + for (UINT64 i = 0; i < totalThreads / 2; i++) { EXPECT_EQ(STATUS_SUCCESS, THREAD_CREATE(&threads[threadCount++], readingThread, &user)); } - for(UINT64 i = 0; i < totalThreads/2; i++) { + for (UINT64 i = 0; i < totalThreads / 2; i++) { EXPECT_EQ(STATUS_SUCCESS, THREAD_CREATE(&threads[threadCount++], writingThread, &user)); } - for(UINT64 i = 0; i < totalThreads; i++) { + for (UINT64 i = 0; i < totalThreads; i++) { EXPECT_EQ(STATUS_SUCCESS, THREAD_JOIN(threads[i], NULL)); } ATOMIC_STORE_BOOL(&user.usable, FALSE); @@ -164,19 +163,19 @@ TEST_F(ThreadsafeBlockingQueueFunctionalityTest, multithreadTeardownTest) BOOL empty = FALSE; TID threads[8] = {0}; srand(GETTIME()); - totalThreads = rand()%7 + 2; - //make it even - totalThreads -= totalThreads%2; + totalThreads = rand() % 7 + 2; + // make it even + totalThreads -= totalThreads % 2; EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueCreate(&pSafeQueue)); user.pSafeQueue = pSafeQueue; ATOMIC_STORE_BOOL(&user.usable, TRUE); - for(UINT64 i = 0; i < totalThreads; i++) { + for (UINT64 i = 0; i < totalThreads; i++) { EXPECT_EQ(STATUS_SUCCESS, THREAD_CREATE(&threads[threadCount++], readingThread, &user)); } THREAD_SLEEP(125 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); ATOMIC_STORE_BOOL(&user.usable, FALSE); EXPECT_EQ(STATUS_SUCCESS, safeBlockingQueueFree(pSafeQueue)); - for(UINT64 i = 0; i < totalThreads; i++) { + for (UINT64 i = 0; i < totalThreads; i++) { EXPECT_EQ(STATUS_SUCCESS, THREAD_JOIN(threads[i], NULL)); } } diff --git a/tst/utils/TimerQueue.cpp b/tst/utils/TimerQueue.cpp index 8d918b554..fb19409bb 100644 --- a/tst/utils/TimerQueue.cpp +++ b/tst/utils/TimerQueue.cpp @@ -1,13 +1,9 @@ #include "UtilTestFixture.h" class TimerQueueFunctionalityTest : public UtilTestBase { -public: - TimerQueueFunctionalityTest() : testTimerId(MAX_UINT32), - invokeCount(0), - cancelAfterCount(MAX_UINT32), - retStatus(STATUS_SUCCESS), - checkTimerId(TRUE), - sleepFor(0) + public: + TimerQueueFunctionalityTest() + : testTimerId(MAX_UINT32), invokeCount(0), cancelAfterCount(MAX_UINT32), retStatus(STATUS_SUCCESS), checkTimerId(TRUE), sleepFor(0) { } @@ -119,7 +115,8 @@ TEST_F(TimerQueueFunctionalityTest, addRemoveTimerApiTest) EXPECT_NE(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, testTimerCallback, (UINT64) this, NULL)); // Valid callback - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, 100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, period, testTimerCallback, (UINT64) this, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, + timerQueueAddTimer(handle, 100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, period, testTimerCallback, (UINT64) this, &timerId)); ATOMIC_STORE(&testTimerId, (SIZE_T) timerId); THREAD_SLEEP(200 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); EXPECT_EQ(1, ATOMIC_LOAD(&invokeCount)); @@ -179,8 +176,7 @@ TEST_F(TimerQueueFunctionalityTest, multipleAddRemoveMax) EXPECT_EQ(STATUS_SUCCESS, timerQueueCreate(&handle)); for (i = 0; i < DEFAULT_TIMER_QUEUE_TIMER_COUNT; i++) { - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, - testTimerCallback, (UINT64) this, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, testTimerCallback, (UINT64) this, &timerId)); if (i == DEFAULT_TIMER_QUEUE_TIMER_COUNT / 2) { middleTimerId = timerId; @@ -188,23 +184,18 @@ TEST_F(TimerQueueFunctionalityTest, multipleAddRemoveMax) } // We should fail with max timer error - EXPECT_EQ(STATUS_MAX_TIMER_COUNT_REACHED, timerQueueAddTimer(handle, startTime, period, - testTimerCallback, (UINT64) this, &timerId)); - + EXPECT_EQ(STATUS_MAX_TIMER_COUNT_REACHED, timerQueueAddTimer(handle, startTime, period, testTimerCallback, (UINT64) this, &timerId)); // Remove one and add back again EXPECT_EQ(STATUS_SUCCESS, timerQueueCancelTimer(handle, timerId, (UINT64) this)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, - testTimerCallback, (UINT64) this, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, testTimerCallback, (UINT64) this, &timerId)); // Remove one in the middle and add back again EXPECT_EQ(STATUS_SUCCESS, timerQueueCancelTimer(handle, middleTimerId, (UINT64) this)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, - testTimerCallback, (UINT64) this, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, testTimerCallback, (UINT64) this, &timerId)); // We should fail with max timer error if we add again - EXPECT_EQ(STATUS_MAX_TIMER_COUNT_REACHED, timerQueueAddTimer(handle, startTime, period, - testTimerCallback, (UINT64) this, &timerId)); + EXPECT_EQ(STATUS_MAX_TIMER_COUNT_REACHED, timerQueueAddTimer(handle, startTime, period, testTimerCallback, (UINT64) this, &timerId)); THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); EXPECT_EQ(0, ATOMIC_LOAD(&invokeCount)); @@ -224,8 +215,7 @@ TEST_F(TimerQueueFunctionalityTest, addedTimerFiresBeforeOlder) EXPECT_EQ(STATUS_SUCCESS, timerQueueCreate(&handle)); for (i = 0; i < DEFAULT_TIMER_QUEUE_TIMER_COUNT; i++) { - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, - testTimerCallback, (UINT64) this, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, testTimerCallback, (UINT64) this, &timerId)); if (i == DEFAULT_TIMER_QUEUE_TIMER_COUNT / 2) { middleTimerId = timerId; @@ -234,8 +224,8 @@ TEST_F(TimerQueueFunctionalityTest, addedTimerFiresBeforeOlder) // Remove one in the middle and add an earlier firing timer EXPECT_EQ(STATUS_SUCCESS, timerQueueCancelTimer(handle, middleTimerId, (UINT64) this)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, 100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, period, - testTimerCallback, (UINT64) this, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, + timerQueueAddTimer(handle, 100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, period, testTimerCallback, (UINT64) this, &timerId)); ATOMIC_STORE(&testTimerId, (SIZE_T) timerId); THREAD_SLEEP(200 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); @@ -255,8 +245,7 @@ TEST_F(TimerQueueFunctionalityTest, timerStartTime) // Create a valid timer queue EXPECT_EQ(STATUS_SUCCESS, timerQueueCreate(&handle)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, - testTimerCallback, (UINT64) this, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, testTimerCallback, (UINT64) this, &timerId)); ATOMIC_STORE(&testTimerId, (SIZE_T) timerId); THREAD_SLEEP(10 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); @@ -290,11 +279,9 @@ TEST_F(TimerQueueFunctionalityTest, timerInterleavedSamePeriodDifferentStart) // Create a valid timer queue EXPECT_EQ(STATUS_SUCCESS, timerQueueCreate(&handle)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime1, period, - testTimerCallback, (UINT64) this, &timerId1)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime1, period, testTimerCallback, (UINT64) this, &timerId1)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime2, period, - testTimerCallback, (UINT64) this, &timerId2)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime2, period, testTimerCallback, (UINT64) this, &timerId2)); // Nothing should have fired yet EXPECT_EQ(0, ATOMIC_LOAD(&invokeCount)); @@ -340,8 +327,7 @@ TEST_F(TimerQueueFunctionalityTest, timerCancelFromCallback) // Create a valid timer queue EXPECT_EQ(STATUS_SUCCESS, timerQueueCreate(&handle)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, - testTimerCallback, (UINT64) this, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, testTimerCallback, (UINT64) this, &timerId)); ATOMIC_STORE(&testTimerId, (SIZE_T) timerId); // Make sure it hasn't fired yet @@ -382,8 +368,7 @@ TEST_F(TimerQueueFunctionalityTest, timerCancelDirectly) // Create a valid timer queue EXPECT_EQ(STATUS_SUCCESS, timerQueueCreate(&handle)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, - testTimerCallback, (UINT64) this, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, testTimerCallback, (UINT64) this, &timerId)); ATOMIC_STORE(&testTimerId, (SIZE_T) timerId); // Make sure it hasn't fired yet @@ -422,9 +407,8 @@ TEST_F(TimerQueueFunctionalityTest, timerSingleInvokeTimer) // Create a valid timer queue EXPECT_EQ(STATUS_SUCCESS, timerQueueCreate(&handle)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, - TIMER_QUEUE_SINGLE_INVOCATION_PERIOD, - testTimerCallback, (UINT64) this, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, + timerQueueAddTimer(handle, startTime, TIMER_QUEUE_SINGLE_INVOCATION_PERIOD, testTimerCallback, (UINT64) this, &timerId)); ATOMIC_STORE(&testTimerId, (SIZE_T) timerId); // Make sure it hasn't fired yet @@ -460,8 +444,7 @@ TEST_F(TimerQueueFunctionalityTest, timerDoesntCancelOnError) // Create a valid timer queue EXPECT_EQ(STATUS_SUCCESS, timerQueueCreate(&handle)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, - testTimerCallback, (UINT64) this, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime, period, testTimerCallback, (UINT64) this, &timerId)); ATOMIC_STORE(&testTimerId, (SIZE_T) timerId); // Make sure it hasn't fired yet @@ -502,10 +485,8 @@ TEST_F(TimerQueueFunctionalityTest, timerCancelDirectlyOneLeaveAnotherStart) // Create a valid timer queue EXPECT_EQ(STATUS_SUCCESS, timerQueueCreate(&handle)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime1, period, - testTimerCallback, (UINT64) this, &timerId1)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime2, period, - testTimerCallback, (UINT64) this, &timerId2)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime1, period, testTimerCallback, (UINT64) this, &timerId1)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, startTime2, period, testTimerCallback, (UINT64) this, &timerId2)); // Make sure it hasn't fired yet EXPECT_EQ(0, ATOMIC_LOAD(&invokeCount)); @@ -550,8 +531,7 @@ TEST_F(TimerQueueFunctionalityTest, miniStressTest) // Create timers that will start in a millisecond for (i = 0; i < DEFAULT_TIMER_QUEUE_TIMER_COUNT; i++) { - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, 0, period, - testTimerCallback, (UINT64) this, &timerIds[i])); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, 0, period, testTimerCallback, (UINT64) this, &timerIds[i])); } // Let it fire for a while @@ -573,17 +553,16 @@ TEST_F(TimerQueueFunctionalityTest, miniStressTest) TEST_F(TimerQueueFunctionalityTest, multiUserAddAndCancelTest) { volatile BOOL user1Called = FALSE, user2Called = FALSE; - UINT64 start = 300 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, period = 10 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND;; + UINT64 start = 300 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, period = 10 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND; + ; TIMER_QUEUE_HANDLE handle = INVALID_TIMER_QUEUE_HANDLE_VALUE; UINT32 user1TimerId, user2TimerId; // Create a valid timer queue EXPECT_EQ(STATUS_SUCCESS, timerQueueCreate(&handle)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, 0, period, - multiUserAddAndCancelTestCallback, (UINT64) &user1Called, &user1TimerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, 0, period, multiUserAddAndCancelTestCallback, (UINT64) &user1Called, &user1TimerId)); THREAD_SLEEP(50 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, - multiUserAddAndCancelTestCallback, (UINT64) &user2Called, &user2TimerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, multiUserAddAndCancelTestCallback, (UINT64) &user2Called, &user2TimerId)); THREAD_SLEEP(50 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); // user 1 may not be aware that it's timerid has exited and call cancel timer again. EXPECT_EQ(STATUS_SUCCESS, timerQueueCancelTimer(handle, user1TimerId, (UINT64) &user1Called)); @@ -607,14 +586,10 @@ TEST_F(TimerQueueFunctionalityTest, cancelTimerWithCustomData) // Create a valid timer queue EXPECT_EQ(STATUS_SUCCESS, timerQueueCreate(&handle)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, - multiUserAddAndCancelTestCallback, (UINT64) &user1called, &timerId)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, - multiUserAddAndCancelTestCallback, (UINT64) &user1called, &timerId)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, - multiUserAddAndCancelTestCallback, (UINT64) &user2called, &timerId)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, - multiUserAddAndCancelTestCallback, (UINT64) &user2called, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, multiUserAddAndCancelTestCallback, (UINT64) &user1called, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, multiUserAddAndCancelTestCallback, (UINT64) &user1called, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, multiUserAddAndCancelTestCallback, (UINT64) &user2called, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, multiUserAddAndCancelTestCallback, (UINT64) &user2called, &timerId)); EXPECT_EQ(STATUS_SUCCESS, timerQueueCancelTimersWithCustomData(handle, 3)); EXPECT_EQ(STATUS_SUCCESS, timerQueueCancelTimersWithCustomData(handle, (UINT64) NULL)); @@ -644,14 +619,10 @@ TEST_F(TimerQueueFunctionalityTest, cancelAllTimer) // Create a valid timer queue EXPECT_EQ(STATUS_SUCCESS, timerQueueCreate(&handle)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, - multiUserAddAndCancelTestCallback, (UINT64) &user1called, &timerId)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, - multiUserAddAndCancelTestCallback, (UINT64) &user1called, &timerId)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, - multiUserAddAndCancelTestCallback, (UINT64) &user2called, &timerId)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, - multiUserAddAndCancelTestCallback, (UINT64) &user2called, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, multiUserAddAndCancelTestCallback, (UINT64) &user1called, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, multiUserAddAndCancelTestCallback, (UINT64) &user1called, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, multiUserAddAndCancelTestCallback, (UINT64) &user2called, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, multiUserAddAndCancelTestCallback, (UINT64) &user2called, &timerId)); EXPECT_EQ(STATUS_SUCCESS, timerQueueCancelAllTimers(handle)); EXPECT_EQ(STATUS_SUCCESS, timerQueueGetTimerCount(handle, &timerCount)); @@ -680,14 +651,10 @@ TEST_F(TimerQueueFunctionalityTest, testGetTimersWithCustomData) // Create a valid timer queue EXPECT_EQ(STATUS_SUCCESS, timerQueueCreate(&handle)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, - multiUserAddAndCancelTestCallback, (UINT64) &user1called, &timerId)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, - multiUserAddAndCancelTestCallback, (UINT64) &user1called, &timerId)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, - multiUserAddAndCancelTestCallback, (UINT64) &user2called, &timerId)); - EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, - multiUserAddAndCancelTestCallback, (UINT64) &user2called, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, multiUserAddAndCancelTestCallback, (UINT64) &user1called, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, multiUserAddAndCancelTestCallback, (UINT64) &user1called, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, multiUserAddAndCancelTestCallback, (UINT64) &user2called, &timerId)); + EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, start, period, multiUserAddAndCancelTestCallback, (UINT64) &user2called, &timerId)); EXPECT_EQ(STATUS_SUCCESS, timerQueueGetTimersWithCustomData(handle, (UINT64) &user1called, &timerCount, timerIds)); EXPECT_EQ(2, timerCount); @@ -782,7 +749,8 @@ TEST_F(TimerQueueFunctionalityTest, shutdownTimerQueueTest) EXPECT_LE(curTime + 3 * HUNDREDS_OF_NANOS_IN_A_SECOND, GETTIME()); // Ensure we can't add a new timer - EXPECT_EQ(STATUS_TIMER_QUEUE_SHUTDOWN, timerQueueAddTimer(handle, 0, 200 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, testTimerCallback, (UINT64) this, &timerId)); + EXPECT_EQ(STATUS_TIMER_QUEUE_SHUTDOWN, + timerQueueAddTimer(handle, 0, 200 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND, testTimerCallback, (UINT64) this, &timerId)); // Calling again has no effect EXPECT_EQ(STATUS_SUCCESS, timerQueueShutdown(handle)); @@ -804,7 +772,7 @@ TEST_F(TimerQueueFunctionalityTest, kickTimerQueueTest) EXPECT_EQ(STATUS_SUCCESS, timerQueueAddTimer(handle, 0, 200 * HUNDREDS_OF_NANOS_IN_A_SECOND, testTimerCallback, (UINT64) this, &timerId)); - //let timer start + // let timer start THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); EXPECT_EQ(1, ATOMIC_LOAD(&invokeCount)); @@ -812,9 +780,9 @@ TEST_F(TimerQueueFunctionalityTest, kickTimerQueueTest) EXPECT_NE(STATUS_SUCCESS, timerQueueKick(INVALID_TIMER_QUEUE_HANDLE_VALUE, timerId)); EXPECT_NE(STATUS_SUCCESS, timerQueueKick(handle, 0)); - //let kick happen + // let kick happen THREAD_SLEEP(100 * HUNDREDS_OF_NANOS_IN_A_MILLISECOND); - //check kick occurred + // check kick occurred EXPECT_EQ(2, ATOMIC_LOAD(&invokeCount)); // Calling again has no effect diff --git a/tst/utils/TrimStringTest.cpp b/tst/utils/TrimStringTest.cpp index a81c68867..0ac5ad643 100644 --- a/tst/utils/TrimStringTest.cpp +++ b/tst/utils/TrimStringTest.cpp @@ -1,7 +1,6 @@ #include "UtilTestFixture.h" -class TrimStringFunctionalityTest : public UtilTestBase { -}; +class TrimStringFunctionalityTest : public UtilTestBase {}; TEST_F(TrimStringFunctionalityTest, ltrim_Negative_Positive_Variations) { @@ -197,7 +196,8 @@ TEST_F(TrimStringFunctionalityTest, trimall_Negative_Positive_Variations) EXPECT_EQ(' ', *pEnd); EXPECT_EQ('c', *(pEnd - 1)); - EXPECT_EQ(STATUS_SUCCESS, TRIMSTRALL((PCHAR) " \t \r \n \v \f abc", (UINT32) STRLEN((PCHAR) " \t \r \n \v \f abc"), &pStart, &pEnd)); + EXPECT_EQ(STATUS_SUCCESS, + TRIMSTRALL((PCHAR) " \t \r \n \v \f abc", (UINT32) STRLEN((PCHAR) " \t \r \n \v \f abc"), &pStart, &pEnd)); EXPECT_EQ('a', *pStart); EXPECT_EQ('\0', *pEnd); EXPECT_EQ('c', *(pEnd - 1)); @@ -219,7 +219,9 @@ TEST_F(TrimStringFunctionalityTest, trimall_Negative_Positive_Variations) EXPECT_EQ(' ', *pEnd); EXPECT_EQ('\t', *(pEnd - 1)); - EXPECT_EQ(STATUS_SUCCESS, TRIMSTRALL((PCHAR) " \t \r \n \v \f abc \t \r \n \v \f ", (UINT32) STRLEN((PCHAR) " \t \r \n \v \f abc \t \r \n \v \f "), &pStart, &pEnd)); + EXPECT_EQ(STATUS_SUCCESS, + TRIMSTRALL((PCHAR) " \t \r \n \v \f abc \t \r \n \v \f ", + (UINT32) STRLEN((PCHAR) " \t \r \n \v \f abc \t \r \n \v \f "), &pStart, &pEnd)); EXPECT_EQ('a', *pStart); EXPECT_EQ(' ', *pEnd); EXPECT_EQ('c', *(pEnd - 1)); diff --git a/tst/utils/VersionsTest.cpp b/tst/utils/VersionsTest.cpp index 55807b15e..3f57d93a3 100644 --- a/tst/utils/VersionsTest.cpp +++ b/tst/utils/VersionsTest.cpp @@ -1,7 +1,6 @@ #include "UtilTestFixture.h" -class VersionsFunctionalityTest : public UtilTestBase { -}; +class VersionsFunctionalityTest : public UtilTestBase {}; TEST_F(VersionsFunctionalityTest, getOsVersion_Negative_Positive_Variations) { diff --git a/tst/view/ViewApiFunctionalityTest.cpp b/tst/view/ViewApiFunctionalityTest.cpp index 53e5d4528..596b340b2 100644 --- a/tst/view/ViewApiFunctionalityTest.cpp +++ b/tst/view/ViewApiFunctionalityTest.cpp @@ -1,10 +1,9 @@ #include "ViewTestFixture.h" -class ViewApiFunctionalityTest : public ViewTestBase { -}; +class ViewApiFunctionalityTest : public ViewTestBase {}; #define MAX_VIEW_ITERATION_COUNT 50 -#define VIEW_ITEM_DURATION 10 +#define VIEW_ITEM_DURATION 10 #define VIEW_ITEM_DURATION_LARGE 20 #define VIEW_ITEM_ALLOCAITON_SIZE 100 @@ -25,7 +24,9 @@ TEST_F(ViewApiFunctionalityTest, SimpleAddGet) windowAvailability = FALSE; EXPECT_EQ(STATUS_SUCCESS, contentViewCheckAvailability(mContentView, &windowAvailability)); EXPECT_TRUE(windowAvailability); - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetTail(mContentView, &pViewItem)); EXPECT_TRUE(CHECK_ITEM_FRAGMENT_START(pViewItem->flags)); @@ -56,12 +57,18 @@ TEST_F(ViewApiFunctionalityTest, SimpleAddGet) EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemAt(mContentView, index, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); } windowAvailability = FALSE; @@ -140,7 +147,9 @@ TEST_F(ViewApiFunctionalityTest, AddGetSetCurrent) // Add/check for (timestamp = 0, index = 0; index < MAX_VIEW_ITERATION_COUNT; index++, timestamp += VIEW_ITEM_DURATION + 1) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetTail(mContentView, &pViewItem)); EXPECT_TRUE(CHECK_ITEM_FRAGMENT_START(pViewItem->flags)); @@ -176,16 +185,22 @@ TEST_F(ViewApiFunctionalityTest, AddGetSetCurrent) EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(index, pViewItem->index); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(index, pViewItem->index); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(index, pViewItem->index); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(index, pViewItem->index); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(index, pViewItem->index); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(index, pViewItem->index); // Get and Set the current again @@ -211,7 +226,9 @@ TEST_F(ViewApiFunctionalityTest, AddGetSetCurrentRemoveAll) // Add/check for (timestamp = 0, index = 0; index < MAX_VIEW_ITERATION_COUNT; index++, timestamp += VIEW_ITEM_DURATION + 1) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetTail(mContentView, &pViewItem)); EXPECT_TRUE(CHECK_ITEM_FRAGMENT_START(pViewItem->flags)); @@ -247,16 +264,22 @@ TEST_F(ViewApiFunctionalityTest, AddGetSetCurrentRemoveAll) EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(index, pViewItem->index); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(index, pViewItem->index); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(index, pViewItem->index); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(index, pViewItem->index); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(index, pViewItem->index); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(index, pViewItem->index); // Get and Set the current again @@ -298,15 +321,10 @@ TEST_F(ViewApiFunctionalityTest, overflowBufferDurationWithDropUntilFragmentStar // buffer duration will run out first CreateContentView(CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START, 10000, TEST_MAX_BUFFER_DURATION); - for(i = 0; i < 2 * FPS; ++i) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); + for (i = 0; i < 2 * FPS; ++i) { + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); timestamp += TEST_VIEW_ITEM_DURATION; } @@ -315,14 +333,9 @@ TEST_F(ViewApiFunctionalityTest, overflowBufferDurationWithDropUntilFragmentStar EXPECT_EQ(0, gCallCount); // should trigger a fragment getting dropped - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); // entire fragment should get dropped EXPECT_EQ(gCallCount, KEY_FRAME_INTERVAL); } @@ -339,15 +352,10 @@ TEST_F(ViewApiFunctionalityTest, overflowItemCountWithDropUntilFragmentStart) // max view item count will run out first CreateContentView(CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START, 2 * FPS, 100 * HUNDREDS_OF_NANOS_IN_A_SECOND); - for(i = 0; i < 2 * FPS; ++i) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); + for (i = 0; i < 2 * FPS; ++i) { + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); timestamp += TEST_VIEW_ITEM_DURATION; } @@ -356,14 +364,9 @@ TEST_F(ViewApiFunctionalityTest, overflowItemCountWithDropUntilFragmentStart) EXPECT_EQ(0, gCallCount); // should trigger a fragment getting dropped - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); // entire fragment should get dropped EXPECT_EQ(gCallCount, KEY_FRAME_INTERVAL); } @@ -381,15 +384,10 @@ TEST_F(ViewApiFunctionalityTest, dropUntilFragmentStartDropsEntireContentView) // Only fit one fragment as limited by FPS CreateContentView(CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START, FPS, 100 * HUNDREDS_OF_NANOS_IN_A_SECOND); - for(i = 0; i < FPS; ++i) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); + for (i = 0; i < FPS; ++i) { + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); timestamp += TEST_VIEW_ITEM_DURATION; } @@ -398,14 +396,9 @@ TEST_F(ViewApiFunctionalityTest, dropUntilFragmentStartDropsEntireContentView) EXPECT_EQ(0, gCallCount); // should trigger a fragment getting dropped - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); // entire view get dropped EXPECT_EQ(gCallCount, KEY_FRAME_INTERVAL); } @@ -422,17 +415,12 @@ TEST_F(ViewApiFunctionalityTest, dropUntilFragmentStartDropsUntilStreamStart) // limited by buffer duration CreateContentView(CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START, INT16_MAX, TEST_MAX_BUFFER_DURATION); - for(i = 0; i < 2 * FPS; ++i) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? - ITEM_FLAG_FRAGMENT_START | ITEM_FLAG_STREAM_START : // stream starts are also fragment start - ITEM_FLAG_NONE)); + for (i = 0; i < 2 * FPS; ++i) { + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem( + mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, VIEW_ITEM_ALLOCAITON_SIZE, + i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START | ITEM_FLAG_STREAM_START : // stream starts are also fragment start + ITEM_FLAG_NONE)); timestamp += TEST_VIEW_ITEM_DURATION; } @@ -441,14 +429,9 @@ TEST_F(ViewApiFunctionalityTest, dropUntilFragmentStartDropsUntilStreamStart) EXPECT_EQ(0, gCallCount); // should trigger a fragment getting dropped - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - ITEM_FLAG_FRAGMENT_START | ITEM_FLAG_STREAM_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START | ITEM_FLAG_STREAM_START)); // only one fragment get dropped EXPECT_EQ(gCallCount, FPS); } @@ -465,7 +448,7 @@ TEST_F(ViewApiFunctionalityTest, dropUntilFragmentStartDropsItemWithEndOfFragmen // limited by buffer duration CreateContentView(CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START, INT16_MAX, TEST_MAX_BUFFER_DURATION); - for(i = 0; i < 2 * FPS; ++i) { + for (i = 0; i < 2 * FPS; ++i) { if (i % KEY_FRAME_INTERVAL == 0) { viewItemFlag = ITEM_FLAG_FRAGMENT_START; } else if ((i + 1) % KEY_FRAME_INTERVAL == 0) { @@ -474,14 +457,9 @@ TEST_F(ViewApiFunctionalityTest, dropUntilFragmentStartDropsItemWithEndOfFragmen } else { viewItemFlag = ITEM_FLAG_NONE; } - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - viewItemFlag)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, viewItemFlag)); timestamp += TEST_VIEW_ITEM_DURATION; } @@ -490,14 +468,9 @@ TEST_F(ViewApiFunctionalityTest, dropUntilFragmentStartDropsItemWithEndOfFragmen EXPECT_EQ(0, gCallCount); // should trigger a fragment getting dropped - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START)); // only one fragment get dropped, including the view item with ITEM_FLAG_FRAGMENT_END flag EXPECT_EQ(gCallCount, FPS); } @@ -514,7 +487,9 @@ TEST_F(ViewApiFunctionalityTest, OverflowCheck) // Add/check for (timestamp = 0, index = 0; index < 2 * MAX_VIEW_ITEM_COUNT; index++, timestamp += VIEW_ITEM_DURATION) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START)); // Get the tail EXPECT_EQ(STATUS_SUCCESS, contentViewGetTail(mContentView, &pViewItem)); @@ -565,12 +540,18 @@ TEST_F(ViewApiFunctionalityTest, OverflowCheck) EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemAt(mContentView, index, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewTimestampInRange(mContentView, timestamp, CHECK_AGAINST_ACKTIMESTAMP, &itemExists)); EXPECT_TRUE(itemExists); @@ -595,7 +576,9 @@ TEST_F(ViewApiFunctionalityTest, OverflowNotificationCallbackSizeCurrent) EXPECT_EQ(index < MAX_VIEW_ITEM_COUNT ? TRUE : FALSE, windowAvailability) << "Failed on index: " << index; // Add the item - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, + ITEM_FLAG_FRAGMENT_START)); if (index < MAX_VIEW_ITEM_COUNT) { EXPECT_EQ(NULL, gContentView); @@ -637,7 +620,9 @@ TEST_F(ViewApiFunctionalityTest, OverflowNotificationCallbackAvailability) EXPECT_EQ(index < MAX_VIEW_ITEM_COUNT ? TRUE : FALSE, windowAvailability) << "Failed on index: " << index; // Add the item - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, + ITEM_FLAG_FRAGMENT_START)); EXPECT_EQ(NULL, gContentView); EXPECT_EQ(0, gViewItem.timestamp); @@ -660,7 +645,9 @@ TEST_F(ViewApiFunctionalityTest, OverflowNotificationCallbackAvailability) EXPECT_EQ(0, gCallCount); // Add an item and ensure the callback is called - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp + VIEW_ITEM_DURATION, timestamp + VIEW_ITEM_DURATION, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp + VIEW_ITEM_DURATION, timestamp + VIEW_ITEM_DURATION, VIEW_ITEM_DURATION, + INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_FRAGMENT_START)); EXPECT_EQ(STATUS_SUCCESS, contentViewCheckAvailability(mContentView, &windowAvailability)); EXPECT_FALSE(windowAvailability); EXPECT_EQ(1, gCallCount); @@ -676,7 +663,9 @@ TEST_F(ViewApiFunctionalityTest, OverflowNotificationCallbackSizeTail) // Add/check overflow on size for (timestamp = 0, index = 0; index < 2 * MAX_VIEW_ITEM_COUNT; index++, timestamp += VIEW_ITEM_DURATION) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, + ITEM_FLAG_FRAGMENT_START)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetNext(mContentView, &pViewItem)); if (index < MAX_VIEW_ITEM_COUNT) { @@ -708,7 +697,9 @@ TEST_F(ViewApiFunctionalityTest, OverflowNotificationCallbackDurationCurrent) // Add/check overflow on size for (timestamp = 0, index = 0; index < MAX_VIEW_ITEM_COUNT; index++, timestamp += VIEW_ITEM_DURATION_LARGE) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION_LARGE, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION_LARGE, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, + ITEM_FLAG_FRAGMENT_START)); if (index < MAX_VIEW_ITEM_COUNT / 2) { EXPECT_EQ(NULL, gContentView); @@ -740,7 +731,9 @@ TEST_F(ViewApiFunctionalityTest, OverflowNotificationCallbackDurationTail) // Add/check overflow on size for (timestamp = 0, index = 0; index < MAX_VIEW_ITEM_COUNT; index++, timestamp += VIEW_ITEM_DURATION_LARGE) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION_LARGE, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION_LARGE, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, + ITEM_FLAG_FRAGMENT_START)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetNext(mContentView, &pViewItem)); if (index < MAX_VIEW_ITEM_COUNT / 2) { @@ -774,7 +767,9 @@ TEST_F(ViewApiFunctionalityTest, RollbackCurrentSimpleVariations) // Add/check for (timestamp = VIEW_ITEM_DURATION, index = 0; index < MAX_VIEW_ITERATION_COUNT; index++, timestamp += VIEW_ITEM_DURATION) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, + ITEM_FLAG_FRAGMENT_START)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetTail(mContentView, &pViewItem)); EXPECT_TRUE(CHECK_ITEM_FRAGMENT_START(pViewItem->flags)); @@ -792,12 +787,18 @@ TEST_F(ViewApiFunctionalityTest, RollbackCurrentSimpleVariations) EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemAt(mContentView, index, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewTimestampInRange(mContentView, timestamp, CHECK_AGAINST_ACKTIMESTAMP, &itemExists)); EXPECT_TRUE(itemExists); @@ -858,7 +859,9 @@ TEST_F(ViewApiFunctionalityTest, RollbackCurrentSimpleVariationsSparse) // Add/check for (timestamp = VIEW_ITEM_DURATION, index = 0; index < MAX_VIEW_ITERATION_COUNT / 2; index++, timestamp += 2 * VIEW_ITEM_DURATION) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, + ITEM_FLAG_FRAGMENT_START)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetTail(mContentView, &pViewItem)); EXPECT_TRUE(CHECK_ITEM_FRAGMENT_START(pViewItem->flags)); @@ -876,24 +879,36 @@ TEST_F(ViewApiFunctionalityTest, RollbackCurrentSimpleVariationsSparse) EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemAt(mContentView, index, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); // Make sure it fails when trying to retrieve a timestamp over the newest duration - EXPECT_NE(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration + 10, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_NE( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration + 10, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); // Make sure it fails when trying to retrieve a timestamp over the newest duration - EXPECT_NE(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration + 10, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_NE( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration + 10, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); if (index != 0) { EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemAt(mContentView, index - 1, &pViewItem)); // This is a sparse view so we should still return an item even if the timestamp is above the last to newest duration - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration + 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration + 1, CHECK_AGAINST_ACKTIMESTAMP, + &pViewItem)); // The expected item is in-between the items and will stick with the newest item EXPECT_EQ(index, pViewItem->index); @@ -901,7 +916,9 @@ TEST_F(ViewApiFunctionalityTest, RollbackCurrentSimpleVariationsSparse) EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemAt(mContentView, index - 1, &pViewItem)); // This is a sparse view so we should still return an item even if the timestamp is above the last to newest duration - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration + 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration + 1, !CHECK_AGAINST_ACKTIMESTAMP, + &pViewItem)); // The expected item is in-between the items and will stick with the newest item EXPECT_EQ(index, pViewItem->index); @@ -969,7 +986,8 @@ TEST_F(ViewApiFunctionalityTest, RollbackCurrentSimpleVariationsSparseKeyFrame) for (timestamp = VIEW_ITEM_DURATION, index = 0; index < MAX_VIEW_ITERATION_COUNT / 2; index++, timestamp += 2 * VIEW_ITEM_DURATION) { // Set a key frame every 7th starting from 2nd fragmentStart = (index % 7 == 2) ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE; - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, fragmentStart)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, fragmentStart)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetTail(mContentView, &pViewItem)); EXPECT_FALSE(CHECK_ITEM_FRAGMENT_START(pViewItem->flags)); @@ -987,12 +1005,18 @@ TEST_F(ViewApiFunctionalityTest, RollbackCurrentSimpleVariationsSparseKeyFrame) EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemAt(mContentView, index, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewTimestampInRange(mContentView, timestamp, CHECK_AGAINST_ACKTIMESTAMP, &itemExists)); EXPECT_TRUE(itemExists); @@ -1078,7 +1102,8 @@ TEST_F(ViewApiFunctionalityTest, RollbackCurrentSimpleVariationsSparseKeyFrameRe for (timestamp = VIEW_ITEM_DURATION, index = 0; index < MAX_VIEW_ITERATION_COUNT / 2; index++, timestamp += 2 * VIEW_ITEM_DURATION) { // Set a key frame every 7th starting from 2nd fragmentStart = (index % 7 == 2) ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE; - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, fragmentStart)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, fragmentStart)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetTail(mContentView, &pViewItem)); EXPECT_FALSE(CHECK_ITEM_FRAGMENT_START(pViewItem->flags)); @@ -1096,12 +1121,18 @@ TEST_F(ViewApiFunctionalityTest, RollbackCurrentSimpleVariationsSparseKeyFrameRe EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemAt(mContentView, index, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewTimestampInRange(mContentView, timestamp, CHECK_AGAINST_ACKTIMESTAMP, &itemExists)); EXPECT_TRUE(itemExists); @@ -1302,7 +1333,9 @@ TEST_F(ViewApiFunctionalityTest, getItemWithTimestamp) // Add/check for (timestamp = 1, index = 0; index < MAX_VIEW_ITERATION_COUNT; index++, timestamp += VIEW_ITEM_DURATION) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetTail(mContentView, &pTail)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetHead(mContentView, &pHead)); @@ -1310,29 +1343,43 @@ TEST_F(ViewApiFunctionalityTest, getItemWithTimestamp) EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemAt(mContentView, index, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); } EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pHead->timestamp, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pHead->timestamp + pHead->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pHead->timestamp + pHead->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pTail->timestamp, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pTail->timestamp + pTail->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pTail->timestamp + pTail->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, VIEW_ITEM_DURATION, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_CONTENT_VIEW_INVALID_TIMESTAMP, contentViewGetItemWithTimestamp(mContentView, pTail->timestamp - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_CONTENT_VIEW_INVALID_TIMESTAMP, contentViewGetItemWithTimestamp(mContentView, pHead->timestamp + pHead->duration + 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_CONTENT_VIEW_INVALID_TIMESTAMP, + contentViewGetItemWithTimestamp(mContentView, pTail->timestamp - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_CONTENT_VIEW_INVALID_TIMESTAMP, + contentViewGetItemWithTimestamp(mContentView, pHead->timestamp + pHead->duration + 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pHead->timestamp, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pHead->timestamp + pHead->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pHead->timestamp + pHead->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pTail->timestamp, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pTail->timestamp + pTail->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pTail->timestamp + pTail->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, VIEW_ITEM_DURATION, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_CONTENT_VIEW_INVALID_TIMESTAMP, contentViewGetItemWithTimestamp(mContentView, pTail->timestamp - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - EXPECT_EQ(STATUS_CONTENT_VIEW_INVALID_TIMESTAMP, contentViewGetItemWithTimestamp(mContentView, pHead->timestamp + pHead->duration + 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_CONTENT_VIEW_INVALID_TIMESTAMP, + contentViewGetItemWithTimestamp(mContentView, pTail->timestamp - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + EXPECT_EQ(STATUS_CONTENT_VIEW_INVALID_TIMESTAMP, + contentViewGetItemWithTimestamp(mContentView, pHead->timestamp + pHead->duration + 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); } TEST_F(ViewApiFunctionalityTest, contentViewTrimTail) @@ -1348,7 +1395,9 @@ TEST_F(ViewApiFunctionalityTest, contentViewTrimTail) // Add/check for (timestamp = 0, index = 0; index < MAX_VIEW_ITERATION_COUNT; index++, timestamp += VIEW_ITEM_DURATION) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetTail(mContentView, &pTail)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetHead(mContentView, &pHead)); @@ -1417,7 +1466,9 @@ TEST_F(ViewApiFunctionalityTest, DISABLED_IntOverflowRangeCheck) DLOGI("View item %llu", index); } - ASSERT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START)); + ASSERT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, ITEM_FLAG_FRAGMENT_START)); ASSERT_EQ(STATUS_SUCCESS, contentViewGetHead(mContentView, &pViewItem)); ASSERT_TRUE(CHECK_ITEM_FRAGMENT_START(pViewItem->flags)); @@ -1438,11 +1489,17 @@ TEST_F(ViewApiFunctionalityTest, DISABLED_IntOverflowRangeCheck) ASSERT_EQ(STATUS_SUCCESS, contentViewGetItemAt(mContentView, index, &pViewItem)); ASSERT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - ASSERT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - ASSERT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + ASSERT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + ASSERT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); ASSERT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - ASSERT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); - ASSERT_EQ(STATUS_SUCCESS, contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + ASSERT_EQ(STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); + ASSERT_EQ( + STATUS_SUCCESS, + contentViewGetItemWithTimestamp(mContentView, pViewItem->timestamp + pViewItem->duration - 1, !CHECK_AGAINST_ACKTIMESTAMP, &pViewItem)); } } diff --git a/tst/view/ViewApiTest.cpp b/tst/view/ViewApiTest.cpp index 6d6234b70..4900e7f88 100644 --- a/tst/view/ViewApiTest.cpp +++ b/tst/view/ViewApiTest.cpp @@ -1,16 +1,19 @@ #include "ViewTestFixture.h" -class ViewApiTest : public ViewTestBase { -}; +class ViewApiTest : public ViewTestBase {}; TEST_F(ViewApiTest, createContentView_InvalidInput) { PContentView pContentView; - EXPECT_TRUE(STATUS_FAILED(createContentView(MIN_CONTENT_VIEW_ITEMS, MIN_CONTENT_VIEW_BUFFER_DURATION + 1, NULL, 0, CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START, &pContentView))); - EXPECT_TRUE(STATUS_FAILED(createContentView(MIN_CONTENT_VIEW_ITEMS + 1, MIN_CONTENT_VIEW_BUFFER_DURATION, NULL, 0, CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START, &pContentView))); - EXPECT_TRUE(STATUS_FAILED(createContentView(MIN_CONTENT_VIEW_ITEMS, MIN_CONTENT_VIEW_BUFFER_DURATION, NULL, 0, CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START, &pContentView))); - EXPECT_TRUE(STATUS_FAILED(createContentView(MIN_CONTENT_VIEW_ITEMS + 1, MIN_CONTENT_VIEW_BUFFER_DURATION + 1, NULL, 0, CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START, NULL))); + EXPECT_TRUE(STATUS_FAILED(createContentView(MIN_CONTENT_VIEW_ITEMS, MIN_CONTENT_VIEW_BUFFER_DURATION + 1, NULL, 0, + CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START, &pContentView))); + EXPECT_TRUE(STATUS_FAILED(createContentView(MIN_CONTENT_VIEW_ITEMS + 1, MIN_CONTENT_VIEW_BUFFER_DURATION, NULL, 0, + CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START, &pContentView))); + EXPECT_TRUE(STATUS_FAILED(createContentView(MIN_CONTENT_VIEW_ITEMS, MIN_CONTENT_VIEW_BUFFER_DURATION, NULL, 0, + CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START, &pContentView))); + EXPECT_TRUE(STATUS_FAILED(createContentView(MIN_CONTENT_VIEW_ITEMS + 1, MIN_CONTENT_VIEW_BUFFER_DURATION + 1, NULL, 0, + CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START, NULL))); } TEST_F(ViewApiTest, freeContentView_NullPointer) @@ -18,7 +21,8 @@ TEST_F(ViewApiTest, freeContentView_NullPointer) PContentView pContentView; // Create a valid view - EXPECT_TRUE(STATUS_SUCCEEDED(createContentView(MIN_CONTENT_VIEW_ITEMS + 1, MIN_CONTENT_VIEW_BUFFER_DURATION + 1, NULL, 0, CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START, &pContentView))); + EXPECT_TRUE(STATUS_SUCCEEDED(createContentView(MIN_CONTENT_VIEW_ITEMS + 1, MIN_CONTENT_VIEW_BUFFER_DURATION + 1, NULL, 0, + CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START, &pContentView))); // Free the view EXPECT_TRUE(STATUS_SUCCEEDED(freeContentView(pContentView))); @@ -198,9 +202,9 @@ TEST_F(ViewApiTest, contentViewGetTail_NullPointer) // Add a few items, try to get the tail (success), remove tail for all, // get the head again - the view should have no items but // getting the tail should succeed - EXPECT_EQ(STATUS_SUCCESS,contentViewAddItem(mContentView, 5, 5, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_STREAM_START)); - EXPECT_EQ(STATUS_SUCCESS,contentViewAddItem(mContentView, 6, 6, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_FRAGMENT_START)); - EXPECT_EQ(STATUS_SUCCESS,contentViewAddItem(mContentView, 7, 7, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_NONE)); + EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, 5, 5, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_STREAM_START)); + EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, 6, 6, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, 7, 7, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_NONE)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetWindowItemCount(mContentView, ¤tCount, &windowCount)); EXPECT_EQ(3, currentCount); EXPECT_EQ(3, windowCount); @@ -233,9 +237,9 @@ TEST_F(ViewApiTest, contentViewGetHead_NullPointer) // Add a few items, try to get the head (success), remove tail for all, // get the head again - the view should have no items but // getting the head should succeed - EXPECT_EQ(STATUS_SUCCESS,contentViewAddItem(mContentView, 5, 5, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_STREAM_START)); - EXPECT_EQ(STATUS_SUCCESS,contentViewAddItem(mContentView, 6, 6, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_FRAGMENT_START)); - EXPECT_EQ(STATUS_SUCCESS,contentViewAddItem(mContentView, 7, 7, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_NONE)); + EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, 5, 5, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_STREAM_START)); + EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, 6, 6, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_FRAGMENT_START)); + EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, 7, 7, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_NONE)); EXPECT_EQ(STATUS_SUCCESS, contentViewGetWindowItemCount(mContentView, ¤tCount, &windowCount)); EXPECT_EQ(3, currentCount); EXPECT_EQ(3, windowCount); @@ -277,13 +281,15 @@ TEST_F(ViewApiTest, contentViewAddItem_InvalidTime) EXPECT_TRUE(STATUS_SUCCEEDED(contentViewAddItem(mContentView, 40, 40, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_NONE))); // Add with older timestamp - EXPECT_EQ(STATUS_CONTENT_VIEW_INVALID_TIMESTAMP, contentViewAddItem(mContentView, 39, 39, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_NONE)); + EXPECT_EQ(STATUS_CONTENT_VIEW_INVALID_TIMESTAMP, + contentViewAddItem(mContentView, 39, 39, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_NONE)); // contentViewAddItem should succeed as long as timestamp dont overlap. EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, 49, 49, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 1, ITEM_FLAG_NONE)); // Add a 0-length item - EXPECT_EQ(STATUS_INVALID_CONTENT_VIEW_LENGTH, contentViewAddItem(mContentView, 60, 60, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 0, ITEM_FLAG_NONE)); + EXPECT_EQ(STATUS_INVALID_CONTENT_VIEW_LENGTH, + contentViewAddItem(mContentView, 60, 60, 10, INVALID_ALLOCATION_HANDLE_VALUE, 0, 0, ITEM_FLAG_NONE)); } TEST_F(ViewApiTest, contentViewGetWindowDuration_NullPointer) diff --git a/tst/view/ViewDropPolicyFunctionalityTest.cpp b/tst/view/ViewDropPolicyFunctionalityTest.cpp index b6fab10a9..3a3ed7573 100644 --- a/tst/view/ViewDropPolicyFunctionalityTest.cpp +++ b/tst/view/ViewDropPolicyFunctionalityTest.cpp @@ -1,16 +1,15 @@ #include "ViewTestFixture.h" -using ::testing::WithParamInterface; using ::testing::Bool; -using ::testing::Values; using ::testing::Combine; +using ::testing::Values; +using ::testing::WithParamInterface; -class ViewDropPolicyFunctionalityTest : public ViewTestBase, - public WithParamInterface< ::std::tuple >{ - - protected: +class ViewDropPolicyFunctionalityTest : public ViewTestBase, public WithParamInterface< ::std::tuple > { + protected: CONTENT_VIEW_OVERFLOW_POLICY mOverflowPolicy; - void SetUp() { + void SetUp() + { ViewTestBase::SetUp(); std::tie(mOverflowPolicy) = GetParam(); } @@ -31,16 +30,11 @@ TEST_P(ViewDropPolicyFunctionalityTest, retainedItemTrimedByContentViewTrimTail) // buffer duration will run out first CreateContentView(mOverflowPolicy, 10000, TEST_MAX_BUFFER_DURATION); - for(i = 0; i < 3 * FPS; ++i) { + for (i = 0; i < 3 * FPS; ++i) { allocHandle = i == 0 ? FIRST_FRAME_ALLOCATION_HANDLE : INVALID_ALLOCATION_HANDLE_VALUE; - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - allocHandle, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, allocHandle, 0, VIEW_ITEM_ALLOCAITON_SIZE, + i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); if (i == 0) { // get next view item, simulating upper layer start consuming first view item, and it will be retained @@ -54,14 +48,9 @@ TEST_P(ViewDropPolicyFunctionalityTest, retainedItemTrimedByContentViewTrimTail) EXPECT_EQ(0, gCallCount); // should trigger a fragment getting dropped - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); // more than one frame dropped EXPECT_GT(gCallCount, 0); @@ -93,16 +82,11 @@ TEST_P(ViewDropPolicyFunctionalityTest, retainedItemTrimedByDropFrameAfterConsum // buffer duration will run out first CreateContentView(mOverflowPolicy, 10000, TEST_MAX_BUFFER_DURATION); - for(i = 0; i < 3 * FPS; ++i) { + for (i = 0; i < 3 * FPS; ++i) { allocHandle = i == 0 ? FIRST_FRAME_ALLOCATION_HANDLE : INVALID_ALLOCATION_HANDLE_VALUE; - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - allocHandle, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, allocHandle, 0, VIEW_ITEM_ALLOCAITON_SIZE, + i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); if (i == 0) { // get next view item, simulating upper layer start consuming first view item, and it will be retained EXPECT_EQ(STATUS_SUCCESS, contentViewGetNext(mContentView, &pViewItem)); @@ -115,14 +99,9 @@ TEST_P(ViewDropPolicyFunctionalityTest, retainedItemTrimedByDropFrameAfterConsum EXPECT_EQ(0, gCallCount); // should trigger a fragment getting dropped - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); timestamp += TEST_VIEW_ITEM_DURATION; // more than one frame dropped @@ -141,15 +120,10 @@ TEST_P(ViewDropPolicyFunctionalityTest, retainedItemTrimedByDropFrameAfterConsum gCallCount = 0; // put 2 more fragment. should cause frame drop - for(i = 0; i < 2 * FPS; ++i) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); + for (i = 0; i < 2 * FPS; ++i) { + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); timestamp += TEST_VIEW_ITEM_DURATION; } @@ -177,15 +151,10 @@ TEST_P(ViewDropPolicyFunctionalityTest, retainingViewItemWhileDroppingStillReduc // buffer duration will run out first CreateContentView(mOverflowPolicy, 10000, TEST_MAX_BUFFER_DURATION); - for(i = 0; i < 3 * FPS; ++i) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); + for (i = 0; i < 3 * FPS; ++i) { + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); if (i == 0) { // get next view item, simulating upper layer start consuming first view item, and it will be retained @@ -199,16 +168,10 @@ TEST_P(ViewDropPolicyFunctionalityTest, retainingViewItemWhileDroppingStillReduc EXPECT_EQ(0, gCallCount); EXPECT_EQ(STATUS_SUCCESS, contentViewGetWindowDuration(mContentView, ¤tDuration, &windowDurationBeforeDrop)); - // should trigger a fragment getting dropped - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); timestamp += TEST_VIEW_ITEM_DURATION; // more than one frame dropped @@ -235,14 +198,9 @@ TEST_P(ViewDropPolicyFunctionalityTest, consumedViewItemStayRetained) // keep putting view item until at least 100 view items have been dropped while (gCallCount < 100) { allocHandle = i == 0 ? FIRST_FRAME_ALLOCATION_HANDLE : INVALID_ALLOCATION_HANDLE_VALUE; - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - allocHandle, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, allocHandle, 0, VIEW_ITEM_ALLOCAITON_SIZE, + i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); if (i == 0) { // get next view item, simulating upper layer start consuming first view item, and it will be retained EXPECT_EQ(STATUS_SUCCESS, contentViewGetNext(mContentView, &pViewItem)); @@ -264,14 +222,9 @@ TEST_P(ViewDropPolicyFunctionalityTest, consumedViewItemStayRetained) // put until new drop frame while (gCallCount == 0) { - EXPECT_EQ(STATUS_SUCCESS, contentViewAddItem(mContentView, - timestamp, - timestamp, - TEST_VIEW_ITEM_DURATION, - INVALID_ALLOCATION_HANDLE_VALUE, - 0, - VIEW_ITEM_ALLOCAITON_SIZE, - i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); + EXPECT_EQ(STATUS_SUCCESS, + contentViewAddItem(mContentView, timestamp, timestamp, TEST_VIEW_ITEM_DURATION, INVALID_ALLOCATION_HANDLE_VALUE, 0, + VIEW_ITEM_ALLOCAITON_SIZE, i % KEY_FRAME_INTERVAL == 0 ? ITEM_FLAG_FRAGMENT_START : ITEM_FLAG_NONE)); timestamp += TEST_VIEW_ITEM_DURATION; i++; @@ -283,4 +236,4 @@ TEST_P(ViewDropPolicyFunctionalityTest, consumedViewItemStayRetained) } INSTANTIATE_TEST_SUITE_P(PermutatedDropPolicy, ViewDropPolicyFunctionalityTest, - Values(CONTENT_VIEW_OVERFLOW_POLICY_DROP_TAIL_VIEW_ITEM, CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START)); \ No newline at end of file + Values(CONTENT_VIEW_OVERFLOW_POLICY_DROP_TAIL_VIEW_ITEM, CONTENT_VIEW_OVERFLOW_POLICY_DROP_UNTIL_FRAGMENT_START)); \ No newline at end of file diff --git a/tst/view/ViewTestFixture.cpp b/tst/view/ViewTestFixture.cpp index 7ee1252a2..1784d7a52 100644 --- a/tst/view/ViewTestFixture.cpp +++ b/tst/view/ViewTestFixture.cpp @@ -2,7 +2,7 @@ VOID ViewTestBase::removeNotificationCallback(PContentView pContentView, UINT64 customData, PViewItem pViewItem, BOOL frameNotTransferred) { - ViewTestBase* pTestBase = (ViewTestBase *) customData; + ViewTestBase* pTestBase = (ViewTestBase*) customData; pTestBase->gContentView = pContentView; pTestBase->gCustomData = customData; pTestBase->gFrameDropped = frameNotTransferred;