This repository has been archived by the owner on Sep 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 34
Improves calendar cards tests by using navigator to confirm card is open #560
Open
haahmad
wants to merge
1
commit into
blackberry:next
Choose a base branch
from
blackberry-webworks:cardAutomation
base: next
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,26 +34,61 @@ describe("calendar cards", function () { | |
onCancel = null; | ||
}); | ||
|
||
/* | ||
* @param func Function function that will cause some change in the foreground application | ||
* @param test Function boolean condition that guarantees the foreground application has changed | ||
* @param onComplete callback triggered condition in test function is satisfied | ||
*/ | ||
function testForegroundApp(func, test, onComplete) { | ||
var intervalId, | ||
flag, | ||
checkForeground = function () { | ||
flag = test(); | ||
}; | ||
runs(function () { | ||
func(); | ||
intervalId = setInterval(checkForeground, 500); | ||
}); | ||
waitsFor(function () { | ||
return flag; | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should have a timeout threshold here |
||
runs(function () { | ||
clearInterval(intervalId); | ||
onComplete(); | ||
}); | ||
} | ||
|
||
it("opens and cancels calendarPicker", function () { | ||
blackberry.invoke.card.invokeCalendarPicker({}, onDone, onCancel, invokeCallback); | ||
waits(waitTimeout); | ||
runs(function () { | ||
internal.automation.touchTopLeft(); | ||
waits(waitTimeout); | ||
runs(function () { | ||
var intervalId; | ||
testForegroundApp(function () { | ||
blackberry.invoke.card.invokeCalendarPicker({}, onDone, onCancel, invokeCallback); | ||
}, function () { | ||
return (internal.automation.getForegroundAppInfo()["label-card0"] === "calendar.viewer.nav"); | ||
}, function () { | ||
testForegroundApp(function () { | ||
intervalId = setInterval(internal.automation.touchTopLeft, 500); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this running in a loop? Shouldn't we only be clicking cancel once? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The card is in the foreground before the button is clickable, so even though we are sure the card is in the foreground we cannot click anything until all of the ui for the card is active. This keeps touching the button location until the card is ready. |
||
}, function () { | ||
var appInfo = internal.automation.getForegroundAppInfo(); | ||
return !(appInfo.hasOwnProperty("label-card0")); | ||
}, function () { | ||
clearInterval(intervalId); | ||
expect(onCancel).toHaveBeenCalledWith('cancel'); | ||
}); | ||
}); | ||
}); | ||
|
||
it("opens and cancels calendarComposer", function () { | ||
blackberry.invoke.card.invokeCalendarComposer({}, onDone, onCancel, invokeCallback); | ||
waits(waitTimeout); | ||
runs(function () { | ||
internal.automation.touchTopLeft(); | ||
waits(waitTimeout); | ||
runs(function () { | ||
testForegroundApp(function () { | ||
blackberry.invoke.card.invokeCalendarComposer({}, onDone, onCancel, invokeCallback); | ||
}, function () { | ||
return (internal.automation.getForegroundAppInfo()["label-card0"] === "calendar.eventcreate"); | ||
}, function () { | ||
testForegroundApp(function () { | ||
internal.automation.touchTopLeft(); | ||
}, function () { | ||
var appInfo = internal.automation.getForegroundAppInfo(); | ||
return !(appInfo.hasOwnProperty("label-card0")); | ||
}, function () { | ||
expect(onDone).toHaveBeenCalled(); | ||
}); | ||
}); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't need this runs() as you aren't waiting for anything. I don't think there's much point to pass in func at all. Just run that code inline before you start the check.