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

Unified Diff: test/ConsoleJsObject.cpp

Issue 10310030: Convert references to FileSystem & Co. into shared pointers (avoid use after free) (Closed)
Patch Set: Created April 18, 2013, 11:59 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: test/ConsoleJsObject.cpp
===================================================================
--- a/test/ConsoleJsObject.cpp
+++ b/test/ConsoleJsObject.cpp
@@ -9,27 +9,29 @@ public:
void operator()(const std::string& message)
{
lastMessage = message;
}
};
TEST(ConsoleJsObjectTest, ErrorInvokesErrorCallback)
{
- MockErrorCallback errorCallback;
- AdblockPlus::JsEngine jsEngine(AdblockPlus::AppInfo(), 0, 0, &errorCallback);
+ AdblockPlus::JsEngine jsEngine;
+ MockErrorCallback* errorCallback = new MockErrorCallback();
+ jsEngine.SetErrorCallback(AdblockPlus::ErrorCallbackPtr(errorCallback));
jsEngine.Evaluate("console.error('foo')");
- ASSERT_EQ("foo", errorCallback.lastMessage);
+ ASSERT_EQ("foo", errorCallback->lastMessage);
}
TEST(ConsoleJsObjectTest, ErrorWithMultipleArguments)
{
- MockErrorCallback errorCallback;
- AdblockPlus::JsEngine jsEngine(AdblockPlus::AppInfo(), 0, 0, &errorCallback);
+ AdblockPlus::JsEngine jsEngine;
+ MockErrorCallback* errorCallback = new MockErrorCallback();
+ jsEngine.SetErrorCallback(AdblockPlus::ErrorCallbackPtr(errorCallback));
jsEngine.Evaluate("console.error('foo', 'bar')");
- ASSERT_EQ("foobar", errorCallback.lastMessage);
+ ASSERT_EQ("foobar", errorCallback->lastMessage);
}
TEST(ConsoleJsObjectTest, TraceDoesNothing)
{
- AdblockPlus::JsEngine jsEngine(AdblockPlus::AppInfo(), 0, 0, 0);
+ AdblockPlus::JsEngine jsEngine;
jsEngine.Evaluate("console.trace()");
}
« src/JsEngine.cpp ('K') | « test/AppInfoJsObject.cpp ('k') | test/FileSystemJsObject.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld