aboutsummaryrefslogtreecommitdiff
path: root/tests/integration/usb-manager-test.cpp
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2016-09-22 16:30:07 -0500
committerCharles Kerr <charles.kerr@canonical.com>2016-09-22 16:30:07 -0500
commitb7c135151300dee6d6cb433cd9df989d4f04935f (patch)
tree89e6097c31e509ddf5948280e2ec35fe4e670fb3 /tests/integration/usb-manager-test.cpp
parentfe6fe0ae1e87d46c6060045cc3b25865df4533bd (diff)
parent403fd0a388e565daf195729d9211ff03c23c93a0 (diff)
downloadayatana-indicator-display-b7c135151300dee6d6cb433cd9df989d4f04935f.tar.gz
ayatana-indicator-display-b7c135151300dee6d6cb433cd9df989d4f04935f.tar.bz2
ayatana-indicator-display-b7c135151300dee6d6cb433cd9df989d4f04935f.zip
sync with lp:~charlesk/indicator-display/lp-1572545-prompt-in-lockscreen
Diffstat (limited to 'tests/integration/usb-manager-test.cpp')
-rw-r--r--tests/integration/usb-manager-test.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/tests/integration/usb-manager-test.cpp b/tests/integration/usb-manager-test.cpp
index d62756f..805ba6e 100644
--- a/tests/integration/usb-manager-test.cpp
+++ b/tests/integration/usb-manager-test.cpp
@@ -143,7 +143,7 @@ TEST_F(UsbManagerFixture, Allow)
);
// confirm that the AdbdServer got the right response
- wait_for([adbd_server](){return !adbd_server->m_responses.empty();}, 2000);
+ wait_for([adbd_server](){return !adbd_server->m_responses.empty();}, 5000);
ASSERT_EQ(1, adbd_server->m_responses.size());
EXPECT_EQ("OK", adbd_server->m_responses.front());
@@ -163,13 +163,16 @@ TEST_F(UsbManagerFixture, USBDisconnectedDuringPrompt)
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 size_t N_TESTS {3};
const std::string public_key {"public_key"};
- auto adbd_server = std::make_shared<GAdbdServer>(*socket_path, std::vector<std::string>{"PK"+public_key});
+ const std::vector<std::string> requests(N_TESTS, "PK"+public_key);
+ const std::vector<std::string> expected_responses(N_TESTS, "NO");
+ auto adbd_server = std::make_shared<GAdbdServer>(*socket_path, requests);
// set up a UsbManager to process the request
auto usb_manager = std::make_shared<UsbManager>(*socket_path, *public_keys_path, m_usb_monitor, m_greeter);
- for (int i=0; i<3; i++)
+ for (std::remove_const<decltype(N_TESTS)>::type i=0; i<N_TESTS; ++i)
{
// add a signal spy to listen to the notification daemon
QSignalSpy notificationsSpy(
@@ -194,6 +197,9 @@ TEST_F(UsbManagerFixture, USBDisconnectedDuringPrompt)
EXPECT_EQ("CloseNotification", notificationsSpy.at(0).at(0));
notificationsSpy.clear();
}
+
+ EXPECT_TRUE(wait_for([adbd_server, N_TESTS](){return adbd_server->m_responses.size() == N_TESTS;}, 5000));
+ EXPECT_EQ(expected_responses, adbd_server->m_responses);
}
TEST_F(UsbManagerFixture, Greeter)
@@ -206,7 +212,7 @@ TEST_F(UsbManagerFixture, Greeter)
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);
+ m_greeter->m_state.set(Greeter::State::ACTIVE);
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
@@ -219,7 +225,7 @@ TEST_F(UsbManagerFixture, Greeter)
EXPECT_FALSE(notificationsSpy.wait(2000));
// disable the greeter, the notification should appear
- m_greeter->m_is_active.set(false);
+ m_greeter->m_state.set(Greeter::State::INACTIVE);
wait_for_signals(notificationsSpy, 1);
EXPECT_EQ("Notify", notificationsSpy.at(0).at(0));
notificationsSpy.clear();