Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QTestLib and signal emission.
Forum Updated to NodeBB v4.3 + New Features

QTestLib and signal emission.

Scheduled Pinned Locked Moved General and Desktop
4 Posts 2 Posters 5.7k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Thanatos
    wrote on 20 Oct 2010, 10:31 last edited by
    #1

    I am not sure whats wrong here.. shouldn't QTest::mouseClick emit a signal ?

    @void FinallyTest::testCase1()
    {
    QCheckBox tmp;
    tmp.show();

    QSignalSpy spy(&tmp, SIGNAL(clicked(bool)));
    
    QTest::mouseClick( &tmp, Qt::LeftButton ); // simulates signal emision ???
    
    QCOMPARE(spy.count(), 1);
    

    }@

    FAIL! : FinallyTest::testCase1() Compared values are not the same

    Actual (spy.count()): 0
    Expected (1): 1

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lyuts
      wrote on 20 Oct 2010, 12:59 last edited by
      #2

      According to the source code for QTest::mouseClick which is:

      @switch (action)
      {
      case MousePress:
      me = QMouseEvent(QEvent::MouseButtonPress, pos, widget->mapToGlobal(pos), button, button, stateKey);
      break;

      case MouseRelease:
          me = QMouseEvent(QEvent::MouseButtonRelease, pos, widget->mapToGlobal(pos), button, 0, stateKey);
          break;
      
      case MouseDClick:
          me = QMouseEvent(QEvent::MouseButtonDblClick, pos, widget->mapToGlobal(pos), button, button, stateKey);
          break;
      
      case MouseMove:
          QCursor::setPos(widget->mapToGlobal(pos));
          qApp->processEvents();
          return;
      
      default:
          QTEST_ASSERT(false);
      

      }@

      it uses QMouseEvent, so I would think that no signal is emitted, but QMouseEvent is generated.

      I'm a rebel in the S.D.G.

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Thanatos
        wrote on 20 Oct 2010, 14:20 last edited by
        #3

        Great, thanks for the good explanation.

        I see that this is excellent way how to investigate problems (and learn more deeply Qt source). I am kind of new to programming, no real experience - university does not count in my opinion =) Maybe or (and others as well) can explain me how to properly browse through Qt modules?

        For now i see that each module has *.pro file so i can open each module in Qt Creator as project. Seems fine, but just in case - is there any better way?

        Also i am not clear in which file did you find the source code for QTest::mouseClick? in .\qt\src\testlib\ I can see the qtest.h file but not the qtest.cpp ?

        Thanks in advance.

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lyuts
          wrote on 20 Oct 2010, 17:09 last edited by
          #4

          [quote author="Thanatos" date="1287584432"]
          I see that this is excellent way how to investigate problems (and learn more deeply Qt source). I am kind of new to programming, no real experience - university does not count in my opinion =) Maybe or (and others as well) can explain me how to properly browse through Qt modules?

          For now i see that each module has *.pro file so i can open each module in Qt Creator as project. Seems fine, but just in case - is there any better way?
          [/quote]

          University, I wish I could go to the university again. Just love that time. Anyway, I don't know how to describe the better way. It's just everyone is doing this in his own and more convenient way. I'll tell you how I do it. I read Qt's source code if I have some problems or if I don't understand completely, the way something works. Getting to know Qt modules starts for me from getting to know its API.

          [quote author="Thanatos" date="1287584432"]
          Also i am not clear in which file did you find the source code for QTest::mouseClick? in .\qt\src\testlib\ I can see the qtest.h file but not the qtest.cpp ?

          Thanks in advance. [/quote]
          I found it in this file src/testlib/qtestmouse.h. The implementation of mouseClick is in this header. You will find several signatures for it.

          I'm a rebel in the S.D.G.

          1 Reply Last reply
          0

          1/4

          20 Oct 2010, 10:31

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved