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

@@ -183,10 +183,11 @@
<Content Include="apps\tests\pages\tab-view.xml" /> <Content Include="apps\tests\pages\tab-view.xml" />
<Content Include="apps\ui-tests-app\app.css" /> <Content Include="apps\ui-tests-app\app.css" />
<TypeScriptCompile Include="apps\ui-tests-app\nordic\nordic.ts"> <TypeScriptCompile Include="apps\ui-tests-app\nordic\nordic.ts">
<DependentUpon>nordic.xml</DependentUpon> <DependentUpon>nordic.xml</DependentUpon>
</TypeScriptCompile> </TypeScriptCompile>
<TypeScriptCompile Include="apps\ui-tests-app\pages\handlers.ts" /> <TypeScriptCompile Include="apps\ui-tests-app\pages\handlers.ts" />
<TypeScriptCompile Include="apps\ui-tests-app\pages\htmlview.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.d.ts" />
<TypeScriptCompile Include="ui\animation\animation-common.ts"> <TypeScriptCompile Include="ui\animation\animation-common.ts">
<DependentUpon>animation.d.ts</DependentUpon> <DependentUpon>animation.d.ts</DependentUpon>
@@ -576,6 +577,11 @@
<TypeScriptCompile Include="ui\action-bar\action-bar.ios.ts"> <TypeScriptCompile Include="ui\action-bar\action-bar.ios.ts">
<DependentUpon>action-bar.d.ts</DependentUpon> <DependentUpon>action-bar.d.ts</DependentUpon>
</TypeScriptCompile> </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\ui.d.ts" />
<TypeScriptCompile Include="ui\html-view\html-view-common.ts" /> <TypeScriptCompile Include="ui\html-view\html-view-common.ts" />
<TypeScriptCompile Include="ui\html-view\html-view.android.ts" /> <TypeScriptCompile Include="ui\html-view\html-view.android.ts" />
@@ -1922,6 +1928,7 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content> </Content>
<Content Include="ui\package.json" /> <Content Include="ui\package.json" />
<Content Include="tsconfig.json" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="build\tslint.json" /> <None Include="build\tslint.json" />
@@ -1984,7 +1991,7 @@
<SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile> <SaveServerSettingsInUserFile>False</SaveServerSettingsInUserFile>
</WebProjectProperties> </WebProjectProperties>
</FlavorProperties> </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> </VisualStudio>
</ProjectExtensions> </ProjectExtensions>
</Project> </Project>

View File

@@ -30,7 +30,7 @@ var _createWebViewFunc = function (): webViewModule.WebView {
return webView; return webView;
} }
export var testLoadExistingUrl = function () { function prepare(): webViewModule.WebView {
var newPage: page.Page; var newPage: page.Page;
var webView = _createWebViewFunc(); var webView = _createWebViewFunc();
var pageFactory = function (): page.Page { var pageFactory = function (): page.Page {
@@ -41,6 +41,12 @@ export var testLoadExistingUrl = function () {
helper.navigate(pageFactory); helper.navigate(pageFactory);
return webView;
}
export var testLoadExistingUrl = function () {
var webView = prepare();
var testFinished = false; var testFinished = false;
var actualUrl; var actualUrl;
var actualError; var actualError;
@@ -80,15 +86,7 @@ export var testLoadExistingUrl = function () {
} }
export var testLoadLocalFile = function () { export var testLoadLocalFile = function () {
var newPage: page.Page; var webView = prepare();
var webView = _createWebViewFunc();
var pageFactory = function (): page.Page {
newPage = new page.Page();
newPage.content = webView;
return newPage;
};
helper.navigate(pageFactory);
var testFinished = false; var testFinished = false;
var actualHtml; var actualHtml;
@@ -142,15 +140,7 @@ export var testLoadLocalFile = function () {
} }
export var testLoadHTMLString = function () { export var testLoadHTMLString = function () {
var newPage: page.Page; var webView = prepare();
var webView = _createWebViewFunc();
var pageFactory = function (): page.Page {
newPage = new page.Page();
newPage.content = webView;
return newPage;
};
helper.navigate(pageFactory);
var testFinished = false; var testFinished = false;
var actualHtml; var actualHtml;
@@ -204,15 +194,7 @@ export var testLoadHTMLString = function () {
} }
export var testLoadInvalidUrl = function () { export var testLoadInvalidUrl = function () {
var newPage: page.Page; var webView = prepare();
var webView = _createWebViewFunc();
var pageFactory = function (): page.Page {
newPage = new page.Page();
newPage.content = webView;
return newPage;
};
helper.navigate(pageFactory);
var testFinished = false; var testFinished = false;
var actualError; var actualError;
@@ -237,3 +219,31 @@ export var testLoadInvalidUrl = function () {
TKUnit.assert(false, "TIMEOUT"); 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": { "compilerOptions": {
"moduleResolution": "classic", "moduleResolution": "classic",
"target": "es5", "target": "es5",
@@ -8,7 +8,8 @@
"noImplicitAny": false, "noImplicitAny": false,
"removeComments": true, "removeComments": true,
"noLib": true, "noLib": true,
"outDir": "dist" "outDir": "dist",
"experimentalDecorators": true
}, },
"filesGlob": [ "filesGlob": [
"./**/*.ts", "./**/*.ts",

View File

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