forked from organicmaps/organicmaps
[storage] Remove indexes when country is deleted.
This commit is contained in:
parent
adf2f32a24
commit
29b7e8462a
4 changed files with 42 additions and 2 deletions
|
@ -334,6 +334,7 @@ void Storage::DeleteCustomCountryVersion(LocalCountryFile const & localFile)
|
|||
{
|
||||
CountryFile const countryFile = localFile.GetCountryFile();
|
||||
localFile.DeleteFromDisk(MapOptions::MapWithCarRouting);
|
||||
CountryIndexes::DeleteFromDisk(localFile);
|
||||
|
||||
{
|
||||
auto it = m_localFilesForFakeCountries.find(countryFile);
|
||||
|
|
|
@ -177,6 +177,8 @@ public:
|
|||
void SetDownloaderForTesting(unique_ptr<MapFilesDownloader> && downloader);
|
||||
|
||||
private:
|
||||
friend void UnitTest_StorageTest_DeleteCountry();
|
||||
|
||||
TStatus CountryStatusWithoutFailed(TIndex const & index) const;
|
||||
TStatus CountryStatusFull(TIndex const & index, TStatus const status) const;
|
||||
|
||||
|
|
|
@ -11,6 +11,7 @@
|
|||
#include "platform/local_country_file.hpp"
|
||||
#include "platform/local_country_file_utils.hpp"
|
||||
#include "platform/platform.hpp"
|
||||
#include "platform/platform_tests_support/scoped_file.hpp"
|
||||
|
||||
#include "coding/file_name_utils.hpp"
|
||||
#include "coding/file_writer.hpp"
|
||||
|
@ -23,12 +24,14 @@
|
|||
|
||||
#include "std/bind.hpp"
|
||||
#include "std/map.hpp"
|
||||
#include "std/shared_ptr.hpp"
|
||||
#include "std/unique_ptr.hpp"
|
||||
#include "std/vector.hpp"
|
||||
|
||||
using namespace platform;
|
||||
using namespace storage;
|
||||
|
||||
namespace storage
|
||||
{
|
||||
namespace
|
||||
{
|
||||
// This class checks steps Storage::DownloadMap() performs to download a map.
|
||||
|
@ -583,3 +586,37 @@ UNIT_TEST(StorageTest_CancelDownloadingWhenAlmostDone)
|
|||
shared_ptr<LocalCountryFile> file = storage.GetLatestLocalFile(index);
|
||||
TEST(!file, (*file));
|
||||
}
|
||||
|
||||
UNIT_TEST(StorageTest_DeleteCountry)
|
||||
{
|
||||
Storage storage;
|
||||
TaskRunner runner;
|
||||
InitStorage(storage, runner);
|
||||
|
||||
tests_support::ScopedFile map("Uruguay.mwm", "Map");
|
||||
tests_support::ScopedFile routing("Uruguay.mwm.routing", "Map");
|
||||
LocalCountryFile file = LocalCountryFile::MakeForTesting("Uruguay");
|
||||
TEST_EQUAL(MapOptions::MapWithCarRouting, file.GetFiles(), ());
|
||||
|
||||
TEST(CountryIndexes::PreparePlaceOnDisk(file), ());
|
||||
string const bitsPath = CountryIndexes::GetPath(file, CountryIndexes::Index::Bits);
|
||||
{
|
||||
FileWriter writer(bitsPath);
|
||||
string const data = "bits";
|
||||
writer.Write(data.data(), data.size());
|
||||
}
|
||||
|
||||
storage.RegisterCountryFiles(make_shared<LocalCountryFile>(file));
|
||||
TEST(map.Exists(), ());
|
||||
TEST(routing.Exists(), ());
|
||||
TEST(Platform::IsFileExistsByFullPath(bitsPath), (bitsPath));
|
||||
|
||||
storage.DeleteCustomCountryVersion(file);
|
||||
TEST(!map.Exists(), ())
|
||||
TEST(!routing.Exists(), ())
|
||||
TEST(!Platform::IsFileExistsByFullPath(bitsPath), (bitsPath));
|
||||
|
||||
map.Reset();
|
||||
routing.Reset();
|
||||
}
|
||||
} // namespace storage
|
||||
|
|
|
@ -6,7 +6,7 @@ CONFIG -= app_bundle
|
|||
TEMPLATE = app
|
||||
|
||||
ROOT_DIR = ../..
|
||||
DEPENDENCIES = storage indexer platform geometry coding base jansson tomcrypt stats_client zlib
|
||||
DEPENDENCIES = storage indexer platform_tests_support platform geometry coding base jansson tomcrypt stats_client zlib
|
||||
|
||||
include($$ROOT_DIR/common.pri)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue