~aacid/unity8/fixLauncherUpDownKeys

« back to all changes in this revision

Viewing changes to tests/plugins/Utils/WindowStateStorageTest.cpp

Protect against loading invalid window geometry (LP: #1674262)

Approved by: Albert Astals Cid

Show diffs side-by-side

added added

removed removed

Lines of Context:
56
56
        QTRY_COMPARE(storage->getStage(QTest::currentTestFunction(), 0), stage);
57
57
    }
58
58
 
 
59
    void testProtectAgainstInvalidGeometry() {
 
60
        const QRect geometry{10, 20, 0, 10}; // zero-width (invalid) rectangle
 
61
        storage->saveGeometry(QTest::currentTestFunction(), geometry);
 
62
        const QRect defaultGeometry{10, 20, 30, 40};
 
63
        const QRect loadedGeometry = storage->getGeometry(QTest::currentTestFunction(), defaultGeometry);
 
64
        // ensure we don't load a broken geometry, instead we fall back to the default one
 
65
        QCOMPARE(loadedGeometry, defaultGeometry);
 
66
    }
 
67
 
59
68
private:
60
69
    WindowStateStorage * storage{nullptr};
61
70
};