2 * Copyright (c) 2022 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.
18 #include <dali-toolkit-test-suite-utils.h>
19 #include <dali-toolkit/dali-toolkit.h>
20 #include <dali-toolkit/devel-api/controls/text-controls/text-selection-popup.h>
28 using namespace Toolkit;
32 const char* DEFAULT_LOCALE_DIR = "/tmp/locale/";
33 static std::string gLocaleLang;
34 static std::string gLocaleLanguage;
38 void dali_textselectionpopupmirroringltr_startup(void)
40 // Keep the current locale environment.
41 char* langPtr = getenv("LANG");
42 gLocaleLang = std::string(langPtr);
44 char* languagePtr = getenv("LANGUAGE");
45 gLocaleLanguage = std::string(languagePtr);
47 // Set the locale environment to Arabic.
48 setenv("LANG", "en_GB.UTF-8", 1);
49 setenv("LANGUAGE", "en_GB:en", 1);
51 test_return_value = TET_UNDEF;
54 void dali_textselectionpopupmirroringltr_cleanup(void)
56 // Restore the locale environment.
57 setenv("LANG", gLocaleLang.c_str(), 1);
58 setenv("LANGUAGE", gLocaleLanguage.c_str(), 1);
60 test_return_value = TET_PASS;
63 int UtcDaliToolkitTextSelectionPopupMirroringLTR(void)
65 // Test the popup mirroring.
66 const std::string CUT("optionCut");
67 const std::string COPY("optionCopy");
68 const std::string PASTE("optionPaste");
70 ToolkitTestApplication application;
72 setlocale(LC_ALL, "en_GB.UTF-8");
73 textdomain("dali-toolkit");
74 bindtextdomain("dali-toolkit", DEFAULT_LOCALE_DIR);
76 TextSelectionPopup textSelectionPopup = TextSelectionPopup::New(NULL);
78 // Enable some buttons.
79 TextSelectionPopup::Buttons buttons = static_cast<TextSelectionPopup::Buttons>(TextSelectionPopup::COPY | TextSelectionPopup::CUT | TextSelectionPopup::PASTE);
80 textSelectionPopup.EnableButtons(buttons);
83 textSelectionPopup.ShowPopup();
85 Actor cutActor = textSelectionPopup.FindChildByName(CUT);
91 Actor tableOfButtons = cutActor.GetParent();
97 // The order should be COPY, CUT, PASTE
98 DALI_TEST_EQUALS(COPY, tableOfButtons.GetChildAt(0).GetProperty<std::string>(Dali::Actor::Property::NAME), TEST_LOCATION);
99 DALI_TEST_EQUALS(CUT, tableOfButtons.GetChildAt(2).GetProperty<std::string>(Dali::Actor::Property::NAME), TEST_LOCATION);
100 DALI_TEST_EQUALS(PASTE, tableOfButtons.GetChildAt(4).GetProperty<std::string>(Dali::Actor::Property::NAME), TEST_LOCATION);
102 tet_result(TET_PASS);