aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/integration/usb-manager-test.cpp57
1 files changed, 32 insertions, 25 deletions
diff --git a/tests/integration/usb-manager-test.cpp b/tests/integration/usb-manager-test.cpp
index 19c0401..3ce79d0 100644
--- a/tests/integration/usb-manager-test.cpp
+++ b/tests/integration/usb-manager-test.cpp
@@ -19,6 +19,7 @@
#include <tests/utils/adbd-server.h>
#include <tests/utils/qt-fixture.h>
+#include <tests/utils/mock-greeter.h>
#include <tests/utils/mock-usb-monitor.h>
#include <src/dbus-names.h>
@@ -64,6 +65,7 @@ protected:
super::SetUp();
m_usb_monitor.reset(new MockUsbMonitor{});
+ m_greeter.reset(new MockGreeter{});
char tmpl[] = {"usb-manager-test-XXXXXX"};
m_tmpdir.reset(new std::string{g_mkdtemp(tmpl)}, file_deleter);
@@ -85,6 +87,7 @@ protected:
QtDBusMock::DBusMock dbusMock;
std::shared_ptr<std::string> m_tmpdir;
std::shared_ptr<MockUsbMonitor> m_usb_monitor;
+ std::shared_ptr<Greeter> m_greeter;
};
TEST_F(UsbManagerFixture, Allow)
@@ -104,7 +107,7 @@ TEST_F(UsbManagerFixture, Allow)
auto adbd_server = std::make_shared<GAdbdServer>(*socket_path, std::vector<std::string>{"PK"+public_key});
// set up a UsbManager to process the request
- auto usb_manager = std::make_shared<UsbManager>(*socket_path, *public_keys_path, m_usb_monitor);
+ auto usb_manager = std::make_shared<UsbManager>(*socket_path, *public_keys_path, m_usb_monitor, m_greeter);
// wait for the notification to show up, confirm it looks right
wait_for_signals(notificationsSpy, 1);
@@ -154,38 +157,42 @@ TEST_F(UsbManagerFixture, Allow)
EXPECT_EQ(public_key, lines[0]);
}
-TEST_F(UsbManagerFixture, Cancel)
+TEST_F(UsbManagerFixture, AndroidInterruptus)
{
const std::shared_ptr<std::string> socket_path {new std::string{*m_tmpdir+"/socket"}, file_deleter};
const std::shared_ptr<std::string> public_keys_path {new std::string{*m_tmpdir+"/adb_keys"}, file_deleter};
- // add a signal spy to listen to the notification daemon
- QSignalSpy notificationsSpy(
- &notificationsMockInterface(),
- SIGNAL(MethodCalled(const QString &, const QVariantList &))
- );
-
// start a mock AdbdServer ready to submit a request
const std::string public_key {"public_key"};
auto adbd_server = std::make_shared<GAdbdServer>(*socket_path, std::vector<std::string>{"PK"+public_key});
// set up a UsbManager to process the request
- auto usb_manager = std::make_shared<UsbManager>(*socket_path, *public_keys_path, m_usb_monitor);
+ auto usb_manager = std::make_shared<UsbManager>(*socket_path, *public_keys_path, m_usb_monitor, m_greeter);
- // wait for a notification to show up
- wait_for_signals(notificationsSpy, 1);
- EXPECT_EQ("Notify", notificationsSpy.at(0).at(0));
- notificationsSpy.clear();
-
- // wait for UsbSnap to receive dbusmock's response to the Notify request.
- // there's no event to key off of for this, so just wait for a moment
- wait_msec();
-
- // disconnect the USB before the user has a chance to allow/deny
- m_usb_monitor->m_on_usb_disconnected("android0");
-
- // confirm that we requested the notification to be pulled down
- wait_for_signals(notificationsSpy, 1);
- EXPECT_EQ("CloseNotification", notificationsSpy.at(0).at(0));
- notificationsSpy.clear();
+ for (int i=0; i<3; i++)
+ {
+g_message("i %d", i);
+ // add a signal spy to listen to the notification daemon
+ QSignalSpy notificationsSpy(
+ &notificationsMockInterface(),
+ SIGNAL(MethodCalled(const QString &, const QVariantList &))
+ );
+
+ // wait for a notification to show up
+ wait_for_signals(notificationsSpy, 1);
+ EXPECT_EQ("Notify", notificationsSpy.at(0).at(0));
+ notificationsSpy.clear();
+
+ // wait for UsbSnap to receive dbusmock's response to the Notify request.
+ // there's no event to key off of for this, so just wait for a moment
+ wait_msec();
+
+ // disconnect the USB before the user has a chance to allow/deny
+ m_usb_monitor->m_on_usb_disconnected("android0");
+
+ // confirm that we requested the notification to be pulled down
+ wait_for_signals(notificationsSpy, 1);
+ EXPECT_EQ("CloseNotification", notificationsSpy.at(0).at(0));
+ notificationsSpy.clear();
+ }
}