int SDateTime::hourMode() { bool format12h = false; #if defined(Q_OS_WIN) wchar_t data[10]; GetLocaleInfo(LOCALE_USER_DEFAULT, LOCALE_STIMEFORMAT, data, 10); format12h = QString::fromWCharArray(data).startsWith(QLatin1Char('h')); #elif defined(Q_OS_SYMBIAN) TExtendedLocale loc; loc.LoadSystemSettings(); format12h = loc.GetLocale()->TimeFormat() == ETime12; #endif return format12h ? TwelveHours : TwentyFourHours; }
/** Sets up the system-wide locale and language downgrade path for the new locale model. */ void REComLanguagePluginTest::SetLanguage(const TDesC& aLanguage,const TDesC& aReg,const TDesC& aColl,const TLanguage aLang[3]) { TLocale locale; TExtendedLocale extendedLocale; TInt loadval = 0; extendedLocale.LoadSystemSettings(); loadval = extendedLocale.LoadLocale(aLanguage,aReg,aColl); TEST(loadval==KErrNone, __LINE__); extendedLocale.SaveSystemSettings(); locale.SetLanguageDowngrade(0, aLang[0]); locale.SetLanguageDowngrade(1, aLang[1]); locale.SetLanguageDowngrade(2, aLang[2]); locale.Set(); }
/*! Retrieves Symbian locale group separator. */ static QString symbianGroupSeparator() { TLocale *locale = _s60Locale.GetLocale(); TChar grpSep = locale->ThousandsSeparator(); int val = grpSep; return QChar(val); }
/*! Retrieves Symbian locale decimal separator. */ static QString symbianDecimalPoint() { TLocale *locale = _s60Locale.GetLocale(); TChar decPoint = locale->DecimalSeparator(); int val = decPoint; return QChar(val); }
/*! \brief Changes the system UI language. \param language identifier of the language \return true if operation was successful */ bool setLocale( int language ) { TExtendedLocale dummy; dummy.LoadSystemSettings(); QString no; no = QString( "%1" ).arg( language, 2, 10, QLatin1Char( '0' ) ); QString name = QString( "elocl." ).append( no ); TPtrC nameptr(name.utf16()); TInt err = dummy.LoadLocale( nameptr ); if( err != KErrNone ) return false; dummy.SaveSystemSettings(); // cause localeprivate update on next qlocale object( glp->m_language_id = 0 ) QSystemLocale dummy2; return true; }
/*! Retrieves Symbian locale zero digit. */ static QString symbianZeroDigit() { TLocale *locale = _s60Locale.GetLocale(); // TDigitType enumeration value returned by TLocale // will always correspond to zero digit unicode value. TDigitType digit = locale->DigitType(); return QChar(digit); }
void Util::SetAppropriateTimezoneL() { TUid repUid = {0x1020e4d3}; CRepository* rep = CRepository::NewLC(repUid); // Set the date format to European User::LeaveIfError(rep->StartTransaction(CRepository::EConcurrentReadWriteTransaction)); User::LeaveIfError(rep->Set(101, EDateEuropean)); // 101 is the date format reg entry TUint32 keys(0); User::LeaveIfError(rep->CommitTransaction(keys)); CleanupStack::PopAndDestroy(rep); TExtendedLocale locale; locale.LoadSystemSettings(); locale.GetLocale()->SetDateFormat(EDateEuropean); User::LeaveIfError(locale.SaveSystemSettings()); }
void CTestChangeLanguageStep::ChangeLocaleL(TLanguage aLanguage) { #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL _LIT(KLitLocaleDllNameBase, "elocl_lan"); _LIT(KLitLocaleDllNameExtension, ".loc"); #else _LIT(KLitLocaleDllNameBase, "ELOCL"); _LIT(KLitLocaleDllNameExtension, ".LOC"); #endif RLibrary localeDll; TBuf<16> localeDllName(KLitLocaleDllNameBase); CleanupClosePushL(localeDll); const TUidType uidType(TUid::Uid(0x10000079),TUid::Uid(0x100039e6)); #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL _LIT(ThreeDigExt,".%03d"); localeDllName.AppendFormat(ThreeDigExt, aLanguage); #else _LIT(KTwoDigExt,".%02d"); localeDllName.AppendFormat(KTwoDigExt, aLanguage); #endif TInt error=localeDll.Load(localeDllName, uidType); if (error == KErrNotFound) { _LIT(KLoadError,"ChangeLanguageStep : localeDll-Load() returned error = %d"); ERR_PRINTF2(KLoadError,error); localeDllName=KLitLocaleDllNameBase; localeDllName.Append(KLitLocaleDllNameExtension); error=localeDll.Load(localeDllName, uidType); } User::LeaveIfError(error); #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL _LIT(KLoadLocale,"Using API LoadLocaleAspect()"); INFO_PRINTF1(KLoadLocale); TExtendedLocale myExtendedLocale; User::LeaveIfError(myExtendedLocale.LoadLocaleAspect(localeDllName)); User::LeaveIfError(myExtendedLocale.SaveSystemSettings()); #else _LIT(KSecure,"Using Secure API ChangeLocale()"); INFO_PRINTF1(KSecure); User::LeaveIfError(UserSvr::ChangeLocale(localeDllName)); #endif CleanupStack::PopAndDestroy(); // localeDll }
void CTCnfStep::ChangeLocaleL(TLanguage aLanguage) { TBuf<50> libraryName; #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL libraryName.Format(_L("elocl_lan.%03d"), aLanguage); TExtendedLocale myExtendedLocale; TInt err = myExtendedLocale.LoadLocaleAspect(libraryName); TEST(err == KErrNone); User::LeaveIfError(err); err = myExtendedLocale.SaveSystemSettings(); TEST(err == KErrNone); User::LeaveIfError(err); #else libraryName.Format(_L("ELOCL.%02d"), aLanguage); TInt err = UserSvr::ChangeLocale(libraryName); User::LeaveIfError(err); TEST(err == KErrNone); #endif }
/*! Returns localized string representation of given \a date formatted with Symbian locale date format. If \a short_format is true the format will be a short version. Otherwise it uses a longer version. */ static QString symbianDateToString(const QDate &date, bool short_format) { int month = date.month() - 1; int day = date.day() - 1; int year = date.year(); TDateTime dateTime; dateTime.Set(year, TMonth(month), day, 0, 0, 0, 0); TTime timeStr(dateTime); TBuf<KMaxLongDateFormatSpec*2> buffer; TPtrC dateFormat; if (short_format) { dateFormat.Set(ptrGetShortDateFormatSpec(_s60Locale)); } else { dateFormat.Set(ptrGetLongDateFormatSpec(_s60Locale)); } TRAPD(err, ptrTimeFormatL(timeStr, buffer, dateFormat, *_s60Locale.GetLocale());) if (err == KErrNone)
/*! Returns a Qt version of the given \a sys_fmt Symbian locale format string. */ static QString s60ToQtFormat(const QString &sys_fmt) { TLocale *locale = _s60Locale.GetLocale(); QString result; QString other; QString qtformatchars = QString::fromLatin1("adhmsyzAHM"); QChar c; int i = 0; bool open_escape = false; bool abbrev_next = false; bool locale_indep_ordering = false; bool minus_mode = false; bool plus_mode = false; bool n_mode = false; TTimeFormat tf = locale->TimeFormat(); while (i < sys_fmt.size()) { c = sys_fmt.at(i); // let formatting thru if (c.unicode() == '%') { // if we have gathered string, concat it if (!other.isEmpty()) { result += other; other.clear(); } // if we have open escape, end it if (open_escape) { result += QLatin1Char('\''); open_escape = false; } ++i; if (i >= sys_fmt.size()) break; c = sys_fmt.at(i); // process specials abbrev_next = c.unicode() == '*'; plus_mode = c.unicode() == '+'; minus_mode = c.unicode() == '-'; if (abbrev_next || plus_mode || minus_mode) { ++i; if (i >= sys_fmt.size()) break; c = sys_fmt.at(i); if (plus_mode || minus_mode) { // break on undefined plus/minus mode if (c.unicode() != 'A' && c.unicode() != 'B') break; } } switch (c.unicode()) { case 'F': { // locale indep mode on locale_indep_ordering = true; break; } case '/': { // date sep 0-3 ++i; if (i >= sys_fmt.size()) break; c = sys_fmt.at(i); if (c.isDigit() && c.digitValue() <= 3) { TChar s = locale->DateSeparator(c.digitValue()); TUint val = s; // some indexes return zero for empty if (val > 0) result += QChar(val); } break; } case 'D': { if (!locale_indep_ordering) break; if (!abbrev_next) result += QLatin1String("dd"); else result += QLatin1Char('d'); break; } case 'M': { if (!locale_indep_ordering) break; if (!n_mode) { if (!abbrev_next) result += QLatin1String("MM"); else result += QLatin1String("M"); } else { if (!abbrev_next) result += QLatin1String("MMMM"); else result += QLatin1String("MMM"); } break; } case 'N': { n_mode = true; if (!locale_indep_ordering) break; if (!abbrev_next) result += QLatin1String("MMMM"); else result += QLatin1String("MMM"); break; } case 'Y': { if (!locale_indep_ordering) break; if (!abbrev_next) result += QLatin1String("yyyy"); else result += QLatin1String("yy"); break; } case 'E': { if (!abbrev_next) result += QLatin1String("dddd"); else result += QLatin1String("ddd"); break; } case ':': { // timesep 0-3 ++i; if (i >= sys_fmt.size()) break; c = sys_fmt.at(i); if (c.isDigit() && c.digitValue() <= 3) { TChar s = locale->TimeSeparator(c.digitValue()); TUint val = s; // some indexes return zero for empty if (val > 0) result += QChar(val); } break; } case 'J': { if (tf == ETime24 && !abbrev_next) result += QLatin1String("hh"); else result += QLatin1Char('h'); break; } case 'H': { if (!abbrev_next) result += QLatin1String("hh"); else result += QLatin1Char('h'); break; } case 'I': { result += QLatin1Char('h'); break; } case 'T': { if (!abbrev_next) result += QLatin1String("mm"); else result += QLatin1Char('m'); break; } case 'S': { if (!abbrev_next) result += QLatin1String("ss"); else result += QLatin1Char('s'); break; } case 'B': { // only done for 12h clock if (tf == ETime24) break; } // fallthru to A case 'A': { // quickie to get capitalization, can't use s60 string as is because Qt 'hh' format's am/pm logic TAmPmName ampm = TAmPmName(); TChar first(ampm[0]); QString qtampm = QString::fromLatin1(first.IsUpper() ? "AP" : "ap"); int pos = locale->AmPmSymbolPosition(); if ((minus_mode && pos != ELocaleBefore) || (plus_mode && pos != ELocaleAfter)) break; if (!abbrev_next && locale->AmPmSpaceBetween()) { if (pos == ELocaleBefore) qtampm.append(QLatin1Char(' ')); else qtampm.prepend(QLatin1Char(' ')); } result += qtampm; } break; case '.': { // decimal sep TChar s = locale->DecimalSeparator(); TUint val = s; if (val > 0) result += QChar(val); } break; case 'C': { // six digits in s60, three digits in qt if (!abbrev_next) { result += QLatin1String("zzz"); } else { // next char is number from 0-6, how many digits to display ++i; if (i >= sys_fmt.size()) break; c = sys_fmt.at(i); if (c.isDigit()) { // try to match wanted digits QChar val(c.digitValue()); if (val >= 3) { result += QLatin1String("zzz"); } else if (val > 0) { result += QLatin1Char('z'); } } } break; } // these cases fallthru case '1': case '2': case '3': case '4': case '5': { // shouldn't parse these with %F if (locale_indep_ordering) break; TDateFormat df = locale->DateFormat(); const char **locale_dep; switch (df) { default: // fallthru to american case EDateAmerican: locale_dep = us_locale_dep; break; case EDateEuropean: locale_dep = eu_locale_dep; break; case EDateJapanese: locale_dep = jp_locale_dep; break; } int offset = 0; if (abbrev_next) offset += 5; if (n_mode) offset += 10; result += QLatin1String(locale_dep[offset + (c.digitValue()-1)]); break; } case '%': // fallthru percent { // any junk gets copied as is } default: { result += c; break; } case 'Z': // Qt doesn't support these :( case 'X': case 'W': { break; } } } else { // double any single quotes, don't begin escape if (c.unicode() == '\'') { // end open escape if (open_escape) { result += other; other.clear(); result += QLatin1Char('\''); open_escape = false; } other += c; } // gather chars and escape them in one go if any format chars are found if (!open_escape && qtformatchars.indexOf(c) != -1) { result += QLatin1Char('\''); open_escape = true; } other += c; } ++i; } if (!other.isEmpty()) result += other; if (open_escape) result += QLatin1Char('\''); return result; }
/** @SYMTestCaseID SYSLIB-BAFL-CT-0487 @SYMTestCaseDesc Tests for defect number INC045169L @SYMTestPriority High @SYMTestActions Tests for creation of files @SYMTestExpectedResults Tests must not fail @SYMREQ REQ0000 */ void Defect_INC045169L() { TheTest.Next (_L (" @SYMTestCaseID:SYSLIB-BAFL-CT-0487 Defect_INC045169L ")); __UHEAP_MARK; // find out the number of open handles TInt startProcessHandleCount; TInt startThreadHandleCount; RThread ().HandleCount (startProcessHandleCount, startThreadHandleCount); // // The Test Setup User::LeaveIfError (TheFs.Connect ()); ::CleanupClosePushL (TheFs); // // The Test Begins... // Our test diectory and files... _LIT (KDirectory, "C:\\System\\Data\\"); // ++++++++++++++ // When creating test file names be careful to use different // combinations of charaters as you may get ambiguity! // i.e. '.aaa' will find files '.a' or 'a' if on disk. // similarly, 'abc158' will find files 'abc' or 'abc.'. // Also, file name ending in a period will have them // stripped off by the Fs, so 'abcd.' will give you 'abcd' // Finally, don't have like names like 'abc.rsc' and 'abc.r' // Failure cases _LIT (KFilename1, "c:"); // not supported _LIT (KFilename2, "x"); // not supported _LIT (KFilename3, "C:\\System\\Data\\a"); // not supported _LIT (KFilename4, "C:\\System\\Data\\ab"); // not supported _LIT (KFilename5, "C:\\System\\Data\\i.j"); // no 'i.01' available _LIT (KFilename6, "C:\\System\\Data\\abc.r12345678901234567890"); // suffix too large _LIT (KFilename7, "C:\\System\\Data\\"); // not supported // Successful cases _LIT (KFilename10, "C:\\System\\Data\\cde"); _LIT (KFilename11, "C:\\System\\Data\\abc158"); _LIT (KFilename12, "C:\\System\\Data\\C01abc001"); _LIT (KFilename13, "C:\\System\\Data\\0123456789.012"); _LIT (KFilename14, "C:\\System\\Data\\0123"); _LIT (KFilename15, "C:\\System\\Data\\0123456789012"); _LIT (KFilename16, "C:\\System\\Data\\C.01a1"); _LIT (KFilename17, "C:\\System\\Data\\C.a0a1"); _LIT (KFilename18, "C:\\System\\Data\\.b"); _LIT (KFilename19, "C:\\System\\Data\\.ccc"); _LIT (KFilename20, "C:\\System\\Data\\rfg.3a"); _LIT (KFilename21, "C:\\System\\Data\\abc.r158"); _LIT (KFilename22, "C:\\System\\Data\\abc.rsc"); _LIT (KFilename23, "C:\\System\\Data\\efg.r"); _LIT (KFilename24, "C:\\System\\Data\\klmn."); _LIT (KFilename25, "C:\\System\\Data\\jhgdfgd.123456789abc"); _LIT (KFilename26, "\\abc.r158"); _LIT (KFilename27, "abc.r158"); _LIT (KFilename28, "c:abc.r158"); // ++++++++++++++ // ELangAmerican _LIT (KLocale, "ELOCL.10"); _LIT (KNearestLang, "C:\\System\\Data\\abc.r10"); // Tidy the files if there... // KFilename1 can't be created BaflUtils::DeleteFile (TheFs, KFilename2); BaflUtils::DeleteFile (TheFs, KFilename3); BaflUtils::DeleteFile (TheFs, KFilename4); BaflUtils::DeleteFile (TheFs, KFilename5); BaflUtils::DeleteFile (TheFs, KFilename6); // Do not delete KFileName7, there may be other // files in this directory unrelated to this test // which are required by other tests. // See defect DEF108808 // BaflUtils::DeleteFile (TheFs, KFilename7); BaflUtils::DeleteFile (TheFs, KFilename10); BaflUtils::DeleteFile (TheFs, KFilename11); BaflUtils::DeleteFile (TheFs, KFilename12); BaflUtils::DeleteFile (TheFs, KFilename13); BaflUtils::DeleteFile (TheFs, KFilename14); BaflUtils::DeleteFile (TheFs, KFilename15); BaflUtils::DeleteFile (TheFs, KFilename16); BaflUtils::DeleteFile (TheFs, KFilename17); BaflUtils::DeleteFile (TheFs, KFilename18); BaflUtils::DeleteFile (TheFs, KFilename19); BaflUtils::DeleteFile (TheFs, KFilename20); BaflUtils::DeleteFile (TheFs, KFilename21); BaflUtils::DeleteFile (TheFs, KFilename22); BaflUtils::DeleteFile (TheFs, KFilename23); #ifdef __EPOC32__ BaflUtils::DeleteFile (TheFs, KFilename24); #else // Windows strips off trailing periods BaflUtils::DeleteFile (TheFs, _L("C:\\System\\Data\\klmn")); #endif BaflUtils::DeleteFile (TheFs, KFilename25); BaflUtils::DeleteFile (TheFs, KFilename26); BaflUtils::DeleteFile (TheFs, KFilename27); BaflUtils::DeleteFile (TheFs, KFilename28); BaflUtils::DeleteFile (TheFs, KNearestLang); // Confirm the prerequisites for this test... if (!BaflUtils::PathExists (TheFs, KDirectory)) { BaflUtils::EnsurePathExistsL(TheFs, KDirectory); } // KFilename1 can't be created TheTest (BaflUtils::FileExists (TheFs, KFilename2) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename3) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename4) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename5) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename6) == EFalse); // KFilename7 can't be created, not a file TheTest (BaflUtils::FileExists (TheFs, KFilename10) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename11) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename12) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename13) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename14) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename15) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename16) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename17) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename18) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename19) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename20) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename21) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename22) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename23) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename24) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename25) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename26) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename27) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KFilename28) == EFalse); TheTest (BaflUtils::FileExists (TheFs, KNearestLang) == EFalse); // Create the files... RFile rFile; // KFilename1 can't be created rFile.Create (TheFs, KFilename2, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename3, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename4, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename5, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename6, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename7, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename10, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename11, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename12, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename13, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename14, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename15, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename16, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename17, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename18, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename19, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename20, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename21, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename22, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename23, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename24, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename25, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename26, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename27, EFileRead); rFile.Close (); rFile.Create (TheFs, KFilename28, EFileRead); rFile.Close (); rFile.Create (TheFs, KNearestLang, EFileRead); rFile.Close (); TBuf <256> filename (KFilename1); // Test the defect... BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename1, &filename); TheTest(filename == KFilename1); filename.Copy (KFilename2); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename2, &filename); TheTest(filename == _L("x")); filename.Copy (KFilename3); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename3, &filename); TheTest(filename == KFilename3); filename.Copy (KFilename4); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename4, &filename); TheTest(filename == KFilename4); filename.Copy (KFilename5); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename5, &filename); TheTest(filename == KFilename5); filename.Copy (KFilename6); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename6, &filename); TheTest(filename == KFilename6); filename.Copy (KFilename7); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename7, &filename); TheTest(filename == KFilename7); filename.Copy (KFilename10); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename10, &filename); TheTest(filename == KFilename10); filename.Copy (KFilename11); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename11, &filename); TheTest(filename == KFilename11); filename.Copy (KFilename12); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename12, &filename); TheTest(filename == KFilename12); filename.Copy (KFilename13); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename13, &filename); TheTest(filename == KFilename13); filename.Copy (KFilename14); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename14, &filename); TheTest(filename == KFilename14); filename.Copy (KFilename15); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename15, &filename); TheTest(filename == KFilename15); filename.Copy (KFilename16); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename16, &filename); TheTest(filename == KFilename16); filename.Copy (KFilename17); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename17, &filename); TheTest(filename == KFilename17); filename.Copy (KFilename18); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename18, &filename); TheTest(filename == KFilename18); filename.Copy (KFilename19); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename19, &filename); TheTest(filename == KFilename19); filename.Copy (KFilename20); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename20, &filename); TheTest(filename == KFilename20); filename.Copy (KFilename21); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename21, &filename); TheTest(filename == KFilename21); filename.Copy (KFilename22); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename22, &filename); TheTest(filename == KFilename22); filename.Copy (KFilename23); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename23, &filename); TheTest(filename == KFilename23); filename.Copy (KFilename24); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename24, &filename); TheTest(filename == KFilename24); filename.Copy (KFilename25); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename25, &filename); TheTest(filename == KFilename25); filename.Copy (KFilename26); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename26, &filename); TheTest(filename == KFilename26); filename.Copy (KFilename27); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename27, &filename); TheTest(filename == KFilename27); filename.Copy (KFilename28); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename28, &filename); TheTest(filename == KFilename28); // Store the original locale settings so they can be restored at the // end of the test. TExtendedLocale originalLocale; originalLocale.LoadSystemSettings(); // Change locale TExtendedLocale newLocale; TBuf<50> libraryName; libraryName.Format(KLocale); TInt err = newLocale.LoadLocale(libraryName); User::LeaveIfError (err); newLocale.SaveSystemSettings(); User::After (5000000); filename.Copy (KFilename1); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename1, &filename); TheTest(filename == KFilename1); filename.Copy (KFilename2); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename2, &filename); TheTest(filename == _L("x")); filename.Copy (KFilename3); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename3, &filename); TheTest(filename == KFilename3); filename.Copy (KFilename4); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename4, &filename); TheTest(filename == KFilename4); filename.Copy (KFilename5); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename5, &filename); TheTest(filename == KFilename5); filename.Copy (KFilename6); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename6, &filename); TheTest(filename == KFilename6); filename.Copy (KFilename7); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename7, &filename); TheTest(filename == KFilename7); filename.Copy (KFilename10); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename10, &filename); TheTest(filename == KFilename10); filename.Copy (KFilename11); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename11, &filename); TheTest(filename == KFilename11); filename.Copy (KFilename12); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename12, &filename); TheTest(filename == KFilename12); filename.Copy (KFilename13); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename13, &filename); TheTest(filename == KFilename13); filename.Copy (KFilename14); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename14, &filename); TheTest(filename == KFilename14); filename.Copy (KFilename15); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename15, &filename); TheTest(filename == KFilename15); filename.Copy (KFilename16); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename16, &filename); TheTest(filename == KFilename16); filename.Copy (KFilename17); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename17, &filename); TheTest(filename == KFilename17); filename.Copy (KFilename18); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename18, &filename); TheTest(filename == KFilename18); filename.Copy (KFilename19); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename19, &filename); TheTest(filename == KFilename19); filename.Copy (KFilename20); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename20, &filename); TheTest(filename == KFilename20); filename.Copy (KFilename21); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename21, &filename); TheTest(filename == KNearestLang); filename.Copy (KFilename22); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename22, &filename); TheTest(filename == KNearestLang); filename.Copy (KFilename23); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename23, &filename); TheTest(filename == KFilename23); filename.Copy (KFilename24); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename24, &filename); TheTest(filename == KFilename24); filename.Copy (KFilename25); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename25, &filename); TheTest(filename == KFilename25); filename.Copy (KFilename26); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename26, &filename); TheTest(filename == KFilename26); filename.Copy (KFilename27); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename27, &filename); TheTest(filename == KFilename27); filename.Copy (KFilename28); BaflUtils::NearestLanguageFile (TheFs, filename); TheTest.Printf (_L ("The NearestLanguageFile for %S is %S\n"), &KFilename28, &filename); TheTest(filename == KFilename28); // Tidy the files... // KFilename1 can't be created BaflUtils::DeleteFile (TheFs, KFilename2); BaflUtils::DeleteFile (TheFs, KFilename3); BaflUtils::DeleteFile (TheFs, KFilename4); BaflUtils::DeleteFile (TheFs, KFilename5); BaflUtils::DeleteFile (TheFs, KFilename6); // Do not delete KFileName7, there may be other // files in this directory unrelated to this test // which are required by other tests. // See defect DEF108808 // BaflUtils::DeleteFile (TheFs, KFilename7); BaflUtils::DeleteFile (TheFs, KFilename10); BaflUtils::DeleteFile (TheFs, KFilename11); BaflUtils::DeleteFile (TheFs, KFilename12); BaflUtils::DeleteFile (TheFs, KFilename13); BaflUtils::DeleteFile (TheFs, KFilename14); BaflUtils::DeleteFile (TheFs, KFilename15); BaflUtils::DeleteFile (TheFs, KFilename16); BaflUtils::DeleteFile (TheFs, KFilename17); BaflUtils::DeleteFile (TheFs, KFilename18); BaflUtils::DeleteFile (TheFs, KFilename19); BaflUtils::DeleteFile (TheFs, KFilename20); BaflUtils::DeleteFile (TheFs, KFilename21); BaflUtils::DeleteFile (TheFs, KFilename22); BaflUtils::DeleteFile (TheFs, KFilename23); #ifdef __EPOC32__ BaflUtils::DeleteFile (TheFs, KFilename24); #else // Windows strips off trailing periods BaflUtils::DeleteFile (TheFs, _L("C:\\System\\Data\\klmn")); #endif BaflUtils::DeleteFile (TheFs, KFilename25); BaflUtils::DeleteFile (TheFs, KFilename26); BaflUtils::DeleteFile (TheFs, KFilename27); BaflUtils::DeleteFile (TheFs, KFilename28); BaflUtils::DeleteFile (TheFs, KNearestLang); // Restore the original locale settings. originalLocale.SaveSystemSettings(); CleanupStack::PopAndDestroy (&::TheFs); // The Test Ends... // // check that no handles have leaked TInt endProcessHandleCount; TInt endThreadHandleCount; RThread ().HandleCount (endProcessHandleCount, endThreadHandleCount); TheTest (startThreadHandleCount == endThreadHandleCount); __UHEAP_MARKEND; }
/** Auxiliary Fn for Test Case ID T-LocaleStep-TestAllLanguages This method loads the required DLL for the language specified as argument and changes the locale accordingly. */ void CT_LocaleStep::ChangeLocaleL(TLanguage aLanguage) {/* #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL _LIT(KLitLocaleDllNameBase, "elocl_lan"); _LIT(KLitLocaleDllNameExtension, ".loc"); #else _LIT(KLitLocaleDllNameBase, "ELOCL"); _LIT(KLitLocaleDllNameExtension, ".LOC"); #endif RLibrary localeDll; TBuf<16> localeDllName(KLitLocaleDllNameBase); CleanupClosePushL(localeDll); const TUidType uidType(TUid::Uid(0x10000079),TUid::Uid(0x100039e6)); #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL _LIT(ThreeDigExt,".%03d"); localeDllName.AppendFormat(ThreeDigExt, aLanguage); #else _LIT(TwoDigExt,".%02d"); localeDllName.AppendFormat(TwoDigExt, aLanguage); #endif TInt error=localeDll.Load(localeDllName, uidType); if (error==KErrNotFound) { localeDllName=KLitLocaleDllNameBase; localeDllName.Append(KLitLocaleDllNameExtension); error=localeDll.Load(localeDllName, uidType); } User::LeaveIfError(error); #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL TExtendedLocale myExtendedLocale; User::LeaveIfError(myExtendedLocale.LoadLocaleAspect(localeDllName)); User::LeaveIfError(myExtendedLocale.SaveSystemSettings()); #else User::LeaveIfError(UserSvr::ChangeLocale(localeDllName)); #endif CleanupStack::PopAndDestroy(); // localeDll */ #ifdef SYMBIAN_DISTINCT_LOCALE_MODEL _LIT(KLitLanguageLocaleDllNameBase, "elocl_lan"); //Region and collation code values are hard coded, as the check, after changing the locale is made for the language only. _LIT(KLitRegionLocaleDllNameBase, "elocl_reg.826"); _LIT(KLitCollationLocaleDllNameBase, "elocl_col.001"); _LIT(ThreeDigExt,".%03d"); TExtendedLocale localeDll; const TUidType uidType(TUid::Uid(0x10000079),TUid::Uid(0x100039e6)); TBuf<16> languageLocaleDllName(KLitLanguageLocaleDllNameBase); languageLocaleDllName.AppendFormat(ThreeDigExt, aLanguage); TBuf<16> regionLocaleDllName(KLitRegionLocaleDllNameBase); TBuf<16> collationLocaleDllName(KLitCollationLocaleDllNameBase); // Try to load the locale dll TInt error=localeDll.LoadLocale(languageLocaleDllName, regionLocaleDllName, collationLocaleDllName); if (error==KErrNotFound) { // Locale dll is not found for the asked language. ERR_PRINTF2(_L("Failed to find the locale dll for %d"), aLanguage); } User::LeaveIfError(error); localeDll.SaveSystemSettings(); #else _LIT(KLitLocaleDllNameBase, "ELOCL"); _LIT(TwoDigExt,".%02d"); RLibrary localeDll; CleanupClosePushL(localeDll); const TUidType uidType(TUid::Uid(0x10000079),TUid::Uid(0x100039e6)); TBuf<16> localeDllName(KLitLocaleDllNameBase); localeDllName.AppendFormat(TwoDigExt, language); // Try to load the locale dll TInt error=localeDll.Load(localeDllName, uidType); if (error==KErrNotFound) { // Locale dll is not found for the asked language. ERR_PRINTF2(_L("Failed to find the locale dll for %d"), language); } User::LeaveIfError(error); User::LeaveIfError(UserSvr::ChangeLocale(localeDllName)); CleanupStack::PopAndDestroy(); // localeDll #endif // Check if the device locale has changed if (aLanguage == User::Language()) { SetTestStepResult(EPass); } else { ERR_PRINTF3(_L("Failed to change the locale to %d whereas the current locale is"), aLanguage, User::Language()); } }