Back to index

lightning-sunbird  0.9+nobinonly
Functions | Variables
nsLocaleTest.cpp File Reference
#include <stdlib.h>
#include "nsILocale.h"
#include "nsILocaleFactory.h"
#include "nsLocaleCID.h"
#include "nsIComponentManager.h"
#include "nsILocaleService.h"

Go to the source code of this file.

Functions

 NS_DEFINE_CID (kLocaleFactoryCID, NS_LOCALEFACTORY_CID)
 NS_DEFINE_IID (kILocaleFactoryIID, NS_ILOCALEFACTORY_IID)
 NS_DEFINE_IID (kILocaleServiceIID, NS_ILOCALESERVICE_IID)
 NS_DEFINE_CID (kLocaleServiceCID, NS_LOCALESERVICE_CID)
 NS_DEFINE_IID (kIFactoryIID, NS_IFACTORY_IID)
 NS_DEFINE_IID (kISupportsIID, NS_ISUPPORTS_IID)
void serivce_create_interface (void)
void factory_create_interface (void)
void factory_test_isupports (void)
void factory_new_locale (void)
void factory_get_locale (void)
int main (int argc, char **argv)
 The Xalan testcases app.

Variables

char * localeCategoryList [6]

Function Documentation

Definition at line 101 of file nsLocaleTest.cpp.

