From aee56b879d0039befcd748a12621646f420aca3f Mon Sep 17 00:00:00 2001 From: Vladimir Byko-Ianko Date: Thu, 4 Feb 2016 15:56:05 +0300 Subject: [PATCH] [new downloader] Fixing and adding tests. --- .../storage_downloading_tests.cpp | 4 ++-- .../storage_group_download_tests.cpp | 12 ++++++------ .../storage_update_tests.cpp | 10 +++++----- storage/storage_tests/storage_tests.cpp | 19 +++++++++++++++---- 4 files changed, 28 insertions(+), 17 deletions(-) diff --git a/storage/storage_integration_tests/storage_downloading_tests.cpp b/storage/storage_integration_tests/storage_downloading_tests.cpp index 2f906e2530..1eb3cb7cb7 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(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, ()); } diff --git a/storage/storage_integration_tests/storage_group_download_tests.cpp b/storage/storage_integration_tests/storage_group_download_tests.cpp index ad6f1e781c..d3b55056b7 100644 --- a/storage/storage_integration_tests/storage_group_download_tests.cpp +++ b/storage/storage_integration_tests/storage_group_download_tests.cpp @@ -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 diff --git a/storage/storage_integration_tests/storage_update_tests.cpp b/storage/storage_integration_tests/storage_update_tests.cpp index d80c6c7a1e..920ed98a99 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(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 diff --git a/storage/storage_tests/storage_tests.cpp b/storage/storage_tests/storage_tests.cpp index 06641511fe..f93ce7a950 100644 --- a/storage/storage_tests/storage_tests.cpp +++ b/storage/storage_tests/storage_tests.cpp @@ -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