aboutsummaryrefslogtreecommitdiff
path: root/tests/unit
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2016-03-10 17:09:59 -0600
committerCharles Kerr <charles.kerr@canonical.com>2016-03-10 17:09:59 -0600
commitd8ef8e68805ab7f53258427c79ee5aaafec916ba (patch)
tree9d3b9afff38739829f41dc6c8ee327ccbafdb96b /tests/unit
parentf8a5d99b5ac03b5b759f67b33ed2c989fc0d0ceb (diff)
downloadayatana-indicator-display-d8ef8e68805ab7f53258427c79ee5aaafec916ba.tar.gz
ayatana-indicator-display-d8ef8e68805ab7f53258427c79ee5aaafec916ba.tar.bz2
ayatana-indicator-display-d8ef8e68805ab7f53258427c79ee5aaafec916ba.zip
add UsbManager
Diffstat (limited to 'tests/unit')
-rw-r--r--tests/unit/adbd-client-test.cpp22
-rw-r--r--tests/unit/usb-snap-test.cpp38
2 files changed, 12 insertions, 48 deletions
diff --git a/tests/unit/adbd-client-test.cpp b/tests/unit/adbd-client-test.cpp
index 1e28cc9..6514456 100644
--- a/tests/unit/adbd-client-test.cpp
+++ b/tests/unit/adbd-client-test.cpp
@@ -31,22 +31,22 @@ private:
protected:
- std::string m_tmpdir;
+ static void file_deleter (std::string* s)
+ {
+ fprintf(stderr, "remove \"%s\"\n", s->c_str());
+ remove(s->c_str());
+ delete s;
+ }
+
+ std::shared_ptr<std::string> m_tmpdir;
void SetUp()
{
super::SetUp();
char tmpl[] {"adb-client-test-XXXXXX"};
- m_tmpdir = mkdtemp(tmpl);
- g_message("using tmpdir '%s'", m_tmpdir.c_str());
- }
-
- void TearDown()
- {
- g_rmdir(m_tmpdir.c_str());
-
- super::TearDown();
+ m_tmpdir.reset(new std::string{mkdtemp(tmpl)}, file_deleter);
+ g_message("using tmpdir '%s'", m_tmpdir->c_str());
}
};
@@ -67,7 +67,7 @@ TEST_F(AdbdClientFixture, SocketPlumbing)
const auto main_thread = g_thread_self();
- const auto socket_path = m_tmpdir + "/test-socket-plumbing";
+ const auto socket_path = *m_tmpdir + "/test-socket-plumbing";
g_message("socket_path is %s", socket_path.c_str());
for (const auto& test : tests)
diff --git a/tests/unit/usb-snap-test.cpp b/tests/unit/usb-snap-test.cpp
index 70c9d97..84555cc 100644
--- a/tests/unit/usb-snap-test.cpp
+++ b/tests/unit/usb-snap-test.cpp
@@ -20,6 +20,7 @@
#define QT_NO_KEYWORDS
#include <tests/utils/dbus-types.h>
#include <tests/utils/glib-fixture.h>
+#include <tests/utils/gtest-qt-print-helpers.h>
#include <src/usb-snap.h>
@@ -36,43 +37,6 @@
using namespace QtDBusTest;
using namespace QtDBusMock;
-inline QString qVariantToString(const QVariant& variant) {
- QString output;
- QDebug dbg(&output);
- dbg << variant;
- return output;
-}
-
-inline void PrintTo(const QVariant& variant, std::ostream* os) {
- QString output;
- QDebug dbg(&output);
- dbg << variant;
-
- *os << "QVariant(" << output.toStdString() << ")";
-}
-
-inline void PrintTo(const QString& s, std::ostream* os) {
- *os << "\"" << s.toStdString() << "\"";
-}
-
-inline void PrintTo(const QStringList& list, std::ostream* os) {
- QString output;
- QDebug dbg(&output);
- dbg << list;
-
- *os << "QStringList(" << output.toStdString() << ")";
-}
-
-inline void PrintTo(const QList<QDBusObjectPath>& list, std::ostream* os) {
- QString output;
- for (const auto& path: list)
- {
- output.append("\"" + path.path() + "\",");
- }
-
- *os << "QList<QDBusObjectPath>(" << output.toStdString() << ")";
-}
-
#define WAIT_FOR_SIGNALS(signalSpy, signalsExpected)\
{\
while (signalSpy.size() < signalsExpected)\