Add WebView test. Make its members abstract.

This commit is contained in:
atanasovg
2015-09-30 14:33:03 +03:00
parent 1a76b58768
commit 198f4f1dbc
4 changed files with 60 additions and 58 deletions

View File

@ -187,6 +187,7 @@
</TypeScriptCompile>
<TypeScriptCompile Include="apps\ui-tests-app\pages\handlers.ts" />
<TypeScriptCompile Include="apps\ui-tests-app\pages\htmlview.ts" />
<TypeScriptCompile Include="color\known-colors.d.ts" />
<TypeScriptCompile Include="ui\animation\animation.d.ts" />
<TypeScriptCompile Include="ui\animation\animation-common.ts">
<DependentUpon>animation.d.ts</DependentUpon>
@ -576,6 +577,11 @@
<TypeScriptCompile Include="ui\action-bar\action-bar.ios.ts">
<DependentUpon>action-bar.d.ts</DependentUpon>
</TypeScriptCompile>
<TypeScriptCompile Include="ui\builder\binding-builder.d.ts" />
<TypeScriptCompile Include="ui\builder\special-properties.d.ts" />
<TypeScriptCompile Include="ui\builder\special-properties.ts" />
<TypeScriptCompile Include="ui\styling\style-scope.d.ts" />
<TypeScriptCompile Include="ui\styling\style.d.ts" />
<TypeScriptCompile Include="ui\ui.d.ts" />
<TypeScriptCompile Include="ui\html-view\html-view-common.ts" />
<TypeScriptCompile Include="ui\html-view\html-view.android.ts" />
@ -1922,6 +1928,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<Content Include="ui\package.json" />
<Content Include="tsconfig.json" />
</ItemGroup>
<ItemGroup>
<None Include="build\tslint.json" />
@ -1984,7 +1991,7 @@
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties>
</FlavorProperties>
<UserProperties ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" />
<UserProperties ui_2scroll-view_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2editable-text-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2absolute-layout-demo_2package_1json__JSONSchema="http://json.schemastore.org/package" apps_2gallery-app_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2content-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2web-view_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2absolute-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" ui_2layouts_2dock-layout_2package_1json__JSONSchema="" ui_2layouts_2grid-layout_2package_1json__JSONSchema="" ui_2layouts_2wrap-layout_2package_1json__JSONSchema="http://json.schemastore.org/package" />
</VisualStudio>
</ProjectExtensions>
</Project>

View File

@ -30,7 +30,7 @@ var _createWebViewFunc = function (): webViewModule.WebView {
return webView;
}
export var testLoadExistingUrl = function () {
function prepare(): webViewModule.WebView {
var newPage: page.Page;
var webView = _createWebViewFunc();
var pageFactory = function (): page.Page {
@ -41,6 +41,12 @@ export var testLoadExistingUrl = function () {
helper.navigate(pageFactory);
return webView;
}
export var testLoadExistingUrl = function () {
var webView = prepare();
var testFinished = false;
var actualUrl;
var actualError;
@ -80,15 +86,7 @@ export var testLoadExistingUrl = function () {
}
export var testLoadLocalFile = function () {
var newPage: page.Page;
var webView = _createWebViewFunc();
var pageFactory = function (): page.Page {
newPage = new page.Page();
newPage.content = webView;
return newPage;
};
helper.navigate(pageFactory);
var webView = prepare();
var testFinished = false;
var actualHtml;
@ -142,15 +140,7 @@ export var testLoadLocalFile = function () {
}
export var testLoadHTMLString = function () {
var newPage: page.Page;
var webView = _createWebViewFunc();
var pageFactory = function (): page.Page {
newPage = new page.Page();
newPage.content = webView;
return newPage;
};
helper.navigate(pageFactory);
var webView = prepare();
var testFinished = false;
var actualHtml;
@ -204,15 +194,7 @@ export var testLoadHTMLString = function () {
}
export var testLoadInvalidUrl = function () {
var newPage: page.Page;
var webView = _createWebViewFunc();
var pageFactory = function (): page.Page {
newPage = new page.Page();
newPage.content = webView;
return newPage;
};
helper.navigate(pageFactory);
var webView = prepare();
var testFinished = false;
var actualError;
@ -237,3 +219,31 @@ export var testLoadInvalidUrl = function () {
TKUnit.assert(false, "TIMEOUT");
}
}
export var testLoadUpperCaseSrc = function () {
var webView = prepare();
var testFinished = false;
var actualSrc;
var actualError;
webView.on(webViewModule.WebView.loadFinishedEvent, function (args: webViewModule.LoadEventData) {
actualSrc = args.url;
actualError = args.error;
testFinished = true;
});
var targetSrc = "HTTP://nsbuild01.telerik.com/docs/";
webView.src = targetSrc;
TKUnit.wait(4);
helper.goBack();
if (testFinished) {
TKUnit.assert(actualSrc === targetSrc, "args.url should equal '" + targetSrc + "'");
TKUnit.assert(actualError === undefined, actualError);
}
else {
TKUnit.assert(false, "TIMEOUT");
}
}

View File

@ -1,5 +1,5 @@
{
"version": "1.5.0-beta",
"version": "1.6.2",
"compilerOptions": {
"moduleResolution": "classic",
"target": "es5",
@ -8,7 +8,8 @@
"noImplicitAny": false,
"removeComments": true,
"noLib": true,
"outDir": "dist"
"outDir": "dist",
"experimentalDecorators": true
},
"filesGlob": [
"./**/*.ts",

View File

@ -63,7 +63,7 @@ function onSrcPropertyChanged(data: dependencyObservable.PropertyChangeData) {
// register the setNativeValue callback
(<proxy.PropertyMetadata>srcProperty.metadata).onSetNativeValue = onSrcPropertyChanged;
export class WebView extends view.View implements definition.WebView {
export abstract class WebView extends view.View implements definition.WebView {
public static loadStartedEvent = "loadStarted";
public static loadFinishedEvent = "loadFinished";
@ -119,25 +119,15 @@ export class WebView extends view.View implements definition.WebView {
this.notify(args);
}
public _loadUrl(url: string) {
throw new Error("This member is abstract.");
}
abstract _loadUrl(url: string): void;
public _loadFileOrResource(path: string, content: string) {
throw new Error("This member is abstract.");
}
abstract _loadFileOrResource(path: string, content: string): void;
public _loadHttp(src: string) {
throw new Error("This member is abstract.");
}
abstract _loadHttp(src: string): void;
public _loadData(src: string) {
throw new Error("This member is abstract.");
}
abstract _loadData(src: string): void;
public stopLoading(): void {
throw new Error("This member is abstract.");
}
abstract stopLoading(): void;
get canGoBack(): boolean {
throw new Error("This member is abstract.");
@ -147,15 +137,9 @@ export class WebView extends view.View implements definition.WebView {
throw new Error("This member is abstract.");
}
public goBack() {
throw new Error("This member is abstract.");
}
abstract goBack(): void;
public goForward() {
throw new Error("This member is abstract.");
}
abstract goForward(): void;
public reload() {
throw new Error("This member is abstract.");
}
abstract reload(): void;
}