MCPcopy Index your code
hub / github.com/NativeScript/NativeScript / buildUIWithWeakRefAndInteract

Function buildUIWithWeakRefAndInteract

apps/automated/src/ui-helper.ts:120–149  ·  view source on GitHub ↗
(createFunc: () => T, interactWithViewFunc?: (view: T) => void, done?)

Source from the content-addressed store, hash-verified

118}
119
120export function buildUIWithWeakRefAndInteract<T extends View>(createFunc: () => T, interactWithViewFunc?: (view: T) => void, done?) {
121 clearPage();
122 const page = getCurrentPage();
123 const weakRef = new WeakRef(createFunc());
124 page.content = weakRef.get();
125 if (interactWithViewFunc) {
126 interactWithViewFunc(weakRef.get());
127 }
128 page.content = null;
129 // Give a change for native cleanup (e.g. keyboard close, etc.).
130 TKUnit.wait(0.001);
131 if (page.ios) {
132 /* tslint:disable:no-unused-expression */
133 // Could cause GC on the next call.
134 // NOTE: Don't replace this with forceGC();
135 new ArrayBuffer(4 * 1024 * 1024);
136
137 // An additional GC and wait are needed since WebKit upgrade to version 12.0
138 // (TEXT-FIELD.testMemoryLeak test started failing sporadically)
139 Utils.GC();
140 TKUnit.wait(0.2);
141 }
142 Utils.GC();
143 try {
144 TKUnit.assert(!weakRef.get(), weakRef.get() + ' leaked!');
145 done(null);
146 } catch (ex) {
147 done(ex);
148 }
149}
150
151export function navigateToModuleAndRunTest(moduleName, context, testFunction) {
152 let page = navigateToModule(moduleName, context);

Callers

nothing calls this directly

Calls 4

getMethod · 0.95
clearPageFunction · 0.85
assertMethod · 0.80
getCurrentPageFunction · 0.70

Tested by

no test coverage detected