-
Notifications
You must be signed in to change notification settings - Fork 0
/
Automatic for the People UI Automation Script.js
78 lines (54 loc) · 2.25 KB
/
Automatic for the People UI Automation Script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//
// Automatic for the People UI Automation Script.js
// Automatic for the People http://github.com/apontious/Automatic-for-the-People
//
// Created by Andrew Pontious on 11/23/12.
// Copyright (c) 2012 Andrew Pontious.
// Some right reserved: http://opensource.org/licenses/mit-license.php
//
addRowTest()
deleteRowTest()
function addRowTest() {
UIALogger.logStart("Starting Add Row Test")
var tableView = UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0]
var addButton = UIATarget.localTarget().frontMostApp().navigationBar().buttons()["Add Entry"]
var oldCount = tableView.cells().length
var expectedCount = oldCount + 1
addButton.tap()
var newCount
for (var i = 0; i < 12; i++) {
newCount = tableView.cells().length
if (newCount == expectedCount) {
UIALogger.logPass("Added entry correctly")
break
}
UIATarget.localTarget().delay(.25)
UIALogger.logDebug("Delaying...")
}
if (newCount != expectedCount) {
UIALogger.logFail("Pressing Add Entry (plus) button should result in " + expectedCount + " rows, but instead resulted in " + newCount + " rows")
}
}
function deleteRowTest() {
UIALogger.logStart("Starting Delete Row Test")
var tableView = UIATarget.localTarget().frontMostApp().mainWindow().tableViews()[0]
var lastRow = tableView.cells()[tableView.cells().length -1]
lastRow.flickInsideWithOptions({startOffset:{x:0.9, y:0.5}, endOffset:{x:0.0, y:0.5}})
var deleteButton = lastRow.buttons().firstWithPredicate("name beginswith 'Confirm Deletion'")
var oldCount = tableView.cells().length
var expectedCount = oldCount - 1
deleteButton.tap()
var newCount
for (var i = 0; i < 12; i++) {
newCount = tableView.cells().length
if (newCount == expectedCount) {
UIALogger.logPass("Deleted entry correctly")
break
}
UIATarget.localTarget().delay(.25)
UIALogger.logDebug("Delaying...")
}
if (newCount != expectedCount) {
UIALogger.logFail("Deleting last entry should result in " + expectedCount + " rows, but instead resulted in " + newCount + " rows")
}
}