diff options
author | George Kiagiadakis <george.kiagiadakis@collabora.com> | 2012-04-13 22:05:22 +0300 |
---|---|---|
committer | George Kiagiadakis <george.kiagiadakis@collabora.com> | 2012-04-13 22:11:47 +0300 |
commit | 861eb5f86a44c00e79de8c721110680e594c2eef (patch) | |
tree | dfcfed72df27ca138dfec7f7fe1654e5f70801ab | |
parent | 606c2c8255f354397e642aa3eb457fe54a8c7321 (diff) |
tests: Fix a race condition with createAccount() in test-account-basics and test-dbus-properties
Reviewed-by: Andre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk>
-rw-r--r-- | tests/dbus/account-basics.cpp | 10 | ||||
-rw-r--r-- | tests/dbus/dbus-properties.cpp | 9 |
2 files changed, 17 insertions, 2 deletions
diff --git a/tests/dbus/account-basics.cpp b/tests/dbus/account-basics.cpp index 98f02854..88e45240 100644 --- a/tests/dbus/account-basics.cpp +++ b/tests/dbus/account-basics.cpp @@ -60,6 +60,7 @@ private: Tp::AccountManagerPtr mAM; TestConnHelper *mConn; int mAccountsCount; + bool mCreatingAccount; QHash<QString, QVariant> mProps; }; @@ -111,7 +112,9 @@ void TestAccountBasics::onNewAccount(const Tp::AccountPtr &acc) Q_UNUSED(acc); mAccountsCount++; - mLoop->exit(0); + if (!mCreatingAccount) { + mLoop->exit(0); + } } TEST_IMPLEMENT_PROPERTY_CHANGE_SLOT(const QString &, ServiceName) @@ -168,6 +171,7 @@ void TestAccountBasics::initTestCase() void TestAccountBasics::init() { mProps.clear(); + mCreatingAccount = false; initImpl(); } @@ -194,7 +198,9 @@ void TestAccountBasics::testBasics() QVERIFY(connect(pacc, SIGNAL(finished(Tp::PendingOperation *)), SLOT(expectSuccessfulCall(Tp::PendingOperation *)))); + mCreatingAccount = true; QCOMPARE(mLoop->exec(), 0); + mCreatingAccount = false; QVERIFY(pacc->account()); while (mAccountsCount != 1) { @@ -357,7 +363,9 @@ void TestAccountBasics::testBasics() QVERIFY(connect(pacc, SIGNAL(finished(Tp::PendingOperation *)), SLOT(expectSuccessfulCall(Tp::PendingOperation *)))); + mCreatingAccount = true; QCOMPARE(mLoop->exec(), 0); + mCreatingAccount = false; while (mAccountsCount != 2) { QCOMPARE(mLoop->exec(), 0); diff --git a/tests/dbus/dbus-properties.cpp b/tests/dbus/dbus-properties.cpp index 2e17cbed..9b8f6fc1 100644 --- a/tests/dbus/dbus-properties.cpp +++ b/tests/dbus/dbus-properties.cpp @@ -39,6 +39,7 @@ private Q_SLOTS: private: AccountManagerPtr mAM; int mAccountsCount; + bool mCreatingAccount; QVariantMap mAllProperties; }; @@ -47,7 +48,9 @@ void TestDBusProperties::onNewAccount(const Tp::AccountPtr &acc) Q_UNUSED(acc); mAccountsCount++; - mLoop->exit(0); + if (!mCreatingAccount) { + mLoop->exit(0); + } } void TestDBusProperties::expectSuccessfulAllProperties(PendingOperation *op) @@ -75,6 +78,8 @@ void TestDBusProperties::initTestCase() void TestDBusProperties::init() { + mCreatingAccount = false; + initImpl(); } @@ -97,7 +102,9 @@ void TestDBusProperties::testDBusProperties() QVERIFY(connect(pacc, SIGNAL(finished(Tp::PendingOperation *)), SLOT(expectSuccessfulCall(Tp::PendingOperation *)))); + mCreatingAccount = true; QCOMPARE(mLoop->exec(), 0); + mCreatingAccount = false; QVERIFY(pacc->account()); while (mAccountsCount != 1) { |