summaryrefslogtreecommitdiffstats
path: root/tests/auto
diff options
context:
space:
mode:
authorJocelyn Turcotte <jocelyn.turcotte@digia.com>2014-01-27 17:23:13 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-01-27 18:32:45 +0100
commit44e25bdf008742570619877e82ba603b3520b08f (patch)
tree56af4ba169bc206a5aad505c040a5e7e6143f249 /tests/auto
parente5c8a206c0807381bebd928e31beb258b14bc65f (diff)
Get rid of tr1/functional
This header requires rtti in libstdc++ on Mac, which we can't recommend since Qt itself is usually built without rtti. Replace its uses with simpler hand-made template functors. Change-Id: Ic020dcceaf262f77d92b31a8318a513fa200428d Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Diffstat (limited to 'tests/auto')
-rw-r--r--tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp4
-rw-r--r--tests/auto/widgets/util.h30
2 files changed, 19 insertions, 15 deletions
diff --git a/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp b/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp
index 99ad21152..b38a7fdfe 100644
--- a/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp
+++ b/tests/auto/widgets/qwebengineframe/tst_qwebengineframe.cpp
@@ -406,8 +406,8 @@ void tst_QWebEngineFrame::asyncAndDelete()
QWebEnginePage *page = new QWebEnginePage;
CallbackSpy<QString> plainTextSpy;
CallbackSpy<QString> htmlSpy;
- page->toPlainText(ref(plainTextSpy));
- page->toHtml(ref(htmlSpy));
+ page->toPlainText(plainTextSpy.ref());
+ page->toHtml(htmlSpy.ref());
delete page;
// Pending callbacks should be called with an empty value in the page's destructor.
diff --git a/tests/auto/widgets/util.h b/tests/auto/widgets/util.h
index a9a3d487c..5adc7e1b7 100644
--- a/tests/auto/widgets/util.h
+++ b/tests/auto/widgets/util.h
@@ -27,14 +27,6 @@
#include <QTimer>
#include <qwebenginepage.h>
-#if __cplusplus >= 201103L
-#include <functional>
-using std::ref;
-#else
-#include <tr1/functional>
-using std::tr1::ref;
-#endif
-
#if !defined(TESTS_SOURCE_DIR)
#define TESTS_SOURCE_DIR ""
#endif
@@ -87,12 +79,17 @@ public:
}
};
+template<typename T, typename R>
+struct RefWrapper {
+ R &ref;
+ void operator()(const T& result) {
+ ref(result);
+ }
+};
+
template<typename T>
class CallbackSpy {
public:
- // Tells tr1::ref the result of void operator()(const T &result) when decltype isn't available.
- typedef void result_type;
-
CallbackSpy() : called(false) {
timeoutTimer.setSingleShot(true);
QObject::connect(&timeoutTimer, SIGNAL(timeout()), &eventLoop, SLOT(quit()));
@@ -116,6 +113,13 @@ public:
eventLoop.quit();
}
+ // Cheap rip-off of boost/std::ref
+ RefWrapper<T, CallbackSpy<T> > ref()
+ {
+ RefWrapper<T, CallbackSpy<T> > wrapper = {*this};
+ return wrapper;
+ }
+
private:
Q_DISABLE_COPY(CallbackSpy)
bool called;
@@ -127,14 +131,14 @@ private:
static inline QString toPlainText(QWebEnginePage *page)
{
CallbackSpy<QString> spy;
- page->toPlainText(ref(spy));
+ page->toPlainText(spy.ref());
return spy.waitForResult();
}
static inline QString toHtml(QWebEnginePage *page)
{
CallbackSpy<QString> spy;
- page->toHtml(ref(spy));
+ page->toHtml(spy.ref());
return spy.waitForResult();
}