diff --git a/drape_frontend/gui/country_status_helper.cpp b/drape_frontend/gui/country_status_helper.cpp index 716ab61959..1a5cabc522 100644 --- a/drape_frontend/gui/country_status_helper.cpp +++ b/drape_frontend/gui/country_status_helper.cpp @@ -78,17 +78,17 @@ void CountryStatusHelper::SetCountryInfo(CountryInfo const & countryInfo) CountryStatusHelper::ECountryState state = CountryStatusHelper::COUNTRY_STATE_LOADED; switch(m_countryInfo.m_countryStatus) { - case storage::TStatus::ENotDownloaded: + case storage::Status::ENotDownloaded: state = CountryStatusHelper::COUNTRY_STATE_EMPTY; break; - case storage::TStatus::EDownloading: + case storage::Status::EDownloading: state = CountryStatusHelper::COUNTRY_STATE_LOADING; break; - case storage::TStatus::EInQueue: + case storage::Status::EInQueue: state = CountryStatusHelper::COUNTRY_STATE_IN_QUEUE; break; - case storage::TStatus::EDownloadFailed: - case storage::TStatus::EOutOfMemFailed: + case storage::Status::EDownloadFailed: + case storage::Status::EOutOfMemFailed: state = CountryStatusHelper::COUNTRY_STATE_FAILED; break; default: diff --git a/drape_frontend/gui/country_status_helper.hpp b/drape_frontend/gui/country_status_helper.hpp index b791c66f57..10d4483d9d 100644 --- a/drape_frontend/gui/country_status_helper.hpp +++ b/drape_frontend/gui/country_status_helper.hpp @@ -16,7 +16,7 @@ namespace gui struct CountryInfo { storage::TCountryId m_countryIndex = storage::kInvalidCountryId; - storage::TStatus m_countryStatus = storage::TStatus::EUnknown; + storage::Status m_countryStatus = storage::Status::EUnknown; string m_currentCountryName; size_t m_mapSize = 0; size_t m_downloadProgress = 0; diff --git a/map/framework.cpp b/map/framework.cpp index bcc86dfe19..40d1ab0855 100644 --- a/map/framework.cpp +++ b/map/framework.cpp @@ -480,7 +480,7 @@ void Framework::DownloadCountry(storage::TCountryId const & index, MapOptions op m_storage.DownloadCountry(index, opt); } -TStatus Framework::GetCountryStatus(storage::TCountryId const & index) const +Status Framework::GetCountryStatus(storage::TCountryId const & index) const { return m_storage.CountryStatusEx(index); } @@ -968,7 +968,7 @@ void Framework::UpdateCountryInfo(storage::TCountryId const & countryId, bool is gui::CountryInfo countryInfo; countryInfo.m_countryIndex = countryId; - if (countryInfo.m_countryStatus == storage::TStatus::EDownloading) + if (countryInfo.m_countryStatus == storage::Status::EDownloading) countryInfo.m_downloadProgress = 50; m_drapeEngine->SetCountryInfo(countryInfo, isCurrentCountry); diff --git a/map/framework.hpp b/map/framework.hpp index 4e97469ac1..03ec3557be 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -199,7 +199,7 @@ public: void SetDownloadCancelListener(TDownloadCancelListener const & listener); void SetAutoDownloadListener(TAutoDownloadListener const & listener); - storage::TStatus GetCountryStatus(storage::TCountryId const & index) const; + storage::Status GetCountryStatus(storage::TCountryId const & index) const; string GetCountryName(storage::TCountryId const & index) const; /// Get country rect from borders (not from mwm file). diff --git a/qt/search_panel.cpp b/qt/search_panel.cpp index 46f4bd7adf..f06ad5fba3 100644 --- a/qt/search_panel.cpp +++ b/qt/search_panel.cpp @@ -219,9 +219,9 @@ bool SearchPanel::TryMigrate(QString const & str) auto stateChanged = [&](storage::TCountryId const & id) { - storage::TStatus const nextStatus = m_pDrawWidget->GetFramework().Storage().m_prefetchStorage->CountryStatusEx(id); + storage::Status const nextStatus = m_pDrawWidget->GetFramework().Storage().m_prefetchStorage->CountryStatusEx(id); LOG_SHORT(LINFO, (id, "status :", nextStatus)); - if (nextStatus == storage::TStatus::EOnDisk) + if (nextStatus == storage::Status::EOnDisk) { LOG_SHORT(LINFO, ("Prefetch done. Ready to migrate.")); m_pDrawWidget->GetFramework().Migrate(); diff --git a/qt/update_dialog.cpp b/qt/update_dialog.cpp index 0685285470..abda9c805d 100644 --- a/qt/update_dialog.cpp +++ b/qt/update_dialog.cpp @@ -164,7 +164,7 @@ namespace qt Storage const & st = GetStorage(); switch (m_framework.GetCountryStatus(countryId)) { - case TStatus::ENotDownloaded: + case Status::ENotDownloaded: if (st.CountriesCount(countryId) == 0) { size = st.CountrySizeInBytes(countryId, options); @@ -174,30 +174,30 @@ namespace qt rowColor = COLOR_NOTDOWNLOADED; break; - case TStatus::EOnDisk: + case Status::EOnDisk: statusString = tr("Installed (click to delete)"); rowColor = COLOR_ONDISK; size = st.CountrySizeInBytes(countryId, options); break; - case TStatus::EOnDiskOutOfDate: + case Status::EOnDiskOutOfDate: statusString = tr("Out of date (click to update or delete)"); rowColor = COLOR_OUTOFDATE; size = st.CountrySizeInBytes(countryId, options); break; - case TStatus::EDownloadFailed: + case Status::EDownloadFailed: statusString = tr("Download has failed"); rowColor = COLOR_DOWNLOADFAILED; size = st.CountrySizeInBytes(countryId, options); break; - case TStatus::EDownloading: + case Status::EDownloading: statusString = tr("Downloading ..."); rowColor = COLOR_INPROGRESS; break; - case TStatus::EInQueue: + case Status::EInQueue: statusString = tr("Marked for download"); rowColor = COLOR_INQUEUE; size = st.CountrySizeInBytes(countryId, options); diff --git a/storage/storage.cpp b/storage/storage.cpp index af3782d5d6..e8608de2e8 100644 --- a/storage/storage.cpp +++ b/storage/storage.cpp @@ -350,34 +350,34 @@ Storage::TLocalFilePtr Storage::GetLatestLocalFile(TCountryId const & countryId) return latest; } -TStatus Storage::CountryStatus(TCountryId const & countryId) const +Status Storage::CountryStatus(TCountryId const & countryId) const { // Check if we already downloading this country or have it in the queue if (IsCountryInQueue(countryId)) { if (IsCountryFirstInQueue(countryId)) - return TStatus::EDownloading; + return Status::EDownloading; else - return TStatus::EInQueue; + return Status::EInQueue; } // Check if this country has failed while downloading. if (m_failedCountries.count(countryId) > 0) - return TStatus::EDownloadFailed; + return Status::EDownloadFailed; - return TStatus::EUnknown; + return Status::EUnknown; } -TStatus Storage::CountryStatusEx(TCountryId const & countryId) const +Status Storage::CountryStatusEx(TCountryId const & countryId) const { return CountryStatusFull(countryId, CountryStatus(countryId)); } -void Storage::CountryStatusEx(TCountryId const & countryId, TStatus & status, MapOptions & options) const +void Storage::CountryStatusEx(TCountryId const & countryId, Status & status, MapOptions & options) const { status = CountryStatusEx(countryId); - if (status == TStatus::EOnDisk || status == TStatus::EOnDiskOutOfDate) + if (status == Status::EOnDisk || status == Status::EOnDiskOutOfDate) { options = MapOptions::Map; @@ -786,30 +786,30 @@ void Storage::GetOutdatedCountries(vector & countries) const } } -TStatus Storage::CountryStatusWithoutFailed(TCountryId const & countryId) const +Status Storage::CountryStatusWithoutFailed(TCountryId const & countryId) const { // First, check if we already downloading this country or have in in the queue. if (!IsCountryInQueue(countryId)) - return CountryStatusFull(countryId, TStatus::EUnknown); - return IsCountryFirstInQueue(countryId) ? TStatus::EDownloading : TStatus::EInQueue; + return CountryStatusFull(countryId, Status::EUnknown); + return IsCountryFirstInQueue(countryId) ? Status::EDownloading : Status::EInQueue; } -TStatus Storage::CountryStatusFull(TCountryId const & countryId, TStatus const status) const +Status Storage::CountryStatusFull(TCountryId const & countryId, Status const status) const { - if (status != TStatus::EUnknown) + if (status != Status::EUnknown) return status; TLocalFilePtr localFile = GetLatestLocalFile(countryId); if (!localFile || !localFile->OnDisk(MapOptions::Map)) - return TStatus::ENotDownloaded; + return Status::ENotDownloaded; CountryFile const & countryFile = GetCountryFile(countryId); if (GetRemoteSize(countryFile, MapOptions::Map, GetCurrentDataVersion()) == 0) - return TStatus::EUnknown; + return Status::EUnknown; if (localFile->GetVersion() != GetCurrentDataVersion()) - return TStatus::EOnDiskOutOfDate; - return TStatus::EOnDisk; + return Status::EOnDiskOutOfDate; + return Status::EOnDisk; } // @TODO(bykoianko) This method does nothing and should be removed. @@ -1099,19 +1099,19 @@ bool Storage::DeleteNode(TCountryId const & countryId) return true; } -TStatus Storage::NodeStatus(TCountriesContainer const & node) const +Status Storage::NodeStatus(TCountriesContainer const & node) const { if (node.ChildrenCount() == 0) return CountryStatusEx(node.Value().Name()); - TStatus result = TStatus::EUndefined; + Status result = Status::EUndefined; bool returnMixStatus = false; auto groupStatusCalculator = [&result, &returnMixStatus, this](TCountriesContainer const & nodeInSubtree) { if (returnMixStatus || nodeInSubtree.ChildrenCount() != 0) return; - TStatus status = this->CountryStatusEx(nodeInSubtree.Value().Name()); - if (result == TStatus::EUndefined) + Status status = this->CountryStatusEx(nodeInSubtree.Value().Name()); + if (result == Status::EUndefined) result = status; if (result != status) returnMixStatus = true; @@ -1119,7 +1119,7 @@ TStatus Storage::NodeStatus(TCountriesContainer const & node) const node.ForEachDescendant(groupStatusCalculator); - return (returnMixStatus ? TStatus::EMixed : result); + return (returnMixStatus ? Status::EMixed : result); } void Storage::GetNodeAttrs(TCountryId const & countryId, NodeAttrs & nodeAttrs) const diff --git a/storage/storage.hpp b/storage/storage.hpp index ec3244f178..79ae7d4147 100644 --- a/storage/storage.hpp +++ b/storage/storage.hpp @@ -23,7 +23,7 @@ struct NodeAttrs { NodeAttrs() : m_mwmCounter(0), m_localMwmCounter(0), m_mwmSize(0), m_localMwmSize(0), m_downloadingMwmSize(0), m_downloadingProgress(0), - m_status(TNodeStatus::Undefined), m_error(TNodeErrorCode::NoError) {} + m_status(NodeStatus::Undefined), m_error(NodeErrorCode::NoError) {} /// If the node is expandable (a big country) |m_mwmCounter| is number of mwm files (leaves) /// belongs to the node. If the node isn't expandable |m_mapsDownloaded| == 1. uint32_t m_mwmCounter; @@ -63,8 +63,8 @@ struct NodeAttrs /// |m_downloadingProgress| == 0. uint8_t m_downloadingProgress; - TNodeStatus m_status; - TNodeErrorCode m_error; + NodeStatus m_status; + NodeErrorCode m_error; }; /// This class is used for downloading, updating and deleting maps. @@ -355,7 +355,7 @@ public: TLocalFilePtr GetLatestLocalFile(TCountryId const & countryId) const; /// Slow version, but checks if country is out of date - TStatus CountryStatusEx(TCountryId const & countryId) const; + Status CountryStatusEx(TCountryId const & countryId) const; /// Puts country denoted by countryId into the downloader's queue. /// During downloading process notifies observers about downloading @@ -398,8 +398,8 @@ private: friend void UnitTest_StorageTest_DeleteCountrySingleMwm(); friend void UnitTest_StorageTest_DeleteCountryTwoComponentsMwm(); - TStatus CountryStatusWithoutFailed(TCountryId const & countryId) const; - TStatus CountryStatusFull(TCountryId const & countryId, TStatus const status) const; + Status CountryStatusWithoutFailed(TCountryId const & countryId) const; + Status CountryStatusFull(TCountryId const & countryId, Status const status) const; // Modifies file set of file to deletion - always adds (marks for // removal) a routing file when map file is marked for deletion. @@ -449,11 +449,11 @@ private: // downloaded files. string GetFileDownloadPath(TCountryId const & countryId, MapOptions file) const; - void CountryStatusEx(TCountryId const & countryId, TStatus & status, MapOptions & options) const; + void CountryStatusEx(TCountryId const & countryId, Status & status, MapOptions & options) const; /// Fast version, doesn't check if country is out of date - TStatus CountryStatus(TCountryId const & countryId) const; + Status CountryStatus(TCountryId const & countryId) const; /// Returns status for a node (group node or not) - TStatus NodeStatus(TCountriesContainer const & node) const; + Status NodeStatus(TCountriesContainer const & node) const; }; bool HasCountryId(TCountriesVec const & sorted, TCountryId const & countyId); diff --git a/storage/storage_defines.cpp b/storage/storage_defines.cpp index 6f252f5ad2..2822a764ce 100644 --- a/storage/storage_defines.cpp +++ b/storage/storage_defines.cpp @@ -4,95 +4,95 @@ namespace storage { -string DebugPrint(TStatus status) +string DebugPrint(Status status) { switch (status) { - case TStatus::EUndefined: + case Status::EUndefined: return string("EUndefined"); - case TStatus::EOnDisk: + case Status::EOnDisk: return string("OnDisk"); - case TStatus::ENotDownloaded: + case Status::ENotDownloaded: return string("NotDownloaded"); - case TStatus::EDownloadFailed: + case Status::EDownloadFailed: return string("DownloadFailed"); - case TStatus::EDownloading: + case Status::EDownloading: return string("Downloading"); - case TStatus::EInQueue: + case Status::EInQueue: return string("InQueue"); - case TStatus::EUnknown: + case Status::EUnknown: return string("Unknown"); - case TStatus::EOnDiskOutOfDate: + case Status::EOnDiskOutOfDate: return string("OnDiskOutOfDate"); - case TStatus::EOutOfMemFailed: + case Status::EOutOfMemFailed: return string("OutOfMemFailed"); - case TStatus::EMixed: + case Status::EMixed: return string("EMixed"); } } -string DebugPrint(TNodeStatus status) +string DebugPrint(NodeStatus status) { switch (status) { - case TNodeStatus::Undefined: + case NodeStatus::Undefined: return string("Undefined"); - case TNodeStatus::Error: + case NodeStatus::Error: return string("Error"); - case TNodeStatus::OnDisk: + case NodeStatus::OnDisk: return string("OnDisk"); - case TNodeStatus::NotDownloaded: + case NodeStatus::NotDownloaded: return string("NotDownloaded"); - case TNodeStatus::Downloading: + case NodeStatus::Downloading: return string("Downloading"); - case TNodeStatus::InQueue: + case NodeStatus::InQueue: return string("InQueue"); - case TNodeStatus::OnDiskOutOfDate: + case NodeStatus::OnDiskOutOfDate: return string("OnDiskOutOfDate"); - case TNodeStatus::Mixed: + case NodeStatus::Mixed: return string("Mixed"); } } -string DebugPrint(TNodeErrorCode status) +string DebugPrint(NodeErrorCode status) { switch (status) { - case TNodeErrorCode::NoError: + case NodeErrorCode::NoError: return string("NoError"); - case TNodeErrorCode::UnknownError: + case NodeErrorCode::UnknownError: return string("UnknownError"); - case TNodeErrorCode::OutOfMemFailed: + case NodeErrorCode::OutOfMemFailed: return string("OutOfMemFailed"); - case TNodeErrorCode::NoInetConnection: + case NodeErrorCode::NoInetConnection: return string("NoInetConnection"); } } -StatusAndError ParseStatus(TStatus innerStatus) +StatusAndError ParseStatus(Status innerStatus) { switch (innerStatus) { - case TStatus::EUndefined: - return StatusAndError(TNodeStatus::Undefined, TNodeErrorCode::NoError); - case TStatus::EOnDisk: - return StatusAndError(TNodeStatus::OnDisk, TNodeErrorCode::NoError); - case TStatus::ENotDownloaded: - return StatusAndError(TNodeStatus::NotDownloaded, TNodeErrorCode::NoError); - case TStatus::EDownloadFailed: - return StatusAndError(TNodeStatus::Error, TNodeErrorCode::NoInetConnection); - case TStatus::EDownloading: - return StatusAndError(TNodeStatus::Downloading, TNodeErrorCode::NoError); - case TStatus::EInQueue: - return StatusAndError(TNodeStatus::InQueue, TNodeErrorCode::NoError); - case TStatus::EUnknown: - return StatusAndError(TNodeStatus::Error, TNodeErrorCode::UnknownError); - case TStatus::EOnDiskOutOfDate: - return StatusAndError(TNodeStatus::OnDiskOutOfDate, TNodeErrorCode::NoError); - case TStatus::EOutOfMemFailed: - return StatusAndError(TNodeStatus::Error, TNodeErrorCode::OutOfMemFailed); - case TStatus::EMixed: - return StatusAndError(TNodeStatus::Mixed, TNodeErrorCode::NoError); + case Status::EUndefined: + return StatusAndError(NodeStatus::Undefined, NodeErrorCode::NoError); + case Status::EOnDisk: + return StatusAndError(NodeStatus::OnDisk, NodeErrorCode::NoError); + case Status::ENotDownloaded: + return StatusAndError(NodeStatus::NotDownloaded, NodeErrorCode::NoError); + case Status::EDownloadFailed: + return StatusAndError(NodeStatus::Error, NodeErrorCode::NoInetConnection); + case Status::EDownloading: + return StatusAndError(NodeStatus::Downloading, NodeErrorCode::NoError); + case Status::EInQueue: + return StatusAndError(NodeStatus::InQueue, NodeErrorCode::NoError); + case Status::EUnknown: + return StatusAndError(NodeStatus::Error, NodeErrorCode::UnknownError); + case Status::EOnDiskOutOfDate: + return StatusAndError(NodeStatus::OnDiskOutOfDate, NodeErrorCode::NoError); + case Status::EOutOfMemFailed: + return StatusAndError(NodeStatus::Error, NodeErrorCode::OutOfMemFailed); + case Status::EMixed: + return StatusAndError(NodeStatus::Mixed, NodeErrorCode::NoError); } } diff --git a/storage/storage_defines.hpp b/storage/storage_defines.hpp index 3de1e17959..34e12c13c7 100644 --- a/storage/storage_defines.hpp +++ b/storage/storage_defines.hpp @@ -10,7 +10,7 @@ namespace storage { /// Inner status which is used inside Storage class - enum class TStatus : uint8_t + enum class Status : uint8_t { EUndefined = 0, EOnDisk, /**< Downloaded mwm(s) is up to date. No need to update it. */ @@ -23,9 +23,9 @@ namespace storage EOutOfMemFailed, /**< Downloading failed because it's not enough memory */ EMixed, /**< Descendants of a group node have different statuses. */ }; - string DebugPrint(TStatus status); + string DebugPrint(Status status); - enum class TNodeStatus + enum class NodeStatus { Undefined, Error, /**< An error happened while downloading */ @@ -36,20 +36,20 @@ namespace storage OnDiskOutOfDate, /**< An update for a downloaded mwm is ready according to counties.txt. */ Mixed, /**< Descendants of a group node have different statuses. */ }; - string DebugPrint(TNodeStatus status); + string DebugPrint(NodeStatus status); - enum class TNodeErrorCode + enum class NodeErrorCode { NoError, UnknownError, /**< Downloading failed because of unknown error. */ OutOfMemFailed, /**< Downloading failed because it's not enough memory */ NoInetConnection, /**< Downloading failed because internet connection was interrupted */ }; - string DebugPrint(TNodeErrorCode status); + string DebugPrint(NodeErrorCode status); struct StatusAndError { - StatusAndError(TNodeStatus nodeStatus, TNodeErrorCode nodeError) : + StatusAndError(NodeStatus nodeStatus, NodeErrorCode nodeError) : status(nodeStatus), error(nodeError) {} bool operator==(StatusAndError const & other) @@ -57,14 +57,14 @@ namespace storage return other.status == status && other.error == error; } - TNodeStatus status; - TNodeErrorCode error; + NodeStatus status; + NodeErrorCode error; }; string DebugPrint(StatusAndError statusAndError); using TLocalAndRemoteSize = pair; - StatusAndError ParseStatus(TStatus innerStatus); + StatusAndError ParseStatus(Status innerStatus); } // namespace storage using TDownloadFn = function; diff --git a/storage/storage_helpers.cpp b/storage/storage_helpers.cpp index 421e95a1d7..bd1a4caac0 100644 --- a/storage/storage_helpers.cpp +++ b/storage/storage_helpers.cpp @@ -13,9 +13,9 @@ bool IsPointCoveredByDownloadedMaps(m2::PointD const & position, return storage.IsNodeDownloaded(countryInfoGetter.GetRegionCountryId(position)); } -bool IsDownloadFailed(TStatus status) +bool IsDownloadFailed(Status status) { - return status == TStatus::EDownloadFailed || status == TStatus::EOutOfMemFailed || - status == TStatus::EUnknown; + return status == Status::EDownloadFailed || status == Status::EOutOfMemFailed || + status == Status::EUnknown; } } // namespace storage diff --git a/storage/storage_helpers.hpp b/storage/storage_helpers.hpp index d0ce5c9f0d..67a1a77104 100644 --- a/storage/storage_helpers.hpp +++ b/storage/storage_helpers.hpp @@ -16,5 +16,5 @@ bool IsPointCoveredByDownloadedMaps(m2::PointD const & position, Storage const & storage, CountryInfoGetter const & countryInfoGetter); -bool IsDownloadFailed(TStatus status); +bool IsDownloadFailed(Status status); } // namespace storage diff --git a/storage/storage_integration_tests/migrate_tests.cpp b/storage/storage_integration_tests/migrate_tests.cpp index dca8252905..aa5423bbb2 100644 --- a/storage/storage_integration_tests/migrate_tests.cpp +++ b/storage/storage_integration_tests/migrate_tests.cpp @@ -51,7 +51,7 @@ UNIT_TEST(StorageMigrationTests) auto statePrefetchChanged = [&](TCountryId const & id) { - TStatus const nextStatus = f.Storage().m_prefetchStorage->CountryStatusEx(id); + Status const nextStatus = f.Storage().m_prefetchStorage->CountryStatusEx(id); LOG_SHORT(LINFO, (id, "status :", nextStatus)); if (!f.Storage().m_prefetchStorage->IsDownloadInProgress()) { diff --git a/storage/storage_integration_tests/storage_downloading_tests.cpp b/storage/storage_integration_tests/storage_downloading_tests.cpp index bad79c6708..e72097ba31 100644 --- a/storage/storage_integration_tests/storage_downloading_tests.cpp +++ b/storage/storage_integration_tests/storage_downloading_tests.cpp @@ -101,11 +101,11 @@ UNIT_TEST(SmallMwms_InterruptDownloadResumeDownload_Test) NodeAttrs attrs; storage.GetNodeAttrs(kCountryId, attrs); - TEST_EQUAL(TNodeStatus::Downloading, attrs.m_status, ()); + TEST_EQUAL(NodeStatus::Downloading, attrs.m_status, ()); storage.DownloadNode(kCountryId); testing::RunEventLoop(); storage.GetNodeAttrs(kCountryId, attrs); - TEST_EQUAL(TNodeStatus::OnDisk, attrs.m_status, ()); + TEST_EQUAL(NodeStatus::OnDisk, attrs.m_status, ()); } diff --git a/storage/storage_integration_tests/storage_group_download_tests.cpp b/storage/storage_integration_tests/storage_group_download_tests.cpp index d41b69bff8..6d0d9f51e1 100644 --- a/storage/storage_integration_tests/storage_group_download_tests.cpp +++ b/storage/storage_integration_tests/storage_group_download_tests.cpp @@ -103,10 +103,10 @@ void DownloadGroup(Storage & storage, bool oneByOne) size_t totalGroupSize = 0; for (auto const & countryId : children) { - TEST_EQUAL(TStatus::ENotDownloaded, storage.CountryStatusEx(countryId), ()); + TEST_EQUAL(Status::ENotDownloaded, storage.CountryStatusEx(countryId), ()); NodeAttrs attrs; storage.GetNodeAttrs(countryId, attrs); - TEST_EQUAL(TNodeStatus::NotDownloaded, attrs.m_status, ()); + TEST_EQUAL(NodeStatus::NotDownloaded, attrs.m_status, ()); TEST_GREATER(attrs.m_mwmSize, 0, ()); totalGroupSize += attrs.m_mwmSize; } @@ -114,7 +114,7 @@ void DownloadGroup(Storage & storage, bool oneByOne) // Check status for the group node is set to ENotDownloaded NodeAttrs attrs; storage.GetNodeAttrs(kGroupCountryId, attrs); - TEST_EQUAL(TNodeStatus::NotDownloaded, attrs.m_status, ()); + TEST_EQUAL(NodeStatus::NotDownloaded, attrs.m_status, ()); TEST_EQUAL(attrs.m_mwmSize, totalGroupSize, ()); attrs = NodeAttrs(); @@ -148,15 +148,15 @@ void DownloadGroup(Storage & storage, bool oneByOne) // Check status for the group node is set to EOnDisk storage.GetNodeAttrs(kGroupCountryId, attrs); - TEST_EQUAL(TNodeStatus::OnDisk, attrs.m_status, ()); + TEST_EQUAL(NodeStatus::OnDisk, attrs.m_status, ()); // Check status for the all children nodes is set to EOnDisk for (auto const & countryId : children) { - TEST_EQUAL(TStatus::EOnDisk, storage.CountryStatusEx(countryId), ()); + TEST_EQUAL(Status::EOnDisk, storage.CountryStatusEx(countryId), ()); NodeAttrs attrs; storage.GetNodeAttrs(countryId, attrs); - TEST_EQUAL(TNodeStatus::OnDisk, attrs.m_status, ()); + TEST_EQUAL(NodeStatus::OnDisk, attrs.m_status, ()); } // Check there is only mwm files are present and no any other for the children nodes @@ -226,15 +226,15 @@ void DeleteGroup(Storage & storage, bool oneByOne) // Check state for the group node is set to UpToDate and NoError NodeAttrs attrs; storage.GetNodeAttrs(kGroupCountryId, attrs); - TEST_EQUAL(TNodeStatus::NotDownloaded, attrs.m_status, ()); + TEST_EQUAL(NodeStatus::NotDownloaded, attrs.m_status, ()); // Check state for the all children nodes is set to UpToDate and NoError for (auto const & countryId : children) { - TEST_EQUAL(TStatus::ENotDownloaded, storage.CountryStatusEx(countryId), ()); + TEST_EQUAL(Status::ENotDownloaded, storage.CountryStatusEx(countryId), ()); NodeAttrs attrs; storage.GetNodeAttrs(countryId, attrs); - TEST_EQUAL(TNodeStatus::NotDownloaded, attrs.m_status, ()); + TEST_EQUAL(NodeStatus::NotDownloaded, attrs.m_status, ()); } // Check there are no mwm files for the children nodes diff --git a/storage/storage_integration_tests/storage_update_tests.cpp b/storage/storage_integration_tests/storage_update_tests.cpp index a84be7050e..dc14d63d4e 100644 --- a/storage/storage_integration_tests/storage_update_tests.cpp +++ b/storage/storage_integration_tests/storage_update_tests.cpp @@ -113,7 +113,7 @@ UNIT_TEST(SmallMwms_Update_Test) // Check group node status is EOnDisk NodeAttrs attrs; storage.GetNodeAttrs(kGroupCountryId, attrs); - TEST_EQUAL(TNodeStatus::OnDisk, attrs.m_status, ()); + TEST_EQUAL(NodeStatus::OnDisk, attrs.m_status, ()); // Check mwm files for version 1 are present for (auto const & child : children) @@ -147,14 +147,14 @@ UNIT_TEST(SmallMwms_Update_Test) // Check group node status is EOnDiskOutOfDate NodeAttrs attrs; storage.GetNodeAttrs(kGroupCountryId, attrs); - TEST_EQUAL(TNodeStatus::OnDiskOutOfDate, attrs.m_status, ()); + TEST_EQUAL(NodeStatus::OnDiskOutOfDate, attrs.m_status, ()); // Check children node status is EOnDiskOutOfDate for (auto const & child : children) { NodeAttrs attrs; storage.GetNodeAttrs(child, attrs); - TEST_EQUAL(TNodeStatus::OnDiskOutOfDate, attrs.m_status, ()); + TEST_EQUAL(NodeStatus::OnDiskOutOfDate, attrs.m_status, ()); } // Check mwm files for version 1 are present @@ -170,14 +170,14 @@ UNIT_TEST(SmallMwms_Update_Test) // Check group node status is EOnDisk storage.GetNodeAttrs(kGroupCountryId, attrs); - TEST_EQUAL(TNodeStatus::OnDisk, attrs.m_status, ()); + TEST_EQUAL(NodeStatus::OnDisk, attrs.m_status, ()); // Check children node status is EOnDisk for (auto const & child : children) { NodeAttrs attrs; storage.GetNodeAttrs(child, attrs); - TEST_EQUAL(TNodeStatus::OnDisk, attrs.m_status, ()); + TEST_EQUAL(NodeStatus::OnDisk, attrs.m_status, ()); } // Check mwm files for version 2 are present and not present for version 1 diff --git a/storage/storage_tests/storage_tests.cpp b/storage/storage_tests/storage_tests.cpp index 3a4ad1e46f..c815cd2368 100644 --- a/storage/storage_tests/storage_tests.cpp +++ b/storage/storage_tests/storage_tests.cpp @@ -147,7 +147,7 @@ class CountryDownloaderChecker { public: CountryDownloaderChecker(Storage & storage, TCountryId const & countryId, MapOptions files, - vector const & transitionList) + vector const & transitionList) : m_storage(storage), m_countryId(countryId), m_countryFile(storage.GetCountryFile(m_countryId)), @@ -185,13 +185,13 @@ protected: if (countryId != m_countryId) return; - TStatus const nextStatus = m_storage.CountryStatusEx(m_countryId); + Status const nexStatus = m_storage.CountryStatusEx(m_countryId); LOG(LINFO, (m_countryFile, "status transition: from", m_transitionList[m_currStatus], "to", - nextStatus)); + nexStatus)); TEST_LESS(m_currStatus + 1, m_transitionList.size(), (m_countryFile)); - TEST_EQUAL(nextStatus, m_transitionList[m_currStatus + 1], (m_countryFile)); + TEST_EQUAL(nexStatus, m_transitionList[m_currStatus + 1], (m_countryFile)); ++m_currStatus; - if (m_transitionList[m_currStatus] == TStatus::EDownloading) + if (m_transitionList[m_currStatus] == Status::EDownloading) { TLocalAndRemoteSize localAndRemoteSize = m_storage.CountrySizeInBytes(m_countryId, m_files); m_totalBytesToDownload = localAndRemoteSize.second; @@ -223,7 +223,7 @@ protected: int m_slot; size_t m_currStatus; - vector m_transitionList; + vector m_transitionList; }; class CancelDownloadingWhenAlmostDoneChecker : public CountryDownloaderChecker @@ -232,8 +232,8 @@ public: CancelDownloadingWhenAlmostDoneChecker(Storage & storage, TCountryId const & countryId, TaskRunner & runner) : CountryDownloaderChecker(storage, countryId, MapOptions::Map, - vector{TStatus::ENotDownloaded, TStatus::EDownloading, - TStatus::ENotDownloaded}), + vector{Status::ENotDownloaded, Status::EDownloading, + Status::ENotDownloaded}), m_runner(runner) { } @@ -266,7 +266,7 @@ unique_ptr AbsentCountryDownloaderChecker(Storage & st { return make_unique( storage, countryId, files, - vector{TStatus::ENotDownloaded, TStatus::EDownloading, TStatus::EOnDisk}); + vector{Status::ENotDownloaded, Status::EDownloading, Status::EOnDisk}); } // Checks following state transitions: @@ -277,7 +277,7 @@ unique_ptr PresentCountryDownloaderChecker(Storage & s { return make_unique( storage, countryId, files, - vector{TStatus::EOnDisk, TStatus::EDownloading, TStatus::EOnDisk}); + vector{Status::EOnDisk, Status::EDownloading, Status::EOnDisk}); } // Checks following state transitions: @@ -287,8 +287,8 @@ unique_ptr QueuedCountryDownloaderChecker(Storage & st MapOptions files) { return make_unique( - storage, countryId, files, vector{TStatus::ENotDownloaded, TStatus::EInQueue, - TStatus::EDownloading, TStatus::EOnDisk}); + storage, countryId, files, vector{Status::ENotDownloaded, Status::EInQueue, + Status::EDownloading, Status::EOnDisk}); } // Checks following state transitions: @@ -299,13 +299,13 @@ unique_ptr CancelledCountryDownloaderChecker(Storage & { return make_unique( storage, countryId, files, - vector{TStatus::ENotDownloaded, TStatus::EDownloading, TStatus::ENotDownloaded}); + vector{Status::ENotDownloaded, Status::EDownloading, Status::ENotDownloaded}); } class CountryStatusChecker { public: - CountryStatusChecker(Storage & storage, TCountryId const & countryId, TStatus status) + CountryStatusChecker(Storage & storage, TCountryId const & countryId, Status status) : m_storage(storage), m_countryId(countryId), m_status(status), m_triggered(false) { m_slot = m_storage.Subscribe( @@ -325,7 +325,7 @@ private: if (countryId != m_countryId) return; TEST(!m_triggered, ("Status checker can be triggered only once.")); - TStatus status = m_storage.CountryStatusEx(m_countryId); + Status status = m_storage.CountryStatusEx(m_countryId); TEST_EQUAL(m_status, status, ()); m_triggered = true; } @@ -338,7 +338,7 @@ private: Storage & m_storage; TCountryId const & m_countryId; - TStatus m_status; + Status m_status; bool m_triggered; int m_slot; }; @@ -372,8 +372,8 @@ public: { if (countryId != m_countryId) return; - TStatus const status = m_storage.CountryStatusEx(countryId); - if (status != TStatus::EDownloadFailed) + Status const status = m_storage.CountryStatusEx(countryId); + if (status != Status::EDownloadFailed) return; lock_guard lock(m_mu); m_finished = true; @@ -533,21 +533,21 @@ UNIT_TEST(StorageTest_DeleteTwoVersionsOfTheSameCountry) storage.DeleteCountry(countryId, MapOptions::Map); TLocalFilePtr latestLocalFile = storage.GetLatestLocalFile(countryId); TEST(!latestLocalFile.get(), ("Country wasn't deleted from disk.")); - TEST_EQUAL(TStatus::ENotDownloaded, storage.CountryStatusEx(countryId), ()); + TEST_EQUAL(Status::ENotDownloaded, storage.CountryStatusEx(countryId), ()); TLocalFilePtr localFileV1 = CreateDummyMapFile(countryFile, v1, 1024 /* size */); storage.RegisterAllLocalMaps(); latestLocalFile = storage.GetLatestLocalFile(countryId); TEST(latestLocalFile.get(), ("Created map file wasn't found by storage.")); TEST_EQUAL(latestLocalFile->GetVersion(), localFileV1->GetVersion(), ()); - TEST_EQUAL(TStatus::EOnDiskOutOfDate, storage.CountryStatusEx(countryId), ()); + TEST_EQUAL(Status::EOnDiskOutOfDate, storage.CountryStatusEx(countryId), ()); TLocalFilePtr localFileV2 = CreateDummyMapFile(countryFile, v2, 2048 /* size */); storage.RegisterAllLocalMaps(); latestLocalFile = storage.GetLatestLocalFile(countryId); TEST(latestLocalFile.get(), ("Created map file wasn't found by storage.")); TEST_EQUAL(latestLocalFile->GetVersion(), localFileV2->GetVersion(), ()); - TEST_EQUAL(TStatus::EOnDiskOutOfDate, storage.CountryStatusEx(countryId), ()); + TEST_EQUAL(Status::EOnDiskOutOfDate, storage.CountryStatusEx(countryId), ()); storage.DeleteCountry(countryId, MapOptions::Map); @@ -557,7 +557,7 @@ UNIT_TEST(StorageTest_DeleteTwoVersionsOfTheSameCountry) localFileV2->SyncWithDisk(); TEST_EQUAL(MapOptions::Nothing, localFileV2->GetFiles(), ()); - TEST_EQUAL(TStatus::ENotDownloaded, storage.CountryStatusEx(countryId), ()); + TEST_EQUAL(Status::ENotDownloaded, storage.CountryStatusEx(countryId), ()); } UNIT_TEST(StorageTest_DownloadMapAndRoutingSeparately) @@ -622,7 +622,7 @@ UNIT_TEST(StorageTest_DownloadMapAndRoutingSeparately) // Delete routing file and check status update. { - CountryStatusChecker checker(storage, countryId, TStatus::EOnDisk); + CountryStatusChecker checker(storage, countryId, Status::EOnDisk); storage.DeleteCountry(countryId, MapOptions::CarRouting); } TLocalFilePtr localFileC = storage.GetLatestLocalFile(countryId); @@ -635,7 +635,7 @@ UNIT_TEST(StorageTest_DownloadMapAndRoutingSeparately) // Delete map file and check status update. { - CountryStatusChecker checker(storage, countryId, TStatus::ENotDownloaded); + CountryStatusChecker checker(storage, countryId, Status::ENotDownloaded); storage.DeleteCountry(countryId, MapOptions::Map); } @@ -688,12 +688,12 @@ UNIT_TEST(StorageTest_DownloadTwoCountriesAndDeleteSingleMwm) { unique_ptr uruguayChecker = make_unique( storage, uruguayCountryId, MapOptions::Map, - vector{TStatus::ENotDownloaded, TStatus::EDownloading, TStatus::EOnDisk}); + vector{Status::ENotDownloaded, Status::EDownloading, Status::EOnDisk}); unique_ptr venezuelaChecker = make_unique( storage, venezuelaCountryId, MapOptions::Map, - vector{TStatus::ENotDownloaded, TStatus::EInQueue, - TStatus::EDownloading, TStatus::EOnDisk}); + vector{Status::ENotDownloaded, Status::EInQueue, + Status::EDownloading, Status::EOnDisk}); uruguayChecker->StartDownload(); venezuelaChecker->StartDownload(); @@ -703,11 +703,11 @@ UNIT_TEST(StorageTest_DownloadTwoCountriesAndDeleteSingleMwm) { unique_ptr uruguayChecker = make_unique( storage, uruguayCountryId, MapOptions::Map, - vector{TStatus::EOnDisk, TStatus::ENotDownloaded}); + vector{Status::EOnDisk, Status::ENotDownloaded}); unique_ptr venezuelaChecker = make_unique( storage, venezuelaCountryId, MapOptions::Map, - vector{TStatus::EOnDisk, TStatus::ENotDownloaded}); + vector{Status::EOnDisk, Status::ENotDownloaded}); storage.DeleteCountry(uruguayCountryId, MapOptions::Map); storage.DeleteCountry(venezuelaCountryId, MapOptions::Map); @@ -747,7 +747,7 @@ UNIT_TEST(StorageTest_DownloadTwoCountriesAndDeleteTwoComponentMwm) // Uruguay should pass through following states: NotDownloaded -> Downloading -> NotDownloaded. unique_ptr uruguayChecker = make_unique( storage, uruguayCountryId, MapOptions::MapWithCarRouting, - vector{TStatus::ENotDownloaded, TStatus::EDownloading, TStatus::ENotDownloaded}); + vector{Status::ENotDownloaded, Status::EDownloading, Status::ENotDownloaded}); // Only routing file will be deleted for Venezuela, thus, Venezuela should pass through // following // states: @@ -755,8 +755,8 @@ UNIT_TEST(StorageTest_DownloadTwoCountriesAndDeleteTwoComponentMwm) // (second notification will be sent after deletion of a routing file) -> OnDisk. unique_ptr venezuelaChecker = make_unique( storage, venezuelaCountryId, MapOptions::MapWithCarRouting, - vector{TStatus::ENotDownloaded, TStatus::EInQueue, TStatus::EDownloading, - TStatus::EDownloading, TStatus::EOnDisk}); + vector{Status::ENotDownloaded, Status::EInQueue, Status::EDownloading, + Status::EDownloading, Status::EOnDisk}); uruguayChecker->StartDownload(); venezuelaChecker->StartDownload(); storage.DeleteCountry(uruguayCountryId, MapOptions::Map); @@ -985,12 +985,12 @@ UNIT_TEST(StorageTest_DownloadedMapTests) { auto algeriaCentralChecker = make_unique( storage, algeriaCentralCountryId, MapOptions::Map, - vector{TStatus::ENotDownloaded, TStatus::EDownloading, TStatus::EOnDisk}); + vector{Status::ENotDownloaded, Status::EDownloading, Status::EOnDisk}); auto algeriaCoastChecker = make_unique( storage, algeriaCoastCountryId, MapOptions::Map, - vector{TStatus::ENotDownloaded, TStatus::EInQueue, - TStatus::EDownloading, TStatus::EOnDisk}); + vector{Status::ENotDownloaded, Status::EInQueue, + Status::EDownloading, Status::EOnDisk}); algeriaCentralChecker->StartDownload(); algeriaCoastChecker->StartDownload(); @@ -1166,29 +1166,29 @@ UNIT_TEST(StorageTest_GetNodeAttrsSingleMwm) storage.GetNodeAttrs("Abkhazia", nodeAttrs); TEST_EQUAL(nodeAttrs.m_mwmCounter, 1, ()); TEST_EQUAL(nodeAttrs.m_mwmSize, 4689718, ()); - TEST_EQUAL(nodeAttrs.m_status, TNodeStatus::NotDownloaded, ()); - TEST_EQUAL(nodeAttrs.m_error, TNodeErrorCode::NoError, ()); + TEST_EQUAL(nodeAttrs.m_status, NodeStatus::NotDownloaded, ()); + TEST_EQUAL(nodeAttrs.m_error, NodeErrorCode::NoError, ()); storage.GetNodeAttrs("Algeria", nodeAttrs); TEST_EQUAL(nodeAttrs.m_mwmCounter, 2, ()); TEST_EQUAL(nodeAttrs.m_mwmSize, 90878678, ()); - TEST_EQUAL(nodeAttrs.m_status, TNodeStatus::NotDownloaded, ()); - TEST_EQUAL(nodeAttrs.m_error, TNodeErrorCode::NoError, ()); + TEST_EQUAL(nodeAttrs.m_status, NodeStatus::NotDownloaded, ()); + TEST_EQUAL(nodeAttrs.m_error, NodeErrorCode::NoError, ()); storage.GetNodeAttrs("South Korea_South", nodeAttrs); TEST_EQUAL(nodeAttrs.m_mwmCounter, 1, ()); TEST_EQUAL(nodeAttrs.m_mwmSize, 48394664, ()); - TEST_EQUAL(nodeAttrs.m_status, TNodeStatus::NotDownloaded, ()); - TEST_EQUAL(nodeAttrs.m_error, TNodeErrorCode::NoError, ()); + TEST_EQUAL(nodeAttrs.m_status, NodeStatus::NotDownloaded, ()); + TEST_EQUAL(nodeAttrs.m_error, NodeErrorCode::NoError, ()); } UNIT_TEST(StorageTest_ParseStatus) { - TEST_EQUAL(StatusAndError(TNodeStatus::Undefined, TNodeErrorCode::NoError), - ParseStatus(TStatus::EUndefined), ()); - TEST_EQUAL(StatusAndError(TNodeStatus::Error, TNodeErrorCode::NoInetConnection), - ParseStatus(TStatus::EDownloadFailed), ()); - TEST_EQUAL(StatusAndError(TNodeStatus::Downloading, TNodeErrorCode::NoError), - ParseStatus(TStatus::EDownloading), ()); + TEST_EQUAL(StatusAndError(NodeStatus::Undefined, NodeErrorCode::NoError), + ParseStatus(Status::EUndefined), ()); + TEST_EQUAL(StatusAndError(NodeStatus::Error, NodeErrorCode::NoInetConnection), + ParseStatus(Status::EDownloadFailed), ()); + TEST_EQUAL(StatusAndError(NodeStatus::Downloading, NodeErrorCode::NoError), + ParseStatus(Status::EDownloading), ()); } } // namespace storage