Skip to content

Commit 28f57a7

Browse files
committed
fix: missing lua ref
Signed-off-by: 82Flex <82flex@gmail.com>
1 parent af30ac8 commit 28f57a7

3 files changed

Lines changed: 2635 additions & 19 deletions

File tree

blog/2025-04/a-simple-testcase.md

Lines changed: 26 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@ tags: [touch, screen, ocr_text, find_color, testcase, lua]
77

88
This is a simple testcase that demonstrates how to use the [`touch`](/docs/lua-manual/touch) and [`screen`](/docs/lua-manual/screen) modules in Lua to automate some tasks on an iOS device.
99

10+
:::note
11+
Download the multi-touch gesture recording from the following link:
12+
[rec_20221011184701.lua](assets/rec_20221011184701.lua)
13+
:::
14+
1015
<!-- truncate -->
1116

1217
The script performs the following actions:
1318

1419
```lua title="a-simple-testcase.lua"
1520
local function tapWord(word)
16-
local txts, details =
17-
screen.ocr_text {
18-
languages = {"en-US"},
19-
words = {word},
20-
confidence = 0.8
21-
}
21+
local txts, details = screen.ocr_text {}
2222
local tapped = false
2323
for i, v in ipairs(txts) do
2424
if v == word then
@@ -29,9 +29,19 @@ local function tapWord(word)
2929
return tapped
3030
end
3131

32+
function string:startswith(start)
33+
return self:sub(1, #start) == start
34+
end
35+
36+
touch.show_pose(true)
37+
if not sys.language():startswith("en") then
38+
nLog("Set language…")
39+
sys.set_language("en")
40+
sys.sleep(10)
41+
end
42+
3243
while true do
3344
nLog("Exit all applications…")
34-
touch.show_pose(true)
3545
app.quit("*")
3646
sys.sleep(2)
3747

@@ -56,6 +66,9 @@ while true do
5666

5767
nLog("Test multi-touch gestures…")
5868
assert(app.front_bid() == "com.apple.mobileslideshow")
69+
sys.sleep(1)
70+
touch.tap(375, 1300)
71+
sys.sleep(1)
5972
require("rec_20221011184701")
6073
sys.sleep(2)
6174

@@ -71,17 +84,12 @@ while true do
7184
x, y =
7285
screen.find_color(
7386
{
74-
{713, 1497, 0xe3ae09, 90.00}, -- 1
75-
{688, 1522, 0xe3ae09, 90.00}, -- 2
76-
{698, 1501, 0xe3ae09, 90.00}, -- 3
77-
{674, 1518, 0xe3ae09, 90.00}, -- 4
78-
{692, 1536, 0xe3ae09, 90.00}, -- 5
79-
{709, 1512, 0xe3ae09, 90.00}, -- 6
80-
{698, 1506, 0xffffff, 90.00}, -- 7
81-
{704, 1513, 0xffffff, 90.00}, -- 8
82-
{678, 1506, 0xffffff, 90.00}, -- 9
83-
{678, 1532, 0xffffff, 90.00}, -- 10
84-
{704, 1532, 0xffffff, 90.00} -- 11
87+
{1056,2341,0xe4af0a},
88+
{1057,2388,0xe4af0a},
89+
{1105,2389,0xe4af0a},
90+
{1079,2366,0xe4af0a},
91+
{1106,2339,0xe4af0a},
92+
{1113,2332,0xe4af0a},
8593
}
8694
)
8795
if x > -1 then

0 commit comments

Comments
 (0)