void FramesCreatorTest::shouldWriteDataToFrame() { QByteArray data; EXPECT_CALL(*mockFramesFactory, create(QByteArray("header data"))).WillOnce(Return(mockFrame)); EXPECT_CALL(*mockFrame, frameData()).Times(AnyNumber()).WillRepeatedly(Return(&data)); EXPECT_CALL(*mockFrame, totalbytes()).Times(AnyNumber()).WillRepeatedly(Return(100)); framesCreator->createNewFrame(QByteArray("header data")); framesCreator->addFramesData(QByteArray("Any data to write into the frame")); QCOMPARE(data, QByteArray("Any data to write into the frame")); }
AnyNumber& AnyNumber::operator +=(const AnyNumber &lhs) { Fraction *ptr_fraction=dynamic_cast<Fraction*>(lhs.ptr_number); Integer *ptr_integer=dynamic_cast<Integer*>(lhs.ptr_number); Fraction *rhs_fraction=dynamic_cast<Fraction*>(ptr_number); Integer *rhs_integer=dynamic_cast<Integer*>(ptr_number); if (ptr_fraction!=NULL && rhs_fraction!=NULL) (*this)=AnyNumber((*ptr_fraction)+(*rhs_fraction)); else if (ptr_integer!=NULL && rhs_fraction!=NULL) (*this)=AnyNumber((*ptr_integer)+(*rhs_fraction)); else if (ptr_fraction!=NULL && rhs_integer!=NULL) (*this)=AnyNumber((*ptr_fraction)+(*rhs_integer)); else if (ptr_integer!=NULL && rhs_integer!=NULL) (*this)=AnyNumber((*ptr_integer)+(*rhs_integer)); else {ptr_number=NULL; return *this;} }
// Test that Init() calls DisconnectAllSupportedDevices(). TEST_F(AudioDeviceHandlerTest, InitCallsDisconnectAllSupportedDevices) { EXPECT_CALL(handler_, NotifyAudioPolicyService( _, AUDIO_POLICY_DEVICE_STATE_UNAVAILABLE)).Times(3); EXPECT_CALL(handler_, TriggerCallback( AudioDeviceHandlerMock::DeviceConnectionState::kDevicesDisconnected)) .Times(AtLeast(1)); EXPECT_CALL(handler_, NotifyAudioPolicyService( _, AUDIO_POLICY_DEVICE_STATE_AVAILABLE)).Times(AnyNumber()); EXPECT_CALL(handler_, TriggerCallback( AudioDeviceHandlerMock::DeviceConnectionState::kDevicesConnected)) .Times(AnyNumber()); handler_.Init(nullptr); }
void FramesCreatorTest::shouldReportRemainingBytes() { QByteArray data; EXPECT_CALL(*mockFramesFactory, create(QByteArray("header data"))).WillOnce(Return(mockFrame)); EXPECT_CALL(*mockFrame, totalbytes()).Times(AnyNumber()).WillRepeatedly(Return(1024)); EXPECT_CALL(*mockFrame, frameData()).Times(AnyNumber()).WillRepeatedly(Return(&data)); framesCreator->createNewFrame(QByteArray("header data")); QCOMPARE(framesCreator->remainingBytesForCurrentFrame(), (quint64) 1024); data.append("1234567890"); QCOMPARE(framesCreator->remainingBytesForCurrentFrame(), (quint64) (1024-10) ); data.append("123456789012345"); QCOMPARE(framesCreator->remainingBytesForCurrentFrame(), (quint64) (1024-10-15) ); }
void FramesCreatorTest::shouldEmitProcessedFrameSignalWhenNoMoreBytesAreRemaining() { QByteArray data; QSignalSpy spy(framesCreator, SIGNAL(frameProcessed(Frame*))); EXPECT_CALL(*mockFramesFactory, create(QByteArray("header data"))).WillOnce(Return(mockFrame)); EXPECT_CALL(*mockFrame, frameData()).Times(AnyNumber()).WillRepeatedly(Return(&data)); EXPECT_CALL(*mockFrame, totalbytes()).Times(AnyNumber()).WillRepeatedly(Return(10)); framesCreator->createNewFrame(QByteArray("header data")); framesCreator->addFramesData(QByteArray("12345")); QCOMPARE(spy.count(), 0); framesCreator->addFramesData(QByteArray("12345")); QCOMPARE(framesCreator->remainingBytesForCurrentFrame(), (quint64)0); QCOMPARE(spy.count(), 1); }
TEST(TestKeysValues, Check) { KeysValues keys_values(":", " "); keys_values.Add<string>("a", "1.2"); keys_values.Add<string>("a", "2.2"); keys_values.Add<string>("a", "3.2"); keys_values.Add<string>("b", "(1.0,2.0)"); keys_values.Add<string>("b", "(1.1,2.0)"); keys_values.Add<string>("b", "2.0"); keys_values.Add<string>("cc", "abc 1.03 (1.1,2.0)"); keys_values.Add<string>("cc", "a 1.1 (1.0,8.0)"); keys_values.Add<string>("dd", "1 2 3 1.1"); EXPECT_NO_THROW (keys_values.Check<string>( NumberIs(3),"a")); EXPECT_NO_THROW(keys_values.Check<double>(AnyNumber(), "a")); EXPECT_NO_THROW(keys_values.Check<int>(ZeroOrOne(), "e")); keys_values.Check<string,double,CD>(AnyNumber(), "cc"); }
void IgnoreWidgetDestructionCallbacks() { EXPECT_CALL(*mock_observer_, SetAllRenderWidgetsHidden(true)) .Times(AnyNumber()); }