File: scriptable.txt

package info (click to toggle)
ofono-phonesim 2.1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,976 kB
  • sloc: cpp: 18,743; xml: 7,288; sh: 1,313; ansic: 245; makefile: 71
file content (55 lines) | stat: -rw-r--r-- 2,183 bytes parent folder | download
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
With the support of QtScript, now phonesim is scriptable, which means you may
manipulate or extend phonesim's functionality using ECMA script language
(defined in ECMA-262). At the same time, some D-Bus interface and dedicated
methods are also defined to facilitate this feature. As a result, full test
automation can be achieved (Without this, if you want to initiate an incoming
call, you have to do some operations manually within phonesim GUI).  Below are
several examples:

1. call.js (stand for incoming call and copy it to /tmp/call/)
tabCall.gbIncomingCall.leCaller.text = "12345";
tabCall.gbIncomingCall.pbIncomingCall.click();

Then set the path of script and run the script with its name:

dbus-send --session --print-reply --dest=org.ofono.phonesim /
org.ofono.phonesim.Script.SetPath string:/tmp/call

dbus-send --session --print-reply --dest=org.ofono.phonesim /
org.ofono.phonesim.Script.Run string:call.js

Now you have simulated an incoming call.

PS: If you want to know the hierarchy of UI elements, check the file
src/controlbase.ui

2. sms.js (stand for incoming sms and copy it to /tmp/sms/)
tabSMS.gbMessage1.leMessageSender.text = "Yang";
tabSMS.gbMessage1.leSMSClass.text = "1";
tabSMS.gbMessage1.teSMSText.setPlainText("Sent from phonesim");
tabSMS.gbMessage1.pbSendSMSMessage.click();

Then do the similar things as first example:

dbus-send --session --print-reply --dest=org.ofono.phonesim /
org.ofono.phonesim.Script.SetPath string:/tmp/sms

dbus-send --session --print-reply --dest=org.ofono.phonesim /
org.ofono.phonesim.Script.Run string:sms.js

Now you have simulated an incoming sms.

3. Get the current path for script
dbus-send --session --print-reply --dest=org.ofono.phonesim /
org.ofono.phonesim.Script.GetPath

4. Make script return some string
The string can be any string, number, bool, date, etc in JavaScript, but it
couldn't be a object because of some side effect. Refer "QScriptValue Class
Reference" for details.
For example, if you want to know the current incoming number, you may write a
script as below:
// number.js
tabCall.gbIncomingCall.leCaller.text

After running the script the similar way as above, you may get the number.