Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/FilterEngine.cpp

Issue 29372702: Issue #4826 - Use latch to replace thread-sleeping in tests
Patch Set: Created Jan. 19, 2017, 5:56 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/FilterEngine.cpp
===================================================================
--- a/test/FilterEngine.cpp
+++ b/test/FilterEngine.cpp
@@ -16,6 +16,7 @@
*/
#include "BaseJsTest.h"
+#include "JsLatch.h"
#include <thread>
#include "../src/JsEngineTransition.h"
@@ -136,9 +137,6 @@
int& timesCalled;
};
- // Workaround for https://issues.adblockplus.org/ticket/1397.
- void NoOpUpdaterCallback(const std::string&) {}
-
class FilterEngineWithFreshFolder : public ::testing::Test
{
protected:
@@ -556,13 +554,15 @@
MockUpdateAvailableCallback mockUpdateAvailableCallback(timesCalled);
filterEngine->SetUpdateAvailableCallback(mockUpdateAvailableCallback);
- filterEngine->ForceUpdateCheck(&NoOpUpdaterCallback);
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ Latch latchA(1);
+ filterEngine->ForceUpdateCheck([&](const std::string&) {latchA.Arrive(); });
+ latchA.Wait();
ASSERT_EQ(1, timesCalled);
filterEngine->RemoveUpdateAvailableCallback();
- filterEngine->ForceUpdateCheck(&NoOpUpdaterCallback);
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ Latch latchB(1);
+ filterEngine->ForceUpdateCheck([&](const std::string&) {latchB.Arrive(); });
+ latchB.Wait();
ASSERT_EQ(1, timesCalled);
}
« no previous file with comments | « test/FileSystemJsObject.cpp ('k') | test/GlobalJsObject.cpp » ('j') | test/GlobalJsObject.cpp » ('J')

Powered by Google App Engine
This is Rietveld