[new downloader] Fixing and adding tests.

This commit is contained in:
Vladimir Byko-Ianko 2016-02-04 15:56:05 +03:00 committed by Sergey Yershov
parent 5c7e4b173c
commit aee56b879d
4 changed files with 28 additions and 17 deletions

View file

@ -101,11 +101,11 @@ UNIT_TEST(SmallMwms_InterruptDownloadResumeDownload_Test)
NodeAttrs attrs;
storage.GetNodeAttrs(kCountryId, attrs);
TEST_EQUAL(TStatus::EDownloading, attrs.m_status, ());
TEST_EQUAL(TNodeStatus::Downloading, attrs.m_status, ());
storage.DownloadNode(kCountryId);
testing::RunEventLoop();
storage.GetNodeAttrs(kCountryId, attrs);
TEST_EQUAL(TStatus::EOnDisk, attrs.m_status, ());
TEST_EQUAL(TNodeStatus::OnDisk, attrs.m_status, ());
}

View file

@ -106,7 +106,7 @@ void DownloadGroup(Storage & storage, bool oneByOne)
TEST_EQUAL(TStatus::ENotDownloaded, storage.CountryStatusEx(countryId), ());
NodeAttrs attrs;
storage.GetNodeAttrs(countryId, attrs);
TEST_EQUAL(TStatus::ENotDownloaded, attrs.m_status, ());
TEST_EQUAL(TNodeStatus::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(TStatus::ENotDownloaded, attrs.m_status, ());
TEST_EQUAL(TNodeStatus::NotDownloaded, attrs.m_status, ());
TEST_EQUAL(attrs.m_mwmSize, totalGroupSize, ());
attrs = NodeAttrs();
@ -148,7 +148,7 @@ void DownloadGroup(Storage & storage, bool oneByOne)
// Check status for the group node is set to EOnDisk
storage.GetNodeAttrs(kGroupCountryId, attrs);
TEST_EQUAL(TStatus::EOnDisk, attrs.m_status, ());
TEST_EQUAL(TNodeStatus::OnDisk, attrs.m_status, ());
// Check status for the all children nodes is set to EOnDisk
for (auto const & countryId : children)
@ -156,7 +156,7 @@ void DownloadGroup(Storage & storage, bool oneByOne)
TEST_EQUAL(TStatus::EOnDisk, storage.CountryStatusEx(countryId), ());
NodeAttrs attrs;
storage.GetNodeAttrs(countryId, attrs);
TEST_EQUAL(TStatus::EOnDisk, attrs.m_status, ());
TEST_EQUAL(TNodeStatus::OnDisk, attrs.m_status, ());
}
// Check there is only mwm files are present and no any other for the children nodes
@ -226,7 +226,7 @@ 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(TStatus::ENotDownloaded, attrs.m_status, ());
TEST_EQUAL(TNodeStatus::NotDownloaded, attrs.m_status, ());
// Check state for the all children nodes is set to UpToDate and NoError
for (auto const & countryId : children)
@ -234,7 +234,7 @@ void DeleteGroup(Storage & storage, bool oneByOne)
TEST_EQUAL(TStatus::ENotDownloaded, storage.CountryStatusEx(countryId), ());
NodeAttrs attrs;
storage.GetNodeAttrs(countryId, attrs);
TEST_EQUAL(TStatus::ENotDownloaded, attrs.m_status, ());
TEST_EQUAL(TNodeStatus::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(TStatus::EOnDisk, attrs.m_status, ());
TEST_EQUAL(TNodeStatus::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(TStatus::EOnDiskOutOfDate, attrs.m_status, ());
TEST_EQUAL(TNodeStatus::OnDiskOutOfDate, attrs.m_status, ());
// Check children node status is EOnDiskOutOfDate
for (auto const & child : children)
{
NodeAttrs attrs;
storage.GetNodeAttrs(child, attrs);
TEST_EQUAL(TStatus::EOnDiskOutOfDate, attrs.m_status, ());
TEST_EQUAL(TNodeStatus::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(TStatus::EOnDisk, attrs.m_status, ());
TEST_EQUAL(TNodeStatus::OnDisk, attrs.m_status, ());
// Check children node status is EOnDisk
for (auto const & child : children)
{
NodeAttrs attrs;
storage.GetNodeAttrs(child, attrs);
TEST_EQUAL(TStatus::EOnDisk, attrs.m_status, ());
TEST_EQUAL(TNodeStatus::OnDisk, attrs.m_status, ());
}
// Check mwm files for version 2 are present and not present for version 1

View file

@ -1166,17 +1166,28 @@ 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, TStatus::ENotDownloaded, ());
TEST_EQUAL(nodeAttrs.m_status, TNodeStatus::NotDownloaded, ());
TEST_EQUAL(nodeAttrs.m_error, TErrNodeStatus::NoError, ());
storage.GetNodeAttrs("Algeria", nodeAttrs);
TEST_EQUAL(nodeAttrs.m_mwmCounter, 2, ());
TEST_EQUAL(nodeAttrs.m_mwmSize, 90878678, ());
TEST_EQUAL(nodeAttrs.m_status, TStatus::ENotDownloaded, ());
TEST_EQUAL(nodeAttrs.m_status, TNodeStatus::NotDownloaded, ());
TEST_EQUAL(nodeAttrs.m_error, TErrNodeStatus::NoError, ());
storage.GetNodeAttrs("South Korea_South", nodeAttrs);
TEST_EQUAL(nodeAttrs.m_mwmCounter, 1, ());
TEST_EQUAL(nodeAttrs.m_mwmSize, 48394664, ());
TEST_EQUAL(nodeAttrs.m_status, TStatus::ENotDownloaded, ());
TEST_EQUAL(nodeAttrs.m_status, TNodeStatus::NotDownloaded, ());
TEST_EQUAL(nodeAttrs.m_error, TErrNodeStatus::NoError, ());
}
UNIT_TEST(StorageTest_ParseStatus)
{
TEST_EQUAL(TStatusAndError(TNodeStatus::Undefined, TErrNodeStatus::NoError),
ParseStatus(TStatus::EUndefined), ());
TEST_EQUAL(TStatusAndError(TNodeStatus::Error, TErrNodeStatus::NoInetConnection),
ParseStatus(TStatus::EDownloadFailed), ());
TEST_EQUAL(TStatusAndError(TNodeStatus::Downloading, TErrNodeStatus::NoError),
ParseStatus(TStatus::EDownloading), ());
}
} // namespace storage