Module: tools Branch: master Commit: 12134f879ae7b29d12d5e8d8a31ebdf781ca73ad URL: https://source.winehq.org/git/tools.git/?a=commit;h=12134f879ae7b29d12d5e8d8...
Author: Francois Gouget fgouget@codeweavers.com Date: Fri Dec 24 09:44:33 2021 +0100
testbot/SetWinLocale: Check that the locale changes took effect.
Signed-off-by: Francois Gouget fgouget@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
testbot/bin/SetWinLocale | 107 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+)
diff --git a/testbot/bin/SetWinLocale b/testbot/bin/SetWinLocale index 8d2fb5e..0355d41 100755 --- a/testbot/bin/SetWinLocale +++ b/testbot/bin/SetWinLocale @@ -608,6 +608,62 @@ if ($OptShow) }
+# +# Helper to get the LCIDs +# + +my (%WinLCIDs, %WinKeyboardIds); + +sub GetWinKeyboardIds($) +{ + my ($Locale) = @_; + + # Look for that locale's keyboard id. + # Its first component is the locale's LCID. + my $Values = RegGetValues("$HKCU_USER_PROFILE\$Locale", "*:*"); + foreach my $VName (keys %$Values) + { + next if ($VName !~ /^[0-9A-F]{4}:/); + $WinKeyboardIds{$Locale} = [$VName]; + last; + } + $WinKeyboardIds{$Locale} ||= $Keyboards{$Locale}; + if (!$WinKeyboardIds{$Locale}) + { + FatalError("could not find the $Locale LCID and keyboard ids\n"); + } + + my $WinLCID = uc($WinKeyboardIds{$Locale}->[0]); + $WinLCID =~ s/:.*$//; + $WinLCIDs{$Locale} = $WinLCID; + + # Check our builtin information + if ($Keyboards{$Locale}) + { + my $LCID = uc($Keyboards{$Locale}->[0]); + $LCID =~ s/:.*$//; + if ($LCID ne $WinLCID) + { + FatalError("inconsistent $Locale LCID: expected $LCID, got $WinLCID\n"); + } + } + + return $WinKeyboardIds{$Locale}; +} + +sub GetLCID($) +{ + my ($Locale) = @_; + return undef if (!$Locale); + + GetWinKeyboardIds($Locale) if (!$WinLCIDs{$Locale}); + return $WinLCIDs{$Locale}; +} + +my $LCIDLocale = GetLCID($OptLocale); +my $LCIDSystem = GetLCID($OptSystem); + + # # Generate the intl.cpl configuration # @@ -738,5 +794,56 @@ if ($OptReboot) } }
+ +# +# Check that all the changes succeeded +# + +my $Success = 1; +sub CheckSetting($$$$;$) +{ + my ($Settings, $VName, $Expected, $For, $IgnoreCase) = @_; + + my $Value = $Settings->{$VName}; + if (defined $Value) + { + if ((!$IgnoreCase and $Value ne $Expected) or + ($IgnoreCase and uc($Value) ne uc($Expected))) + { + Error("expected $VName = $Expected but got $Value $For\n"); + $Success = 0; + } + } +} + +Debug(Elapsed($Start), " Checking the new locale settings\n"); +my $Settings = GetWinSettings($Debug); +ShowWinSettings($Settings) if ($Debug); +if ($OptLocale) +{ + CheckSetting($Settings, "Locale", "0000$LCIDLocale", "for --locale $OptLocale", 1); + CheckSetting($Settings, "LocaleName", $OptLocale, "for --locale $OptLocale"); +} +if ($OptKeyboard) +{ + CheckSetting($Settings, "InputMethod", $Keyboards{$OptKeyboard}->[0], "for --keyboard $OptKeyboard", 1); +} +if ($OptMUI) +{ + CheckSetting($Settings, "PreferredUILanguages", $OptMUI, "for --mui $OptMUI"); +} +if ($OptCountry) +{ + CheckSetting($Settings, "Country", $CountryId, "for --country $OptCountry"); + CheckSetting($Settings, "CountryName", $OptCountry, "for --country $OptCountry"); +} +if ($OptSystem) +{ + CheckSetting($Settings, "SysLanguage", $LCIDSystem, "for --system $OptSystem", 1); + CheckSetting($Settings, "SysLocale", "0000$LCIDSystem", "for --system $OptSystem", 1); +} +exit(1) if (!$Success); + + Debug(Elapsed($Start), " All done!\n"); exit(0);