mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Fix: Timer somtimes crashing in IOS
This commit is contained in:
@@ -136,4 +136,54 @@ export function test_setInterval_callbackShouldBeCleared() {
|
||||
|
||||
TKUnit.waitUntilReady(() => false, 0.5);
|
||||
TKUnit.assert(counter === 1, "Callback should be raised only once!");
|
||||
};
|
||||
};
|
||||
|
||||
export function test_clearTimeout_multipleTimes_afterTick() {
|
||||
let completed = false;
|
||||
|
||||
let id = timer.setTimeout(() => {
|
||||
completed = true;
|
||||
});
|
||||
|
||||
TKUnit.waitUntilReady(() => completed, 0.5);
|
||||
TKUnit.assert(completed, "Callback should be called");
|
||||
|
||||
timer.clearTimeout(id);
|
||||
timer.clearTimeout(id);
|
||||
}
|
||||
|
||||
export function test_clearTimeout_immediatelyAfterCreate() {
|
||||
let completed = false;
|
||||
|
||||
let id = timer.setTimeout(() => {
|
||||
completed = true;
|
||||
});
|
||||
timer.clearTimeout(id);
|
||||
|
||||
TKUnit.waitUntilReady(() => false, 0.02);
|
||||
TKUnit.assert(!completed, "Callback should not be called");
|
||||
}
|
||||
|
||||
export function test_clearInterval_immediatelyAfterCreate() {
|
||||
let completed = false;
|
||||
|
||||
let id = timer.setInterval(() => {
|
||||
completed = true;
|
||||
});
|
||||
timer.clearInterval(id);
|
||||
|
||||
TKUnit.waitUntilReady(() => false, 0.02);
|
||||
TKUnit.assert(!completed, "Callback should not be called");
|
||||
}
|
||||
|
||||
export function test_clearTimeout_insideCallback() {
|
||||
let completed = false;
|
||||
|
||||
let id = timer.setTimeout(() => {
|
||||
completed = true;
|
||||
timer.clearTimeout(id);
|
||||
});
|
||||
|
||||
TKUnit.waitUntilReady(() => completed, 0.5);
|
||||
TKUnit.assert(completed, "Callback should be called");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user