[new downloader] Getting rid of letter T in the beginging of enum classes

This commit is contained in:
Vladimir Byko-Ianko 2016-02-04 17:32:15 +03:00 committed by Sergey Yershov
parent fd9fa541f6
commit 6f8c37e958
17 changed files with 172 additions and 172 deletions

View file

@ -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:

View file

@ -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;

View file

@ -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);

View file

@ -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).

View file

@ -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();

View file

@ -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);

View file

@ -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<Country const *> & 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

View file

@ -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);

View file

@ -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);
}
}

View file

@ -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<uint64_t, uint64_t>;
StatusAndError ParseStatus(TStatus innerStatus);
StatusAndError ParseStatus(Status innerStatus);
} // namespace storage
using TDownloadFn = function<void (storage::TCountryId const &)>;

View file

@ -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

View file

@ -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

View file

@ -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())
{

View file

@ -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, ());
}

View file

@ -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

View file

@ -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

View file

@ -147,7 +147,7 @@ class CountryDownloaderChecker
{
public:
CountryDownloaderChecker(Storage & storage, TCountryId const & countryId, MapOptions files,
vector<TStatus> const & transitionList)
vector<Status> 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<TStatus> m_transitionList;
vector<Status> 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>{TStatus::ENotDownloaded, TStatus::EDownloading,
TStatus::ENotDownloaded}),
vector<Status>{Status::ENotDownloaded, Status::EDownloading,
Status::ENotDownloaded}),
m_runner(runner)
{
}
@ -266,7 +266,7 @@ unique_ptr<CountryDownloaderChecker> AbsentCountryDownloaderChecker(Storage & st
{
return make_unique<CountryDownloaderChecker>(
storage, countryId, files,
vector<TStatus>{TStatus::ENotDownloaded, TStatus::EDownloading, TStatus::EOnDisk});
vector<Status>{Status::ENotDownloaded, Status::EDownloading, Status::EOnDisk});
}
// Checks following state transitions:
@ -277,7 +277,7 @@ unique_ptr<CountryDownloaderChecker> PresentCountryDownloaderChecker(Storage & s
{
return make_unique<CountryDownloaderChecker>(
storage, countryId, files,
vector<TStatus>{TStatus::EOnDisk, TStatus::EDownloading, TStatus::EOnDisk});
vector<Status>{Status::EOnDisk, Status::EDownloading, Status::EOnDisk});
}
// Checks following state transitions:
@ -287,8 +287,8 @@ unique_ptr<CountryDownloaderChecker> QueuedCountryDownloaderChecker(Storage & st
MapOptions files)
{
return make_unique<CountryDownloaderChecker>(
storage, countryId, files, vector<TStatus>{TStatus::ENotDownloaded, TStatus::EInQueue,
TStatus::EDownloading, TStatus::EOnDisk});
storage, countryId, files, vector<Status>{Status::ENotDownloaded, Status::EInQueue,
Status::EDownloading, Status::EOnDisk});
}
// Checks following state transitions:
@ -299,13 +299,13 @@ unique_ptr<CountryDownloaderChecker> CancelledCountryDownloaderChecker(Storage &
{
return make_unique<CountryDownloaderChecker>(
storage, countryId, files,
vector<TStatus>{TStatus::ENotDownloaded, TStatus::EDownloading, TStatus::ENotDownloaded});
vector<Status>{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<mutex> 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<CountryDownloaderChecker> uruguayChecker = make_unique<CountryDownloaderChecker>(
storage, uruguayCountryId, MapOptions::Map,
vector<TStatus>{TStatus::ENotDownloaded, TStatus::EDownloading, TStatus::EOnDisk});
vector<Status>{Status::ENotDownloaded, Status::EDownloading, Status::EOnDisk});
unique_ptr<CountryDownloaderChecker> venezuelaChecker = make_unique<CountryDownloaderChecker>(
storage, venezuelaCountryId, MapOptions::Map,
vector<TStatus>{TStatus::ENotDownloaded, TStatus::EInQueue,
TStatus::EDownloading, TStatus::EOnDisk});
vector<Status>{Status::ENotDownloaded, Status::EInQueue,
Status::EDownloading, Status::EOnDisk});
uruguayChecker->StartDownload();
venezuelaChecker->StartDownload();
@ -703,11 +703,11 @@ UNIT_TEST(StorageTest_DownloadTwoCountriesAndDeleteSingleMwm)
{
unique_ptr<CountryDownloaderChecker> uruguayChecker = make_unique<CountryDownloaderChecker>(
storage, uruguayCountryId, MapOptions::Map,
vector<TStatus>{TStatus::EOnDisk, TStatus::ENotDownloaded});
vector<Status>{Status::EOnDisk, Status::ENotDownloaded});
unique_ptr<CountryDownloaderChecker> venezuelaChecker = make_unique<CountryDownloaderChecker>(
storage, venezuelaCountryId, MapOptions::Map,
vector<TStatus>{TStatus::EOnDisk, TStatus::ENotDownloaded});
vector<Status>{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<CountryDownloaderChecker> uruguayChecker = make_unique<CountryDownloaderChecker>(
storage, uruguayCountryId, MapOptions::MapWithCarRouting,
vector<TStatus>{TStatus::ENotDownloaded, TStatus::EDownloading, TStatus::ENotDownloaded});
vector<Status>{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<CountryDownloaderChecker> venezuelaChecker = make_unique<CountryDownloaderChecker>(
storage, venezuelaCountryId, MapOptions::MapWithCarRouting,
vector<TStatus>{TStatus::ENotDownloaded, TStatus::EInQueue, TStatus::EDownloading,
TStatus::EDownloading, TStatus::EOnDisk});
vector<Status>{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<CountryDownloaderChecker>(
storage, algeriaCentralCountryId, MapOptions::Map,
vector<TStatus>{TStatus::ENotDownloaded, TStatus::EDownloading, TStatus::EOnDisk});
vector<Status>{Status::ENotDownloaded, Status::EDownloading, Status::EOnDisk});
auto algeriaCoastChecker = make_unique<CountryDownloaderChecker>(
storage, algeriaCoastCountryId, MapOptions::Map,
vector<TStatus>{TStatus::ENotDownloaded, TStatus::EInQueue,
TStatus::EDownloading, TStatus::EOnDisk});
vector<Status>{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