From f2087917702f7819f522168a82d2296527299f0c Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Thu, 11 Feb 2016 15:07:57 +0200 Subject: [PATCH 1/2] fixed tests --- apps/tests/ui/list-view/list-view-tests.ts | 17 +++++++++++------ apps/tests/ui/scroll-view/scroll-view-tests.ts | 16 ++++++++++------ 2 files changed, 21 insertions(+), 12 deletions(-) diff --git a/apps/tests/ui/list-view/list-view-tests.ts b/apps/tests/ui/list-view/list-view-tests.ts index 45cfb7808..d5d6ffd48 100644 --- a/apps/tests/ui/list-view/list-view-tests.ts +++ b/apps/tests/ui/list-view/list-view-tests.ts @@ -228,18 +228,23 @@ export class ListViewTest extends testModule.UITest { 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() { diff --git a/apps/tests/ui/scroll-view/scroll-view-tests.ts b/apps/tests/ui/scroll-view/scroll-view-tests.ts index 3eba7778e..244a969a0 100644 --- a/apps/tests/ui/scroll-view/scroll-view-tests.ts +++ b/apps/tests/ui/scroll-view/scroll-view-tests.ts @@ -81,32 +81,36 @@ class ScrollLayoutTest extends testModule.UITest { } } - 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"); From b62d1f451a69fc6b5a88714273edd0fedb6070ca Mon Sep 17 00:00:00 2001 From: Hristo Hristov Date: Thu, 11 Feb 2016 16:45:33 +0200 Subject: [PATCH 2/2] Fixed scroll-view tests --- apps/tests/ui/scroll-view/scroll-view-tests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/tests/ui/scroll-view/scroll-view-tests.ts b/apps/tests/ui/scroll-view/scroll-view-tests.ts index 244a969a0..66c7a232a 100644 --- a/apps/tests/ui/scroll-view/scroll-view-tests.ts +++ b/apps/tests/ui/scroll-view/scroll-view-tests.ts @@ -230,7 +230,7 @@ class ScrollLayoutTest extends testModule.UITest { } 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) => { @@ -245,7 +245,7 @@ class ScrollLayoutTest extends testModule.UITest { 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) => {