Add isIOS, isAndroid in platform, and fast ts watcher and transpiler

Image should not requestLayout when sized with 'exactly' spec

Update image tests

Tests will run in ios only
This commit is contained in:
Panayot Cankov
2016-05-27 14:49:22 +03:00
parent 44abf94add
commit 717b5131b1
9 changed files with 272 additions and 41 deletions

View File

@@ -1,5 +1,6 @@
import TKUnit = require("./TKUnit");
import app = require("application");
import { isIOS, isAndroid } from "platform";
// >> platform-require
import platformModule = require("platform");
@@ -29,3 +30,12 @@ export function snippet_print_all() {
console.log("Screen scale: " + platformModule.screen.mainScreen.scale);
// << platform-current
};
export function testIsIOSandIsAndroid() {
if (isIOS) {
TKUnit.assertTrue(!!NSObject, "isIOS is true-ish but common iOS APIs are not available.");
} else if (isAndroid) {
TKUnit.assertTrue(!!android, "isAndroid is true but common 'android' package is not available.");
}
}

View File

@@ -1,4 +1,11 @@
import TKUnit = require("../../TKUnit");
import {Image} from "ui/image";
import {StackLayout} from "ui/layouts/stack-layout";
import {GridLayout} from "ui/layouts/grid-layout";
import {isIOS} from "platform";
// import {target} from "../../TKUnit";
import TKUnit = require("../../TKUnit");
// >> img-require
import ImageModule = require("ui/image");
// << img-require
@@ -244,3 +251,62 @@ export var test_SettingStretch_none = function () {
helper.buildUIAndRunTest(image, testFunc);
}
function ios<T>(func: T): T {
return isIOS ? func : undefined;
}
export var test_SettingImageSourceWhenSizedToParentDoesNotRequestLayout = ios(() => {
let host = new GridLayout();
let image = new Image();
host.width = 300;
host.height = 300;
host.addChild(image);
let mainPage = helper.getCurrentPage();
mainPage.content = host;
TKUnit.waitUntilReady(() => host.isLoaded);
let called = false;
image.requestLayout = () => called = true;
image.src = "~/logo.png";
TKUnit.assertFalse(called, "image.requestLayout should not be called.");
});
export var test_SettingImageSourceWhenFixedWidthAndHeightDoesNotRequestLayout = ios(() => {
let host = new StackLayout();
let image = new Image();
image.width = 100;
image.height = 100;
host.addChild(image);
let mainPage = helper.getCurrentPage();
mainPage.content = host;
TKUnit.waitUntilReady(() => host.isLoaded);
let called = false;
image.requestLayout = () => called = true;
image.src = "~/logo.png";
TKUnit.assertFalse(called, "image.requestLayout should not be called.");
});
export var test_SettingImageSourceWhenSizedToContentShouldInvalidate = ios(() => {
let host = new StackLayout();
let image = new Image();
host.addChild(image);
let mainPage = helper.getCurrentPage();
mainPage.content = host;
TKUnit.waitUntilReady(() => host.isLoaded);
let called = false;
image.requestLayout = () => called = true;
image.src = "~/logo.png";
TKUnit.assertTrue(called, "image.requestLayout should be called.");
});