Commit b8ee29d6 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen
Browse files

tests: Add a MockDeviceLister

parent 59a3176b
/*****************************************************************************
* Media Library
*****************************************************************************
* Copyright (C) 2015 Hugo Beauzée-Luyssen, Videolabs
*
* Authors: Hugo Beauzée-Luyssen<hugo@beauzee.fr>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#pragma once
#include "medialibrary/IDeviceLister.h"
namespace mock
{
class MockDeviceLister : public medialibrary::IDeviceLister
{
public:
virtual std::vector<std::tuple<std::string, std::string, bool>> devices() const override
{
abort();
}
};
}
......@@ -56,8 +56,12 @@ void Tests::Reload( std::shared_ptr<factory::IFileSystem> fs /*= nullptr*/, IMed
cbMock.reset( new mock::NoopCallback );
metadataCb = cbMock.get();
}
// Instantiate it here to avoid fiddling with multiple SetUp overloads
if ( mockDeviceLister == nullptr )
mockDeviceLister = std::make_shared<mock::MockDeviceLister>();
ml->setFsFactory( fs );
ml->setDeviceLister( mockDeviceLister );
ml->setVerbosity( LogLevel::Error );
bool res = ml->initialize( "test.db", "/tmp", metadataCb );
ASSERT_TRUE( res );
......
......@@ -24,6 +24,7 @@
#include "factory/IFileSystem.h"
#include "mocks/NoopCallback.h"
#include "mocks/MockDeviceLister.h"
#include "common/MediaLibraryTester.h"
#include "filesystem/IDirectory.h"
......@@ -33,6 +34,7 @@ protected:
std::unique_ptr<MediaLibraryTester> ml;
std::unique_ptr<mock::NoopCallback> cbMock;
std::shared_ptr<factory::IFileSystem> fsFactory;
std::shared_ptr<mock::MockDeviceLister> mockDeviceLister;
virtual void SetUp() override;
virtual void InstantiateMediaLibrary();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment