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

Side by Side Diff: test/GlobalJsObject.cpp

Issue 10085006: Implement setTimeout (Closed)
Patch Set: Created April 5, 2013, 3:49 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« src/JsEngine.cpp ('K') | « src/JsEngine.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 #include <AdblockPlus.h>
2 #include <gtest/gtest.h>
3
4 #include "../src/Thread.h"
5
6 TEST(GlobalJsObjectTest, SetTimeout)
7 {
8 AdblockPlus::JsEngine jsEngine(0, 0);
9 jsEngine.Evaluate("setTimeout(function() {foo = 'bar';}, 100)");
10 ASSERT_EQ("", jsEngine.GetGlobal("foo"));
11 AdblockPlus::Sleep(200);
12 ASSERT_EQ("bar", jsEngine.GetGlobal("foo"));
13 }
14
15 TEST(GlobalJsObjectTest, SetTimeoutWithArgs)
16 {
17 AdblockPlus::JsEngine jsEngine(0, 0);
18 jsEngine.Evaluate("setTimeout(function(s) {foo = s;}, 100, 'foobar')");
19 ASSERT_EQ("", jsEngine.GetGlobal("foo"));
20 AdblockPlus::Sleep(200);
21 ASSERT_EQ("foobar", jsEngine.GetGlobal("foo"));
22 }
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.
OLDNEW
« src/JsEngine.cpp ('K') | « src/JsEngine.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld