Enable recycling of nativeView 2 (#4467)

* enable recycling of nativeView

* backgroundInternal is reset if setting new value leads to background.isEmpty() == true.

* android background.getDefault always return copy of the background. Now all controls that mutate the background can be reset to initial state (e.g. Button & ActionBar)
passing resources to copied background so it respect density.
fix properties initNativeView

* reset padding when backgroundInternal is reset.

* Fix text reset
Fix padding reset

* fix tsc errors

* fix ugly text rendering.

* Add unit tests for recycling native views
Fix several issues that came from the above tests
Fix maxLength property missing a converter callback
Remove old files

* Remove old files

* Revert backgroundInternal setter

* change the order of tests so that appium can work again

* Remove suggestion on every TextView & TextField init (strangely it is enabled after view is recycled....)

* Fix function to get parent layout if specified

* Button stateListAnimator restored when button is recycled
zIndex defaultValue is now undefined instead of NaN

* revert zIndex.setNative to always clear stateListAnimator because it was breaking one UI test (setting value=0 was returning the previous stateListAnimator)

* fix search-bar backgound-color recycling

* Fix alignments setters

* Fix imageView recycling
Fix button recycling
Fix edit-text recycling
resetNativeView is called only if recycleNativeView flag is true

* Fix incorrect merge

* Fix text-view & text-field textTransform

* Fix EditText text reset

* Fix runtime crash on ARM emulator API 21

* Fix text-base minHeight. maxHeight reset
Fix reset of isUserInteractionEnabled
This commit is contained in:
Alexander Vakrilov
2017-06-29 18:01:22 +03:00
committed by GitHub
parent b1432679e6
commit 23757e5dfc
97 changed files with 1405 additions and 578 deletions

View File

@ -210,7 +210,7 @@ export function assertNotEqual(actual: any, expected: any, message?: string) {
}
if (equals) {
throw new Error(message + " Actual: " + actual + " Expected: " + expected);
throw new Error(message + " Actual: " + actual + " Not_Expected: " + expected);
}
}
@ -233,59 +233,59 @@ export function assertEqual<T extends { equals?(arg: T): boolean }>(actual: T, e
/**
* Assert two json like objects are deep equal.
*/
export function assertDeepEqual(actual, expected, path: any[] = []): void {
export function assertDeepEqual(actual, expected, message: string = '', path: any[] = []): void {
let typeofActual: string = typeof actual;
let typeofExpected: string = typeof expected;
if (typeofActual !== typeofExpected) {
throw new Error("At /" + path.join("/") + " types of actual " + typeofActual + " and expected " + typeofExpected + " differ.");
throw new Error(message + ' ' + "At /" + path.join("/") + " types of actual " + typeofActual + " and expected " + typeofExpected + " differ.");
} else if (typeofActual === "object" || typeofActual === "array") {
if (expected instanceof Map) {
if (actual instanceof Map) {
expected.forEach((value, key) => {
if (actual.has(key)) {
assertDeepEqual(actual.get(key), value, path.concat([key]));
assertDeepEqual(actual.get(key), value, message, path.concat([key]));
} else {
throw new Error("At /" + path.join("/") + " expected Map has key '" + key + "' but actual does not.");
throw new Error(message + ' ' + "At /" + path.join("/") + " expected Map has key '" + key + "' but actual does not.");
}
});
actual.forEach((value, key) => {
if (!expected.has(key)) {
throw new Error("At /" + path.join("/") + " actual Map has key '" + key + "' but expected does not.");
throw new Error(message + ' ' + "At /" + path.join("/") + " actual Map has key '" + key + "' but expected does not.");
}
});
} else {
throw new Error("At /" + path.join("/") + " expected is Map but actual is not.");
throw new Error(message + ' ' + "At /" + path.join("/") + " expected is Map but actual is not.");
}
}
if (expected instanceof Set) {
if (actual instanceof Set) {
expected.forEach(i => {
if (!actual.has(i)) {
throw new Error("At /" + path.join("/") + " expected Set has item '" + i + "' but actual does not.");
throw new Error(message + ' ' + "At /" + path.join("/") + " expected Set has item '" + i + "' but actual does not.");
}
});
actual.forEach(i => {
if (!expected.has(i)) {
throw new Error("At /" + path.join("/") + " actual Set has item '" + i + "' but expected does not.");
throw new Error(message + ' ' + "At /" + path.join("/") + " actual Set has item '" + i + "' but expected does not.");
}
})
} else {
throw new Error("At /" + path.join("/") + " expected is Set but actual is not.");
throw new Error(message + ' ' + "At /" + path.join("/") + " expected is Set but actual is not.");
}
}
for (let key in actual) {
if (!(key in expected)) {
throw new Error("At /" + path.join("/") + " found unexpected key " + key + ".");
throw new Error(message + ' ' + "At /" + path.join("/") + " found unexpected key " + key + ".");
}
assertDeepEqual(actual[key], expected[key], path.concat([key]));
assertDeepEqual(actual[key], expected[key], message, path.concat([key]));
}
for (let key in expected) {
if (!(key in actual)) {
throw new Error("At /" + path.join("/") + " expected a key " + key + ".");
throw new Error(message + ' ' + "At /" + path.join("/") + " expected a key " + key + ".");
}
}
} else if (actual !== expected) {
throw new Error("At /" + path.join("/") + " actual: '" + actual + "' and expected: '" + expected + "' differ.");
throw new Error(message + ' ' + "At /" + path.join("/") + " actual: '" + actual + "' and expected: '" + expected + "' differ.");
}
}