| 1 |
import QtQuick 2.4 |
| 2 |
import QtQuick.Window 2.1 |
| 3 |
import QtTest 1.0 |
| 4 |
import MazDB 1.0 |
| 5 |
|
| 6 |
TestCase { |
| 7 |
id: test |
| 8 |
name: "MazDB::Settings" |
| 9 |
|
| 10 |
MazDBSettings { |
| 11 |
id: settings |
| 12 |
property string property1: "Hello" |
| 13 |
property string property2: "World" |
| 14 |
readonly property int readonlyproperty3: 1000 |
| 15 |
} |
| 16 |
|
| 17 |
MazDB { |
| 18 |
id: db |
| 19 |
} |
| 20 |
|
| 21 |
function initTestCase() { |
| 22 |
db.source = settings.fileName() |
| 23 |
} |
| 24 |
|
| 25 |
function cleanupTestCase() { |
| 26 |
settings.close() |
| 27 |
db.destroyDB(db.source) |
| 28 |
} |
| 29 |
|
| 30 |
function test_settings() { |
| 31 |
compare(db.opened, true, db.errorString) |
| 32 |
compare(db.get("property1"), "Hello") |
| 33 |
compare(db.get("property2"), "World") |
| 34 |
compare(db.get("readonlyproperty3"), undefined) |
| 35 |
} |
| 36 |
|
| 37 |
function test_overwrite() { |
| 38 |
compare(db.opened, true, db.errorString) |
| 39 |
compare(db.get("property1"), "Hello") |
| 40 |
compare(db.putSync("property1", "Foo"),true) |
| 41 |
compare(settings.property1, "Foo") |
| 42 |
compare(db.putSync("property1", "Hello"), true) |
| 43 |
compare(db.get("property1"), "Hello") |
| 44 |
} |
| 45 |
|
| 46 |
} |