×

Discussion Board

Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    23

    Signal is not getting called in my qtest testcase

    Hi

    I have some doubta reagrding qtest

    1) can we have multiple QVERIFY or QCOMPARE in one testcase?

    2) I connected a signal and slot in my testcase, but the slot is not getting called at all. what might be the problem ?
    [I made the slot a public slot.Signal is from my class which has to be tested- which surely is emitting the signal.]

    HELP!!!!

    Kalyani

  2. #2
    Super Contributor
    Join Date
    Oct 2008
    Location
    INDIA
    Posts
    2,326

    Re: Signal is not getting called in my qtest testcase

    Can you post the sample code here....>?

  3. #3
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,800

    Re: Signal is not getting called in my qtest testcase

    Quote Originally Posted by pkalyani View Post
    Hi

    2) I connected a signal and slot in my testcase, but the slot is not getting called at all. what might be the problem ?
    [I made the slot a public slot.Signal is from my class which has to be tested- which surely is emitting the signal.]
    Did you check using tips given in this thread?
    http://discussion.forum.nokia.com/fo...light=Q_ASSERT
    Pankaj Nathani
    www.croozeus.com

  4. #4
    Registered User
    Join Date
    Apr 2010
    Posts
    23

    Re: Signal is not getting called in my qtest testcase

    Hi


    Here in the testcase,
    I am trying link to a dll which has api which connect to the a site and get me related data- and it generates a signal that data is available.

    Now I want to test that api.
    I connected that signal to my slot.and called that api.
    1) I am unable to see the logs of my slot function in the test logs.
    Due to which I feel the slot is not called.
    2)I introduced a delay also, QTest::qwait(milliseconds) to see that there is enough time to catch the signal before the testcase ends.But still the logs in slot are not seen.
    3)when I tried to test that signal using QSignalSpy, it failed .

    (But a simple app has been written to check the data flow, and the data is sen, which means signal is working. then y is not working with QTestLib!! )

    Thanks
    Kalyani

  5. #5
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Signal is not getting called in my qtest testcase

    Quote Originally Posted by pkalyani View Post
    1) can we have multiple QVERIFY or QCOMPARE in one testcase?
    Sure you can.

    Quote Originally Posted by pkalyani View Post
    2) I connected a signal and slot in my testcase, but the slot is not getting called at all. what might be the problem ?
    [I made the slot a public slot.Signal is from my class which has to be tested- which surely is emitting the signal.]
    Typical problem in such case is typos in signal/slot's names, while using QObject::connect().

  6. #6
    Registered User
    Join Date
    Apr 2010
    Posts
    23

    Re: Signal is not getting called in my qtest testcase

    no, there are no typos in signal/slot's names !!!

    I want the testcase to wait till the signal is generated,
    how to do that ?

  7. #7
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Signal is not getting called in my qtest testcase

    Quote Originally Posted by pkalyani View Post
    no, there are no typos in signal/slot's names !!!
    Does QObject::connects return true? If you didn't check it basically you cannot state that.

    Quote Originally Posted by pkalyani View Post
    I want the testcase to wait till the signal is generated, how to do that ?
    Using QTest::qwait is a correct approach, but it doesn't look to me like a timeout problem taking into account you didn't disclose any details
    on nature of you signal. Why QSignalSpy failed?

  8. #8
    Registered User
    Join Date
    Apr 2010
    Posts
    23

    Re: Signal is not getting called in my qtest testcase

    1) I used
    bool ok = connect (...)
    Q_ASSERT(ok)
    The testcase passed.

    2)I used QTest::qwait(5000) // give time to connect to the site and return data
    but the testcase doesnt start at all!!! [ Logs stop at at initTestcase()...my testcase hasnt even started!!! ]

    3) this is my code for testing the signal [this is another case to test the signal ]

    QSignalSpy signalSpy(myclass, SIGNAL(ListAvailable(List*, QString ))) ;
    // Now we check to make sure we don't have any signals already
    QCOMPARE( signalSpy.count(), 0 );
    myclass->list(); //connect to the site and fetch the list
    // when the list is ready, we should get a signal.
    QCOMPARE( signalSpy.count(), 1 );


    Is anything wrong with the testcode?

    -Kalyani

  9. #9
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Signal is not getting called in my qtest testcase

    Quote Originally Posted by pkalyani View Post
    [ Logs stop at at initTestcase()...my testcase hasnt even started!!! ]
    Could you please show us your test code?

    Quote Originally Posted by pkalyani View Post
    QSignalSpy signalSpy(myclass, SIGNAL(ListAvailable(List*, QString ))) ;
    // Now we check to make sure we don't have any signals already
    QCOMPARE( signalSpy.count(), 0 );
    myclass->list(); //connect to the site and fetch the list
    // when the list is ready, we should get a signal.
    QCOMPARE( signalSpy.count(), 1 );
    What is an output of qDebug() << signalSpy.isValid() (or Q_ASSERT(signalSpy.isValid())).

  10. #10
    Super Contributor
    Join Date
    Nov 2009
    Location
    Minnesota, USA
    Posts
    3,209

    Re: Signal is not getting called in my qtest testcase

    Quote Originally Posted by pkalyani View Post
    no, there are no typos in signal/slot's names !!!
    Famous last words. ALWAYS capture the return code from connect() and test it to be sure that the connect() statement is correct.

  11. #11
    Registered User
    Join Date
    Apr 2010
    Posts
    23

    Re: Signal is not getting called in my qtest testcase

    The result is " no such signal....test failed , signal count is 0"

  12. #12
    Registered User
    Join Date
    Apr 2010
    Posts
    23

    Re: Signal is not getting called in my qtest testcase

    Quote Originally Posted by divanov View Post
    Could you please show us your test code?

    {
    MyClient* client = new MyClient();
    //Get the list of provider who implement this interface
    QString name("some name"); //works fine
    QList<Provider>* providerList = client->GetMyServices(name);
    if(providerList)
    {
    //now create contact fetcher with the 0th provider
    Provider P(providerList->at(0));
    Fetcher* Fetcher = new Fetcher(&P);
    bool ok =connect(Fetcher,SIGNAL(ListAvailable(List*, Error )),
    this,SLOT(showFriends(List*,Error )),Qt:irectConnection);
    Q_ASSERT(ok);
    //this shud connect to site and fetch the list and generate signal
    Fetcher->friends();
    }
    QTest::qWait(5000);
    }



    What is an output of qDebug() << signalSpy.isValid() (or Q_ASSERT(signalSpy.isValid())).
    The output is "not valid", donno y...

  13. #13
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Signal is not getting called in my qtest testcase

    Quote Originally Posted by pkalyani View Post
    The output is "not valid", donno y...
    I've meant the test code like in this example.
    http://qt.gitorious.org/qt/qt/blobs/...estqstring.cpp
    But not valid signal in QSignalSpy tells a lot about nature of your problems.
    Last edited by divanov; 2010-05-04 at 11:18. Reason: fixing a typo

  14. #14
    Registered User
    Join Date
    Apr 2010
    Posts
    23

    Re: Signal is not getting called in my qtest testcase

    Hi Daniil

    I am sending the code ::



    class TestClientApp : public QObject
    {
    Q_OBJECT
    private slots:

    // testing signals
    void testFriendsListAvailableSignal();



    };

    void TestClientApp::testFriendsListAvailableSignal()
    {

    MyClient* client = new MyClient();

    //Get the list of provider who implement this interface
    QString name("org.symbian.my.client.friends.list");
    QList<Provider>* providerList=
    client->GetServices(name);

    if(providerList)
    {
    int count = providerList->count();
    Provider smfP(providerList->at(0));
    Fetcher* fetcher = new Fetcher(&smfP);
    QSignalSpy signalSpy(fetcher, SIGNAL(ListAvailable(ContactList*, QString , ResultPage))) ;
    QVERIFY( signalSpy.isValid() ); //just to check if it is correct or not
    // Now we check to make sure we don't have any signals already
    QCOMPARE( signalSpy.count(), 0 );
    //which connects a site and emits a signal once list is available

    fetcher->List();

    QTest::qWait(5000);
    // when the list is ready, we should get a signal.
    QCOMPARE( signalSpy.count(), 1 );

    }

    }

  15. #15
    Super Contributor
    Join Date
    Oct 2009
    Posts
    4,326

    Re: Signal is not getting called in my qtest testcase

    Quote Originally Posted by pkalyani View Post
    Hi Daniil

    I am sending the code ::
    And where is QTEST_MAIN?

Similar Threads

  1. Nokia N95 signal problem - help pleaseeeeee
    By postmanstu in forum General Development Questions
    Replies: 4
    Last Post: 2011-04-26, 08:11
  2. How to get a callback function called upon signal strengthdrop
    By islamfunny in forum Symbian Networking & Messaging (Closed)
    Replies: 2
    Last Post: 2009-06-24, 13:56
  3. N73 signal problem
    By Degeneratemoo in forum General Development Questions
    Replies: 2
    Last Post: 2007-10-01, 11:30
  4. SMS-send problem during loss os signal
    By novis in forum Symbian
    Replies: 2
    Last Post: 2007-05-28, 12:38
  5. Errors building project in VS.2003
    By jensesaat in forum Symbian
    Replies: 11
    Last Post: 2006-11-13, 16:54

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×