Fix dp vs dip conversions in iOS for errors of tests

This commit is contained in:
Panayot Cankov
2017-03-07 17:28:55 +02:00
parent 9f1ebc11ca
commit 6d6564af16
7 changed files with 26 additions and 19 deletions

View File

@@ -139,8 +139,10 @@ export class LabelTest extends testModule.UITest<LabelModule.Label> {
if (label.ios) {
this.waitUntilTestElementLayoutIsValid();
const expectedValue = 3;
let expectedValue = NSString.stringWithString("i").sizeWithAttributes(<any>{
[NSFontAttributeName]: UIFont.systemFontOfSize(9)
}).width;
expectedValue = Math.ceil(utils.layout.toDevicePixels(expectedValue));
const measuredWidth = label.getMeasuredWidth();
TKUnit.assertEqual(measuredWidth, expectedValue, "measuredWidth should not be rounded down.");
}

View File

@@ -5,6 +5,7 @@ import * as color from "color";
import * as helper from "../helper";
import * as TKUnit from "../../TKUnit";
import * as button from "ui/button";
import * as utils from "utils/utils";
global.moduleMerge(commonTests, exports);
@@ -21,7 +22,7 @@ class MyGrid extends grid.GridLayout {
}
export function getUniformNativeBorderWidth(v: view.View): number {
return (<UIView>v.ios).layer.borderWidth;
return utils.layout.toDevicePixels((<UIView>v.ios).layer.borderWidth);
}
export function checkUniformNativeBorderColor(v: view.View): boolean {