1999-01-29 02:27:55 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The contents of this file are subject to the Netscape Public
|
|
|
|
* License Version 1.1 (the "License"); you may not use this file
|
|
|
|
* except in compliance with the License. You may obtain a copy of
|
|
|
|
* the License at http://www.mozilla.org/NPL/
|
1999-01-29 02:27:55 +03:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* Software distributed under the License is distributed on an "AS
|
|
|
|
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
|
|
|
|
* implied. See the License for the specific language governing
|
|
|
|
* rights and limitations under the License.
|
1999-01-29 02:27:55 +03:00
|
|
|
*
|
1999-11-06 06:43:54 +03:00
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape
|
1999-01-29 02:27:55 +03:00
|
|
|
* Communications Corporation. Portions created by Netscape are
|
1999-11-06 06:43:54 +03:00
|
|
|
* Copyright (C) 1998 Netscape Communications Corporation. All
|
|
|
|
* Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
1999-01-29 02:27:55 +03:00
|
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include "nsILocale.h"
|
|
|
|
#include "nsILocaleFactory.h"
|
|
|
|
#include "nsLocaleCID.h"
|
1999-03-09 12:44:27 +03:00
|
|
|
#include "nsIComponentManager.h"
|
1999-08-02 07:00:23 +04:00
|
|
|
#include "nsILocaleService.h"
|
|
|
|
|
1999-02-04 03:33:44 +03:00
|
|
|
#ifdef XP_PC
|
1999-02-07 15:29:31 +03:00
|
|
|
#include "nsIWin32Locale.h"
|
1999-02-04 03:33:44 +03:00
|
|
|
#include <windows.h>
|
|
|
|
#endif
|
1999-04-07 10:13:19 +04:00
|
|
|
#ifdef XP_UNIX
|
|
|
|
#include "nsIPosixLocale.h"
|
|
|
|
#endif
|
1999-05-28 09:01:54 +04:00
|
|
|
#ifdef XP_MAC
|
|
|
|
#include "nsIMacLocale.h"
|
|
|
|
#endif
|
1999-01-29 02:27:55 +03:00
|
|
|
|
|
|
|
NS_DEFINE_CID(kLocaleFactoryCID, NS_LOCALEFACTORY_CID);
|
|
|
|
NS_DEFINE_IID(kILocaleFactoryIID, NS_ILOCALEFACTORY_IID);
|
1999-08-04 11:16:00 +04:00
|
|
|
NS_DEFINE_IID(kILocaleServiceIID,NS_ILOCALESERVICE_IID);
|
|
|
|
NS_DEFINE_CID(kLocaleServiceCID,NS_LOCALESERVICE_CID);
|
1999-01-29 02:27:55 +03:00
|
|
|
NS_DEFINE_CID(kLocaleCID, NS_LOCALE_CID);
|
|
|
|
NS_DEFINE_IID(kILocaleIID, NS_ILOCALE_IID);
|
|
|
|
NS_DEFINE_IID(kIFactoryIID, NS_IFACTORY_IID);
|
|
|
|
NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID);
|
|
|
|
|
1999-02-04 03:33:44 +03:00
|
|
|
#ifdef XP_PC
|
|
|
|
NS_DEFINE_CID(kWin32LocaleFactoryCID, NS_WIN32LOCALEFACTORY_CID);
|
|
|
|
NS_DEFINE_IID(kIWin32LocaleIID, NS_IWIN32LOCALE_IID);
|
1999-04-06 09:46:29 +04:00
|
|
|
|
|
|
|
#define USER_DEFINED_PRIMARYLANG 0x0200
|
|
|
|
#define USER_DEFINED_SUBLANGUAGE 0x20
|
|
|
|
|
1999-04-07 10:13:19 +04:00
|
|
|
#endif
|
|
|
|
#ifdef XP_UNIX
|
|
|
|
NS_DEFINE_CID(kPosixLocaleFactoryCID, NS_POSIXLOCALEFACTORY_CID);
|
|
|
|
NS_DEFINE_IID(kIPosixLocaleIID, NS_IPOSIXLOCALE_IID);
|
1999-02-04 03:33:44 +03:00
|
|
|
#endif
|
1999-05-28 09:01:54 +04:00
|
|
|
#ifdef XP_MAC
|
|
|
|
NS_DEFINE_CID(kMacLocaleFactoryCID, NS_MACLOCALEFACTORY_CID);
|
|
|
|
NS_DEFINE_IID(kIMacLocaleIID, NS_IMACLOCALE_IID);
|
|
|
|
#endif
|
1999-02-04 03:33:44 +03:00
|
|
|
|
1999-06-09 06:37:14 +04:00
|
|
|
char* localeCategoryList[6] = { "NSILOCALE_TIME",
|
1999-01-29 02:27:55 +03:00
|
|
|
"NSILOCALE_COLLATE",
|
|
|
|
"NSILOCALE_CTYPE",
|
|
|
|
"NSILOCALE_MONETARY",
|
|
|
|
"NSILOCALE_MESSAGES",
|
|
|
|
"NSILOCALE_NUMERIC"
|
|
|
|
};
|
|
|
|
|
1999-08-02 07:00:23 +04:00
|
|
|
void
|
|
|
|
serivce_create_interface(void)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsILocaleService* localeService;
|
|
|
|
|
|
|
|
result = nsComponentManager::CreateInstance(kLocaleServiceCID,
|
|
|
|
NULL,
|
1999-08-04 11:16:00 +04:00
|
|
|
kILocaleServiceIID,
|
1999-08-02 07:00:23 +04:00
|
|
|
(void**)&localeService);
|
|
|
|
NS_ASSERTION(localeService!=NULL,"nsLocaleTest: service_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: service_create_interface failed");
|
1999-08-02 07:00:23 +04:00
|
|
|
|
|
|
|
localeService->Release();
|
|
|
|
}
|
|
|
|
|
1999-01-29 02:27:55 +03:00
|
|
|
void
|
|
|
|
factory_create_interface(void)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsILocaleFactory* localeFactory;
|
|
|
|
nsIFactory* genericFactory;
|
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
result = nsComponentManager::CreateInstance(kLocaleFactoryCID,
|
1999-01-29 02:27:55 +03:00
|
|
|
NULL,
|
|
|
|
kILocaleFactoryIID,
|
|
|
|
(void**)&localeFactory);
|
|
|
|
NS_ASSERTION(localeFactory!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-01-29 02:27:55 +03:00
|
|
|
|
|
|
|
localeFactory->Release();
|
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
result = nsComponentManager::CreateInstance(kLocaleFactoryCID,
|
1999-01-29 02:27:55 +03:00
|
|
|
NULL,
|
|
|
|
kIFactoryIID,
|
|
|
|
(void**)&genericFactory);
|
|
|
|
NS_ASSERTION(localeFactory!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-01-29 02:27:55 +03:00
|
|
|
|
|
|
|
genericFactory->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
factory_test_isupports(void)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsILocaleFactory* localeFactory;
|
|
|
|
nsISupports* genericInterface1, *genericInterface2;
|
|
|
|
nsIFactory* genericFactory1, *genericFactory2;
|
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
result = nsComponentManager::FindFactory(kLocaleFactoryCID,
|
1999-01-29 02:27:55 +03:00
|
|
|
(nsIFactory**)&localeFactory);
|
|
|
|
NS_ASSERTION(localeFactory!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-01-29 02:27:55 +03:00
|
|
|
|
|
|
|
//
|
|
|
|
// test AddRef
|
|
|
|
localeFactory->AddRef();
|
|
|
|
|
|
|
|
//
|
|
|
|
// test Release
|
|
|
|
//
|
|
|
|
localeFactory->Release();
|
|
|
|
|
|
|
|
//
|
|
|
|
// test generic interface
|
|
|
|
//
|
|
|
|
result = localeFactory->QueryInterface(kISupportsIID,(void**)&genericInterface1);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_test_isupports failed.");
|
1999-01-29 02:27:55 +03:00
|
|
|
NS_ASSERTION(genericInterface1!=NULL,"nsLocaleTest: factory_test_isupports failed.");
|
|
|
|
|
|
|
|
result = localeFactory->QueryInterface(kISupportsIID,(void**)&genericInterface2);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_test_isupports failed.");
|
1999-01-29 02:27:55 +03:00
|
|
|
NS_ASSERTION(genericInterface2!=NULL,"nsLocaleTest: factory_test_isupports failed.");
|
|
|
|
NS_ASSERTION(genericInterface1==genericInterface2,"nsLocaleTest: factory_test_isupports failed.");
|
|
|
|
|
|
|
|
genericInterface1->Release();
|
|
|
|
genericInterface2->Release();
|
|
|
|
|
|
|
|
//
|
|
|
|
// test generic factory
|
|
|
|
//
|
|
|
|
result = localeFactory->QueryInterface(kIFactoryIID,(void**)&genericFactory1);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_test_isupports failed.");
|
1999-01-29 02:27:55 +03:00
|
|
|
NS_ASSERTION(genericFactory1!=NULL,"nsLocaleTest: factory_test_isupports failed.");
|
|
|
|
|
|
|
|
result = localeFactory->QueryInterface(kIFactoryIID,(void**)&genericFactory2);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_test_isupports failed.");
|
1999-01-29 02:27:55 +03:00
|
|
|
NS_ASSERTION(genericFactory1!=NULL,"nsLocaleTest: factory_test_isupports failed.");
|
|
|
|
NS_ASSERTION(genericFactory1==genericFactory2,"nsLocaleTest: factory_test_isupports failed.");
|
|
|
|
|
|
|
|
genericFactory1->Release();
|
|
|
|
genericFactory2->Release();
|
|
|
|
|
|
|
|
localeFactory->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
factory_new_locale(void)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsILocaleFactory* localeFactory;
|
|
|
|
nsILocale* locale;
|
1999-06-09 06:37:14 +04:00
|
|
|
nsString* localeName, *category, *value;
|
1999-01-29 02:27:55 +03:00
|
|
|
int i;
|
1999-06-09 06:37:14 +04:00
|
|
|
nsString** categoryList, **valueList;
|
1999-08-04 11:16:00 +04:00
|
|
|
PRUnichar *lc_name_unichar;
|
1999-01-29 02:27:55 +03:00
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
result = nsComponentManager::FindFactory(kLocaleFactoryCID,
|
1999-01-29 02:27:55 +03:00
|
|
|
(nsIFactory**)&localeFactory);
|
|
|
|
NS_ASSERTION(localeFactory!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-01-29 02:27:55 +03:00
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// test NewLocale
|
|
|
|
//
|
|
|
|
localeName = new nsString("ja-JP");
|
|
|
|
result = localeFactory->NewLocale(localeName,&locale);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_new_interface failed");
|
1999-01-29 02:27:55 +03:00
|
|
|
NS_ASSERTION(locale!=NULL,"nsLocaleTest: factory_new_interface failed");
|
|
|
|
|
|
|
|
for(i=0;i<6;i++)
|
|
|
|
{
|
1999-06-09 06:37:14 +04:00
|
|
|
category = new nsString(localeCategoryList[i]);
|
1999-01-29 02:27:55 +03:00
|
|
|
value = new nsString();
|
|
|
|
|
1999-07-17 02:57:45 +04:00
|
|
|
result = locale->GetCategory(category->GetUnicode(),&lc_name_unichar);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_new_interface failed");
|
1999-01-29 02:27:55 +03:00
|
|
|
|
1999-07-17 02:57:45 +04:00
|
|
|
value->SetString(lc_name_unichar);
|
1999-06-09 06:37:14 +04:00
|
|
|
delete category;
|
1999-01-29 02:27:55 +03:00
|
|
|
delete value;
|
|
|
|
}
|
1999-04-07 07:55:34 +04:00
|
|
|
delete localeName;
|
1999-01-29 02:27:55 +03:00
|
|
|
locale->Release();
|
|
|
|
|
1999-06-09 06:37:14 +04:00
|
|
|
categoryList = new nsString*[6];
|
1999-01-29 02:27:55 +03:00
|
|
|
valueList = new nsString*[6];
|
|
|
|
|
|
|
|
for(i=0;i<6;i++)
|
|
|
|
{
|
1999-06-09 06:37:14 +04:00
|
|
|
categoryList[i] = new nsString(localeCategoryList[i]);
|
1999-01-29 02:27:55 +03:00
|
|
|
valueList[i] = new nsString("x-netscape");
|
|
|
|
}
|
|
|
|
|
1999-06-09 06:37:14 +04:00
|
|
|
result = localeFactory->NewLocale(categoryList,valueList,6,&locale);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_new_interface failed");
|
1999-01-29 02:27:55 +03:00
|
|
|
NS_ASSERTION(locale!=NULL,"nsLocaleTest: factory_new_interface failed");
|
|
|
|
|
|
|
|
for(i=0;i<6;i++)
|
|
|
|
{
|
|
|
|
value = new nsString();
|
1999-07-17 02:57:45 +04:00
|
|
|
result = locale->GetCategory(categoryList[i]->GetUnicode(),&lc_name_unichar);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_new_interface failed");
|
1999-01-29 02:27:55 +03:00
|
|
|
|
1999-07-17 02:57:45 +04:00
|
|
|
value->SetString(lc_name_unichar);
|
1999-01-29 02:27:55 +03:00
|
|
|
delete value;
|
|
|
|
}
|
|
|
|
|
|
|
|
for(i=0;i<6;i++)
|
|
|
|
{
|
1999-06-09 06:37:14 +04:00
|
|
|
delete categoryList[i];
|
1999-01-29 02:27:55 +03:00
|
|
|
delete valueList[i];
|
|
|
|
}
|
|
|
|
|
1999-06-09 06:37:14 +04:00
|
|
|
delete [] categoryList;
|
1999-01-29 02:27:55 +03:00
|
|
|
delete [] valueList;
|
|
|
|
|
|
|
|
locale->Release();
|
|
|
|
|
|
|
|
localeFactory->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
factory_get_locale(void)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsILocaleFactory* localeFactory;
|
|
|
|
nsILocale* locale;
|
1999-06-09 06:37:14 +04:00
|
|
|
nsString* category;
|
1999-01-29 02:27:55 +03:00
|
|
|
nsString* value;
|
1999-06-03 05:57:55 +04:00
|
|
|
const char* acceptLangString = "ja;q=0.9,en;q=1.0,*";
|
1999-08-04 11:16:00 +04:00
|
|
|
PRUnichar *lc_name_unichar;
|
1999-01-29 02:27:55 +03:00
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
result = nsComponentManager::FindFactory(kLocaleFactoryCID,
|
1999-01-29 02:27:55 +03:00
|
|
|
(nsIFactory**)&localeFactory);
|
|
|
|
NS_ASSERTION(localeFactory!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-01-29 02:27:55 +03:00
|
|
|
|
|
|
|
//
|
|
|
|
// get the application locale
|
|
|
|
//
|
|
|
|
result = localeFactory->GetApplicationLocale(&locale);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_get_locale failed");
|
1999-01-29 02:27:55 +03:00
|
|
|
NS_ASSERTION(locale!=NULL,"nsLocaleTest: factory_get_locale failed");
|
|
|
|
|
|
|
|
//
|
|
|
|
// test and make sure the locale is a valid Interface
|
|
|
|
//
|
|
|
|
locale->AddRef();
|
|
|
|
|
1999-06-09 06:37:14 +04:00
|
|
|
category = new nsString("NSILOCALE_CTYPE");
|
1999-01-29 02:27:55 +03:00
|
|
|
value = new nsString();
|
|
|
|
|
1999-07-17 02:57:45 +04:00
|
|
|
result = locale->GetCategory(category->GetUnicode(),&lc_name_unichar);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_get_locale failed");
|
1999-01-29 02:27:55 +03:00
|
|
|
|
1999-07-17 02:57:45 +04:00
|
|
|
value->SetString(lc_name_unichar);
|
1999-01-29 02:27:55 +03:00
|
|
|
locale->Release();
|
|
|
|
locale->Release();
|
|
|
|
|
1999-06-09 06:37:14 +04:00
|
|
|
delete category;
|
1999-01-29 02:27:55 +03:00
|
|
|
delete value;
|
|
|
|
|
|
|
|
//
|
|
|
|
// test GetSystemLocale
|
|
|
|
//
|
|
|
|
result = localeFactory->GetSystemLocale(&locale);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_get_locale failed");
|
1999-01-29 02:27:55 +03:00
|
|
|
NS_ASSERTION(locale!=NULL,"nsLocaleTest: factory_get_locale failed");
|
|
|
|
|
|
|
|
//
|
|
|
|
// test and make sure the locale is a valid Interface
|
|
|
|
//
|
|
|
|
locale->AddRef();
|
|
|
|
|
1999-06-09 06:37:14 +04:00
|
|
|
category = new nsString("NSILOCALE_CTYPE");
|
1999-01-29 02:27:55 +03:00
|
|
|
value = new nsString();
|
|
|
|
|
1999-07-17 02:57:45 +04:00
|
|
|
result = locale->GetCategory(category->GetUnicode(),&lc_name_unichar);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_get_locale failed");
|
1999-01-29 02:27:55 +03:00
|
|
|
|
1999-07-17 02:57:45 +04:00
|
|
|
value->SetString(lc_name_unichar);
|
1999-01-29 02:27:55 +03:00
|
|
|
locale->Release();
|
|
|
|
locale->Release();
|
|
|
|
|
1999-06-09 06:37:14 +04:00
|
|
|
delete category;
|
1999-01-29 02:27:55 +03:00
|
|
|
delete value;
|
|
|
|
|
1999-06-03 05:57:55 +04:00
|
|
|
//
|
|
|
|
// test GetLocaleFromAcceptLanguage
|
|
|
|
//
|
|
|
|
result = localeFactory->GetLocaleFromAcceptLanguage(acceptLangString,&locale);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_get_locale failed");
|
1999-06-03 05:57:55 +04:00
|
|
|
NS_ASSERTION(locale!=NULL,"nsLocaleTest: factory_get_locale failed");
|
|
|
|
|
|
|
|
//
|
|
|
|
// test and make sure the locale is a valid Interface
|
|
|
|
//
|
|
|
|
locale->AddRef();
|
|
|
|
|
1999-06-09 06:37:14 +04:00
|
|
|
category = new nsString("NSILOCALE_CTYPE");
|
1999-06-03 05:57:55 +04:00
|
|
|
value = new nsString();
|
|
|
|
|
1999-07-17 02:57:45 +04:00
|
|
|
result = locale->GetCategory(category->GetUnicode(),&lc_name_unichar);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_get_locale failed");
|
1999-06-03 05:57:55 +04:00
|
|
|
|
1999-07-17 02:57:45 +04:00
|
|
|
value->SetString(lc_name_unichar);
|
1999-06-03 05:57:55 +04:00
|
|
|
locale->Release();
|
|
|
|
locale->Release();
|
|
|
|
|
1999-06-09 06:37:14 +04:00
|
|
|
delete category;
|
1999-06-03 05:57:55 +04:00
|
|
|
delete value;
|
|
|
|
|
1999-01-29 02:27:55 +03:00
|
|
|
localeFactory->Release();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-06-03 05:57:55 +04:00
|
|
|
|
1999-02-04 03:33:44 +03:00
|
|
|
#ifdef XP_PC
|
|
|
|
|
|
|
|
void
|
|
|
|
win32factory_create_interface(void)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsIFactory* factory;
|
|
|
|
nsIWin32Locale* win32Locale;
|
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
result = nsComponentManager::CreateInstance(kWin32LocaleFactoryCID,
|
1999-02-04 03:33:44 +03:00
|
|
|
NULL,
|
|
|
|
kIFactoryIID,
|
|
|
|
(void**)&factory);
|
|
|
|
NS_ASSERTION(factory!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-02-04 03:33:44 +03:00
|
|
|
|
|
|
|
factory->Release();
|
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
result = nsComponentManager::CreateInstance(kWin32LocaleFactoryCID,
|
1999-02-04 03:33:44 +03:00
|
|
|
NULL,
|
|
|
|
kIWin32LocaleIID,
|
|
|
|
(void**)&win32Locale);
|
|
|
|
NS_ASSERTION(win32Locale!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-02-04 03:33:44 +03:00
|
|
|
|
|
|
|
win32Locale->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
win32locale_test(void)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsIWin32Locale* win32Locale;
|
|
|
|
nsString* locale;
|
|
|
|
LCID loc_id;
|
1999-01-29 02:27:55 +03:00
|
|
|
|
1999-02-04 03:33:44 +03:00
|
|
|
//
|
|
|
|
// test with a simple locale
|
|
|
|
//
|
|
|
|
locale = new nsString("en-US");
|
|
|
|
loc_id = 0;
|
1999-01-29 02:27:55 +03:00
|
|
|
|
1999-03-09 12:44:27 +03:00
|
|
|
result = nsComponentManager::CreateInstance(kWin32LocaleFactoryCID,
|
1999-02-04 03:33:44 +03:00
|
|
|
NULL,
|
|
|
|
kIWin32LocaleIID,
|
|
|
|
(void**)&win32Locale);
|
|
|
|
NS_ASSERTION(win32Locale!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-02-04 03:33:44 +03:00
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
1999-02-04 03:33:44 +03:00
|
|
|
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
//
|
|
|
|
// test with a not so simple locale
|
|
|
|
//
|
|
|
|
locale = new nsString("x-netscape");
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(USER_DEFINED_PRIMARYLANG,USER_DEFINED_SUBLANGUAGE),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
1999-02-04 03:33:44 +03:00
|
|
|
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("en");
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
1999-02-04 03:33:44 +03:00
|
|
|
|
|
|
|
delete locale;
|
|
|
|
win32Locale->Release();
|
|
|
|
}
|
1999-04-06 09:46:29 +04:00
|
|
|
|
|
|
|
void
|
|
|
|
win32locale_conversion_test(void)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsIWin32Locale* win32Locale;
|
|
|
|
nsString* locale;
|
|
|
|
LCID loc_id;
|
|
|
|
|
|
|
|
result = nsComponentManager::CreateInstance(kWin32LocaleFactoryCID,
|
|
|
|
NULL,
|
|
|
|
kIWin32LocaleIID,
|
|
|
|
(void**)&win32Locale);
|
|
|
|
NS_ASSERTION(win32Locale!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-04-06 09:46:29 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// check english variants
|
|
|
|
//
|
|
|
|
locale = new nsString("en"); // generic english
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_DEFAULT),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("en-US"); // US english
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("en-GB"); // UK english
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_UK),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("en-CA"); // Canadian english
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_CAN),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
//
|
|
|
|
// japanese
|
|
|
|
//
|
|
|
|
locale = new nsString("ja");
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_JAPANESE,SUBLANG_DEFAULT),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("ja-JP");
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_JAPANESE,SUBLANG_DEFAULT),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
//
|
|
|
|
// chinese Locales
|
|
|
|
//
|
|
|
|
locale = new nsString("zh");
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_CHINESE,SUBLANG_DEFAULT),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("zh-CN");
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_SIMPLIFIED),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("zh-TW");
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_CHINESE,SUBLANG_CHINESE_TRADITIONAL),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
//
|
|
|
|
// german and variants
|
|
|
|
//
|
|
|
|
locale = new nsString("de");
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_GERMAN,SUBLANG_DEFAULT),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("de-DE");
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_GERMAN,SUBLANG_GERMAN),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("de-AT");
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_GERMAN,SUBLANG_GERMAN_AUSTRIAN),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
//
|
|
|
|
// french and it's variants
|
|
|
|
//
|
|
|
|
locale = new nsString("fr");
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_FRENCH,SUBLANG_DEFAULT),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("fr-FR");
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_FRENCH,SUBLANG_FRENCH),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("fr-CA");
|
|
|
|
loc_id = 0;
|
|
|
|
|
|
|
|
result = win32Locale->GetPlatformLocale(locale,&loc_id);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-06 09:46:29 +04:00
|
|
|
NS_ASSERTION(loc_id==MAKELCID(MAKELANGID(LANG_FRENCH,SUBLANG_FRENCH_CANADIAN),SORT_DEFAULT),
|
|
|
|
"nsLocaleTest: GetPlatformLocale failed.");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
//
|
|
|
|
// delete the XPCOM inteface
|
|
|
|
//
|
|
|
|
win32Locale->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
win32locale_reverse_conversion_test(void)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsIWin32Locale* win32Locale;
|
|
|
|
|
|
|
|
result = nsComponentManager::CreateInstance(kWin32LocaleFactoryCID,
|
|
|
|
NULL,
|
|
|
|
kIWin32LocaleIID,
|
|
|
|
(void**)&win32Locale);
|
|
|
|
NS_ASSERTION(win32Locale!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-04-06 09:46:29 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// english and variants
|
|
|
|
//
|
|
|
|
win32Locale->Release();
|
|
|
|
}
|
|
|
|
|
1999-04-16 01:00:16 +04:00
|
|
|
void
|
|
|
|
win32_test_special_locales(void)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsIWin32Locale* win32Locale;
|
|
|
|
nsILocale* xp_locale;
|
|
|
|
nsILocaleFactory* xp_locale_factory;
|
1999-06-09 06:37:14 +04:00
|
|
|
nsString* locale, *result_locale, *category;
|
1999-04-16 01:00:16 +04:00
|
|
|
LCID sys_lcid, user_lcid;
|
1999-08-04 11:16:00 +04:00
|
|
|
PRUnichar *lc_name_unichar;
|
1999-04-16 01:00:16 +04:00
|
|
|
|
|
|
|
result = nsComponentManager::CreateInstance(kWin32LocaleFactoryCID,
|
|
|
|
NULL,
|
|
|
|
kIWin32LocaleIID,
|
|
|
|
(void**)&win32Locale);
|
|
|
|
NS_ASSERTION(win32Locale!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-04-16 01:00:16 +04:00
|
|
|
|
|
|
|
result = nsComponentManager::FindFactory(kLocaleFactoryCID,
|
|
|
|
(nsIFactory**)&xp_locale_factory);
|
|
|
|
NS_ASSERTION(xp_locale_factory!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-04-16 01:00:16 +04:00
|
|
|
|
1999-06-09 06:37:14 +04:00
|
|
|
category = new nsString(localeCategoryList[0]);
|
1999-04-16 01:00:16 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// derive a system locale
|
|
|
|
//
|
|
|
|
result = xp_locale_factory->GetSystemLocale(&xp_locale);
|
|
|
|
NS_ASSERTION(xp_locale!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-04-16 01:00:16 +04:00
|
|
|
|
|
|
|
sys_lcid = GetSystemDefaultLCID();
|
|
|
|
locale = new nsString();
|
|
|
|
result_locale = new nsString();
|
|
|
|
|
|
|
|
result = win32Locale->GetXPLocale(sys_lcid,locale);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-07-17 02:57:45 +04:00
|
|
|
result = xp_locale->GetCategory(category->GetUnicode(),&lc_name_unichar);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-04-16 01:00:16 +04:00
|
|
|
|
1999-07-17 02:57:45 +04:00
|
|
|
result_locale->SetString(lc_name_unichar);
|
1999-04-16 01:00:16 +04:00
|
|
|
delete locale;
|
|
|
|
delete result_locale;
|
|
|
|
xp_locale->Release();
|
|
|
|
|
|
|
|
//
|
|
|
|
// derive a system locale
|
|
|
|
//
|
|
|
|
result = xp_locale_factory->GetApplicationLocale(&xp_locale);
|
|
|
|
NS_ASSERTION(xp_locale!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-04-16 01:00:16 +04:00
|
|
|
|
|
|
|
user_lcid = GetUserDefaultLCID();
|
|
|
|
locale = new nsString();
|
|
|
|
result_locale = new nsString();
|
|
|
|
|
|
|
|
result = win32Locale->GetXPLocale(user_lcid,locale);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-07-17 02:57:45 +04:00
|
|
|
result = xp_locale->GetCategory(category->GetUnicode(),&lc_name_unichar);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-04-16 01:00:16 +04:00
|
|
|
|
1999-08-04 11:16:00 +04:00
|
|
|
result_locale->SetString(lc_name_unichar);
|
1999-04-16 01:00:16 +04:00
|
|
|
delete locale;
|
|
|
|
delete result_locale;
|
|
|
|
xp_locale->Release();
|
|
|
|
|
1999-06-09 06:37:14 +04:00
|
|
|
delete category;
|
1999-04-16 01:00:16 +04:00
|
|
|
xp_locale_factory->Release();
|
|
|
|
win32Locale->Release();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
1999-02-04 03:33:44 +03:00
|
|
|
|
|
|
|
#endif XP_PC
|
1999-01-29 02:27:55 +03:00
|
|
|
|
1999-04-07 10:13:19 +04:00
|
|
|
#ifdef XP_UNIX
|
|
|
|
void
|
|
|
|
posixfactory_create_interface(void)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsIFactory* factory;
|
|
|
|
nsIPosixLocale* posix_locale;
|
|
|
|
|
|
|
|
result = nsComponentManager::CreateInstance(kPosixLocaleFactoryCID,
|
|
|
|
NULL,
|
|
|
|
kIFactoryIID,
|
|
|
|
(void**)&factory);
|
|
|
|
NS_ASSERTION(factory!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-04-07 10:13:19 +04:00
|
|
|
|
|
|
|
factory->Release();
|
|
|
|
|
|
|
|
result = nsComponentManager::CreateInstance(kPosixLocaleFactoryCID,
|
|
|
|
NULL,
|
|
|
|
kIPosixLocaleIID,
|
|
|
|
(void**)&posix_locale);
|
|
|
|
NS_ASSERTION(posix_locale!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-04-07 10:13:19 +04:00
|
|
|
|
|
|
|
posix_locale->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
posixlocale_test(void)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsIPosixLocale* posix_locale;
|
|
|
|
nsString* locale;
|
|
|
|
char posix_locale_string[9];
|
|
|
|
|
|
|
|
//
|
|
|
|
// create the locale object
|
|
|
|
//
|
|
|
|
result = nsComponentManager::CreateInstance(kPosixLocaleFactoryCID,
|
|
|
|
NULL,
|
|
|
|
kIPosixLocaleIID,
|
|
|
|
(void**)&posix_locale);
|
|
|
|
NS_ASSERTION(posix_locale!=NULL,"nsLocaleTest: create interface failed.\n");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: create interface failed\n");
|
1999-04-07 10:13:19 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// test with a simple locale
|
|
|
|
//
|
|
|
|
locale = new nsString("en-US");
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_string,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.\n");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("en_US",posix_locale_string)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
//
|
|
|
|
// test with a not so simple locale
|
|
|
|
//
|
|
|
|
locale = new nsString("x-netscape");
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_string,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.\n");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("C",posix_locale_string)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
//
|
|
|
|
// test with a generic locale
|
|
|
|
//
|
|
|
|
locale = new nsString("en");
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_string,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.\n");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("en",posix_locale_string)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
// release the locale interface
|
|
|
|
//
|
|
|
|
posix_locale->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
posixlocale_conversion_test()
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsIPosixLocale* posix_locale;
|
|
|
|
nsString* locale;
|
|
|
|
char posix_locale_result[9];
|
|
|
|
|
|
|
|
result = nsComponentManager::CreateInstance(kPosixLocaleFactoryCID,
|
|
|
|
NULL,
|
|
|
|
kIPosixLocaleIID,
|
|
|
|
(void**)&posix_locale);
|
|
|
|
NS_ASSERTION(posix_locale!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-04-07 10:13:19 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// check english variants
|
|
|
|
//
|
|
|
|
locale = new nsString("en"); // generic english
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_result,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("en",posix_locale_result)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("en-US"); // US english
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_result,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("en_US",posix_locale_result)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("en-GB"); // UK english
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_result,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("en_GB",posix_locale_result)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("en-CA"); // Canadian english
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_result,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("en_CA",posix_locale_result)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
//
|
|
|
|
// japanese
|
|
|
|
//
|
|
|
|
locale = new nsString("ja");
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_result,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("ja",posix_locale_result)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("ja-JP");
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_result,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("ja_JP",posix_locale_result)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
//
|
|
|
|
// chinese Locales
|
|
|
|
//
|
|
|
|
locale = new nsString("zh");
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_result,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("zh",posix_locale_result)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("zh-CN");
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_result,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("zh_CN",posix_locale_result)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("zh-TW");
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_result,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("zh_TW",posix_locale_result)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
//
|
|
|
|
// german and variants
|
|
|
|
//
|
|
|
|
locale = new nsString("de");
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_result,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("de",posix_locale_result)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("de-DE");
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_result,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("de_DE",posix_locale_result)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("de-AT");
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_result,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("de_AT",posix_locale_result)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
//
|
|
|
|
// french and it's variants
|
|
|
|
//
|
|
|
|
locale = new nsString("fr");
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_result,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("fr",posix_locale_result)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("fr-FR");
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_result,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("fr_FR",posix_locale_result)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("fr-CA");
|
|
|
|
result = posix_locale->GetPlatformLocale(locale,posix_locale_result,9);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetPlatformLocale failed.");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(strcmp("fr_CA",posix_locale_result)==0,"nsLocaleTest: GetPlatformLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
//
|
|
|
|
// delete the XPCOM inteface
|
|
|
|
//
|
|
|
|
posix_locale->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
posixlocale_reverse_conversion_test()
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsIPosixLocale* posix_locale;
|
|
|
|
nsString* locale;
|
|
|
|
|
|
|
|
//
|
|
|
|
// create the locale object
|
|
|
|
//
|
|
|
|
result = nsComponentManager::CreateInstance(kPosixLocaleFactoryCID,
|
|
|
|
NULL,
|
|
|
|
kIPosixLocaleIID,
|
|
|
|
(void**)&posix_locale);
|
|
|
|
NS_ASSERTION(posix_locale!=NULL,"nsLocaleTest: create interface failed.\n");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: create interface failed\n");
|
1999-04-07 10:13:19 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// test with a simple locale
|
|
|
|
//
|
|
|
|
locale = new nsString("");
|
|
|
|
result = posix_locale->GetXPLocale("en_US",locale);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetXPLocale failed.\n");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(*locale=="en-US","nsLocaleTest: GetXPLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("");
|
|
|
|
result = posix_locale->GetXPLocale("C",locale);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetXPLocale failed.\n");
|
1999-04-28 00:01:35 +04:00
|
|
|
NS_ASSERTION(*locale=="en","nsLocaleTest: GetXPLocale failed.\n");
|
1999-04-07 10:13:19 +04:00
|
|
|
delete locale;
|
|
|
|
|
|
|
|
locale = new nsString("");
|
|
|
|
result = posix_locale->GetXPLocale("en",locale);
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetXPLocale failed.\n");
|
1999-04-07 10:13:19 +04:00
|
|
|
NS_ASSERTION(*locale=="en","nsLocaleTest: GetXPLocale failed.\n");
|
|
|
|
delete locale;
|
|
|
|
|
|
|
|
posix_locale->Release();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-04-28 00:01:35 +04:00
|
|
|
void
|
|
|
|
posixlocale_test_special(void)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsILocaleFactory* xp_factory;
|
|
|
|
nsILocale* xp_locale;
|
1999-07-20 06:07:41 +04:00
|
|
|
const PRUnichar *lc_name_unichar;
|
1999-04-28 00:01:35 +04:00
|
|
|
nsString* locale, *result_locale;
|
|
|
|
nsString* lc_message;
|
|
|
|
|
|
|
|
//
|
|
|
|
// create the locale objects
|
|
|
|
//
|
|
|
|
result = nsComponentManager::FindFactory(kLocaleFactoryCID,
|
|
|
|
(nsIFactory**)&xp_factory);
|
|
|
|
|
|
|
|
NS_ASSERTION(xp_factory!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-04-28 00:01:35 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// settup strings
|
|
|
|
//
|
|
|
|
locale = new nsString("en");
|
|
|
|
result_locale = new nsString();
|
|
|
|
lc_message = new nsString("NSILOCALE_MESSAGES");
|
|
|
|
|
|
|
|
//
|
|
|
|
// test GetSystemLocale
|
|
|
|
//
|
|
|
|
result = xp_factory->GetSystemLocale(&xp_locale);
|
|
|
|
NS_ASSERTION(xp_locale!=NULL,"nsLocaleTest: GetSystemLocale failed.\n");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetSystemLocale failed.\n");
|
1999-04-28 00:01:35 +04:00
|
|
|
|
1999-07-17 02:57:45 +04:00
|
|
|
result = xp_locale->GetCategory(lc_message->GetUnicode(),&lc_name_unichar);
|
1999-04-28 00:01:35 +04:00
|
|
|
NS_ASSERTION(*result_locale==*locale,"nsLocaleTest: GetSystemLocale failed.\n");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetSystemLocale failed.\n");
|
1999-04-28 00:01:35 +04:00
|
|
|
|
1999-07-17 02:57:45 +04:00
|
|
|
result_locale->SetString(lc_name_unichar);
|
1999-04-28 00:01:35 +04:00
|
|
|
xp_locale->Release();
|
|
|
|
|
|
|
|
result = xp_factory->GetApplicationLocale(&xp_locale);
|
|
|
|
NS_ASSERTION(xp_locale!=NULL,"nsLocaleTest: GetApplicationLocale failed.\n");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetApplicationLocale failed.\n");
|
1999-04-28 00:01:35 +04:00
|
|
|
|
|
|
|
|
1999-07-17 02:57:45 +04:00
|
|
|
result = xp_locale->GetCategory(lc_message->GetUnicode(),&lc_name_unichar);
|
1999-04-28 00:01:35 +04:00
|
|
|
NS_ASSERTION(*result_locale==*locale,"nsLocaleTest: GetSystemLocale failed.\n");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: GetSystemLocale failed.\n");
|
1999-07-17 02:57:45 +04:00
|
|
|
result_locale->SetString(lc_name_unichar);
|
1999-04-28 00:01:35 +04:00
|
|
|
xp_locale->Release();
|
1999-07-17 02:57:45 +04:00
|
|
|
|
1999-04-28 00:01:35 +04:00
|
|
|
//
|
|
|
|
// delete strings
|
|
|
|
//
|
|
|
|
delete locale;
|
|
|
|
delete result_locale;
|
|
|
|
delete lc_message;
|
|
|
|
|
|
|
|
xp_factory->Release();
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
1999-05-28 09:01:54 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef XP_MAC
|
|
|
|
|
|
|
|
void
|
|
|
|
macfactory_create_interface(void)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsIFactory* factory;
|
|
|
|
nsIMacLocale* mac_locale;
|
|
|
|
|
|
|
|
result = nsComponentManager::CreateInstance(kMacLocaleFactoryCID,
|
|
|
|
NULL,
|
|
|
|
kIFactoryIID,
|
|
|
|
(void**)&factory);
|
|
|
|
NS_ASSERTION(factory!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-05-28 09:01:54 +04:00
|
|
|
|
|
|
|
factory->Release();
|
|
|
|
|
|
|
|
result = nsComponentManager::CreateInstance(kMacLocaleFactoryCID,
|
|
|
|
NULL,
|
|
|
|
kIMacLocaleIID,
|
|
|
|
(void**)&mac_locale);
|
|
|
|
NS_ASSERTION(posix_locale!=NULL,"nsLocaleTest: factory_create_interface failed.");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");
|
1999-05-28 09:01:54 +04:00
|
|
|
|
|
|
|
mac_locale->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
maclocale_test(void)
|
|
|
|
{
|
|
|
|
nsresult result;
|
|
|
|
nsIMacLocale* mac_locale;
|
|
|
|
nsString* locale;
|
|
|
|
short script_code;
|
|
|
|
|
|
|
|
//
|
|
|
|
// create the locale object
|
|
|
|
//
|
|
|
|
result = nsComponentManager::CreateInstance(kMacLocaleFactoryCID,
|
|
|
|
NULL,
|
|
|
|
kIMacLocaleIID,
|
|
|
|
(void**)&mac_locale);
|
|
|
|
NS_ASSERTION(posix_locale!=NULL,"nsLocaleTest: create interface failed.\n");
|
1999-08-31 05:56:44 +04:00
|
|
|
NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: create interface failed\n");
|
1999-05-28 09:01:54 +04:00
|
|
|
|
|
|
|
//
|
|
|
|
// release the locale interface
|
|
|
|
//
|
|
|
|
mac_locale->Release();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1999-04-07 10:13:19 +04:00
|
|
|
#endif
|
|
|
|
|
1999-01-29 02:27:55 +03:00
|
|
|
int
|
|
|
|
main(int argc, char** argv)
|
|
|
|
{
|
|
|
|
|
|
|
|
//
|
|
|
|
// what are we doing?
|
|
|
|
//
|
|
|
|
printf("Starting nsLocaleTest\n");
|
|
|
|
printf("---------------------\n");
|
|
|
|
printf("This test has completed successfully if no error messages are printed.\n");
|
|
|
|
|
|
|
|
//
|
|
|
|
// run the nsILocaleFactory tests (nsILocale gets tested in the prcoess)
|
|
|
|
//
|
|
|
|
factory_create_interface();
|
|
|
|
factory_get_locale();
|
|
|
|
factory_new_locale();
|
|
|
|
|
1999-02-04 03:33:44 +03:00
|
|
|
#ifdef XP_PC
|
|
|
|
|
|
|
|
//
|
|
|
|
// run the nsIWin32LocaleFactory tests
|
|
|
|
//
|
|
|
|
win32factory_create_interface();
|
|
|
|
win32locale_test();
|
1999-04-06 09:46:29 +04:00
|
|
|
win32locale_conversion_test();
|
|
|
|
win32locale_reverse_conversion_test();
|
1999-04-16 01:00:16 +04:00
|
|
|
win32_test_special_locales();
|
1999-05-28 09:01:54 +04:00
|
|
|
#elif defined(XP_UNIX)
|
1999-02-04 03:33:44 +03:00
|
|
|
|
1999-04-07 10:13:19 +04:00
|
|
|
//
|
|
|
|
// do the younicks tests
|
|
|
|
//
|
|
|
|
posixfactory_create_interface();
|
|
|
|
posixlocale_test();
|
|
|
|
posixlocale_conversion_test();
|
|
|
|
posixlocale_reverse_conversion_test();
|
1999-04-28 00:01:35 +04:00
|
|
|
posixlocale_test_special();
|
1999-04-07 10:13:19 +04:00
|
|
|
|
1999-05-28 09:01:54 +04:00
|
|
|
#elif defined(XP_MAC)
|
|
|
|
|
|
|
|
//
|
|
|
|
// do the Mac specific tests
|
|
|
|
//
|
|
|
|
macfactory_create_interface();
|
|
|
|
maclocale_test();
|
|
|
|
|
1999-04-07 10:13:19 +04:00
|
|
|
#endif
|
1999-02-04 03:33:44 +03:00
|
|
|
|
1999-01-29 02:27:55 +03:00
|
|
|
//
|
|
|
|
// we done
|
|
|
|
//
|
|
|
|
printf("---------------------\n");
|
|
|
|
printf("Finished nsLocaleTest\n");
|
|
|
|
|
|
|
|
return 0;
|
1999-01-29 07:09:40 +03:00
|
|
|
}
|