fixed unit tests, buffer indexes were not reset, caused tests to fail on 2nd repeat.

This commit is contained in:
Nick Bolton 2013-04-10 12:14:59 +00:00
parent 880819fab7
commit 72cbcd70c0
3 changed files with 21 additions and 8 deletions

View File

@ -32,18 +32,20 @@ using ::testing::AnyNumber;
const UInt8 mouseMove_bufferLen = 16;
UInt8 mouseMove_buffer[mouseMove_bufferLen];
UInt32 mouseMove_bufferIndex = 0;
UInt32 mouseMove_bufferIndex;
UInt32 mouseMove_mockRead(void* buffer, UInt32 n);
const UInt8 cryptoIv_bufferLen = 20;
UInt8 cryptoIv_buffer[cryptoIv_bufferLen];
UInt32 cryptoIv_bufferIndex = 0;
UInt32 cryptoIv_bufferIndex;
CString cryptoIv_result;
UInt32 cryptoIv_mockRead(void* buffer, UInt32 n);
void cryptoIv_setCryptoIv(const UInt8*);
TEST(CServerProxyTests, mouseMove)
{
mouseMove_bufferIndex = 0;
NiceMock<CMockEventQueue> eventQueue;
NiceMock<CMockClient> client;
NiceMock<CMockStream> stream;
@ -61,6 +63,8 @@ TEST(CServerProxyTests, mouseMove)
TEST(CServerProxyTests, cryptoIv)
{
cryptoIv_bufferIndex = 0;
NiceMock<CMockEventQueue> eventQueue;
NiceMock<CMockClient> client;
NiceMock<CMockStream> stream;

View File

@ -28,13 +28,15 @@ using ::testing::Invoke;
const UInt8 cryptoIvWrite_bufferLen = 200;
UInt8 cryptoIvWrite_buffer[cryptoIvWrite_bufferLen];
UInt32 cryptoIvWrite_bufferIndex = 0;
UInt32 cryptoIvWrite_bufferIndex;
void
cryptoIv_mockWrite(const void* in, UInt32 n);
TEST(CClientProxyTests, cryptoIvWrite)
{
{
cryptoIvWrite_bufferIndex = 0;
NiceMock<CMockEventQueue> eventQueue;
NiceMock<CMockStream> innerStream;
NiceMock<CMockServer> server;

View File

@ -36,18 +36,18 @@ UInt8 g_read_buffer[4];
UInt8 read_mockRead(void* out, UInt32 n);
UInt8 g_write4Read1_buffer[4];
UInt32 g_write4Read1_bufferIndex = 0;
UInt32 g_write4Read1_bufferIndex;
void write4Read1_mockWrite(const void* in, UInt32 n);
UInt8 write4Read1_mockRead(void* out, UInt32 n);
UInt8 g_write1Read4_buffer[4];
UInt32 g_write1Read4_bufferIndex = 0;
UInt32 g_write1Read4_bufferIndex;
void write1Read4_mockWrite(const void* in, UInt32 n);
UInt8 write1Read4_mockRead(void* out, UInt32 n);
UInt8 g_readWriteIvChanged_buffer[4];
UInt32 g_readWriteIvChangeTrigger_writeBufferIndex = 0;
UInt32 g_readWriteIvChangeTrigger_readBufferIndex = 0;
UInt32 g_readWriteIvChangeTrigger_writeBufferIndex;
UInt32 g_readWriteIvChangeTrigger_readBufferIndex;
void readWriteIvChanged_mockWrite(const void* in, UInt32 n);
UInt8 readWriteIvChanged_mockRead(void* out, UInt32 n);
@ -108,6 +108,8 @@ TEST(CCryptoTests, read)
TEST(CCryptoTests, write4Read1)
{
g_write4Read1_bufferIndex = 0;
NiceMock<CMockEventQueue> eventQueue;
NiceMock<CMockStream> innerStream;
CCryptoOptions options("ctr", "mock");
@ -137,6 +139,8 @@ TEST(CCryptoTests, write4Read1)
TEST(CCryptoTests, write1Read4)
{
g_write1Read4_bufferIndex = 0;
NiceMock<CMockEventQueue> eventQueue;
NiceMock<CMockStream> innerStream;
CCryptoOptions options("ctr", "mock");
@ -171,6 +175,9 @@ TEST(CCryptoTests, write1Read4)
TEST(CCryptoTests, readWriteIvChanged)
{
g_readWriteIvChangeTrigger_writeBufferIndex = 0;
g_readWriteIvChangeTrigger_readBufferIndex = 0;
NiceMock<CMockEventQueue> eventQueue;
NiceMock<CMockStream> innerStream;
CCryptoOptions options("ctr", "mock");