I'm writing a test to verify the sequence of calls on an image processing thread. The relevant piece of test code looks like this:
Sequence s1, s2;
...
EXPECT_CALL(*mMockVideoSource, getFrame()).InSequence(s2).WillRepeatedly(Return(mFakeBuffer));
EXPECT_CALL(*mMockProcessor, processFrame(_,_)).InSequence(s2).WillRepeatedly(Return(0));
EXPECT_CALL(*mMockVideoSource, releaseFrame(_)).Times(AnyNumber()).InSequence(s2);
...
In this case, the sequence of calls is extremely important. getFrame()
, processFrame()
and releaseFrame()
must be called in this order. Unfortunately, the above code isn't really accomplishing what I want. The above code will allow getFrame()
to be called repeatedly before the call to processFrame()
, and a call to getFrame()
after releaseFrame()
is considered an error since it breaks the sequence.
Is there a way to expect a specific sequence of calls to be made repeatedly? I don't care how many times the sequence is executed, so long as the functions are called in order: get, process, release, get, process, release...
WillRepeatedly
then instead of e.g.WillOnce
? – Lycurgus