os/graphics/windowing/windowserver/test/scripts/wsini-writer.pl
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/graphics/windowing/windowserver/test/scripts/wsini-writer.pl	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,115 @@
     1.4 +#
     1.5 +# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
     1.6 +# All rights reserved.
     1.7 +# This component and the accompanying materials are made available
     1.8 +# under the terms of "Eclipse Public License v1.0"
     1.9 +# which accompanies this distribution, and is available
    1.10 +# at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.11 +#
    1.12 +# Initial Contributors:
    1.13 +# Nokia Corporation - initial contribution.
    1.14 +#
    1.15 +# Contributors:
    1.16 +#
    1.17 +# Description: 
    1.18 +#
    1.19 +#!perl
    1.20 +
    1.21 +use strict;
    1.22 +
    1.23 +my $file = $ARGV[0];
    1.24 +
    1.25 +die "Usage: $0 filename\n" if (!$file);
    1.26 +die "ERROR: \"$file\" does not exist\n" if (!-f $file);
    1.27 +
    1.28 +&AddNoRedrawStoring($file) if($ARGV[3] =~ /^noredrawstoring$/i);
    1.29 +&AddAutoLine($file) if ($ARGV[2] =~ /^auto$/i);
    1.30 +&AddMultiLine($file) if ($ARGV[1] =~ /^multiscreen$/i);
    1.31 +
    1.32 +
    1.33 +# This function adds a line to a wsini.ini so that it runs the tests in auto mode
    1.34 +# This functions assumes the file is in UTF16
    1.35 +sub AddAutoLine
    1.36 +{
    1.37 +  my $file = shift;
    1.38 +
    1.39 +  my $string = &ascii_to_utf16('SHELLCMD AUTO');
    1.40 +
    1.41 +  &Write_UTF16_Newline($file);
    1.42 +
    1.43 +  open(FILE, ">>$file") or warn "WARNING: Could not open file: $!\n";
    1.44 +  print FILE $string;
    1.45 +  close FILE;
    1.46 +
    1.47 +  &Write_UTF16_Newline($file);
    1.48 +}
    1.49 +
    1.50 +
    1.51 +# This function adds a line to a wsini.ini so that it runs in multiscreen
    1.52 +# This functions assumes the file is in UTF16
    1.53 +sub AddMultiLine
    1.54 +{
    1.55 +  my $file = shift;
    1.56 +
    1.57 +  my $string0 = &ascii_to_utf16('[SCREEN0]');
    1.58 +  my $string1 = &ascii_to_utf16('[SCREEN1]');
    1.59 +
    1.60 +  &Write_UTF16_Newline($file);
    1.61 +
    1.62 +  open(FILE0, ">>$file") or warn "WARNING: Could not open file: $!\n";
    1.63 +  print FILE0 $string0;
    1.64 +  close FILE0;
    1.65 +  &Write_UTF16_Newline($file);
    1.66 +
    1.67 +  open(FILE1, ">>$file") or warn "WARNING: Could not open file: $!\n";
    1.68 +  print FILE1 $string1;
    1.69 +  close FILE1;
    1.70 +  &Write_UTF16_Newline($file);
    1.71 +}
    1.72 +
    1.73 +# This function adds a line to a wsini.ini so that it runs the tests with NOREDRAWSTORING flag
    1.74 +# This functions assumes the file is in UTF16
    1.75 +sub AddNoRedrawStoring
    1.76 +{
    1.77 +  my $file = shift;
    1.78 +
    1.79 +  my $string = &ascii_to_utf16('NOREDRAWSTORING');
    1.80 +
    1.81 +  &Write_UTF16_Newline($file);
    1.82 +
    1.83 +  open(FILE, ">>$file") or warn "WARNING: Could not open file: $!\n";
    1.84 +  print FILE $string;
    1.85 +  close FILE;
    1.86 +
    1.87 +  &Write_UTF16_Newline($file);
    1.88 +}
    1.89 +
    1.90 +
    1.91 +sub Write_UTF16_Newline
    1.92 +{
    1.93 +  my $file = shift;
    1.94 +
    1.95 +  open(BIN, ">>$file") or warn "WARNING: Could not open \"$file\": $!\n";
    1.96 +  binmode BIN;
    1.97 +  sysseek BIN, 0, 'SEEK_END';
    1.98 +  syswrite BIN, "\x0D\x00\x0A\x00" or warn "WARNING: Could not write to file\n";
    1.99 +  close BIN;
   1.100 +}
   1.101 +
   1.102 +
   1.103 +
   1.104 +# Function that accepts an ASCII string and returns the same string in UTF16
   1.105 +sub ascii_to_utf16 {
   1.106 +  my $utf16_string = "";
   1.107 +  my $ascii_string = shift;
   1.108 +  my $lengthofstring = length($ascii_string);
   1.109 +
   1.110 +  for (my $count=1; $count<=$lengthofstring; $count++)
   1.111 +  {
   1.112 +    my $char = substr($ascii_string,$count-1,1);
   1.113 +    $utf16_string .= $char;
   1.114 +    $utf16_string .= "\x00";
   1.115 +  }
   1.116 +
   1.117 +  return $utf16_string;
   1.118 +}
   1.119 \ No newline at end of file