|
1 # |
|
2 # Copyright (c) 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 #!perl |
|
17 |
|
18 use strict; |
|
19 |
|
20 my $file = $ARGV[0]; |
|
21 |
|
22 die "Usage: $0 filename\n" if (!$file); |
|
23 die "ERROR: \"$file\" does not exist\n" if (!-f $file); |
|
24 |
|
25 &AddNoRedrawStoring($file) if($ARGV[3] =~ /^noredrawstoring$/i); |
|
26 &AddAutoLine($file) if ($ARGV[2] =~ /^auto$/i); |
|
27 &AddMultiLine($file) if ($ARGV[1] =~ /^multiscreen$/i); |
|
28 |
|
29 |
|
30 # This function adds a line to a wsini.ini so that it runs the tests in auto mode |
|
31 # This functions assumes the file is in UTF16 |
|
32 sub AddAutoLine |
|
33 { |
|
34 my $file = shift; |
|
35 |
|
36 my $string = &ascii_to_utf16('SHELLCMD AUTO'); |
|
37 |
|
38 &Write_UTF16_Newline($file); |
|
39 |
|
40 open(FILE, ">>$file") or warn "WARNING: Could not open file: $!\n"; |
|
41 print FILE $string; |
|
42 close FILE; |
|
43 |
|
44 &Write_UTF16_Newline($file); |
|
45 } |
|
46 |
|
47 |
|
48 # This function adds a line to a wsini.ini so that it runs in multiscreen |
|
49 # This functions assumes the file is in UTF16 |
|
50 sub AddMultiLine |
|
51 { |
|
52 my $file = shift; |
|
53 |
|
54 my $string0 = &ascii_to_utf16('[SCREEN0]'); |
|
55 my $string1 = &ascii_to_utf16('[SCREEN1]'); |
|
56 |
|
57 &Write_UTF16_Newline($file); |
|
58 |
|
59 open(FILE0, ">>$file") or warn "WARNING: Could not open file: $!\n"; |
|
60 print FILE0 $string0; |
|
61 close FILE0; |
|
62 &Write_UTF16_Newline($file); |
|
63 |
|
64 open(FILE1, ">>$file") or warn "WARNING: Could not open file: $!\n"; |
|
65 print FILE1 $string1; |
|
66 close FILE1; |
|
67 &Write_UTF16_Newline($file); |
|
68 } |
|
69 |
|
70 # This function adds a line to a wsini.ini so that it runs the tests with NOREDRAWSTORING flag |
|
71 # This functions assumes the file is in UTF16 |
|
72 sub AddNoRedrawStoring |
|
73 { |
|
74 my $file = shift; |
|
75 |
|
76 my $string = &ascii_to_utf16('NOREDRAWSTORING'); |
|
77 |
|
78 &Write_UTF16_Newline($file); |
|
79 |
|
80 open(FILE, ">>$file") or warn "WARNING: Could not open file: $!\n"; |
|
81 print FILE $string; |
|
82 close FILE; |
|
83 |
|
84 &Write_UTF16_Newline($file); |
|
85 } |
|
86 |
|
87 |
|
88 sub Write_UTF16_Newline |
|
89 { |
|
90 my $file = shift; |
|
91 |
|
92 open(BIN, ">>$file") or warn "WARNING: Could not open \"$file\": $!\n"; |
|
93 binmode BIN; |
|
94 sysseek BIN, 0, 'SEEK_END'; |
|
95 syswrite BIN, "\x0D\x00\x0A\x00" or warn "WARNING: Could not write to file\n"; |
|
96 close BIN; |
|
97 } |
|
98 |
|
99 |
|
100 |
|
101 # Function that accepts an ASCII string and returns the same string in UTF16 |
|
102 sub ascii_to_utf16 { |
|
103 my $utf16_string = ""; |
|
104 my $ascii_string = shift; |
|
105 my $lengthofstring = length($ascii_string); |
|
106 |
|
107 for (my $count=1; $count<=$lengthofstring; $count++) |
|
108 { |
|
109 my $char = substr($ascii_string,$count-1,1); |
|
110 $utf16_string .= $char; |
|
111 $utf16_string .= "\x00"; |
|
112 } |
|
113 |
|
114 return $utf16_string; |
|
115 } |