Index: test/FileSystemJsObject.cpp |
=================================================================== |
--- a/test/FileSystemJsObject.cpp |
+++ b/test/FileSystemJsObject.cpp |
@@ -73,18 +73,18 @@ namespace |
} |
}; |
void ReadFile(AdblockPlus::JsEngine& jsEngine, std::string& content, |
std::string& error) |
{ |
jsEngine.Evaluate("_fileSystem.read('', function(r) {result = r})"); |
AdblockPlus::Sleep(10); |
- content = jsEngine.Evaluate("result.content"); |
- error = jsEngine.Evaluate("result.error"); |
+ content = jsEngine.Evaluate("result.content")->AsString(); |
+ error = jsEngine.Evaluate("result.error")->AsString(); |
} |
} |
TEST(FileSystemJsObjectTest, Read) |
{ |
MockFileSystem fileSystem; |
fileSystem.contentToRead = "foo"; |
AdblockPlus::JsEngine jsEngine(&fileSystem, 0, 0); |
@@ -117,117 +117,117 @@ TEST(FileSystemJsObjectTest, ReadError) |
TEST(FileSystemJsObjectTest, Write) |
{ |
MockFileSystem fileSystem; |
AdblockPlus::JsEngine jsEngine(&fileSystem, 0, 0); |
jsEngine.Evaluate("_fileSystem.write('foo', 'bar', function(e) {error = e})"); |
AdblockPlus::Sleep(10); |
ASSERT_EQ("foo", fileSystem.lastWrittenPath); |
ASSERT_EQ("bar", fileSystem.lastWrittenContent); |
- ASSERT_EQ("", jsEngine.Evaluate("error")); |
+ ASSERT_EQ("", jsEngine.Evaluate("error")->AsString()); |
} |
TEST(FileSystemJsObjectTest, WriteIllegalArguments) |
{ |
AdblockPlus::JsEngine jsEngine(0, 0, 0); |
ASSERT_ANY_THROW(jsEngine.Evaluate("_fileSystem.write()")); |
ASSERT_ANY_THROW(jsEngine.Evaluate("_fileSystem.write('', '', '')")); |
} |
TEST(FileSystemJsObjectTest, WriteError) |
{ |
MockFileSystem fileSystem; |
fileSystem.success = false; |
AdblockPlus::JsEngine jsEngine(&fileSystem, 0, 0); |
jsEngine.Evaluate("_fileSystem.write('foo', 'bar', function(e) {error = e})"); |
AdblockPlus::Sleep(10); |
- ASSERT_NE("", jsEngine.Evaluate("error")); |
+ ASSERT_NE("", jsEngine.Evaluate("error")->AsString()); |
} |
TEST(FileSystemJsObjectTest, Move) |
{ |
MockFileSystem fileSystem; |
AdblockPlus::JsEngine jsEngine(&fileSystem, 0, 0); |
jsEngine.Evaluate("_fileSystem.move('foo', 'bar', function(e) {error = e})"); |
AdblockPlus::Sleep(10); |
ASSERT_EQ("foo", fileSystem.movedFrom); |
ASSERT_EQ("bar", fileSystem.movedTo); |
- ASSERT_EQ("", jsEngine.Evaluate("error")); |
+ ASSERT_EQ("", jsEngine.Evaluate("error")->AsString()); |
} |
TEST(FileSystemJsObjectTest, MoveIllegalArguments) |
{ |
AdblockPlus::JsEngine jsEngine(0, 0, 0); |
ASSERT_ANY_THROW(jsEngine.Evaluate("_fileSystem.move()")); |
ASSERT_ANY_THROW(jsEngine.Evaluate("_fileSystem.move('', '', '')")); |
} |
TEST(FileSystemJsObjectTest, MoveError) |
{ |
MockFileSystem fileSystem; |
fileSystem.success = false; |
AdblockPlus::JsEngine jsEngine(&fileSystem, 0, 0); |
jsEngine.Evaluate("_fileSystem.move('foo', 'bar', function(e) {error = e})"); |
AdblockPlus::Sleep(10); |
- ASSERT_NE("", jsEngine.Evaluate("error")); |
+ ASSERT_NE("", jsEngine.Evaluate("error")->AsString()); |
} |
TEST(FileSystemJsObjectTest, Remove) |
{ |
MockFileSystem fileSystem; |
AdblockPlus::JsEngine jsEngine(&fileSystem, 0, 0); |
jsEngine.Evaluate("_fileSystem.remove('foo', function(e) {error = e})"); |
AdblockPlus::Sleep(10); |
ASSERT_EQ("foo", fileSystem.removedPath); |
- ASSERT_EQ("", jsEngine.Evaluate("error")); |
+ ASSERT_EQ("", jsEngine.Evaluate("error")->AsString()); |
} |
TEST(FileSystemJsObjectTest, RemoveIllegalArguments) |
{ |
AdblockPlus::JsEngine jsEngine(0, 0, 0); |
ASSERT_ANY_THROW(jsEngine.Evaluate("_fileSystem.remove()")); |
ASSERT_ANY_THROW(jsEngine.Evaluate("_fileSystem.remove('', '')")); |
} |
TEST(FileSystemJsObjectTest, RemoveError) |
{ |
MockFileSystem fileSystem; |
fileSystem.success = false; |
AdblockPlus::JsEngine jsEngine(&fileSystem, 0, 0); |
jsEngine.Evaluate("_fileSystem.remove('foo', function(e) {error = e})"); |
AdblockPlus::Sleep(10); |
- ASSERT_NE("", jsEngine.Evaluate("error")); |
+ ASSERT_NE("", jsEngine.Evaluate("error")->AsString()); |
} |
TEST(FileSystemJsObjectTest, Stat) |
{ |
MockFileSystem fileSystem; |
fileSystem.statExists = true; |
fileSystem.statIsDirectory= false; |
fileSystem.statIsFile = true; |
fileSystem.statLastModified = 1337; |
AdblockPlus::JsEngine jsEngine(&fileSystem, 0, 0); |
jsEngine.Evaluate("_fileSystem.stat('foo', function(r) {result = r})"); |
AdblockPlus::Sleep(10); |
ASSERT_EQ("foo", fileSystem.statPath); |
- ASSERT_EQ("", jsEngine.Evaluate("result.error")); |
- ASSERT_EQ("true", jsEngine.Evaluate("result.exists")); |
- ASSERT_EQ("false", jsEngine.Evaluate("result.isDirectory")); |
- ASSERT_EQ("true", jsEngine.Evaluate("result.isFile")); |
- ASSERT_EQ("1337", jsEngine.Evaluate("result.lastModified")); |
+ ASSERT_EQ("", jsEngine.Evaluate("result.error")->AsString()); |
+ ASSERT_TRUE(jsEngine.Evaluate("result.exists")->AsBool()); |
+ ASSERT_FALSE(jsEngine.Evaluate("result.isDirectory")->AsBool()); |
+ ASSERT_TRUE(jsEngine.Evaluate("result.isFile")->AsBool()); |
+ ASSERT_EQ(1337, jsEngine.Evaluate("result.lastModified")->AsInt()); |
} |
TEST(FileSystemJsObjectTest, StatIllegalArguments) |
{ |
AdblockPlus::JsEngine jsEngine(0, 0, 0); |
ASSERT_ANY_THROW(jsEngine.Evaluate("_fileSystem.stat()")); |
ASSERT_ANY_THROW(jsEngine.Evaluate("_fileSystem.stat('', '')")); |
} |
TEST(FileSystemJsObjectTest, StatError) |
{ |
MockFileSystem fileSystem; |
fileSystem.success = false; |
AdblockPlus::JsEngine jsEngine(&fileSystem, 0, 0); |
jsEngine.Evaluate("_fileSystem.stat('foo', function(r) {result = r})"); |
AdblockPlus::Sleep(10); |
- ASSERT_NE("", jsEngine.Evaluate("result.error")); |
+ ASSERT_NE("", jsEngine.Evaluate("result.error")->AsString()); |
} |