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 const std::string DEFAULT_EN_LOCALE_DIR = "/tmp/locale/en/LC_MESSAGES/";
38 void dali_textselectionpopupmirroringrtl_startup(void)
40 // Cheat! Copy the .mo file
41 std::ifstream src( std::string( DEFAULT_EN_LOCALE_DIR + "dali-toolkit.mo.ar" ).c_str(), std::ifstream::binary );
42 std::ofstream dst( std::string( DEFAULT_EN_LOCALE_DIR + "dali-toolkit.mo" ).c_str(), std::ofstream::binary );
45 test_return_value = TET_UNDEF;
48 void dali_textselectionpopupmirroringrtl_cleanup(void)
50 test_return_value = TET_PASS;
53 int UtcDaliToolkitTextSelectionPopupMirroringRTL(void)
55 // Test the popup mirroring.
56 const std::string CUT( "optionCut" );
57 const std::string COPY( "optionCopy" );
58 const std::string PASTE( "optionPaste" );
60 ToolkitTestApplication application;
62 setlocale( LC_ALL, "en_GB.UTF-8" );
63 textdomain("dali-toolkit");
64 bindtextdomain("dali-toolkit", DEFAULT_LOCALE_DIR );
66 TextSelectionPopup textSelectionPopup = TextSelectionPopup::New( NULL );
68 // Enable some buttons.
69 TextSelectionPopup::Buttons buttons = static_cast<TextSelectionPopup::Buttons>( TextSelectionPopup::COPY | TextSelectionPopup::CUT | TextSelectionPopup::PASTE );
70 textSelectionPopup.EnableButtons( buttons );
73 textSelectionPopup.ShowPopup();
75 Actor cutActor = textSelectionPopup.FindChildByName( CUT );
81 Actor tableOfButtons = cutActor.GetParent();
87 // The order should be PASTE, CUT, COPY
88 DALI_TEST_EQUALS( PASTE, tableOfButtons.GetChildAt( 0 ).GetName(), TEST_LOCATION );
89 DALI_TEST_EQUALS( CUT, tableOfButtons.GetChildAt( 2 ).GetName(), TEST_LOCATION );
90 DALI_TEST_EQUALS( COPY, tableOfButtons.GetChildAt( 4 ).GetName(), TEST_LOCATION );