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

Side by Side Diff: test/Prefs.cpp

Issue 29449592: Issue 5183 - Provide async interface for FileSystem (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Make read write deal with binary buffers. Created July 6, 2017, 12:19 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« src/JsValue.cpp ('K') | « test/JsEngine.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-2017 eyeo GmbH 3 * Copyright (C) 2006-2017 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 21 matching lines...) Expand all
32 std::string prefsContents; 32 std::string prefsContents;
33 33
34 std::shared_ptr<std::istream> Read(const std::string& path) const 34 std::shared_ptr<std::istream> Read(const std::string& path) const
35 { 35 {
36 if (path == "prefs.json" && !prefsContents.empty()) 36 if (path == "prefs.json" && !prefsContents.empty())
37 return std::shared_ptr<std::istream>(new std::istringstream(prefsContent s)); 37 return std::shared_ptr<std::istream>(new std::istringstream(prefsContent s));
38 38
39 return LazyFileSystem::Read(path); 39 return LazyFileSystem::Read(path);
40 } 40 }
41 41
42 void Write(const std::string& path, std::istream& content) 42 void Write(const std::string& path, std::ostream& content)
43 { 43 {
44 if (path == "prefs.json") 44 if (path == "prefs.json")
45 { 45 {
46 std::stringstream ss; 46 std::stringstream ss;
47 ss << content.rdbuf(); 47 ss << content.rdbuf();
48 prefsContents = ss.str(); 48 prefsContents = ss.str();
49 } 49 }
50 else 50 else
51 LazyFileSystem::Write(path, content); 51 LazyFileSystem::Write(path, content);
52 } 52 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 { 209 {
210 ResetJsEngine(); 210 ResetJsEngine();
211 AdblockPlus::FilterEngine::Prefs preconfiguredPrefs; 211 AdblockPlus::FilterEngine::Prefs preconfiguredPrefs;
212 preconfiguredPrefs.emplace("suppress_first_run_page", jsEngine->NewValue(tru e)); 212 preconfiguredPrefs.emplace("suppress_first_run_page", jsEngine->NewValue(tru e));
213 auto filterEngine = CreateFilterEngine(preconfiguredPrefs); 213 auto filterEngine = CreateFilterEngine(preconfiguredPrefs);
214 214
215 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").IsBool()); 215 ASSERT_TRUE(filterEngine->GetPref("suppress_first_run_page").IsBool());
216 ASSERT_FALSE(filterEngine->GetPref("suppress_first_run_page").AsBool()); 216 ASSERT_FALSE(filterEngine->GetPref("suppress_first_run_page").AsBool());
217 } 217 }
218 } 218 }
OLDNEW
« src/JsValue.cpp ('K') | « test/JsEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld