Hi All,

I want to test a http application using QTest, my purpose is to
get contents from a url ,and check whether the content is as expected.

the code something like:

Qt Code:
  1. class testHttp : public QObject
  2. {
  3. Q_OBJECT
  4. private slots:
  5. void testGet();
  6. void compareConfig();
  7. private:
  8. CMyhttp *_myhttp;
  9. };
  10.  
  11. void initTestCase()
  12. {
  13. _myhttp = new CMyhttp ;
  14.  
  15. }
  16.  
  17. void testGet()
  18. {
  19. _myhttp->get("some url");
  20. //here I need to wait until the contents returned from web server,
  21. //but it seemed that qtest lib will not wait
  22. connect(_myhttp ,SIGNAL(finished()),this,SLOT(compareConfig()));
  23. }
  24.  
  25. void compareConfig()
  26. {
  27. QCOMPARE
  28. (
  29. _myhttp.content = "content expected ..."
  30. )
  31. }
To copy to clipboard, switch view to plain text mode 

Any ideas about it?

Thanks advance for your help.

Best regards,
hb