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

Side by Side Diff: test/Prefs.cpp

Issue 29731562: Issue 6477 - separate done and error callbacks in IFileSystem::Read (Closed) Base URL: https://github.com/adblockplus/libadblockplus.git@c0a6434596a83383e37678ef3b6ecef00ed6a261
Patch Set: Created March 23, 2018, 10:58 a.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« test/BaseJsTest.h ('K') | « test/FileSystemJsObject.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-present eyeo GmbH 3 * Copyright (C) 2006-present eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 14 matching lines...) Expand all
25 namespace 25 namespace
26 { 26 {
27 class TestFileSystem : public LazyFileSystem 27 class TestFileSystem : public LazyFileSystem
28 { 28 {
29 IOBuffer& prefsContents; 29 IOBuffer& prefsContents;
30 public: 30 public:
31 explicit TestFileSystem(IOBuffer& prefsContent) 31 explicit TestFileSystem(IOBuffer& prefsContent)
32 : prefsContents(prefsContent) 32 : prefsContents(prefsContent)
33 { 33 {
34 } 34 }
35 void Read(const std::string& fileName, const ReadCallback& callback) const o verride 35 void Read(const std::string& fileName, const ReadCallback& callback, const C allback& errorCallback) const override
36 { 36 {
37 scheduler([this, fileName, callback] 37 scheduler([this, fileName, callback, errorCallback]
38 { 38 {
39 if (fileName == "prefs.json" && !prefsContents.empty()) 39 if (fileName == "prefs.json" && !prefsContents.empty())
40 { 40 {
41 callback(IOBuffer(prefsContents.cbegin(), prefsContents.cend()), ""); 41 callback(IOBuffer(prefsContents.cbegin(), prefsContents.cend()));
42 return; 42 return;
43 } 43 }
44 44 LazyFileSystem::Read(fileName, callback, errorCallback);
45 LazyFileSystem::Read(fileName, callback);
46 }); 45 });
47 } 46 }
48 47
49 void Write(const std::string& fileName, const IOBuffer& content, const Callb ack& callback) override 48 void Write(const std::string& fileName, const IOBuffer& content, const Callb ack& callback) override
50 { 49 {
51 scheduler([this, fileName, content, callback] 50 scheduler([this, fileName, content, callback]
52 { 51 {
53 if (fileName == "prefs.json") 52 if (fileName == "prefs.json")
54 { 53 {
55 prefsContents = content; 54 prefsContents = content;
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 { 209 {
211 ResetPlatform(); 210 ResetPlatform();
212 AdblockPlus::FilterEngine::Prefs preconfiguredPrefs; 211 AdblockPlus::FilterEngine::Prefs preconfiguredPrefs;
213 preconfiguredPrefs.emplace("suppress_first_run_page", GetJsEngine().NewValue (true)); 212 preconfiguredPrefs.emplace("suppress_first_run_page", GetJsEngine().NewValue (true));
214 auto& filterEngine = CreateFilterEngine(preconfiguredPrefs); 213 auto& filterEngine = CreateFilterEngine(preconfiguredPrefs);
215 214
216 ASSERT_TRUE(filterEngine.GetPref("suppress_first_run_page").IsBool()); 215 ASSERT_TRUE(filterEngine.GetPref("suppress_first_run_page").IsBool());
217 ASSERT_FALSE(filterEngine.GetPref("suppress_first_run_page").AsBool()); 216 ASSERT_FALSE(filterEngine.GetPref("suppress_first_run_page").AsBool());
218 } 217 }
219 } 218 }
OLDNEW
« test/BaseJsTest.h ('K') | « test/FileSystemJsObject.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld