~faenil/ubuntu-ui-toolkit/UbuntuTestCase_flick_flakiness_fix

« back to all changes in this revision

Viewing changes to tests/unit_x11/tst_statesaver/tst_statesaver.cpp

  • Committer: Andrea Bernabei
  • Date: 2016-02-09 21:30:24 UTC
  • mfrom: (1795.2.47 staging)
  • Revision ID: andrea.bernabei@canonical.com-20160209213024-txzjng3d5bewlu1l
merge staging

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
#include <QtCore/QProcessEnvironment>
35
35
#include "uctestcase.h"
36
36
#include <signal.h>
 
37
#include "plugin.h"
37
38
 
38
39
#define protected public
39
40
#define private public
50
51
 
51
52
private:
52
53
    QString m_modulePath;
 
54
    QQmlEngine *engine = nullptr;
53
55
 
54
56
    QQuickView *createView(const QString &file)
55
57
    {
59
61
 
60
62
    void resetView(QScopedPointer<UbuntuTestCase> &view, const QString &file)
61
63
    {
62
 
        Q_EMIT StateSaverBackend::instance().initiateStateSaving();
 
64
        Q_EMIT StateSaverBackend::instance()->initiateStateSaving();
63
65
        view.reset();
64
66
        // Make sure that the state is reloaded from file
65
 
        StateSaverBackend::instance().m_archive.data()->sync();
 
67
        StateSaverBackend::instance()->m_archive.data()->sync();
66
68
        view.reset(new UbuntuTestCase(file));
67
69
    }
68
70
 
69
71
    void resetView(QScopedPointer<QQuickView> &view, const QString &file)
70
72
    {
71
 
        Q_EMIT StateSaverBackend::instance().initiateStateSaving();
 
73
        Q_EMIT StateSaverBackend::instance()->initiateStateSaving();
72
74
        view.reset();
73
75
        // Make sure that the state is reloaded from file
74
 
        StateSaverBackend::instance().m_archive.data()->sync();
 
76
        StateSaverBackend::instance()->m_archive.data()->sync();
75
77
        view.reset(createView(file));
76
78
    }
77
79
 
99
101
        // Create manually to avoid wrong ownership
100
102
        tempDir.mkdir("tst_statesaver");
101
103
        setenv("XDG_RUNTIME_DIR", testRuntimeDir.toUtf8(), 1);
 
104
    }
 
105
 
 
106
    void cleanupTestCase()
 
107
    {
 
108
    }
 
109
 
 
110
    void init()
 
111
    {
 
112
        engine = new QQmlEngine;
 
113
        UbuntuComponentsPlugin::initializeContextProperties(engine);
102
114
        // invoke initialization
103
 
        StateSaverBackend::instance();
 
115
        StateSaverBackend::instance(engine);
104
116
    }
105
 
 
106
 
    void cleanupTestCase()
 
117
    void cleanup()
107
118
    {
108
 
        StateSaverBackend::instance().reset();
 
119
        StateSaverBackend::instance()->reset();
 
120
        delete engine;
109
121
    }
110
122
 
111
123
    void test_SaveArrays()
467
479
        QCOMPARE(items.count(), 5); // 4 Rectangles + 1 Repeater
468
480
 
469
481
        Q_FOREACH(QQuickItem *item, items) {
470
 
            if (QuickUtils::instance().className(item) == "QQuickRectangle") {
 
482
            if (QuickUtils::instance()->className(item) == "QQuickRectangle") {
471
483
                item->setHeight(25);
472
484
            }
473
485
        }
481
493
        QCOMPARE(items.count(), 5); // 4 Rectangles + 1 Repeater
482
494
 
483
495
        Q_FOREACH(QQuickItem *item, items) {
484
 
            if (QuickUtils::instance().className(item) == "QQuickRectangle") {
 
496
            if (QuickUtils::instance()->className(item) == "QQuickRectangle") {
485
497
                QCOMPARE(item->height(), 25.0);
486
498
            }
487
499
        }