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

Side by Side Diff: test/FileSystemJsObject.cpp

Issue 10488022: Added Android build target (Closed)
Patch Set: Review comments addressed Created May 24, 2013, 8:40 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
« no previous file with comments | « test/DefaultFileSystem.cpp ('k') | third_party/v8_gyp_launcher » ('j') | 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 <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2013 Eyeo GmbH 3 * Copyright (C) 2006-2013 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 #include <sstream>
18 #include "BaseJsTest.h" 19 #include "BaseJsTest.h"
19 #include "../src/Thread.h" 20 #include "../src/Thread.h"
20 #include "../src/Utils.h"
21 21
22 namespace 22 namespace
23 { 23 {
24 class MockFileSystem : public AdblockPlus::FileSystem 24 class MockFileSystem : public AdblockPlus::FileSystem
25 { 25 {
26 public: 26 public:
27 bool success; 27 bool success;
28 std::string contentToRead; 28 std::string contentToRead;
29 std::string lastWrittenPath; 29 std::string lastWrittenPath;
30 std::string lastWrittenContent; 30 std::string lastWrittenContent;
(...skipping 17 matching lines...) Expand all
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::tr1::shared_ptr<std::istream>(stream); 50 return std::tr1::shared_ptr<std::istream>(stream);
51 } 51 }
52 52
53 void Write(const std::string& path, std::tr1::shared_ptr<std::ostream> data) 53 void Write(const std::string& path, std::tr1::shared_ptr<std::ostream> data)
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 lastWrittenContent = AdblockPlus::Utils::Slurp(*data); 58
59 std::stringstream content;
60 content << data->rdbuf();
61 lastWrittenContent = content.str();
59 } 62 }
60 63
61 void Move(const std::string& fromPath, const std::string& toPath) 64 void Move(const std::string& fromPath, const std::string& toPath)
62 { 65 {
63 if (!success) 66 if (!success)
64 throw std::runtime_error("Unable to move " + fromPath + " to " 67 throw std::runtime_error("Unable to move " + fromPath + " to "
65 + toPath); 68 + toPath);
66 movedFrom = fromPath; 69 movedFrom = fromPath;
67 movedTo = toPath; 70 movedTo = toPath;
68 } 71 }
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat('', '')")); 239 ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat('', '')"));
237 } 240 }
238 241
239 TEST_F(FileSystemJsObjectTest, StatError) 242 TEST_F(FileSystemJsObjectTest, StatError)
240 { 243 {
241 mockFileSystem->success = false; 244 mockFileSystem->success = false;
242 jsEngine->Evaluate("_fileSystem.stat('foo', function(r) {result = r})"); 245 jsEngine->Evaluate("_fileSystem.stat('foo', function(r) {result = r})");
243 AdblockPlus::Sleep(50); 246 AdblockPlus::Sleep(50);
244 ASSERT_NE("", jsEngine->Evaluate("result.error")->AsString()); 247 ASSERT_NE("", jsEngine->Evaluate("result.error")->AsString());
245 } 248 }
OLDNEW
« no previous file with comments | « test/DefaultFileSystem.cpp ('k') | third_party/v8_gyp_launcher » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld