X-Git-Url: http://review.tizen.org/git/?p=platform%2Fcore%2Fuifw%2Fdali-toolkit.git;a=blobdiff_plain;f=automated-tests%2Fsrc%2Fdali-toolkit%2Futc-Dali-TextSelectionPopupMirroringLTR.cpp;h=70284e808e1b184aea47373aca108e3572797614;hp=5234210e932e359edb828a468152bc1bc53da637;hb=6a219d0bbcfd016e24b5466d5fb1a666c92feae5;hpb=cc9366b8f2ebab68ef931414afa0ac8f8ba70199 diff --git a/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopupMirroringLTR.cpp b/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopupMirroringLTR.cpp index 5234210..70284e8 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopupMirroringLTR.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-TextSelectionPopupMirroringLTR.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017 Samsung Electronics Co., Ltd. + * Copyright (c) 2022 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,79 +15,89 @@ * */ -#include -#include -#include -#include -#include #include #include #include +#include +#include +#include +#include +#include using namespace Dali; using namespace Toolkit; namespace { +const char* DEFAULT_LOCALE_DIR = "/tmp/locale/"; +static std::string gLocaleLang; +static std::string gLocaleLanguage; -const char* DEFAULT_LOCALE_DIR = "/tmp/locale/"; -const std::string DEFAULT_EN_LOCALE_DIR = "/tmp/locale/en/LC_MESSAGES/"; - -} +} // namespace void dali_textselectionpopupmirroringltr_startup(void) { - // Cheat! Copy the .mo file - std::ifstream src( std::string( DEFAULT_EN_LOCALE_DIR + "dali-toolkit.mo.en" ).c_str(), std::ifstream::binary ); - std::ofstream dst( std::string( DEFAULT_EN_LOCALE_DIR + "dali-toolkit.mo" ).c_str(), std::ofstream::binary ); - dst << src.rdbuf(); + // Keep the current locale environment. + char* langPtr = getenv("LANG"); + gLocaleLang = std::string(langPtr); + + char* languagePtr = getenv("LANGUAGE"); + gLocaleLanguage = std::string(languagePtr); + + // Set the locale environment to Arabic. + setenv("LANG", "en_GB.UTF-8", 1); + setenv("LANGUAGE", "en_GB:en", 1); test_return_value = TET_UNDEF; } void dali_textselectionpopupmirroringltr_cleanup(void) { + // Restore the locale environment. + setenv("LANG", gLocaleLang.c_str(), 1); + setenv("LANGUAGE", gLocaleLanguage.c_str(), 1); + test_return_value = TET_PASS; } int UtcDaliToolkitTextSelectionPopupMirroringLTR(void) { // Test the popup mirroring. - const std::string CUT( "optionCut" ); - const std::string COPY( "optionCopy" ); - const std::string PASTE( "optionPaste" ); + const std::string CUT("optionCut"); + const std::string COPY("optionCopy"); + const std::string PASTE("optionPaste"); ToolkitTestApplication application; - setlocale( LC_ALL, "en_GB.UTF-8" ); + setlocale(LC_ALL, "en_GB.UTF-8"); textdomain("dali-toolkit"); - bindtextdomain("dali-toolkit", DEFAULT_LOCALE_DIR ); + bindtextdomain("dali-toolkit", DEFAULT_LOCALE_DIR); - TextSelectionPopup textSelectionPopup = TextSelectionPopup::New( NULL ); + TextSelectionPopup textSelectionPopup = TextSelectionPopup::New(NULL); // Enable some buttons. - TextSelectionPopup::Buttons buttons = static_cast( TextSelectionPopup::COPY | TextSelectionPopup::CUT | TextSelectionPopup::PASTE ); - textSelectionPopup.EnableButtons( buttons ); + TextSelectionPopup::Buttons buttons = static_cast(TextSelectionPopup::COPY | TextSelectionPopup::CUT | TextSelectionPopup::PASTE); + textSelectionPopup.EnableButtons(buttons); // Show the popup. textSelectionPopup.ShowPopup(); - Actor cutActor = textSelectionPopup.FindChildByName( CUT ); - if( !cutActor ) + Actor cutActor = textSelectionPopup.FindChildByName(CUT); + if(!cutActor) { tet_result(TET_FAIL); } Actor tableOfButtons = cutActor.GetParent(); - if( !tableOfButtons ) + if(!tableOfButtons) { tet_result(TET_FAIL); } // The order should be COPY, CUT, PASTE - DALI_TEST_EQUALS( COPY, tableOfButtons.GetChildAt( 0 ).GetName(), TEST_LOCATION ); - DALI_TEST_EQUALS( CUT, tableOfButtons.GetChildAt( 2 ).GetName(), TEST_LOCATION ); - DALI_TEST_EQUALS( PASTE, tableOfButtons.GetChildAt( 4 ).GetName(), TEST_LOCATION ); + DALI_TEST_EQUALS(COPY, tableOfButtons.GetChildAt(0).GetProperty(Dali::Actor::Property::NAME), TEST_LOCATION); + DALI_TEST_EQUALS(CUT, tableOfButtons.GetChildAt(2).GetProperty(Dali::Actor::Property::NAME), TEST_LOCATION); + DALI_TEST_EQUALS(PASTE, tableOfButtons.GetChildAt(4).GetProperty(Dali::Actor::Property::NAME), TEST_LOCATION); tet_result(TET_PASS); END_TEST;