aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorRobert Tari <robert@tari.in>2021-12-09 12:00:39 +0100
committerRobert Tari <robert@tari.in>2021-12-09 12:03:07 +0100
commitf696e54c767f4971f81237f8e4234289aa3c1b01 (patch)
tree6e48a65257a071273e7f30b4098aa807e04bc13f /tests
parent09dde5270d94be7ec55a4ede3ca4007be097b343 (diff)
downloadayatana-indicator-sound-f696e54c767f4971f81237f8e4234289aa3c1b01.tar.gz
ayatana-indicator-sound-f696e54c767f4971f81237f8e4234289aa3c1b01.tar.bz2
ayatana-indicator-sound-f696e54c767f4971f81237f8e4234289aa3c1b01.zip
Fix cppcheck warnings
Diffstat (limited to 'tests')
-rw-r--r--tests/accounts-service-user.cc6
-rw-r--r--tests/dbus-types/dbus-action-result.h7
-rw-r--r--tests/indicator-fixture.h10
-rw-r--r--tests/integration/indicator-sound-test-base.cpp11
-rw-r--r--tests/integration/test-indicator.cpp8
-rw-r--r--tests/integration/utils/dbus-pulse-volume.cpp12
-rw-r--r--tests/media-player-user.cc22
-rw-r--r--tests/name-watch-test.cc6
-rw-r--r--tests/notifications-mock.h5
-rw-r--r--tests/notifications-test.cc13
-rw-r--r--tests/service-mocks/media-player-mpris-mock/MediaPlayerMprisMock.h9
-rw-r--r--tests/volume-control-test.cc6
12 files changed, 71 insertions, 44 deletions
diff --git a/tests/accounts-service-user.cc b/tests/accounts-service-user.cc
index 3460fd6..77c55ca 100644
--- a/tests/accounts-service-user.cc
+++ b/tests/accounts-service-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 <gtest/gtest.h>
@@ -92,8 +94,8 @@ class AccountsServiceUserTest : 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;
}
diff --git a/tests/dbus-types/dbus-action-result.h b/tests/dbus-types/dbus-action-result.h
index 9371c69..e2795f6 100644
--- a/tests/dbus-types/dbus-action-result.h
+++ b/tests/dbus-types/dbus-action-result.h
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2015 Canonical Ltd.
+ * Copyright 2015 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 version 3, as published
@@ -13,7 +14,9 @@
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
- * Author: Xavi Garcia <xavi.garcia.mena@canonical.com>
+ * Authors:
+ * Xavi Garcia <xavi.garcia.mena@canonical.com>
+ * Robert Tari <robert@tari.in>
*/
#pragma once
diff --git a/tests/indicator-fixture.h b/tests/indicator-fixture.h
index 1d1ac35..48e0ef7 100644
--- a/tests/indicator-fixture.h
+++ b/tests/indicator-fixture.h
@@ -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 <memory>
@@ -422,7 +424,7 @@ class IndicatorFixture : public ::testing::Test
}
protected:
- testing::AssertionResult expectMenuAttribute (const char * menuLocationStr, const char * attributeStr, const char * valueStr, const std::vector<int> menuLocation, const std::string& attribute, GVariant * value) {
+ testing::AssertionResult expectMenuAttribute (const char * menuLocationStr, const char * attributeStr, const char * valueStr, const std::vector<int>& menuLocation, const std::string& attribute, GVariant * value) {
auto varref = std::shared_ptr<GVariant>(g_variant_ref_sink(value), [](GVariant * varptr) {
if (varptr != nullptr)
g_variant_unref(varptr);
@@ -460,17 +462,17 @@ class IndicatorFixture : public ::testing::Test
}
}
- testing::AssertionResult expectMenuAttribute (const char * menuLocationStr, const char * attributeStr, const char * valueStr, const std::vector<int> menuLocation, const std::string& attribute, bool value) {
+ testing::AssertionResult expectMenuAttribute (const char * menuLocationStr, const char * attributeStr, const char * valueStr, const std::vector<int>& menuLocation, const std::string& attribute, bool value) {
GVariant * var = g_variant_new_boolean(value);
return expectMenuAttribute(menuLocationStr, attributeStr, valueStr, menuLocation, attribute, var);
}
- testing::AssertionResult expectMenuAttribute (const char * menuLocationStr, const char * attributeStr, const char * valueStr, const std::vector<int> menuLocation, const std::string& attribute, std::string value) {
+ testing::AssertionResult expectMenuAttribute (const char * menuLocationStr, const char * attributeStr, const char * valueStr, const std::vector<int>& menuLocation, const std::string& attribute, std::string value) {
GVariant * var = g_variant_new_string(value.c_str());
return expectMenuAttribute(menuLocationStr, attributeStr, valueStr, menuLocation, attribute, var);
}
- testing::AssertionResult expectMenuAttribute (const char * menuLocationStr, const char * attributeStr, const char * valueStr, const std::vector<int> menuLocation, const std::string& attribute, const char * value) {
+ testing::AssertionResult expectMenuAttribute (const char * menuLocationStr, const char * attributeStr, const char * valueStr, const std::vector<int>& menuLocation, const std::string& attribute, const char * value) {
GVariant * var = g_variant_new_string(value);
return expectMenuAttribute(menuLocationStr, attributeStr, valueStr, menuLocation, attribute, var);
}
diff --git a/tests/integration/indicator-sound-test-base.cpp b/tests/integration/indicator-sound-test-base.cpp
index 1a74621..6c64815 100644
--- a/tests/integration/indicator-sound-test-base.cpp
+++ b/tests/integration/indicator-sound-test-base.cpp
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015 Canonical Ltd.
- * Copyright (C) 2021 Robert Tari
+ * Copyright 2015 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 version 3, as published
@@ -534,9 +534,10 @@ void IndicatorSoundTestBase::initializeAccountsInterface()
auto userPath = userResp.value().path();
if (userPath != "")
{
- std::unique_ptr<AccountsSoundInterface> soundInterface(new AccountsSoundInterface("org.freedesktop.Accounts",
+ // This silences cppcheck, but let's leave it here in case we actually need it
+ /*std::unique_ptr<AccountsSoundInterface> soundInterface(new AccountsSoundInterface("org.freedesktop.Accounts",
userPath,
- dbusTestRunner.systemConnection(), 0));
+ dbusTestRunner.systemConnection(), 0));*/
accounts_interface_.reset(new DBusPropertiesInterface("org.freedesktop.Accounts",
userPath,
@@ -1008,8 +1009,6 @@ QVariantList IndicatorSoundTestBase::getActionValue(QString const &action)
QStringList IndicatorSoundTestBase::getRootIconValue(bool *isValid)
{
- QString result = 0;
-
QVariantList varList = getActionValue("root");
if (isValid != nullptr)
{
diff --git a/tests/integration/test-indicator.cpp b/tests/integration/test-indicator.cpp
index 5d31508..cbf1c6d 100644
--- a/tests/integration/test-indicator.cpp
+++ b/tests/integration/test-indicator.cpp
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2015 Canonical Ltd.
+ * Copyright 2015 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 version 3, as published
@@ -13,7 +14,9 @@
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
- * Author: Xavi Garcia <xavi.garcia.mena@canonical.com>
+ * Authors:
+ * Xavi Garcia <xavi.garcia.mena@canonical.com>
+ * Robert Tari <robert@tari.in>
*/
#include <indicator-sound-test-base.h>
@@ -32,6 +35,7 @@ class TestIndicator: public IndicatorSoundTestBase
{
};
+// cppcheck-suppress syntaxError
TEST_F(TestIndicator, DISABLED_PhoneCheckRootIcon)
{
double INITIAL_VOLUME = 0.0;
diff --git a/tests/integration/utils/dbus-pulse-volume.cpp b/tests/integration/utils/dbus-pulse-volume.cpp
index 7d51b23..2bbc5d4 100644
--- a/tests/integration/utils/dbus-pulse-volume.cpp
+++ b/tests/integration/utils/dbus-pulse-volume.cpp
@@ -1,6 +1,6 @@
/*
- * Copyright (C) 2015 Canonical Ltd.
- * Copyright (C) 2021 Robert Tari
+ * Copyright 2015 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 version 3, as published
@@ -141,14 +141,14 @@ bool DBusPulseVolume::setVolume(QString const & role, double volume)
if (accounts_interface_)
{
- QDBusVariant dbusVar(QVariant::fromValue(volume));
- QDBusReply<void> set_vol = accounts_interface_->call(QLatin1String("Set"),
+ QDBusVariant pDbusVar(QVariant::fromValue(volume));
+ QDBusReply<void> pSetVol = accounts_interface_->call(QLatin1String("Set"),
QVariant::fromValue(QString("com.lomiri.AccountsService.Sound")),
QVariant::fromValue(QString("Volume")),
- QVariant::fromValue(dbusVar));
+ QVariant::fromValue(pDbusVar));
if (!set_vol.isValid())
{
- qWarning() << "SetVolume::setVolume(): D-Bus error: " << set_vol.error().message();
+ qWarning() << "SetVolume::setVolume(): D-Bus error: " << pSetVol.error().message();
return false;
}
}
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();
diff --git a/tests/name-watch-test.cc b/tests/name-watch-test.cc
index cf06403..263b3f2 100644
--- a/tests/name-watch-test.cc
+++ b/tests/name-watch-test.cc
@@ -1,5 +1,6 @@
/*
* Copyright 2013 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 <gio/gio.h>
@@ -41,8 +43,8 @@ class NameWatchTest : 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;
}
diff --git a/tests/notifications-mock.h b/tests/notifications-mock.h
index 190aa0d..49b2e66 100644
--- a/tests/notifications-mock.h
+++ b/tests/notifications-mock.h
@@ -1,5 +1,6 @@
/*
* Copyright 2015 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
@@ -30,7 +31,7 @@ class NotificationsMock
DbusTestDbusMockObject * baseobj = nullptr;
public:
- NotificationsMock (std::vector<std::string> capabilities = {"actions", "body", "body-markup", "icon-static", "image/svg+xml", "x-canonical-private-synchronous", "x-canonical-append", "x-canonical-private-icon-only", "x-canonical-truncation", "private-synchronous", "append", "private-icon-only", "truncation"}) {
+ NotificationsMock (const std::vector<std::string>& capabilities = {"actions", "body", "body-markup", "icon-static", "image/svg+xml", "x-canonical-private-synchronous", "x-canonical-append", "x-canonical-private-icon-only", "x-canonical-truncation", "private-synchronous", "append", "private-icon-only", "truncation"}) {
mock = dbus_test_dbus_mock_new("org.freedesktop.Notifications");
dbus_test_task_set_bus(DBUS_TEST_TASK(mock), DBUS_TEST_SERVICE_BUS_SESSION);
dbus_test_task_set_name(DBUS_TEST_TASK(mock), "Notify");
@@ -64,7 +65,7 @@ class NotificationsMock
std::string vector2py (std::vector<std::string> vect) {
std::string retval("[ ");
- std::for_each(vect.begin(), vect.end() - 1, [&retval](std::string entry) {
+ std::for_each(vect.begin(), vect.end() - 1, [&retval](const std::string& entry) {
retval += "'";
retval += entry;
retval += "', ";
diff --git a/tests/notifications-test.cc b/tests/notifications-test.cc
index b1531df..a9fa55d 100644
--- a/tests/notifications-test.cc
+++ b/tests/notifications-test.cc
@@ -98,8 +98,8 @@ class NotificationsTest : 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;
}
@@ -234,7 +234,7 @@ TEST_F(NotificationsTest, BasicObject) {
auto volumeControl = volumeControlMock(options);
auto volumeWarning = volumeWarningMock(options);
auto accountsService = std::make_shared<AccountsServiceAccess>();
- auto soundService = standardService(volumeControl, playerListMock(), options, volumeWarning, accountsService);
+ standardService(volumeControl, playerListMock(), options, volumeWarning, accountsService);
/* Give some time settle */
loop(50);
@@ -247,6 +247,7 @@ TEST_F(NotificationsTest, VolumeChanges) {
auto volumeControl = volumeControlMock(options);
auto volumeWarning = volumeWarningMock(options);
auto accountsService = std::make_shared<AccountsServiceAccess>();
+ // cppcheck-suppress unreadVariable
auto soundService = standardService(volumeControl, playerListMock(), options, volumeWarning, accountsService);
/* Set a volume */
@@ -289,6 +290,7 @@ TEST_F(NotificationsTest, DISABLED_StreamChanges) {
auto volumeControl = volumeControlMock(options);
auto volumeWarning = volumeWarningMock(options);
auto accountsService = std::make_shared<AccountsServiceAccess>();
+ // cppcheck-suppress unreadVariable
auto soundService = standardService(volumeControl, playerListMock(), options, volumeWarning, accountsService);
/* Set a volume */
@@ -330,6 +332,7 @@ TEST_F(NotificationsTest, DISABLED_IconTesting) {
auto volumeControl = volumeControlMock(options);
auto volumeWarning = volumeWarningMock(options);
auto accountsService = std::make_shared<AccountsServiceAccess>();
+ // cppcheck-suppress unreadVariable
auto soundService = standardService(volumeControl, playerListMock(), options, volumeWarning, accountsService);
/* Set an initial volume */
@@ -367,6 +370,7 @@ TEST_F(NotificationsTest, DISABLED_ServerRestart) {
auto volumeControl = volumeControlMock(options);
auto volumeWarning = volumeWarningMock(options);
auto accountsService = std::make_shared<AccountsServiceAccess>();
+ // cppcheck-suppress unreadVariable
auto soundService = standardService(volumeControl, playerListMock(), options, volumeWarning, accountsService);
/* Set a volume */
@@ -417,6 +421,7 @@ TEST_F(NotificationsTest, DISABLED_HighVolume) {
auto volumeControl = volumeControlMock(options);
auto volumeWarning = volumeWarningMock(options);
auto accountsService = std::make_shared<AccountsServiceAccess>();
+ // cppcheck-suppress unreadVariable
auto soundService = standardService(volumeControl, playerListMock(), options, volumeWarning, accountsService);
/* Set a volume */
@@ -462,6 +467,7 @@ TEST_F(NotificationsTest, DISABLED_MenuHide) {
auto volumeControl = volumeControlMock(options);
auto volumeWarning = volumeWarningMock(options);
auto accountsService = std::make_shared<AccountsServiceAccess>();
+ // cppcheck-suppress unreadVariable
auto soundService = standardService(volumeControl, playerListMock(), options, volumeWarning, accountsService);
/* Set a volume */
@@ -495,6 +501,7 @@ TEST_F(NotificationsTest, DISABLED_ExtendendVolumeNotification) {
auto volumeControl = volumeControlMock(options);
auto volumeWarning = volumeWarningMock(options);
auto accountsService = std::make_shared<AccountsServiceAccess>();
+ // cppcheck-suppress unreadVariable
auto soundService = standardService(volumeControl, playerListMock(), options, volumeWarning, accountsService);
/* Set a volume */
diff --git a/tests/service-mocks/media-player-mpris-mock/MediaPlayerMprisMock.h b/tests/service-mocks/media-player-mpris-mock/MediaPlayerMprisMock.h
index 6d08a29..c6fdc70 100644
--- a/tests/service-mocks/media-player-mpris-mock/MediaPlayerMprisMock.h
+++ b/tests/service-mocks/media-player-mpris-mock/MediaPlayerMprisMock.h
@@ -1,5 +1,6 @@
/*
- * Copyright (C) 2015 Canonical Ltd.
+ * Copyright 2015 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 version 3, as published
@@ -13,7 +14,9 @@
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*
- * Author: Xavi Garcia <xavi.garcia.mena@canonical.com>
+ * Authors:
+ * Xavi Garcia <xavi.garcia.mena@canonical.com>
+ * Robert Tari <robert@tari.in>
*/
#pragma once
@@ -58,7 +61,7 @@ public Q_SLOTS:
void setDesktopEntry(QString const &destopEntry);
public:
- MediaPlayerMprisMock(QString const &playerName, QObject* parent = 0);
+ MediaPlayerMprisMock(QString const &playerName, QObject* parent);
virtual ~MediaPlayerMprisMock();
private:
diff --git a/tests/volume-control-test.cc b/tests/volume-control-test.cc
index f25048b..36fa05e 100644
--- a/tests/volume-control-test.cc
+++ b/tests/volume-control-test.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 <gtest/gtest.h>
@@ -62,8 +64,8 @@ class VolumeControlTest : 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;
}