We expect SignalProxy::current()->sourcePeer() to be set to the
currently sending peer when handling a signal, so add a check
for this to SignalProxyTest.
using Data = std::pair<int, QString>;
using Spy = ValueSpy<Data>;
using Data = std::pair<int, QString>;
using Spy = ValueSpy<Data>;
+ ProxyObject(Spy* spy, Peer* expectedPeer)
+ , _expectedPeer{expectedPeer}
{}
signals:
void sendData(int, const QString&);
void sendMoreData(int, const QString&);
{}
signals:
void sendData(int, const QString&);
void sendMoreData(int, const QString&);
+ void sendToFunctor(int, const QString&);
- void receiveData(int i, const QString& s) { _spy->notify(std::make_pair(i, s)); }
- void receiveExtraData(int i, const QString& s) { _spy->notify(std::make_pair(-i, s.toUpper())); }
+ void receiveData(int i, const QString& s)
+ {
+ EXPECT_EQ(_expectedPeer, SignalProxy::current()->sourcePeer());
+ _spy->notify(std::make_pair(i, s));
+ }
+
+ void receiveExtraData(int i, const QString& s)
+ {
+ EXPECT_EQ(_expectedPeer, SignalProxy::current()->sourcePeer());
+ _spy->notify(std::make_pair(-i, s.toUpper()));
+ }
};
TEST_F(SignalProxyTest, attachSignal)
};
TEST_F(SignalProxyTest, attachSignal)
}
ProxyObject::Spy clientSpy, serverSpy;
}
ProxyObject::Spy clientSpy, serverSpy;
- ProxyObject clientObject{&clientSpy};
- ProxyObject serverObject{&serverSpy};
+ ProxyObject clientObject{&clientSpy, _clientPeer};
+ ProxyObject serverObject{&serverSpy, _serverPeer};
// Deliberately not normalize some of the macro invocations
_clientProxy.attachSignal(&clientObject, SIGNAL(sendData(int, const QString&)));
// Deliberately not normalize some of the macro invocations
_clientProxy.attachSignal(&clientObject, SIGNAL(sendData(int, const QString&)));