title: How can I test method calling QMetaObject::invokeMethod with Qt::QueuedConnection -- using gtest gmock framework
body: <p>Suppose I have a method and I want to test it using gtest/gmock framework. This method calls another method inside itself using a Qt queued invoke:</p>
  <pre class="lang-cpp prettyprint-override"><code>void MyClass::handleFoo()
  {
      // ...
      Q_ASSERT(QMetaObject::invokeMethod(this, &quot;handleBar&quot;, Qt::QueuedConnection));
  }
  
  void MyClass::handleBar()
  {
      _view.show();
  }
  </code></pre>
  <pre class="lang-cpp prettyprint-override"><code>TEST_F(MyTestSuite, MyTest)
  {
      EXPECT_CALL(_viewMock, show()); // Fails with never called
  
      emit _myClassObj-&gt;foo();
  
      // Tried QCoreApplication::processEvents() -- does not help
  }
  </code></pre>
  <p>Is there any way to do it? I think maybe I should just test these two handlers separately. But how can I test that the method <code>handleFoo()</code> will indeed call <code>handleBar()</code>?</p>