Index: test/FileSystemJsObject.cpp |
=================================================================== |
--- a/test/FileSystemJsObject.cpp |
+++ b/test/FileSystemJsObject.cpp |
@@ -98,18 +98,18 @@ |
} |
}; |
void ReadFile(AdblockPlus::JsEnginePtr jsEngine, std::string& content, |
std::string& error) |
{ |
jsEngine->Evaluate("_fileSystem.read('', function(r) {result = r})"); |
AdblockPlus::Sleep(50); |
- content = jsEngine->Evaluate("result.content")->AsString(); |
- error = jsEngine->Evaluate("result.error")->AsString(); |
+ content = jsEngine->Evaluate("result.content").AsString(); |
+ error = jsEngine->Evaluate("result.error").AsString(); |
} |
typedef std::shared_ptr<MockFileSystem> MockFileSystemPtr; |
class FileSystemJsObjectTest : public BaseJsTest |
{ |
protected: |
MockFileSystemPtr mockFileSystem; |
@@ -150,99 +150,99 @@ |
} |
TEST_F(FileSystemJsObjectTest, Write) |
{ |
jsEngine->Evaluate("_fileSystem.write('foo', 'bar', function(e) {error = e})"); |
AdblockPlus::Sleep(50); |
ASSERT_EQ("foo", mockFileSystem->lastWrittenPath); |
ASSERT_EQ("bar", mockFileSystem->lastWrittenContent); |
- ASSERT_EQ("", jsEngine->Evaluate("error")->AsString()); |
+ ASSERT_EQ("", jsEngine->Evaluate("error").AsString()); |
} |
TEST_F(FileSystemJsObjectTest, WriteIllegalArguments) |
{ |
ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.write()")); |
ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.write('', '', '')")); |
} |
TEST_F(FileSystemJsObjectTest, WriteError) |
{ |
mockFileSystem->success = false; |
jsEngine->Evaluate("_fileSystem.write('foo', 'bar', function(e) {error = e})"); |
AdblockPlus::Sleep(50); |
- ASSERT_NE("", jsEngine->Evaluate("error")->AsString()); |
+ ASSERT_NE("", jsEngine->Evaluate("error").AsString()); |
} |
TEST_F(FileSystemJsObjectTest, Move) |
{ |
jsEngine->Evaluate("_fileSystem.move('foo', 'bar', function(e) {error = e})"); |
AdblockPlus::Sleep(50); |
ASSERT_EQ("foo", mockFileSystem->movedFrom); |
ASSERT_EQ("bar", mockFileSystem->movedTo); |
- ASSERT_EQ("", jsEngine->Evaluate("error")->AsString()); |
+ ASSERT_EQ("", jsEngine->Evaluate("error").AsString()); |
} |
TEST_F(FileSystemJsObjectTest, MoveIllegalArguments) |
{ |
ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.move()")); |
ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.move('', '', '')")); |
} |
TEST_F(FileSystemJsObjectTest, MoveError) |
{ |
mockFileSystem->success = false; |
jsEngine->Evaluate("_fileSystem.move('foo', 'bar', function(e) {error = e})"); |
AdblockPlus::Sleep(50); |
- ASSERT_NE("", jsEngine->Evaluate("error")->AsString()); |
+ ASSERT_NE("", jsEngine->Evaluate("error").AsString()); |
} |
TEST_F(FileSystemJsObjectTest, Remove) |
{ |
jsEngine->Evaluate("_fileSystem.remove('foo', function(e) {error = e})"); |
AdblockPlus::Sleep(50); |
ASSERT_EQ("foo", mockFileSystem->removedPath); |
- ASSERT_EQ("", jsEngine->Evaluate("error")->AsString()); |
+ ASSERT_EQ("", jsEngine->Evaluate("error").AsString()); |
} |
TEST_F(FileSystemJsObjectTest, RemoveIllegalArguments) |
{ |
ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.remove()")); |
ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.remove('', '')")); |
} |
TEST_F(FileSystemJsObjectTest, RemoveError) |
{ |
mockFileSystem->success = false; |
jsEngine->Evaluate("_fileSystem.remove('foo', function(e) {error = e})"); |
AdblockPlus::Sleep(50); |
- ASSERT_NE("", jsEngine->Evaluate("error")->AsString()); |
+ ASSERT_NE("", jsEngine->Evaluate("error").AsString()); |
} |
TEST_F(FileSystemJsObjectTest, Stat) |
{ |
mockFileSystem->statExists = true; |
mockFileSystem->statIsDirectory= false; |
mockFileSystem->statIsFile = true; |
mockFileSystem->statLastModified = 1337; |
jsEngine->Evaluate("_fileSystem.stat('foo', function(r) {result = r})"); |
AdblockPlus::Sleep(50); |
ASSERT_EQ("foo", mockFileSystem->statPath); |
- 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()); |
+ 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_F(FileSystemJsObjectTest, StatIllegalArguments) |
{ |
ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat()")); |
ASSERT_ANY_THROW(jsEngine->Evaluate("_fileSystem.stat('', '')")); |
} |
TEST_F(FileSystemJsObjectTest, StatError) |
{ |
mockFileSystem->success = false; |
jsEngine->Evaluate("_fileSystem.stat('foo', function(r) {result = r})"); |
AdblockPlus::Sleep(50); |
- ASSERT_NE("", jsEngine->Evaluate("result.error")->AsString()); |
+ ASSERT_NE("", jsEngine->Evaluate("result.error").AsString()); |
} |