diff --git a/src/core/albumcoverfetcher.cpp b/src/core/albumcoverfetcher.cpp index 88badf77b..22f91aada 100644 --- a/src/core/albumcoverfetcher.cpp +++ b/src/core/albumcoverfetcher.cpp @@ -26,9 +26,9 @@ const int AlbumCoverFetcher::kMaxConcurrentRequests = 5; -AlbumCoverFetcher::AlbumCoverFetcher(QObject* parent) +AlbumCoverFetcher::AlbumCoverFetcher(QObject* parent, QNetworkAccessManager* network) : QObject(parent), - network_(new NetworkAccessManager(this)), + network_(network ? network : new NetworkAccessManager(this)), next_id_(0), request_starter_(new QTimer(this)) { diff --git a/src/core/albumcoverfetcher.h b/src/core/albumcoverfetcher.h index 0fdd2f371..c2836fb65 100644 --- a/src/core/albumcoverfetcher.h +++ b/src/core/albumcoverfetcher.h @@ -34,7 +34,7 @@ class AlbumCoverFetcher : public QObject { Q_OBJECT public: - AlbumCoverFetcher(QObject* parent = 0); + AlbumCoverFetcher(QObject* parent = 0, QNetworkAccessManager* network = 0); virtual ~AlbumCoverFetcher() {} struct SearchResult { diff --git a/src/ui/albumcovermanager.cpp b/src/ui/albumcovermanager.cpp index 9c11d7037..28634a4a5 100644 --- a/src/ui/albumcovermanager.cpp +++ b/src/ui/albumcovermanager.cpp @@ -41,13 +41,14 @@ const char* AlbumCoverManager::kSettingsGroup = "CoverManager"; -AlbumCoverManager::AlbumCoverManager(LibraryBackend* backend, QWidget *parent) +AlbumCoverManager::AlbumCoverManager(LibraryBackend* backend, QWidget* parent, + QNetworkAccessManager* network) : QMainWindow(parent), constructed_(false), ui_(new Ui_CoverManager), backend_(backend), cover_loader_(new BackgroundThreadImplementation(this)), - cover_fetcher_(new AlbumCoverFetcher(this)), + cover_fetcher_(new AlbumCoverFetcher(this, network)), cover_searcher_(new AlbumCoverSearcher(this)), artist_icon_(IconLoader::Load("x-clementine-artist")), all_artists_icon_(IconLoader::Load("x-clementine-album")), diff --git a/src/ui/albumcovermanager.h b/src/ui/albumcovermanager.h index 08a3e2da6..623d3269f 100644 --- a/src/ui/albumcovermanager.h +++ b/src/ui/albumcovermanager.h @@ -34,12 +34,14 @@ class Ui_CoverManager; class QListWidgetItem; class QMenu; +class QNetworkAccessManager; class QProgressBar; class AlbumCoverManager : public QMainWindow { Q_OBJECT public: - AlbumCoverManager(LibraryBackend* backend, QWidget *parent = 0); + AlbumCoverManager(LibraryBackend* backend, QWidget *parent = 0, + QNetworkAccessManager* network = 0); ~AlbumCoverManager(); static const char* kSettingsGroup; diff --git a/tests/albumcovermanager_test.cpp b/tests/albumcovermanager_test.cpp index c01ea8109..6feca3135 100644 --- a/tests/albumcovermanager_test.cpp +++ b/tests/albumcovermanager_test.cpp @@ -14,7 +14,6 @@ along with Clementine. If not, see . */ -#include "core/networkaccessmanager.h" #include "ui/albumcovermanager.h" #include "gtest/gtest.h" @@ -26,12 +25,10 @@ class AlbumCoverManagerTest : public ::testing::Test { protected: AlbumCoverManagerTest() - : network_(NULL, &mock_network_), - manager_(&network_, NULL) { + : manager_(NULL, NULL, &mock_network_) { } MockNetworkAccessManager mock_network_; - NetworkAccessManager network_; AlbumCoverManager manager_; };