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

Side by Side Diff: test/FileSystemJsObject.cpp

Issue 29409580: Issue 5013 - Make parameter const ref when applicable. (Closed) Base URL: https://hg.adblockplus.org/libadblockplus/
Patch Set: Created April 11, 2017, 1:58 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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 43
44 std::shared_ptr<std::istream> Read(const std::string& path) const 44 std::shared_ptr<std::istream> Read(const std::string& path) const
45 { 45 {
46 if (!success) 46 if (!success)
47 throw std::runtime_error("Unable to read " + path); 47 throw std::runtime_error("Unable to read " + path);
48 std::stringstream* const stream = new std::stringstream; 48 std::stringstream* const stream = new std::stringstream;
49 *stream << contentToRead; 49 *stream << contentToRead;
50 return std::shared_ptr<std::istream>(stream); 50 return std::shared_ptr<std::istream>(stream);
51 } 51 }
52 52
53 void Write(const std::string& path, std::shared_ptr<std::istream> data) 53 void Write(const std::string& path, const std::shared_ptr<std::istream>& dat a)
54 { 54 {
55 if (!success) 55 if (!success)
56 throw std::runtime_error("Unable to write to " + path); 56 throw std::runtime_error("Unable to write to " + path);
57 lastWrittenPath = path; 57 lastWrittenPath = path;
58 58
59 std::stringstream content; 59 std::stringstream content;
60 content << data->rdbuf(); 60 content << data->rdbuf();
61 lastWrittenContent = content.str(); 61 lastWrittenContent = content.str();
62 } 62 }
63 63
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
239 ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat('', '')")); 239 ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat('', '')"));
240 } 240 }
241 241
242 TEST_F(FileSystemJsObjectTest, StatError) 242 TEST_F(FileSystemJsObjectTest, StatError)
243 { 243 {
244 mockFileSystem->success = false; 244 mockFileSystem->success = false;
245 jsEngine->Evaluate("_fileSystem.stat('foo', function(r) {result = r})"); 245 jsEngine->Evaluate("_fileSystem.stat('foo', function(r) {result = r})");
246 AdblockPlus::Sleep(50); 246 AdblockPlus::Sleep(50);
247 ASSERT_NE("", jsEngine->Evaluate("result.error")->AsString()); 247 ASSERT_NE("", jsEngine->Evaluate("result.error")->AsString());
248 } 248 }
OLDNEW
« src/Utils.cpp ('K') | « test/BaseJsTest.h ('k') | test/Prefs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld