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

Delta Between Two Patch Sets: test/FileSystemJsObject.cpp

Issue 10369004: File system path resolving (Closed)
Left Patch Set: Comments addressed Created April 30, 2013, 8:09 a.m.
Right Patch Set: Addressing comments Created May 5, 2013, 10:49 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« src/DefaultFileSystem.cpp ('K') | « test/BaseJsTest.h ('k') | no next file » | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 #include "BaseJsTest.h" 1 #include "BaseJsTest.h"
2 #include "../src/Thread.h" 2 #include "../src/Thread.h"
3 #include "../src/Utils.h" 3 #include "../src/Utils.h"
4 4
5 namespace 5 namespace
6 { 6 {
7 class MockFileSystem : public AdblockPlus::FileSystem 7 class MockFileSystem : public AdblockPlus::FileSystem
8 { 8 {
9 public: 9 public:
10 bool success; 10 bool success;
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 result.lastModified = statLastModified; 69 result.lastModified = statLastModified;
70 return result; 70 return result;
71 } 71 }
72 72
73 std::string Resolve(const std::string& path) const 73 std::string Resolve(const std::string& path) const
74 { 74 {
75 if (!success) 75 if (!success)
76 throw std::runtime_error("Unable to stat " + path); 76 throw std::runtime_error("Unable to stat " + path);
77 return path; 77 return path;
78 } 78 }
79
80 void SetBasePath(const std::string& path)
81 {
82 basePath = "";
83 return;
Felix Dahlke 2013/04/30 09:14:52 I don't think this return is necessary.
84 }
85
86 }; 79 };
87 80
88 void ReadFile(AdblockPlus::JsEnginePtr jsEngine, std::string& content, 81 void ReadFile(AdblockPlus::JsEnginePtr jsEngine, std::string& content,
89 std::string& error) 82 std::string& error)
90 { 83 {
91 jsEngine->Evaluate("_fileSystem.read('', function(r) {result = r})"); 84 jsEngine->Evaluate("_fileSystem.read('', function(r) {result = r})");
92 AdblockPlus::Sleep(50); 85 AdblockPlus::Sleep(50);
93 content = jsEngine->Evaluate("result.content")->AsString(); 86 content = jsEngine->Evaluate("result.content")->AsString();
94 error = jsEngine->Evaluate("result.error")->AsString(); 87 error = jsEngine->Evaluate("result.error")->AsString();
95 } 88 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat('', '')")); 219 ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat('', '')"));
227 } 220 }
228 221
229 TEST_F(FileSystemJsObjectTest, StatError) 222 TEST_F(FileSystemJsObjectTest, StatError)
230 { 223 {
231 mockFileSystem->success = false; 224 mockFileSystem->success = false;
232 jsEngine->Evaluate("_fileSystem.stat('foo', function(r) {result = r})"); 225 jsEngine->Evaluate("_fileSystem.stat('foo', function(r) {result = r})");
233 AdblockPlus::Sleep(50); 226 AdblockPlus::Sleep(50);
234 ASSERT_NE("", jsEngine->Evaluate("result.error")->AsString()); 227 ASSERT_NE("", jsEngine->Evaluate("result.error")->AsString());
235 } 228 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld