|
1 # |
|
2 # Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 # All rights reserved. |
|
4 # This component and the accompanying materials are made available |
|
5 # under the terms of "Eclipse Public License v1.0" |
|
6 # which accompanies this distribution, and is available |
|
7 # at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 # |
|
9 # Initial Contributors: |
|
10 # Nokia Corporation - initial contribution. |
|
11 # |
|
12 # Contributors: |
|
13 # |
|
14 # Description: |
|
15 # |
|
16 |
|
17 # which accompanies this distribution, and is available |
|
18 |
|
19 # |
|
20 # Initial Contributors: |
|
21 # Nokia Corporation - initial contribution. |
|
22 # |
|
23 # Contributors: |
|
24 # |
|
25 # Description: |
|
26 # |
|
27 |
|
28 use Win32::API; |
|
29 use StatAPI; |
|
30 |
|
31 ######################################## |
|
32 # Set up initial data |
|
33 # You will want to change: |
|
34 # - def_connection |
|
35 # - def_codetype |
|
36 # - loglevel |
|
37 ######################################## |
|
38 |
|
39 my $result = 1; |
|
40 my $dll = "stat.dll"; |
|
41 # For the connection, refer to the enumeration in stat.h. |
|
42 my $def_connection = 2; |
|
43 my $def_codetype = "COM1"; |
|
44 my $logfile = "C:\\apps\\stat\\LogFiles\\stat_perl.log"; |
|
45 # For log level, specify 2 for command line testing, specify 3 for automatic testing. |
|
46 my $loglevel = 2; |
|
47 my $senddir = "/"; # (must end in 'slash') |
|
48 my $recvdir = "Recvd/"; |
|
49 my $commondir = "Common/"; |
|
50 my $hndl = 0; # a handle to a remote device connection |
|
51 |
|
52 ######################################## |
|
53 # Set options from parameters |
|
54 ######################################## |
|
55 |
|
56 if (@ARGV > 4) |
|
57 { |
|
58 print "Usage : perl stat.pl [connection type <"; |
|
59 print $def_connection; |
|
60 print ">] [connection data<"; |
|
61 print $def_codetype; |
|
62 print ">] [log level<"; |
|
63 print $loglevel; |
|
64 print ">]\n"; |
|
65 exit 0; |
|
66 } |
|
67 |
|
68 if (@ARGV > 0) |
|
69 { |
|
70 $def_connection = @ARGV[0]; |
|
71 } |
|
72 |
|
73 if (@ARGV > 1) |
|
74 { |
|
75 $def_codetype = @ARGV[1]; |
|
76 } |
|
77 |
|
78 if (@ARGV > 2) |
|
79 { |
|
80 $loglevel = @ARGV[2]; |
|
81 } |
|
82 |
|
83 ######################################## |
|
84 # Create the argument list |
|
85 ######################################## |
|
86 |
|
87 my @arglist = ($dll, $def_connection, $def_codetype, $loglevel, $logfile , $senddir, $recvdir, $commondir); |
|
88 |
|
89 ######################################## |
|
90 # Create the connection |
|
91 ######################################## |
|
92 |
|
93 print "==========================\n"; |
|
94 print "STAT API Connectivity Test\n"; |
|
95 print "==========================\n\n"; |
|
96 |
|
97 # set folders |
|
98 Symbian::StatAPI::set_dll_folder("\\epoc32\\tools\\stat"); |
|
99 |
|
100 # initialise |
|
101 Symbian::StatAPI::initialise(@arglist) or goto scripterror; # initialise the DLL |
|
102 |
|
103 # connect to a device |
|
104 $hndl = Symbian::StatAPI::connect_to_target(); |
|
105 $hndl or goto scripterror; |
|
106 |
|
107 Symbian::StatAPI::set_connection_logging(); |
|
108 |
|
109 Symbian::StatAPI::set_command_logging($hndl); |
|
110 |
|
111 ######################################## |
|
112 # The script |
|
113 ######################################## |
|
114 |
|
115 Symbian::StatAPI::get_screenshot($hndl); |
|
116 |
|
117 Symbian::StatAPI::basic_key_sequence($hndl,'b'); |
|
118 |
|
119 Symbian::StatAPI::get_device_info($hndl); |
|
120 |
|
121 Symbian::StatAPI::start_application($hndl,'Z:\Sys\Bin\Contacts.app','Test'); |
|
122 Symbian::StatAPI::control_keystroke($hndl,'Menu'); |
|
123 Symbian::StatAPI::control_keystroke($hndl,'RightArrow'); |
|
124 Symbian::StatAPI::basic_key_sequence($hndl,'1'); |
|
125 Symbian::StatAPI::basic_key_sequence($hndl,'Os'); |
|
126 Symbian::StatAPI::control_keystroke($hndl,'DownArrow'); |
|
127 Symbian::StatAPI::basic_key_sequence($hndl,'Symbian'); |
|
128 Symbian::StatAPI::combination_keystroke($hndl,'Ctrl+S'); |
|
129 Symbian::StatAPI::get_screenshot($hndl); |
|
130 Symbian::StatAPI::combination_keystroke($hndl,'Ctrl+E'); |
|
131 |
|
132 Symbian::StatAPI::start_application($hndl,'Z:\Sys\Bin\Agenda.app','Test'); |
|
133 Symbian::StatAPI::combination_keystroke($hndl,'Shift+Ctrl+E'); |
|
134 Symbian::StatAPI::control_keystroke($hndl,'Enter'); |
|
135 Symbian::StatAPI::basic_key_sequence($hndl,'My Birthday'); |
|
136 Symbian::StatAPI::control_keystroke($hndl,'DownArrow'); |
|
137 Symbian::StatAPI::control_keystroke($hndl,'DownArrow'); |
|
138 Symbian::StatAPI::control_keystroke($hndl,'DownArrow'); |
|
139 Symbian::StatAPI::control_keystroke($hndl,'LeftArrow'); |
|
140 Symbian::StatAPI::control_keystroke($hndl,'Enter'); |
|
141 Symbian::StatAPI::get_screenshot($hndl); |
|
142 Symbian::StatAPI::combination_keystroke($hndl,'Ctrl+E'); |
|
143 |
|
144 Symbian::StatAPI::start_application($hndl,'Z:\Sys\Bin\TimeW.app'); |
|
145 Symbian::StatAPI::combination_keystroke($hndl,'Ctrl+Shift+K'); |
|
146 Symbian::StatAPI::get_screenshot($hndl); |
|
147 Symbian::StatAPI::combination_keystroke($hndl,'Ctrl+E'); |
|
148 |
|
149 Symbian::StatAPI::get_screenshot($hndl); |
|
150 |
|
151 Symbian::StatAPI::copy_testfile_to_target($hndl,'StdAfx.sbr','C:\System\StdAfx.sb_'); |
|
152 Symbian::StatAPI::copy_from_target($hndl,'C:\System\StdAfx.sb_'); |
|
153 Symbian::StatAPI::remove_file($hndl,'C:\System\StdAfx.sb_'); |
|
154 |
|
155 goto endscript; |
|
156 |
|
157 ######################################## |
|
158 # Error handling routine |
|
159 ######################################## |
|
160 scripterror: |
|
161 print "\nScript aborted due to error:\n" . Symbian::StatAPI::get_last_error($hndl) . "\n"; |
|
162 $result = 0; |
|
163 |
|
164 ######################################## |
|
165 # Finish |
|
166 ######################################## |
|
167 endscript: |
|
168 $hndl and Symbian::StatAPI::disconnect_from_target($hndl) and print "Disconnected OK\n"; |
|
169 Symbian::StatAPI::close_connection_logging(); # close log file |
|
170 |
|
171 exit ($result); |
|
172 |