Index: test/GlobalJsObject.cpp |
=================================================================== |
new file mode 100644 |
--- /dev/null |
+++ b/test/GlobalJsObject.cpp |
@@ -0,0 +1,22 @@ |
+#include <AdblockPlus.h> |
+#include <gtest/gtest.h> |
+ |
+#include "../src/Thread.h" |
+ |
+TEST(GlobalJsObjectTest, SetTimeout) |
+{ |
+ AdblockPlus::JsEngine jsEngine(0, 0); |
+ jsEngine.Evaluate("setTimeout(function() {foo = 'bar';}, 100)"); |
+ ASSERT_EQ("", jsEngine.GetGlobal("foo")); |
+ AdblockPlus::Sleep(200); |
+ ASSERT_EQ("bar", jsEngine.GetGlobal("foo")); |
+} |
+ |
+TEST(GlobalJsObjectTest, SetTimeoutWithArgs) |
+{ |
+ AdblockPlus::JsEngine jsEngine(0, 0); |
+ jsEngine.Evaluate("setTimeout(function(s) {foo = s;}, 100, 'foobar')"); |
+ ASSERT_EQ("", jsEngine.GetGlobal("foo")); |
+ AdblockPlus::Sleep(200); |
+ ASSERT_EQ("foobar", jsEngine.GetGlobal("foo")); |
+} |
Wladimir Palant
2013/04/08 08:36:00
How about testing whether two timeouts execute in
Felix Dahlke
2013/04/08 13:07:49
Sure, added a test.
|