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

tests: Fix cross compilation for win32

parent 2974fe57
......@@ -30,7 +30,7 @@
#include "History.h"
#include "Media.h"
#include <thread>
#include "compat/Thread.h"
class HistoryTest : public Tests
{
......@@ -63,7 +63,7 @@ TEST_F( HistoryTest, MaxEntries )
TEST_F( HistoryTest, Ordering )
{
ml->addToHistory( "first-stream" );
std::this_thread::sleep_for( std::chrono::seconds( 1 ) );
compat::this_thread::sleep_for( std::chrono::seconds( 1 ) );
ml->addToHistory( "second-stream" );
auto hList = ml->lastStreamsPlayed();
ASSERT_EQ( 2u, hList.size() );
......@@ -77,7 +77,7 @@ TEST_F( HistoryTest, UpdateInsertionDate )
auto hList = ml->lastStreamsPlayed();
ASSERT_EQ( 1u, hList.size() );
auto date = hList[0]->insertionDate();
std::this_thread::sleep_for( std::chrono::seconds( 1 ) );
compat::this_thread::sleep_for( std::chrono::seconds( 1 ) );
ml->addToHistory( "stream" );
hList = ml->lastStreamsPlayed();
ASSERT_EQ( 1u, hList.size() );
......@@ -102,7 +102,7 @@ TEST_F( HistoryTest, ReinsertFavorited )
auto item = hList[0];
auto date = item->insertionDate();
item->setFavorite( true );
std::this_thread::sleep_for( std::chrono::seconds{ 1 } );
compat::this_thread::sleep_for( std::chrono::seconds{ 1 } );
ml->addToHistory( "stream" );
hList = ml->lastStreamsPlayed();
item = hList[0];
......
......@@ -33,8 +33,7 @@
#include "Album.h"
#include "AlbumTrack.h"
#include "mocks/FileSystem.h"
#include <thread>
#include "compat/Thread.h"
class Medias : public Tests
{
......@@ -293,7 +292,7 @@ TEST_F( Medias, History )
ASSERT_EQ( 1u, history.size() );
ASSERT_EQ( m->id(), history[0]->id() );
std::this_thread::sleep_for( std::chrono::seconds{ 1 } );
compat::this_thread::sleep_for( std::chrono::seconds{ 1 } );
auto m2 = ml->addFile( "media.mkv" );
m2->increasePlayCount();
m2->save();
......
......@@ -28,6 +28,7 @@
#include "Media.h"
#include "File.h"
#include "mocks/NoopCallback.h"
#include "compat/Mutex.h"
class MockCallback : public mock::NoopCallback
{
......@@ -36,25 +37,25 @@ public:
private:
virtual void onMediaDeleted( std::vector<int64_t> batch ) override
{
std::lock_guard<std::mutex> lock( m_lock );
std::lock_guard<compat::Mutex> lock( m_lock );
m_nbMedia = batch.size();
m_cond.notify_all();
}
public:
std::unique_lock<std::mutex> prepareWait()
std::unique_lock<compat::Mutex> prepareWait()
{
m_nbMedia = 0;
return std::unique_lock<std::mutex>{ m_lock };
return std::unique_lock<compat::Mutex>{ m_lock };
}
unsigned int waitForNotif( std::unique_lock<std::mutex> preparedLock, std::chrono::duration<int64_t> timeout )
unsigned int waitForNotif( std::unique_lock<compat::Mutex> preparedLock, std::chrono::duration<int64_t> timeout )
{
m_cond.wait_for( preparedLock, timeout, [this]() { return m_nbMedia != 0; });
return m_nbMedia;
}
private:
std::mutex m_lock;
compat::Mutex m_lock;
compat::ConditionVariable m_cond;
uint32_t m_nbMedia;
};
......
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