diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-01-07 20:30:03 +0200 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-01-07 20:54:01 +0200 |
commit | c8a39e1587272b2d9619bd157cf21fea31a4d86e (patch) | |
tree | 635b3a6c59e161b11912aa8ef906aabcb8db8f34 /test | |
parent | 0ef257bfc623b1c68eeb9a60dad9c8dd18a7befb (diff) | |
download | qtlocation-mapboxgl-c8a39e1587272b2d9619bd157cf21fea31a4d86e.tar.gz |
[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.
Diffstat (limited to 'test')
-rw-r--r-- | test/storage/cache_size.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/test/storage/cache_size.cpp b/test/storage/cache_size.cpp index 87f033e71c..f94c52d234 100644 --- a/test/storage/cache_size.cpp +++ b/test/storage/cache_size.cpp @@ -6,12 +6,11 @@ #include <mbgl/util/run_loop.hpp> #include <mbgl/util/string.hpp> #include <mbgl/util/time.hpp> +#include <mbgl/util/timer.hpp> #include <memory> #include <random> -#include <unistd.h> - 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)); |