[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.
This commit is contained in:
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user