fix(devtools-ios): Ensure UI modifications run on main thread

Modifications to the UI can only be made from the main thread.
Since {N} 5.3.0 all debugger protocol messages are processed
by the worker thread that receives them in iOS.

refs #7219, https://github.com/NativeScript/ios-runtime/pull/1101
This commit is contained in:
Martin Bektchiev
2019-05-08 13:56:45 +03:00
parent f51bb119c2
commit c60f74d4eb
6 changed files with 87 additions and 7 deletions

View File

@ -18,6 +18,38 @@ export function test_releaseNativeObject_canBeCalledWithNativeObject() {
}
};
export function test_executeOnMainThread_Works(done: Function) {
utils.executeOnMainThread(() => {
try {
TKUnit.assertTrue(utils.isMainThread());
done();
} catch (e) {
done(e);
}
});
}
export function test_mainThreadify_PassesArgs(done: Function) {
const expectedN = 434;
const expectedB = true;
const expectedS = "string";
const f = utils.mainThreadify(function (n: number, b: boolean, s: string) {
try {
TKUnit.assertTrue(utils.isMainThread());
TKUnit.assertEqual(n, expectedN);
TKUnit.assertEqual(b, expectedB);
TKUnit.assertEqual(s, expectedS);
done();
} catch (e) {
done(e);
}
});
f(expectedN, expectedB, expectedS);
}
function test_releaseNativeObject_canBeCalledWithNativeObject_iOS() {
let deallocated = false;
const obj = new ((<any>NSObject).extend({