diff options
author | Robert Tari <robert@tari.in> | 2021-12-09 12:00:39 +0100 |
---|---|---|
committer | Robert Tari <robert@tari.in> | 2021-12-09 12:03:07 +0100 |
commit | f696e54c767f4971f81237f8e4234289aa3c1b01 (patch) | |
tree | 6e48a65257a071273e7f30b4098aa807e04bc13f /tests/media-player-user.cc | |
parent | 09dde5270d94be7ec55a4ede3ca4007be097b343 (diff) | |
download | ayatana-indicator-sound-f696e54c767f4971f81237f8e4234289aa3c1b01.tar.gz ayatana-indicator-sound-f696e54c767f4971f81237f8e4234289aa3c1b01.tar.bz2 ayatana-indicator-sound-f696e54c767f4971f81237f8e4234289aa3c1b01.zip |
Fix cppcheck warnings
Diffstat (limited to 'tests/media-player-user.cc')
-rw-r--r-- | tests/media-player-user.cc | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/tests/media-player-user.cc b/tests/media-player-user.cc index 218a752..2bd4995 100644 --- a/tests/media-player-user.cc +++ b/tests/media-player-user.cc @@ -1,5 +1,6 @@ /* * Copyright 2014 Canonical Ltd. + * Copyright 2021 Robert Tari * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,6 +16,7 @@ * * Authors: * Ted Gould <ted@canonical.com> + * Robert Tari <robert@tari.in> */ #include <chrono> @@ -119,16 +121,16 @@ class MediaPlayerUserTest : public ::testing::Test } static gboolean timeout_cb (gpointer user_data) { - GMainLoop * loop = static_cast<GMainLoop *>(user_data); - g_main_loop_quit(loop); + GMainLoop * pLoop = static_cast<GMainLoop *>(user_data); + g_main_loop_quit(pLoop); return G_SOURCE_REMOVE; } void loop (unsigned int ms) { - GMainLoop * loop = g_main_loop_new(NULL, FALSE); - g_timeout_add(ms, timeout_cb, loop); - g_main_loop_run(loop); - g_main_loop_unref(loop); + GMainLoop * pLoop = g_main_loop_new(NULL, FALSE); + g_timeout_add(ms, timeout_cb, pLoop); + g_main_loop_run(pLoop); + g_main_loop_unref(pLoop); } void set_property (const gchar * name, GVariant * value) { @@ -136,7 +138,7 @@ class MediaPlayerUserTest : public ::testing::Test } testing::AssertionResult expectEventually (std::function<testing::AssertionResult(void)> &testfunc) { - auto loop = std::shared_ptr<GMainLoop>(g_main_loop_new(nullptr, FALSE), [](GMainLoop * loop) { if (loop != nullptr) g_main_loop_unref(loop); }); + auto pLoop = std::shared_ptr<GMainLoop>(g_main_loop_new(nullptr, FALSE), [](GMainLoop * pLoop) { if (pLoop != nullptr) g_main_loop_unref(pLoop); }); std::promise<testing::AssertionResult> retpromise; auto retfuture = retpromise.get_future(); @@ -144,7 +146,7 @@ class MediaPlayerUserTest : public ::testing::Test /* The core of the idle function as an object so we can use the C++-isms of attaching the variables and make this code reasonably readable */ - std::function<void(void)> idlefunc = [&loop, &retpromise, &testfunc, &start, this]() -> void { + std::function<void(void)> idlefunc = [&pLoop, &retpromise, &testfunc, &start, this]() -> void { auto result = testfunc(); if (result == false && _eventuallyTime > (std::chrono::steady_clock::now() - start)) { @@ -152,7 +154,7 @@ class MediaPlayerUserTest : public ::testing::Test } retpromise.set_value(result); - g_main_loop_quit(loop.get()); + g_main_loop_quit(pLoop.get()); }; auto idlesrc = g_idle_add([](gpointer data) -> gboolean { @@ -161,7 +163,7 @@ class MediaPlayerUserTest : public ::testing::Test return G_SOURCE_CONTINUE; }, &idlefunc); - g_main_loop_run(loop.get()); + g_main_loop_run(pLoop.get()); g_source_remove(idlesrc); return retfuture.get(); |