From 5b6008fa3b5a9b0373b2f03791140ca1fa8dc8de Mon Sep 17 00:00:00 2001 From: Charles Kerr Date: Thu, 17 Mar 2016 10:24:41 -0500 Subject: introduce a QtFixture gtest base class to reduce redundancy in test fixtures' helper/util code --- tests/unit/adbd-client-test.cpp | 2 +- tests/unit/usb-snap-test.cpp | 34 +++++----------------------------- 2 files changed, 6 insertions(+), 30 deletions(-) (limited to 'tests/unit') diff --git a/tests/unit/adbd-client-test.cpp b/tests/unit/adbd-client-test.cpp index c00c07a..754f76c 100644 --- a/tests/unit/adbd-client-test.cpp +++ b/tests/unit/adbd-client-test.cpp @@ -32,7 +32,7 @@ protected: static void file_deleter (std::string* s) { fprintf(stderr, "remove \"%s\"\n", s->c_str()); - remove(s->c_str()); + g_remove(s->c_str()); delete s; } diff --git a/tests/unit/usb-snap-test.cpp b/tests/unit/usb-snap-test.cpp index dc17696..663f9e6 100644 --- a/tests/unit/usb-snap-test.cpp +++ b/tests/unit/usb-snap-test.cpp @@ -18,47 +18,24 @@ */ #define QT_NO_KEYWORDS -#include -#include -#include -#include +#include #include #include -#include - #include #include #include -#include - -#include - -using namespace QtDBusTest; -using namespace QtDBusMock; - -#define WAIT_FOR_SIGNALS(signalSpy, signalsExpected)\ -{\ - while (signalSpy.size() < signalsExpected)\ - {\ - ASSERT_TRUE(signalSpy.wait());\ - }\ - ASSERT_EQ(signalsExpected, signalSpy.size());\ -} - -class UsbSnapFixture: public GlibFixture +class UsbSnapFixture: public QtFixture { - using super = GlibFixture; + using super = QtFixture; public: UsbSnapFixture(): dbusMock{dbusTestRunner} { - DBusTypes::registerMetaTypes(); - dbusTestRunner.startServices(); } @@ -84,7 +61,6 @@ protected: QtDBusTest::DBusTestRunner dbusTestRunner; QtDBusMock::DBusMock dbusMock; - QtDBusTest::DBusServicePtr indicator; }; TEST_F(UsbSnapFixture, TestRoundTrip) @@ -119,7 +95,7 @@ TEST_F(UsbSnapFixture, TestRoundTrip) }); // test that UsbSnap creates a fdo notification - WAIT_FOR_SIGNALS(notificationsSpy, 1); + wait_for_signals(notificationsSpy, 1); { QVariantList const& call(notificationsSpy.at(0)); EXPECT_EQ("Notify", call.at(0)); @@ -157,7 +133,7 @@ TEST_F(UsbSnapFixture, TestRoundTrip) // confirm that the snap dtor cleans up the notification snap.reset(); - WAIT_FOR_SIGNALS(notificationsSpy, 1); + wait_for_signals(notificationsSpy, 1); { QVariantList const& call(notificationsSpy.at(0)); EXPECT_EQ("CloseNotification", call.at(0)); -- cgit v1.2.3