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

tests: Add an unmount/mount test

parent 94d3126a
...@@ -147,9 +147,9 @@ public: ...@@ -147,9 +147,9 @@ public:
return m_device; return m_device;
} }
void removeDevice() void setDevice( std::shared_ptr<fs::IDevice> device )
{ {
m_device = nullptr; m_device = device;
} }
void addFile( const std::string& fileName ) void addFile( const std::string& fileName )
......
...@@ -105,7 +105,8 @@ TEST_F( DeviceFs, RemoveDisk ) ...@@ -105,7 +105,8 @@ TEST_F( DeviceFs, RemoveDisk )
ASSERT_NE( nullptr, file ); ASSERT_NE( nullptr, file );
auto subdir = fsMock->directory( mock::FileSystemFactory::SubFolder ); auto subdir = fsMock->directory( mock::FileSystemFactory::SubFolder );
subdir->removeDevice(); subdir->setDevice( nullptr );
fsMock->removableDevice = nullptr;
cbMock->prepareForReload(); cbMock->prepareForReload();
Reload(); Reload();
...@@ -147,3 +148,46 @@ TEST_F( DeviceFs, UnmountDisk ) ...@@ -147,3 +148,46 @@ TEST_F( DeviceFs, UnmountDisk )
file = ml->file( std::string( mock::FileSystemFactory::SubFolder ) + "subfile.mp4" ); file = ml->file( std::string( mock::FileSystemFactory::SubFolder ) + "subfile.mp4" );
ASSERT_EQ( nullptr, file ); ASSERT_EQ( nullptr, file );
} }
TEST_F( DeviceFs, ReplugDisk )
{
cbMock->prepareForWait( 1 );
ml->discover( "." );
bool discovered = cbMock->wait();
ASSERT_TRUE( discovered );
auto files = ml->files();
ASSERT_EQ( 3u, files.size() );
auto file = ml->file( std::string( mock::FileSystemFactory::SubFolder ) + "subfile.mp4" );
ASSERT_NE( nullptr, file );
auto subdir = fsMock->directory( mock::FileSystemFactory::SubFolder );
auto device = std::static_pointer_cast<mock::Device>( subdir->device() );
subdir->setDevice( nullptr );
fsMock->removableDevice = nullptr;
cbMock->prepareForReload();
Reload();
bool reloaded = cbMock->waitForReload();
ASSERT_TRUE( reloaded );
files = ml->files();
ASSERT_EQ( 2u, files.size() );
file = ml->file( std::string( mock::FileSystemFactory::SubFolder ) + "subfile.mp4" );
ASSERT_EQ( nullptr, file );
subdir->setDevice( device );
fsMock->removableDevice = device;
cbMock->prepareForReload();
Reload();
reloaded = cbMock->waitForReload();
ASSERT_TRUE( reloaded );
files = ml->files();
ASSERT_EQ( 3u, files.size() );
file = ml->file( std::string( mock::FileSystemFactory::SubFolder ) + "subfile.mp4" );
ASSERT_NE( nullptr, file );
}
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