aboutsummaryrefslogtreecommitdiff
path: root/tests/integration/usb-manager-test.cpp
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2016-03-22 16:01:47 -0500
committerCharles Kerr <charles.kerr@canonical.com>2016-03-22 16:01:47 -0500
commit4f8a17f23a0bba7da7654c147ca377e271abe0db (patch)
tree3e564cececf09842f7e758b74b0850e3693ab2b9 /tests/integration/usb-manager-test.cpp
parenta5f330f6b73101d7bbdeadc6a5f53b8da3349999 (diff)
downloadayatana-indicator-display-4f8a17f23a0bba7da7654c147ca377e271abe0db.tar.gz
ayatana-indicator-display-4f8a17f23a0bba7da7654c147ca377e271abe0db.tar.bz2
ayatana-indicator-display-4f8a17f23a0bba7da7654c147ca377e271abe0db.zip
add tests for not showing snap decisions in greeter mode
Diffstat (limited to 'tests/integration/usb-manager-test.cpp')
-rw-r--r--tests/integration/usb-manager-test.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/tests/integration/usb-manager-test.cpp b/tests/integration/usb-manager-test.cpp
index 3ce79d0..03c80c7 100644
--- a/tests/integration/usb-manager-test.cpp
+++ b/tests/integration/usb-manager-test.cpp
@@ -87,7 +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;
+ std::shared_ptr<MockGreeter> m_greeter;
};
TEST_F(UsbManagerFixture, Allow)
@@ -157,7 +157,7 @@ TEST_F(UsbManagerFixture, Allow)
EXPECT_EQ(public_key, lines[0]);
}
-TEST_F(UsbManagerFixture, AndroidInterruptus)
+TEST_F(UsbManagerFixture, USBDisconnectedDuringPrompt)
{
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};
@@ -171,7 +171,6 @@ TEST_F(UsbManagerFixture, AndroidInterruptus)
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(),
@@ -196,3 +195,32 @@ g_message("i %d", i);
notificationsSpy.clear();
}
}
+
+TEST_F(UsbManagerFixture, Greeter)
+{
+ 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};
+
+ // 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
+ m_greeter->m_is_active.set(true);
+ auto usb_manager = std::make_shared<UsbManager>(*socket_path, *public_keys_path, m_usb_monitor, m_greeter);
+
+ // add a signal spy to listen to the notification daemon
+ QSignalSpy notificationsSpy(
+ &notificationsMockInterface(),
+ SIGNAL(MethodCalled(const QString &, const QVariantList &))
+ );
+
+ // the greeter is active, so the notification should not appear
+ EXPECT_FALSE(notificationsSpy.wait(2000));
+
+ // disable the greeter, the notification should appear
+ m_greeter->m_is_active.set(false);
+ wait_for_signals(notificationsSpy, 1);
+ EXPECT_EQ("Notify", notificationsSpy.at(0).at(0));
+ notificationsSpy.clear();
+}