aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Kerr <charles.kerr@canonical.com>2016-03-07 09:34:37 -0600
committerCharles Kerr <charles.kerr@canonical.com>2016-03-07 09:34:37 -0600
commit95277f3c7344e537ad42835c64607339e1d3e6e9 (patch)
treec9ecd6267bef1767d949b9fbd131a86262d19e19
parentd911528cfb367fac34a5764ad6bce339a12f56d0 (diff)
downloadayatana-indicator-display-95277f3c7344e537ad42835c64607339e1d3e6e9.tar.gz
ayatana-indicator-display-95277f3c7344e537ad42835c64607339e1d3e6e9.tar.bz2
ayatana-indicator-display-95277f3c7344e537ad42835c64607339e1d3e6e9.zip
add test to confirm on_pk() signal is fired in the main thread rather than the worker thread
-rw-r--r--tests/adbd-client-test.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/tests/adbd-client-test.cpp b/tests/adbd-client-test.cpp
index 4fa16a8..ae0378b 100644
--- a/tests/adbd-client-test.cpp
+++ b/tests/adbd-client-test.cpp
@@ -53,9 +53,6 @@ protected:
TEST_F(AdbdClientFixture, SocketPlumbing)
{
- const auto socket_path = m_tmpdir + "/test-socket-plumbing";
- g_message("socket_path is %s", socket_path.c_str());
-
struct {
const std::string request;
const std::string expected_pk;
@@ -68,18 +65,24 @@ TEST_F(AdbdClientFixture, SocketPlumbing)
{ "PK", "", AdbdClient::PKResponse::DENY, "NO" }
};
+ const auto main_thread = g_thread_self();
+
+ const auto socket_path = m_tmpdir + "/test-socket-plumbing";
+ g_message("socket_path is %s", socket_path.c_str());
+
for (const auto& test : tests)
{
- // make the AdbdClient and start listening for Requests
+ // start an AdbdClient that listens for PKRequests
std::string pk;
auto adbd_client = std::make_shared<GAdbdClient>(socket_path);
- adbd_client->on_pk_request().connect([&pk, test](const AdbdClient::PKRequest& req){
+ adbd_client->on_pk_request().connect([&pk, main_thread, test](const AdbdClient::PKRequest& req){
+ EXPECT_EQ(main_thread, g_thread_self());
g_message("in on_pk_request with %s", req.public_key.c_str());
pk = req.public_key;
req.respond(test.response);
});
- // fire up a mock ADB server with a preloaded request, and wait for a response
+ // start a mock AdbdServer with to fire test key requests and wait for a response
auto adbd_server = std::make_shared<GAdbdServer>(socket_path, std::vector<std::string>{test.request});
wait_for([adbd_server](){return !adbd_server->m_responses.empty();}, 2000);
EXPECT_EQ(test.expected_pk, pk);