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

Side by Side Diff: test/FileSystemJsObject.cpp

Issue 10369004: File system path resolving (Closed)
Patch Set: Comments addressed Created April 30, 2013, 8:09 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/BaseJsTest.h ('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 #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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 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
80 }; 86 };
81 87
82 void ReadFile(AdblockPlus::JsEnginePtr jsEngine, std::string& content, 88 void ReadFile(AdblockPlus::JsEnginePtr jsEngine, std::string& content,
83 std::string& error) 89 std::string& error)
84 { 90 {
85 jsEngine->Evaluate("_fileSystem.read('', function(r) {result = r})"); 91 jsEngine->Evaluate("_fileSystem.read('', function(r) {result = r})");
86 AdblockPlus::Sleep(50); 92 AdblockPlus::Sleep(50);
87 content = jsEngine->Evaluate("result.content")->AsString(); 93 content = jsEngine->Evaluate("result.content")->AsString();
88 error = jsEngine->Evaluate("result.error")->AsString(); 94 error = jsEngine->Evaluate("result.error")->AsString();
89 } 95 }
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat('', '')")); 226 ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat('', '')"));
221 } 227 }
222 228
223 TEST_F(FileSystemJsObjectTest, StatError) 229 TEST_F(FileSystemJsObjectTest, StatError)
224 { 230 {
225 mockFileSystem->success = false; 231 mockFileSystem->success = false;
226 jsEngine->Evaluate("_fileSystem.stat('foo', function(r) {result = r})"); 232 jsEngine->Evaluate("_fileSystem.stat('foo', function(r) {result = r})");
227 AdblockPlus::Sleep(50); 233 AdblockPlus::Sleep(50);
228 ASSERT_NE("", jsEngine->Evaluate("result.error")->AsString()); 234 ASSERT_NE("", jsEngine->Evaluate("result.error")->AsString());
229 } 235 }
OLDNEW
« test/BaseJsTest.h ('K') | « test/BaseJsTest.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld