From: Manuel Nickschas Date: Wed, 17 Oct 2018 20:09:53 +0000 (+0200) Subject: tests: Check that sourcePeer() is set in SignalProxyTest X-Git-Tag: test-travis-01~104 X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=commitdiff_plain;h=96e623bcd9a56fdf153a6c82376a9ab0c45aa102 tests: Check that sourcePeer() is set in SignalProxyTest 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. --- diff --git a/tests/common/signalproxytest.cpp b/tests/common/signalproxytest.cpp index c79f0a2d..18b71e1e 100644 --- a/tests/common/signalproxytest.cpp +++ b/tests/common/signalproxytest.cpp @@ -65,20 +65,32 @@ public: using Data = std::pair; using Spy = ValueSpy; - ProxyObject(Spy* spy) + ProxyObject(Spy* spy, Peer* expectedPeer) : _spy{spy} + , _expectedPeer{expectedPeer} {} signals: void sendData(int, const QString&); void sendMoreData(int, const QString&); + void sendToFunctor(int, const QString&); public slots: - 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())); + } private: Spy* _spy; + Peer* _expectedPeer; }; TEST_F(SignalProxyTest, attachSignal) @@ -91,8 +103,8 @@ TEST_F(SignalProxyTest, attachSignal) } 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&)));