| Index: test/Prefs.cpp |
| diff --git a/test/Prefs.cpp b/test/Prefs.cpp |
| index 6a3c1de9e5280ec68b0e0c75456db17edbeb7546..50e48de939ef17c53b348d4381791c8de1449a26 100644 |
| --- a/test/Prefs.cpp |
| +++ b/test/Prefs.cpp |
| @@ -31,32 +31,46 @@ namespace |
| public: |
| IOBuffer prefsContents; |
| - IOBuffer Read(const std::string& path) const |
| + void Read(const std::string& path, const ReadCallback& callback) const override |
| { |
| - if (path == "prefs.json" && !prefsContents.empty()) |
| - return prefsContents; |
| - |
| - return LazyFileSystem::Read(path); |
| + scheduler([this, path, callback] |
| + { |
| + if (path == "prefs.json" && !prefsContents.empty()) |
| + { |
| + callback(IOBuffer(prefsContents.cbegin(), prefsContents.cend()), ""); |
| + return; |
| + } |
| + |
| + LazyFileSystem::Read(path, callback); |
| + }); |
| } |
| - void Write(const std::string& path, const IOBuffer& content) |
| + void Write(const std::string& path, const IOBuffer& content, const Callback& callback) override |
| { |
| - if (path == "prefs.json") |
| - prefsContents = content; |
| - else |
| - LazyFileSystem::Write(path, content); |
| + scheduler([this, path, content, callback] |
| + { |
| + if (path == "prefs.json") |
| + { |
| + prefsContents = content; |
| + callback(""); |
| + } |
| + }); |
| } |
| - StatResult Stat(const std::string& path) const |
| + void Stat(const std::string& path, const StatCallback& callback) const override |
| { |
| - if (path == "prefs.json") |
| + scheduler([this, path, callback] |
| { |
| - StatResult result; |
| - result.exists = result.isFile = !prefsContents.empty(); |
| - return result; |
| - } |
| - |
| - return LazyFileSystem::Stat(path); |
| + if (path == "prefs.json") |
| + { |
| + StatResult result; |
| + result.exists = result.isFile = !prefsContents.empty(); |
| + callback(result, ""); |
| + return; |
| + } |
| + |
| + LazyFileSystem::Stat(path, callback); |
| + }); |
| } |
| }; |
| @@ -87,7 +101,7 @@ namespace |
| { |
| AdblockPlus::FilterEngine::CreationParameters createParams; |
| createParams.preconfiguredPrefs = preconfiguredPrefs; |
| - return AdblockPlus::FilterEngine::Create(jsEngine, createParams); |
| + return ::CreateFilterEngine(*fileSystem, jsEngine, createParams); |
| } |
| }; |
| } |
| @@ -124,8 +138,6 @@ TEST_F(PrefsTest, PrefsPersist) |
| filterEngine->SetPref("patternsfile", jsEngine->NewValue("filters.ini")); |
| filterEngine->SetPref("patternsbackupinterval", jsEngine->NewValue(48)); |
| filterEngine->SetPref("subscriptions_autoupdate", jsEngine->NewValue(false)); |
| - |
| - AdblockPlus::Sleep(100); |
| } |
| ASSERT_FALSE(fileSystem->prefsContents.empty()); |
| @@ -201,8 +213,6 @@ TEST_F(PrefsTest, PrefsPersistWhenPreconfigured) |
| ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").IsBool()); |
| ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").AsBool()); |
| filterEngine->SetPref("suppress_first_run_page", jsEngine->NewValue(false)); |
| - |
| - AdblockPlus::Sleep(100); |
| } |
| ASSERT_FALSE(fileSystem->prefsContents.empty()); |