~mterry/unity8/power-button-on-lock

« back to all changes in this revision

Viewing changes to tests/utils/modules/Unity/Test/testutil.cpp

  • Committer: Michael Terry
  • Date: 2014-11-24 15:25:42 UTC
  • mfrom: (1368.1.82 unity8)
  • Revision ID: michael.terry@canonical.com-20141124152542-5cysva8ds3qfula6
MergeĀ fromĀ trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
    : QObject(parent)
32
32
    , m_targetWindow(0)
33
33
    , m_touchDevice(0)
34
 
    , m_installedTouchRegistry(false)
35
34
{
36
35
}
37
36
 
83
82
 
84
83
void TestUtil::ensureTouchRegistryInstalled()
85
84
{
86
 
    if (m_installedTouchRegistry)
87
 
        return;
88
 
 
89
 
    TouchRegistry *touchRegistry;
90
 
    if (TouchRegistry::instance() == nullptr) {
91
 
        // Tests can be *very* slow to run and we don't want things timing out because
92
 
        // of that. So give it fake timers to use (they will never time out)
93
 
        touchRegistry = new TouchRegistry(this, new FakeTimerFactory);
94
 
    } else {
95
 
        touchRegistry = TouchRegistry::instance();
96
 
        if (touchRegistry->parent() != this) {
97
 
            // someone else created it. leave it alone
98
 
            m_installedTouchRegistry = true;
99
 
        }
100
 
    }
101
 
 
102
 
    ensureTargetWindow();
103
 
 
104
 
    if (m_targetWindow) {
105
 
        QQuickView *view = qobject_cast<QQuickView*>(m_targetWindow);
106
 
        if (view) {
107
 
            view->installEventFilter(touchRegistry);
108
 
            touchRegistry->setParent(view);
109
 
            m_installedTouchRegistry = true;
110
 
        }
 
85
    if (TouchRegistry::instance())
 
86
        return;
 
87
 
 
88
    if (!m_targetWindow)
 
89
        return;
 
90
 
 
91
    // Tests can be *very* slow to run and we don't want things timing out because
 
92
    // of that. So give it fake timers to use (they will never time out)
 
93
    TouchRegistry *touchRegistry = new TouchRegistry(this, new FakeTimerFactory);
 
94
 
 
95
    QQuickView *view = qobject_cast<QQuickView*>(m_targetWindow);
 
96
    if (view) {
 
97
        view->installEventFilter(touchRegistry);
 
98
        touchRegistry->setParent(view);
111
99
    }
112
100
}