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

Unified Diff: test/JsEngine.cpp

Issue 10862008: Automatically add default filter subscription when necessary. (Closed)
Patch Set: Created May 27, 2013, 2:12 p.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
« no previous file with comments | « test/FilterEngine.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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");
« no previous file with comments | « test/FilterEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld