tests added

This commit is contained in:
Vladimir Enchev
2015-06-12 14:54:25 +03:00
parent 108e21f546
commit 919ae660cd
5 changed files with 120 additions and 1 deletions

View File

@ -193,6 +193,7 @@
<TypeScriptCompile Include="apps\tests\ui\scroll-view\scroll-view-tests.ts" />
<TypeScriptCompile Include="apps\tests\ui\search-bar\search-bar-tests.ts" />
<TypeScriptCompile Include="apps\tests\ui\style\style-properties-tests.ts" />
<TypeScriptCompile Include="apps\tests\ui\view\view-tests.d.ts" />
<TypeScriptCompile Include="apps\tests\ui\web-view\web-view-tests.ts" />
<TypeScriptCompile Include="apps\editable-text-demo\app.ts" />
<TypeScriptCompile Include="apps\editable-text-demo\main-page.ts">
@ -1585,7 +1586,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_2layouts_2linear-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_2linear-layout_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

@ -3,6 +3,7 @@ import viewModule = require("ui/core/view");
import frame = require("ui/frame");
import page = require("ui/page");
import button = require("ui/button");
import label = require("ui/label");
import types = require("utils/types");
import helper = require("../../ui/helper");
import color = require("color");
@ -11,6 +12,7 @@ import proxy = require("ui/core/proxy");
import layoutModule = require("ui/layouts/layout");
import observable = require("data/observable");
import bindable = require("ui/core/bindable");
import definition = require("./view-tests");
export var test_eachDescendant = function () {
var test = function (views: Array<viewModule.View>) {
@ -581,3 +583,56 @@ export var test_binding_style_visibility = function () {
export var test_binding_style_opacity = function () {
property_binding_style_test("opacity", 0.5, 0.6);
}
function _createLabelWithBorder(): viewModule.View {
var lbl = new label.Label();
lbl.borderRadius = 10;
lbl.borderWidth = 2;
lbl.borderColor = new color.Color("#FF0000");
lbl.backgroundColor = new color.Color("#FFFF00");
return lbl;
}
export var testBorderWidth = function () {
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<viewModule.View>) {
var lbl = <label.Label>views[0];
var expectedValue = lbl.borderWidth;
var actualValue = definition.getNativeBorderWidth(lbl);
TKUnit.assert(actualValue === expectedValue, "Actual: " + actualValue + "; Expected: " + expectedValue);
});
}
export var testCornerRadius = function () {
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<viewModule.View>) {
var lbl = <label.Label>views[0];
var expectedValue = lbl.borderRadius;
var actualValue = definition.getNativeCornerRadius(lbl);
TKUnit.assert(actualValue === expectedValue, "Actual: " + actualValue + "; Expected: " + expectedValue);
});
}
export var testBorderColor = function () {
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<viewModule.View>) {
var lbl = <label.Label>views[0];
TKUnit.assert(definition.checkNativeBorderColor(lbl), "BorderColor not applied correctly!");
});
}
export var testBackgroundColor = function () {
helper.buildUIAndRunTest(_createLabelWithBorder(), function (views: Array<viewModule.View>) {
var lbl = <label.Label>views[0];
TKUnit.assert(definition.checkNativeBackgroundColor(lbl), "BackgroundColor not applied correctly!");
});
}
export var testBackgroundImage = function () {
var lbl = _createLabelWithBorder();
helper.buildUIAndRunTest(lbl, function (views: Array<viewModule.View>) {
var page = <page.Page>views[1];
page.css = "View { background-image: url('~/logo.png') }";
TKUnit.assert(definition.checkNativeBackgroundImage(lbl), "Style background-image not loaded correctly.");
});
}

View File

@ -253,4 +253,34 @@ export var test_StylePropertiesDefaultValuesCache = function () {
};
helper.do_PageTest_WithStackLayout_AndButton(test);
}
export function getNativeBorderWidth(v: view.View): number {
var bkg = <any>(<android.view.View>v.android).getBackground();
return bkg ? bkg.borderWidth : -1;
}
export function getNativeCornerRadius(v: view.View): number {
var bkg = <any>(<android.view.View>v.android).getBackground();
return bkg ? bkg.cornerRadius : -1;
}
export function checkNativeBorderColor(v: view.View): boolean {
var bkg = <any>(<android.view.View>v.android).getBackground();
return v.borderColor && bkg && bkg.borderColor === v.borderColor.android;
}
export function checkNativeBackgroundColor(v: view.View): boolean {
var bkg = <any>(<android.view.View>v.android).getBackground();
return v.backgroundColor && bkg && bkg.backgroundColor === v.backgroundColor.android;
}
export function checkNativeBackgroundImage(v: view.View): boolean {
var bkg = <any>(<android.view.View>v.android).getBackground();
return bkg && bkg.bitmap !== undefined;
}

12
apps/tests/ui/view/view-tests.d.ts vendored Normal file
View File

@ -0,0 +1,12 @@
//@private
import view = require("ui/core/view");
export declare function getNativeBorderWidth(v: view.View): number;
export declare function getNativeCornerRadius(v: view.View): number;
export declare function checkNativeBorderColor(v: view.View): boolean
export declare function checkNativeBackgroundColor(v: view.View): boolean;
export declare function checkNativeBackgroundImage(v: view.View): boolean

View File

@ -1,5 +1,26 @@
import commonTests = require("./view-tests-common");
import view = require("ui/core/view");
// merge the exports of the application_common file with the exports of this file
declare var exports;
require("utils/module-merge").merge(commonTests, exports);
export function getNativeBorderWidth(v: view.View): number {
return (<UIView>v.ios).layer.borderWidth;
}
export function getNativeCornerRadius(v: view.View): number {
return (<UIView>v.ios).layer.cornerRadius;
}
export function checkNativeBorderColor(v: view.View): boolean {
return v.borderColor && (<UIView>v.ios).layer.borderColor === v.borderColor.ios.CGColor;
}
export function checkNativeBackgroundColor(v: view.View): boolean {
return v.backgroundColor && (<UIView>v.ios).backgroundColor.isEqual(v.backgroundColor.ios);
}
export function checkNativeBackgroundImage(v: view.View): boolean {
return (<UIView>v.ios).backgroundColor !== undefined;
}