Merge pull request #1538 from NativeScript/hhristov/fixed-unit-tests

fixed tests
This commit is contained in:
Hristo Hristov
2016-02-11 17:18:23 +02:00
2 changed files with 23 additions and 14 deletions

View File

@ -228,18 +228,23 @@ export class ListViewTest extends testModule.UITest<listViewModule.ListView> {
completed = args.index === (listView.items.length - 1);
});
// iOS7 needs to know the size of the cell before it is generated so we first measure them using fake cell
// then we generate the real cells. This cause itemLoading to be called twice per index.
let expected = (platform.device.os === platform.platformNames.ios && utils.ios.MajorVersion === 7) ? 2 : 1;
TKUnit.waitUntilReady(() => { return completed; }, ASYNC);
TKUnit.assertEqual(indexes[0], 1, "itemLoading called more than once");
TKUnit.assertEqual(indexes[1], 1, "itemLoading called more than once");
TKUnit.assertEqual(indexes[2], 1, "itemLoading called more than once");
TKUnit.assertEqual(indexes[0], expected, "itemLoading called more than once");
TKUnit.assertEqual(indexes[1], expected, "itemLoading called more than once");
TKUnit.assertEqual(indexes[2], expected, "itemLoading called more than once");
completed = false;
listView.refresh();
// again calling refresh will generate itemLoading twice per item.
expected += expected;
TKUnit.waitUntilReady(() => { return completed; }, ASYNC);
TKUnit.assertEqual(indexes[0], 2, "itemLoading not called for index 0");
TKUnit.assertEqual(indexes[1], 2, "itemLoading not called for index 1");
TKUnit.assertEqual(indexes[2], 2, "itemLoading not called for index 2");
TKUnit.assertEqual(indexes[0], expected, "itemLoading not called for index 0");
TKUnit.assertEqual(indexes[1], expected, "itemLoading not called for index 1");
TKUnit.assertEqual(indexes[2], expected, "itemLoading not called for index 2");
}
public test_set_itmes_to_null_clears_native_items() {

View File

@ -81,32 +81,36 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
}
}
public test_scrollabeHeight_vertical_orientation_when_content_is_small() {
this.testView.content.height = 100;
public test_scrollableHeight_vertical_orientation_when_content_is_small() {
this.testView.content.width = layoutHelper.dp(100);
this.testView.content.height = layoutHelper.dp(100);
this.waitUntilTestElementLayoutIsValid();
TKUnit.assertEqual(this.testView.scrollableHeight, 0, "this.testView.scrollableHeight");
TKUnit.assertEqual(this.testView.scrollableWidth, 0, "this.testView.scrollableWidth");
}
public test_scrollabeHeight_vertical_orientation_when_content_is_big() {
public test_scrollableHeight_vertical_orientation_when_content_is_big() {
this.testView.content.width = layoutHelper.dp(100);
this.waitUntilTestElementLayoutIsValid();
TKUnit.assertAreClose(layoutHelper.dip(this.testView.scrollableHeight), 200, 0.4, "this.testView.scrollableHeight");
TKUnit.assertEqual(this.testView.scrollableWidth, 0, "this.testView.scrollableWidth");
}
public test_scrollabeWidth_horizontal_orientation_when_content_is_small() {
public test_scrollableWidth_horizontal_orientation_when_content_is_small() {
this.testView.orientation = enums.Orientation.horizontal;
this.testView.content.width = 100;
this.testView.content.width = layoutHelper.dp(100);
this.testView.content.height = layoutHelper.dp(100);
this.waitUntilTestElementLayoutIsValid();
TKUnit.assertEqual(this.testView.scrollableHeight, 0, "this.testView.scrollableHeight");
TKUnit.assertEqual(this.testView.scrollableWidth, 0, "this.testView.scrollableWidth");
}
public test_scrollabeWidth_horizontal_orientation_when_content_is_big() {
public test_scrollableWidth_horizontal_orientation_when_content_is_big() {
this.testView.orientation = enums.Orientation.horizontal;
this.testView.content.height = layoutHelper.dp(100);
this.waitUntilTestElementLayoutIsValid();
TKUnit.assertEqual(this.testView.scrollableHeight, 0, "this.testView.scrollableHeight");
@ -226,7 +230,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
}
public test_scrollView_vertical_raised_scroll_event_after_loaded() {
this.waitUntilTestElementIsLoaded();
this.waitUntilTestElementLayoutIsValid();
var scrollY: number;
this.testView.on(scrollViewModule.ScrollView.scrollEvent, (args: scrollViewModule.ScrollEventData) => {
@ -241,7 +245,7 @@ class ScrollLayoutTest extends testModule.UITest<scrollViewModule.ScrollView> {
public test_scrollView_horizontal_raised_scroll_event_after_loaded() {
this.testView.orientation = enums.Orientation.horizontal;
this.waitUntilTestElementIsLoaded();
this.waitUntilTestElementLayoutIsValid();
var scrollX: number;
this.testView.on(scrollViewModule.ScrollView.scrollEvent, (args: scrollViewModule.ScrollEventData) => {