{
       nsresult                    result;
       nsILocaleFactory*    localeFactory;
       nsIFactory*                 genericFactory;

       result = CallCreateInstance(kLocaleFactoryCID, &localeFactory);
       NS_ASSERTION(localeFactory!=NULL,"nsLocaleTest: factory_create_interface failed.");
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");

       localeFactory->Release();

       result = CallCreateInstance(kLocaleFactoryCID, &genericFactory);
       NS_ASSERTION(localeFactory!=NULL,"nsLocaleTest: factory_create_interface failed.");
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");

       genericFactory->Release();
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 224 of file nsLocaleTest.cpp.

{
       nsresult                    result;
       nsCOMPtr<nsILocaleFactory>  localeFactory;
       nsCOMPtr<nsILocale>  locale;
       nsString*                   category;
       nsString*                   value;
       const char*                 acceptLangString = "ja;q=0.9,en;q=1.0,*";
       PRUnichar *lc_name_unichar;

  localeFactory = do_GetClassObject(kLocaleFactoryCID, &result);
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");

       //
       // get the application locale
       //
       result = localeFactory->GetApplicationLocale(getter_AddRefs(locale));
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_get_locale failed");

       //
       // test and make sure the locale is a valid Interface
       //
       locale->AddRef();

       category = new nsString("NSILOCALE_CTYPE");
       value = new nsString();

       result = locale->GetCategory(category, &lc_name_unichar);
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_get_locale failed");

  value->SetString(lc_name_unichar);

       delete category;
       delete value;

       //
       // test GetSystemLocale
       //
       result = localeFactory->GetSystemLocale(getter_AddRefs(locale));
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_get_locale failed");
       NS_ASSERTION(locale!=NULL,"nsLocaleTest: factory_get_locale failed");

       //
       // test and make sure the locale is a valid Interface
       //

       category = new nsString("NSILOCALE_CTYPE");
       value = new nsString();

       result = locale->GetCategory(category->get(),&lc_name_unichar);
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_get_locale failed");

  value->SetString(lc_name_unichar);

       delete category;
       delete value;

       //
       // test GetLocaleFromAcceptLanguage
       //
       result = localeFactory->GetLocaleFromAcceptLanguage(acceptLangString,getter_AddRefs(locale));
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_get_locale failed");

       //
       // test and make sure the locale is a valid Interface
       //
       category = new nsString("NSILOCALE_CTYPE");
       value = new nsString();

       result = locale->GetCategory(category, &lc_name_unichar);
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_get_locale failed");

  value->SetString(lc_name_unichar);

       delete category;
       delete value;

}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 154 of file nsLocaleTest.cpp.

{
       nsresult                    result;
       nsCOMPtr<nsILocaleFactory>  localeFactory;
       nsCOMPtr<nsILocale>  locale;
       nsString*                   *category, *value;
       int    i;
       nsString**                  categoryList, **valueList;
       PRUnichar *lc_name_unichar;

  localeFactory = do_GetClassObject(kLocaleFactoryCID, &result);
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");


       //
       // test NewLocale
       //
       nsAutoString localeName(NS_LITERALSTRING("ja-JP"));
       result = localeFactory->NewLocale(localeName, getter_AddRefs(locale));
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_new_interface failed");
       NS_ASSERTION(locale!=NULL,"nsLocaleTest: factory_new_interface failed");

       for(i=0;i<6;i++)
       {
              category = new nsString(localeCategoryList[i]);
              value = new nsString();

              result = locale->GetCategory(category, &lc_name_unichar);
              NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_new_interface failed");
       
    value->SetString(lc_name_unichar);
              delete category;
              delete value;
       }

       categoryList = new nsStringArray(6);
       valueList = new nsStringArray(6);

       for(i=0;i<6;i++)
       {
              categoryList.InsertStringAt(localeCategoryList[i], i);
              valueList[i] = InsertStringAt(NS_LITERAL_STRING("x-netscape"), i);
       }

       result = localeFactory->NewLocale(categoryList,valueList,6,&locale);
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_new_interface failed");
       NS_ASSERTION(locale!=NULL,"nsLocaleTest: factory_new_interface failed");

       for(i=0;i<6;i++)
       {
              value = new nsString();
              result = locale->GetCategory(categoryList[i], &lc_name_unichar);
              NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_new_interface failed");

    value->SetString(lc_name_unichar);
              delete value;
       }

       for(i=0;i<6;i++)
       {
              delete categoryList.RemoveStringAt(i);
              delete valueList.RemoveStringAt(i);
       }

       delete  categoryList;
       delete  valueList;
}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 121 of file nsLocaleTest.cpp.

{
       nsresult                    result;
       nsCOMPtr<nsILocaleFactory>  localeFactory;
       nsCOMPtr<nsISupports>              genericInterface1, genericInterface2;
       nsCOMPtr<nsIFactory> genericFactory1, genericFactory2;

  localeFactory = do_GetClassObject(kLocaleFactoryCID, &result);
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_create_interface failed");

       //
       // test generic interface
       //
       result = localeFactory->QueryInterface(kISupportsIID, getter_AddRefs(genericInterface1));
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_test_isupports failed.");

       result = localeFactory->QueryInterface(kISupportsIID, getter_AddRefs(genericInterface2));
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_test_isupports failed.");
       NS_ASSERTION(genericInterface1==genericInterface2,"nsLocaleTest: factory_test_isupports failed.");

       //
       // test generic factory
       //
       result = localeFactory->QueryInterface(kIFactoryIID, getter_AddRefs(genericFactory1));
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_test_isupports failed.");

       result = localeFactory->QueryInterface(kIFactoryIID, getter_AddRefs(genericFactory2));
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: factory_test_isupports failed.");
       NS_ASSERTION(genericFactory1==genericFactory2,"nsLocaleTest: factory_test_isupports failed.");

}

Here is the call graph for this function:

int main ( int  argc,
char **  argv 
)

The Xalan testcases app.

Definition at line 911 of file nsLocaleTest.cpp.

{

       //
       // 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();

#if defined(XP_WIN) || defined(XP_OS2)

       //
       // run the nsIWin32LocaleFactory tests
       //
       win32factory_create_interface();
       win32locale_test();
       win32locale_conversion_test();
       win32locale_reverse_conversion_test();
       win32_test_special_locales();
#elif defined(XP_UNIX)

  //
  // do the younicks tests
  //
  posixfactory_create_interface();
  posixlocale_test();
  posixlocale_conversion_test();
  posixlocale_reverse_conversion_test();
  posixlocale_test_special();

#elif defined(XP_MAC)

  //
  // do the Mac specific tests
  //
  macfactory_create_interface();
  maclocale_test();
  
#endif

       //
       // we done
       //
       printf("---------------------\n");
       printf("Finished nsLocaleTest\n");

       return 0;
}

Here is the call graph for this function:

NS_DEFINE_CID ( kLocaleFactoryCID  ,
NS_LOCALEFACTORY_CID   
)
NS_DEFINE_CID ( kLocaleServiceCID  ,
NS_LOCALESERVICE_CID   
)
NS_DEFINE_IID ( kILocaleFactoryIID  ,
NS_ILOCALEFACTORY_IID   
)
NS_DEFINE_IID ( kILocaleServiceIID  ,
NS_ILOCALESERVICE_IID   
)
NS_DEFINE_IID ( kIFactoryIID  ,
NS_IFACTORY_IID   
)
NS_DEFINE_IID ( kISupportsIID  ,
NS_ISUPPORTS_IID   
)

Definition at line 88 of file nsLocaleTest.cpp.

{
       nsresult                    result;
       nsILocaleService*    localeService;

       result = CallCreateInstance(kLocaleServiceCID, &localeService);
       NS_ASSERTION(localeService!=NULL,"nsLocaleTest: service_create_interface failed.");
       NS_ASSERTION(NS_SUCCEEDED(result),"nsLocaleTest: service_create_interface failed");

       localeService->Release();
}

Here is the call graph for this function:


Variable Documentation

Initial value:
 { "NSILOCALE_TIME",
                                                        "NSILOCALE_COLLATE",
                                                        "NSILOCALE_CTYPE",
                                                        "NSILOCALE_MONETARY",
                                                        "NSILOCALE_MESSAGES",
                                                        "NSILOCALE_NUMERIC"
}

Definition at line 79 of file nsLocaleTest.cpp.