From c8a39e1587272b2d9619bd157cf21fea31a4d86e Mon Sep 17 00:00:00 2001 From: "Thiago Marcos P. Santos" Date: Thu, 7 Jan 2016 20:30:03 +0200 Subject: [PATCH] [tests] Sleep more than 1s before refreshing accessed time The cache `accessed` field resolution is 1s, so we need to sleep a little bit more in order to make sure that the cache entries we are refreshing will have a different `accessed` time than the other entries. --- test/storage/cache_size.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/test/storage/cache_size.cpp b/test/storage/cache_size.cpp index 87f033e71..f94c52d23 100644 --- a/test/storage/cache_size.cpp +++ b/test/storage/cache_size.cpp @@ -6,12 +6,11 @@ #include #include #include +#include #include #include -#include - bool tileIsCached(mbgl::SQLiteCache* cache, unsigned id) { using namespace mbgl; @@ -184,7 +183,16 @@ TEST_F(Storage, CacheSizePruneLeastAccessed) { // entry, that should update the // `accessed` time, so it won't get // pruned when we need more space. - sleep(1); + bool done = false; + + util::Timer timer; + timer.start(std::chrono::milliseconds(1300), + Duration::zero(), + [&done] { done = true; }); + + while (!done) { + loop.runOnce(); + } EXPECT_TRUE(tileIsCached(&cache, 7));