2 * Copyright (c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <dali-toolkit-test-suite-utils.h>
24 #include <dali-toolkit/dali-toolkit.h>
25 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
28 using namespace Toolkit;
33 const char* DEFAULT_LOCALE_DIR = "/tmp/locale/";
34 static std::string gLocaleLang;
35 static std::string gLocaleLanguage;
39 void dali_textselectionpopupmirroringrtl_startup(void)
41 // Keep the current locale environment.
42 char* langPtr = getenv( "LANG" );
43 gLocaleLang = std::string( langPtr );
45 char* languagePtr = getenv( "LANGUAGE" );
46 gLocaleLanguage = std::string( languagePtr );
48 // Set the locale environment to Arabic.
49 setenv( "LANG", "ar_AE.UTF-8", 1 );
50 setenv( "LANGUAGE", "ar_AE:ar", 1 );
52 test_return_value = TET_UNDEF;
55 void dali_textselectionpopupmirroringrtl_cleanup(void)
57 // Restore the locale environment.
58 setenv( "LANG", gLocaleLang.c_str(), 1 );
59 setenv( "LANGUAGE", gLocaleLanguage.c_str(), 1 );
61 test_return_value = TET_PASS;
64 int UtcDaliToolkitTextSelectionPopupMirroringRTL(void)
66 // Test the popup mirroring.
67 const std::string CUT( "optionCut" );
68 const std::string COPY( "optionCopy" );
69 const std::string PASTE( "optionPaste" );
71 ToolkitTestApplication application;
73 setlocale( LC_ALL, "ar_AE.UTF-8" );
74 textdomain("dali-toolkit");
75 bindtextdomain("dali-toolkit", DEFAULT_LOCALE_DIR );
77 TextSelectionPopup textSelectionPopup = TextSelectionPopup::New( NULL );
79 // Enable some buttons.
80 TextSelectionPopup::Buttons buttons = static_cast<TextSelectionPopup::Buttons>( TextSelectionPopup::COPY | TextSelectionPopup::CUT | TextSelectionPopup::PASTE );
81 textSelectionPopup.EnableButtons( buttons );
84 textSelectionPopup.ShowPopup();
86 Actor cutActor = textSelectionPopup.FindChildByName( CUT );
92 Actor tableOfButtons = cutActor.GetParent();
98 // The order should be PASTE, CUT, COPY
99 DALI_TEST_EQUALS( PASTE, tableOfButtons.GetChildAt( 0 ).GetName(), TEST_LOCATION );
100 DALI_TEST_EQUALS( CUT, tableOfButtons.GetChildAt( 2 ).GetName(), TEST_LOCATION );
101 DALI_TEST_EQUALS( COPY, tableOfButtons.GetChildAt( 4 ).GetName(), TEST_LOCATION );
103 tet_result(TET_PASS);