mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-17 04:41:36 +08:00

* cache page on forward navigation Still some failing navigation tests * Current page is kept alive when navigating forward Refactoring code and removing all hacks and flags Remove one module circular reference * Disable Page recycling because when there is transition between pages the nativeView stays animated (e.g. when transition is Fade the hidden page nativeView stays with Alpha 0) Disable recycling if there is native anitmation * Fix failing tests on ios & android API17 Fix wrong urls in http tests Made some timer tests async * Animations are not stored in BackstackEntry instead of Fragment because fragments could die (activity die) and recreated and we lose animations. * Fix android crash when activity is recreated. Refactoring transitionListener.
76 lines
2.0 KiB
TypeScript
76 lines
2.0 KiB
TypeScript
import { Page } from "tns-core-modules/ui/page";
|
|
import { View } from "tns-core-modules/ui/core/view";
|
|
import * as trace from "tns-core-modules/trace";
|
|
import * as navHelper from "./ui/helper";
|
|
import * as TKUnit from "./TKUnit";
|
|
|
|
export class UITest<T extends View> implements trace.TraceWriter {
|
|
|
|
private _testPage: Page;
|
|
private _testView: T;
|
|
private _errorMessage;
|
|
|
|
public get errorMessage(): string {
|
|
return this._errorMessage;
|
|
}
|
|
|
|
public get testPage(): Page {
|
|
return this._testPage;
|
|
}
|
|
|
|
public get testView(): T {
|
|
return this._testView;
|
|
}
|
|
|
|
public waitUntilTestElementIsLoaded(timeoutSec: number = 1): void {
|
|
TKUnit.waitUntilReady(() => this.testView.isLoaded, timeoutSec);
|
|
}
|
|
|
|
public waitUntilTestElementLayoutIsValid(timeoutSec: number = 1): void {
|
|
TKUnit.waitUntilReady(() => this.testView.isLayoutValid, timeoutSec);
|
|
}
|
|
|
|
public create(): T {
|
|
throw new Error(this + " should implement Create method.");
|
|
}
|
|
|
|
public setUpModule(): void {
|
|
const pageFactory = () => {
|
|
const page = new Page();
|
|
this._testPage = page;
|
|
return page;
|
|
};
|
|
|
|
trace.addWriter(this);
|
|
navHelper.navigate(pageFactory);
|
|
}
|
|
|
|
public tearDownModule() {
|
|
this._testPage = null;
|
|
this._testView = null;
|
|
trace.removeWriter(this);
|
|
}
|
|
|
|
public setUp() {
|
|
this._testView = this.create();
|
|
this._testPage.content = this._testView;
|
|
}
|
|
|
|
public tearDown() {
|
|
this._testPage.content = null;
|
|
this._testPage.bindingContext = null;
|
|
this._testPage.css = "";
|
|
this._testView = null;
|
|
this._errorMessage = undefined;
|
|
}
|
|
|
|
public write(message: any, category: string, type?: number): void {
|
|
if (category === trace.categories.Error) {
|
|
this._errorMessage = message;
|
|
}
|
|
}
|
|
}
|
|
|
|
export function createTestCase(): UITest<View> {
|
|
return null;
|
|
} |