Positive tests for IPC logging #4624
So far I had only tested what happens when the limits are exceeded. These new tests are for when usage is within limits.
This commit is contained in:
parent
a710b2752b
commit
89a977da66
|
@ -45,7 +45,7 @@ inline const Matcher<const IpcMessage&> IpcLogLineMessageEq(const String& s) {
|
||||||
return MatcherCast<const IpcMessage&>(m);
|
return MatcherCast<const IpcMessage&>(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(IpcLogOutputterTests, write_bufferSizeWrapping)
|
TEST(IpcLogOutputterTests, write_overBufferMaxSize_firstLineTruncated)
|
||||||
{
|
{
|
||||||
MockIpcServer mockServer;
|
MockIpcServer mockServer;
|
||||||
mockServer.delegateToFake();
|
mockServer.delegateToFake();
|
||||||
|
@ -65,7 +65,26 @@ TEST(IpcLogOutputterTests, write_bufferSizeWrapping)
|
||||||
mockServer.waitForSend();
|
mockServer.waitForSend();
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(IpcLogOutputterTests, write_bufferRateLimit)
|
TEST(IpcLogOutputterTests, write_underBufferMaxSize_allLinesAreSent)
|
||||||
|
{
|
||||||
|
MockIpcServer mockServer;
|
||||||
|
mockServer.delegateToFake();
|
||||||
|
|
||||||
|
ON_CALL(mockServer, hasClients(_)).WillByDefault(Return(true));
|
||||||
|
|
||||||
|
EXPECT_CALL(mockServer, hasClients(_)).Times(1);
|
||||||
|
EXPECT_CALL(mockServer, send(IpcLogLineMessageEq("mock 1\nmock 2\n"), _)).Times(1);
|
||||||
|
|
||||||
|
IpcLogOutputter outputter(mockServer);
|
||||||
|
outputter.bufferMaxSize(2);
|
||||||
|
|
||||||
|
// log more lines than the buffer can contain
|
||||||
|
outputter.write(kNOTE, "mock 1");
|
||||||
|
outputter.write(kNOTE, "mock 2");
|
||||||
|
mockServer.waitForSend();
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(IpcLogOutputterTests, write_overBufferRateLimit_lastLineTruncated)
|
||||||
{
|
{
|
||||||
MockIpcServer mockServer;
|
MockIpcServer mockServer;
|
||||||
mockServer.delegateToFake();
|
mockServer.delegateToFake();
|
||||||
|
@ -92,4 +111,30 @@ TEST(IpcLogOutputterTests, write_bufferRateLimit)
|
||||||
mockServer.waitForSend();
|
mockServer.waitForSend();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST(IpcLogOutputterTests, write_underBufferRateLimit_allLinesAreSent)
|
||||||
|
{
|
||||||
|
MockIpcServer mockServer;
|
||||||
|
mockServer.delegateToFake();
|
||||||
|
|
||||||
|
ON_CALL(mockServer, hasClients(_)).WillByDefault(Return(true));
|
||||||
|
|
||||||
|
EXPECT_CALL(mockServer, hasClients(_)).Times(2);
|
||||||
|
EXPECT_CALL(mockServer, send(IpcLogLineMessageEq("mock 1\nmock 2\n"), _)).Times(1);
|
||||||
|
EXPECT_CALL(mockServer, send(IpcLogLineMessageEq("mock 3\nmock 4\n"), _)).Times(1);
|
||||||
|
|
||||||
|
IpcLogOutputter outputter(mockServer);
|
||||||
|
outputter.bufferRateLimit(4, 1); // 1s (should be plenty of time)
|
||||||
|
|
||||||
|
// log 1 more line than the buffer can accept in time limit.
|
||||||
|
outputter.write(kNOTE, "mock 1");
|
||||||
|
outputter.write(kNOTE, "mock 2");
|
||||||
|
mockServer.waitForSend();
|
||||||
|
|
||||||
|
// after waiting the time limit send another to make sure
|
||||||
|
// we can log after the time limit passes.
|
||||||
|
outputter.write(kNOTE, "mock 3");
|
||||||
|
outputter.write(kNOTE, "mock 4");
|
||||||
|
mockServer.waitForSend();
|
||||||
|
}
|
||||||
|
|
||||||
#endif // WINAPI_MSWINDOWS
|
#endif // WINAPI_MSWINDOWS
|
||||||
|
|
Loading…
Reference in New Issue