mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 06:45:37 +08:00
Issue #73 Unittest for CIdentifier dbus object path conversion
This commit is contained in:
@@ -80,7 +80,7 @@ namespace BlackMisc
|
||||
QString toDBusObjectPath(const QString &root = {}) const;
|
||||
|
||||
//! Reconstruct an identifier from a DBus object path.
|
||||
CIdentifier fromDBusObjectPath(const QString &path, const QString &root = {});
|
||||
static CIdentifier fromDBusObjectPath(const QString &path, const QString &root = {});
|
||||
|
||||
//! Name
|
||||
const QString &getName() const { return m_name; }
|
||||
|
||||
@@ -34,6 +34,9 @@ namespace BlackMiscTest
|
||||
|
||||
//! Machine unique id tests
|
||||
void machineUniqueId();
|
||||
|
||||
//! Conversion to dbus object path
|
||||
void dbusObjectPath();
|
||||
};
|
||||
|
||||
//! Test identifiable object
|
||||
@@ -67,6 +70,15 @@ namespace BlackMiscTest
|
||||
QVERIFY2(!o.getMachineId().isEmpty(), "Machine id shall never be empty! If this test failed on a supported platform, get a fallback solution!");
|
||||
}
|
||||
|
||||
void CTestIdentifier::dbusObjectPath()
|
||||
{
|
||||
QObject q;
|
||||
q.setObjectName("!@#$%^&*()_+");
|
||||
CTestIdentifiable id(&q);
|
||||
QString s(id.identifier().toDBusObjectPath());
|
||||
QVERIFY2(id.identifier() == CIdentifier::fromDBusObjectPath(s), "Conversion from dbus object path and back compares equal");
|
||||
}
|
||||
|
||||
CTestIdentifiable::CTestIdentifiable(QObject *nameObject) : CIdentifiable(nameObject)
|
||||
{ }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user