Index: test/JsEngine.cpp |
=================================================================== |
--- a/test/JsEngine.cpp |
+++ b/test/JsEngine.cpp |
@@ -20,19 +20,21 @@ |
namespace |
{ |
class JsEngineTest : public BaseJsTest |
{ |
}; |
bool callbackCalled = false; |
- void Callback() |
+ AdblockPlus::JsValueList callbackParams; |
+ void Callback(AdblockPlus::JsValueList& params) |
{ |
callbackCalled = true; |
+ callbackParams = params; |
} |
} |
TEST_F(JsEngineTest, Evaluate) |
{ |
jsEngine->Evaluate("function hello() { return 'Hello'; }"); |
AdblockPlus::JsValuePtr result = jsEngine->Evaluate("hello()"); |
ASSERT_TRUE(result->IsString()); |
@@ -75,18 +77,22 @@ TEST_F(JsEngineTest, EventCallbacks) |
// Trigger event without a callback |
callbackCalled = false; |
jsEngine->Evaluate("_triggerEvent('foobar')"); |
ASSERT_FALSE(callbackCalled); |
// Set callback |
jsEngine->SetEventCallback("foobar", Callback); |
callbackCalled = false; |
- jsEngine->Evaluate("_triggerEvent('foobar')"); |
+ jsEngine->Evaluate("_triggerEvent('foobar', 1, 'x', true)"); |
ASSERT_TRUE(callbackCalled); |
+ ASSERT_EQ(callbackParams.size(), 3u); |
+ ASSERT_EQ(callbackParams[0]->AsInt(), 1); |
+ ASSERT_EQ(callbackParams[1]->AsString(), "x"); |
+ ASSERT_TRUE(callbackParams[2]->AsBool()); |
// Trigger a different event |
callbackCalled = false; |
jsEngine->Evaluate("_triggerEvent('barfoo')"); |
ASSERT_FALSE(callbackCalled); |
// Remove callback |
jsEngine->RemoveEventCallback("foobar"); |