Back to index

nux  3.0.0
xtest-text-entry-compositionkeys.cpp
Go to the documentation of this file.
00001 /*
00002  * Copyright 2010 Inalogic Inc.
00003  *
00004  * This program is free software: you can redistribute it and/or modify it
00005  * under the terms of the GNU General Public License version 3, as published
00006  * by the  Free Software Foundation.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranties of
00010  * MERCHANTABILITY, SATISFACTORY QUALITY or FITNESS FOR A PARTICULAR
00011  * PURPOSE.  See the GNU General Public License for more details.
00012  *
00013  * You should have received a copy of the GNU General Public License
00014  * version 3 along with this program.  If not, see
00015  * <http://www.gnu.org/licenses/>
00016  *
00017  * Authored by: Jay Taoko <jaytaoko@inalogic.com>
00018  *
00019  */
00020 
00021 #include "Nux/Nux.h"
00022 #include "Nux/WindowThread.h"
00023 #include "Nux/VLayout.h"
00024 #include "Nux/TextEntry.h"
00025 #include "Nux/InputMethodIBus.h"
00026 #include "Nux/ProgramFramework/ProgramTemplate.h"
00027 #include "Nux/ProgramFramework/TestView.h"
00028 #include <X11/extensions/XTest.h>
00029 #include <X11/keysym.h> 
00030 #include "nux_automated_test_framework.h"
00031 
00032 class TextTextEntry: public ProgramTemplate
00033 {
00034 public:
00035   TextTextEntry(const char* program_name, int window_width, int window_height, int program_life_span);
00036   ~TextTextEntry();
00037 
00038   virtual void UserInterfaceSetup();
00039 
00040   void TextEntryClick(nux::TextEntry* text_entry);
00041   void ResetEvents();
00042   nux::TextEntry* text_entry_;
00043 
00044   bool clicked_;
00045 };
00046 
00047 TextTextEntry::TextTextEntry(const char* program_name,
00048   int window_width,
00049   int window_height,
00050   int program_life_span)
00051   : ProgramTemplate(program_name, window_width, window_height, program_life_span)
00052 {
00053   ResetEvents();
00054   text_entry_ = NULL;
00055 }
00056 
00057 TextTextEntry::~TextTextEntry()
00058 {
00059   
00060 }
00061 
00062 void TextTextEntry::ResetEvents()
00063 {
00064   clicked_ = false;
00065 }
00066 
00067 void TextTextEntry::TextEntryClick(nux::TextEntry* text_entry)
00068 {
00069   if (text_entry_ == text_entry)
00070   {
00071     clicked_ = true;
00072   }
00073 }
00074 
00075 void TextTextEntry::UserInterfaceSetup()
00076 {
00077   nux::VLayout* main_layout = new nux::VLayout(NUX_TRACKER_LOCATION);
00078   text_entry_ = new nux::TextEntry("", NUX_TRACKER_LOCATION);
00079   text_entry_->SetFontSize(76);
00080 
00081   main_layout->AddView(text_entry_, 0, nux::MINOR_POSITION_CENTER, nux::MINOR_SIZE_FULL);
00082   main_layout->SetSpaceBetweenChildren(10);
00083   main_layout->SetContentDistribution(nux::MAJOR_POSITION_CENTER);
00084 
00085   static_cast<nux::WindowThread*>(window_thread_)->SetLayout(main_layout);
00086   
00087   nux::ColorLayer background(nux::Color(0xFF4D4D4D));
00088   static_cast<nux::WindowThread*>(window_thread_)->SetWindowBackgroundPaintLayer(&background);
00089 }
00090 
00091 TextTextEntry* test_textentry = NULL;
00092 
00093 void TestingThread(nux::NThread* thread, void* user_data)
00094 {
00095   while (test_textentry->ReadyToGo() == false)
00096   {
00097     nuxDebugMsg("Waiting to start");
00098     nux::SleepForMilliseconds(300);
00099   }
00100 
00101   nux::SleepForMilliseconds(1300);
00102 
00103   nux::WindowThread* wnd_thread = static_cast<nux::WindowThread*>(user_data);
00104 
00105   NuxAutomatedTestFramework test(wnd_thread);
00106 
00107   test.Startup();
00108 
00109   test.TestReportMsg(test_textentry->text_entry_, "TextEntry created");
00110 
00111   test_textentry->ResetEvents();
00112   test.ViewSendMouseMotionToCenter(test_textentry->text_entry_);
00113 
00114   test.ViewSendMouseClick(0, 1);
00115 
00116   test.ViewSendCompositionKeys("`o");
00117   test.TestReportMsg(test_textentry->text_entry_->GetText() == "ò", "ò");
00118 
00119   test.ViewSendCompositionKeys("~o");
00120   test.TestReportMsg(test_textentry->text_entry_->GetText() == "òõ", "òõ");
00121 
00122   test.ViewSendCompositionKeys("^o");
00123   test.TestReportMsg(test_textentry->text_entry_->GetText() == "òõô", "òõô");
00124 
00125   test.ViewSendCompositionKeys("c=");
00126   test.TestReportMsg(test_textentry->text_entry_->GetText() == "òõô€", "òõô€");
00127 
00128   test.ViewSendCompositionKeys("oc");
00129   test.TestReportMsg(test_textentry->text_entry_->GetText() == "òõô€©", "òõô€©");
00130 
00131   test.ViewSendCompositionKeys("\"w");
00132   test.TestReportMsg(test_textentry->text_entry_->GetText() == "òõô€©ẅ", "òõô€©ẅ");
00133 
00134   test.ViewSendCompositionKeys("'S");
00135   test.TestReportMsg(test_textentry->text_entry_->GetText() == "òõô€©ẅŚ", "òõô€©ẅŚ");
00136   test.ViewSendCtrlA();
00137   test.ViewSendDelete();
00138 
00139   nux::SleepForMilliseconds(100);;
00140   //exclamdown # INVERTED EXCLAMATION MARK
00141   test.ViewSendCompositionKeys("!!");
00142   test.TestReportMsg(test_textentry->text_entry_->GetText() == "¡", "¡");
00143   test.ViewSendCtrlA();
00144   test.ViewSendDelete();
00145   nux::SleepForMilliseconds(100);;
00146 
00147   //CENT SIGN
00148   test.ViewSendCompositionKeys("|c");
00149   test.TestReportMsg(test_textentry->text_entry_->GetText() == "¢", "¢");
00150   test.ViewSendCtrlA();
00151   test.ViewSendDelete();
00152   nux::SleepForMilliseconds(100);;
00153 
00154   //POUND SIGN
00155   test.ViewSendCompositionKeys("-L");
00156   test.TestReportMsg(test_textentry->text_entry_->GetText() == "£", "£");
00157   test.ViewSendCtrlA();
00158   test.ViewSendDelete();
00159   nux::SleepForMilliseconds(100);;
00160 
00161   //currency # CURRENCY SIGN
00162   test.ViewSendCompositionKeys("xo");
00163   test.TestReportMsg(test_textentry->text_entry_->GetText() == "¤", "¤");
00164   test.ViewSendCtrlA();
00165   test.ViewSendDelete();
00166   nux::SleepForMilliseconds(100);;
00167 
00168   //yen # YEN SIGN
00169   test.ViewSendCompositionKeys("Y=");
00170   test.TestReportMsg(test_textentry->text_entry_->GetText() == "¥", "¥");
00171   test.ViewSendCtrlA();
00172   test.ViewSendDelete();
00173   nux::SleepForMilliseconds(100);;
00174 
00175    //FEMININE ORDINAL INDICATOR
00176   test.ViewSendCompositionKeys("^_a");
00177   test.TestReportMsg(test_textentry->text_entry_->GetText() == "ª", "ª");
00178   test.ViewSendCtrlA();
00179   test.ViewSendDelete();
00180   nux::SleepForMilliseconds(100);;
00181 
00182   //guillemotleft # LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
00183   test.ViewSendCompositionKeys("<<");
00184   test.TestReportMsg(test_textentry->text_entry_->GetText() == "«", "«");
00185   test.ViewSendCtrlA();
00186   test.ViewSendDelete();
00187   nux::SleepForMilliseconds(100);;
00188 
00189  //SUPERSCRIPT THREE
00190   test.ViewSendCompositionKeys("^3");
00191   test.TestReportMsg(test_textentry->text_entry_->GetText() == "³", "³");
00192   test.ViewSendCtrlA();
00193   test.ViewSendDelete();
00194   nux::SleepForMilliseconds(100);;
00195 
00196   //MIDDLE DOT
00197   test.ViewSendCompositionKeys("..");
00198   test.TestReportMsg(test_textentry->text_entry_->GetText() == "·", "·");
00199   test.ViewSendCtrlA();
00200   test.ViewSendDelete();
00201   nux::SleepForMilliseconds(100);;
00202 
00203   //cedilla # CEDILLA
00204   test.ViewSendCompositionKeys(", ");
00205   test.TestReportMsg(test_textentry->text_entry_->GetText() == "¸", "¸");
00206   test.ViewSendCtrlA();
00207   test.ViewSendDelete();
00208   nux::SleepForMilliseconds(100);;
00209 
00210   //VULGAR FRACTION THREE QUARTERS
00211   test.ViewSendCompositionKeys("34");
00212   test.TestReportMsg(test_textentry->text_entry_->GetText() == "¾", "¾");
00213   test.ViewSendCtrlA();
00214   test.ViewSendDelete();
00215   nux::SleepForMilliseconds(100);;
00216 
00217   //questiondown # INVERTED QUESTION MARK
00218   test.ViewSendCompositionKeys("??");
00219   test.TestReportMsg(test_textentry->text_entry_->GetText() == "¿", "¿");
00220   test.ViewSendCtrlA();
00221   test.ViewSendDelete();
00222   nux::SleepForMilliseconds(100);;
00223 
00224   //LATIN CAPITAL LETTER A WITH GRAVE
00225   test.ViewSendCompositionKeys("`A");
00226   test.TestReportMsg(test_textentry->text_entry_->GetText() == "À", "À");
00227   test.ViewSendCtrlA();
00228   test.ViewSendDelete();
00229   nux::SleepForMilliseconds(100);;
00230 
00231   //LATIN CAPITAL LETTER A WITH ACUTE
00232   test.ViewSendCompositionKeys("'A");
00233   test.TestReportMsg(test_textentry->text_entry_->GetText() == "Á", "Á");
00234   test.ViewSendCtrlA();
00235   test.ViewSendDelete();
00236   nux::SleepForMilliseconds(100);;
00237 
00238   //LATIN CAPITAL LETTER A WITH CIRCUMFLEX
00239   test.ViewSendCompositionKeys("^A");
00240   test.TestReportMsg(test_textentry->text_entry_->GetText() == "Â", "Â");
00241   test.ViewSendCtrlA();
00242   test.ViewSendDelete();
00243   nux::SleepForMilliseconds(100);;
00244 
00245   //LATIN CAPITAL LETTER A WITH TILDE
00246   test.ViewSendCompositionKeys("~A");
00247   test.TestReportMsg(test_textentry->text_entry_->GetText() == "Ã", "Ã");
00248   test.ViewSendCtrlA();
00249   test.ViewSendDelete();
00250   nux::SleepForMilliseconds(100);;
00251 
00252   //LATIN CAPITAL LETTER A WITH DIAERESIS
00253   test.ViewSendCompositionKeys("\"A");
00254   test.TestReportMsg(test_textentry->text_entry_->GetText() == "Ä", "Ä");
00255   test.ViewSendCtrlA();
00256   test.ViewSendDelete();
00257   nux::SleepForMilliseconds(100);;
00258 
00259   //LATIN CAPITAL LETTER A WITH RING ABOVE
00260   test.ViewSendCompositionKeys("oA");
00261   test.TestReportMsg(test_textentry->text_entry_->GetText() == "Å", "Å");
00262   test.ViewSendCtrlA();
00263   test.ViewSendDelete();
00264   nux::SleepForMilliseconds(100);;
00265 
00266   //AE # LATIN CAPITAL LETTER AE
00267   test.ViewSendCompositionKeys("AE");
00268   test.TestReportMsg(test_textentry->text_entry_->GetText() == "Æ", "Æ");
00269   test.ViewSendCtrlA();
00270   test.ViewSendDelete();
00271   nux::SleepForMilliseconds(100);;
00272 
00273   //ssharp # LATIN SMALL LETTER SHARP S
00274   test.ViewSendCompositionKeys("ss");
00275   test.TestReportMsg(test_textentry->text_entry_->GetText() == "ß", "ß");
00276   test.ViewSendCtrlA();
00277   test.ViewSendDelete();
00278   nux::SleepForMilliseconds(100);;
00279 
00280   //LATIN SMALL LETTER A WITH GRAVE
00281   test.ViewSendCompositionKeys("`a");
00282   test.TestReportMsg(test_textentry->text_entry_->GetText() == "à", "à");
00283   test.ViewSendCtrlA();
00284   test.ViewSendDelete();
00285   nux::SleepForMilliseconds(100);;
00286 
00287   //LATIN SMALL LETTER A WITH ACUTE
00288   test.ViewSendCompositionKeys("'a");
00289   test.TestReportMsg(test_textentry->text_entry_->GetText() == "á", "á");
00290   test.ViewSendCtrlA();
00291   test.ViewSendDelete();
00292   nux::SleepForMilliseconds(100);;
00293 
00294   //LATIN SMALL LETTER A WITH CIRCUMFLEX
00295   test.ViewSendCompositionKeys("^a");
00296   test.TestReportMsg(test_textentry->text_entry_->GetText() == "â", "â");
00297   test.ViewSendCtrlA();
00298   test.ViewSendDelete();
00299   nux::SleepForMilliseconds(100);;
00300 
00301   //LATIN SMALL LETTER A WITH TILDE
00302   test.ViewSendCompositionKeys("~a");
00303   test.TestReportMsg(test_textentry->text_entry_->GetText() == "ã", "ã");
00304   test.ViewSendCtrlA();
00305   test.ViewSendDelete();
00306   nux::SleepForMilliseconds(100);;
00307 
00308   //LATIN SMALL LETTER A WITH DIAERESIS
00309   test.ViewSendCompositionKeys("\"a");
00310   test.TestReportMsg(test_textentry->text_entry_->GetText() == "ä", "ä");
00311   test.ViewSendCtrlA();
00312   test.ViewSendDelete();
00313   nux::SleepForMilliseconds(100);;
00314 
00315   //LATIN SMALL LETTER A WITH RING ABOVE
00316   test.ViewSendCompositionKeys("oa");
00317   test.TestReportMsg(test_textentry->text_entry_->GetText() == "å", "å");
00318   test.ViewSendCtrlA();
00319   test.ViewSendDelete();
00320   nux::SleepForMilliseconds(100);;
00321 
00322   //ae # LATIN SMALL LETTER AE
00323   test.ViewSendCompositionKeys("ae");
00324   test.TestReportMsg(test_textentry->text_entry_->GetText() == "æ", "æ");
00325   test.ViewSendCtrlA();
00326   test.ViewSendDelete();
00327   nux::SleepForMilliseconds(100);;
00328 
00329   //DIVISION SIGN
00330   test.ViewSendCompositionKeys("-:");
00331   test.TestReportMsg(test_textentry->text_entry_->GetText() == "÷", "÷");
00332   test.ViewSendCtrlA();
00333   test.ViewSendDelete();
00334   nux::SleepForMilliseconds(100);;
00335 
00336   //LATIN CAPITAL LETTER A WITH OGONEK
00337   test.ViewSendCompositionKeys(";A");
00338   test.TestReportMsg(test_textentry->text_entry_->GetText() == "Ą", "Ą");
00339   test.ViewSendCtrlA();
00340   test.ViewSendDelete();
00341   nux::SleepForMilliseconds(100);;
00342 
00343   //LATIN SMALL LETTER A WITH OGONEK
00344   test.ViewSendCompositionKeys(";a");
00345   test.TestReportMsg(test_textentry->text_entry_->GetText() == "ą", "ą");
00346   test.ViewSendCtrlA();
00347   test.ViewSendDelete();
00348   nux::SleepForMilliseconds(100);;
00349 
00350   //LATIN CAPITAL LETTER A WITH CARON
00351   test.ViewSendCompositionKeys("cA");
00352   test.TestReportMsg(test_textentry->text_entry_->GetText() == "Ǎ", "Ǎ");
00353   test.ViewSendCtrlA();
00354   test.ViewSendDelete();
00355   nux::SleepForMilliseconds(100);
00356    
00357   //EN DASH
00358   test.ViewSendCompositionKeys("--.");
00359   test.TestReportMsg(test_textentry->text_entry_->GetText() == "–", "–");
00360   test.ViewSendCtrlA();
00361   test.ViewSendDelete();
00362   nux::SleepForMilliseconds(100);
00363 
00364   //RIGHT SINGLE QUOTATION MARK
00365   test.ViewSendCompositionKeys(">'");
00366   test.TestReportMsg(test_textentry->text_entry_->GetText() == "’", "’");
00367   test.ViewSendCtrlA();
00368   test.ViewSendDelete();
00369   nux::SleepForMilliseconds(100);
00370 
00371   //LEFT DOUBLE QUOTATION MARK
00372   test.ViewSendCompositionKeys("<\"");
00373   test.TestReportMsg(test_textentry->text_entry_->GetText() == "“", "“");
00374   test.ViewSendCtrlA();
00375   test.ViewSendDelete();
00376   nux::SleepForMilliseconds(100);
00377 
00378   //RIGHT DOUBLE QUOTATION MARK
00379   test.ViewSendCompositionKeys("\">");
00380   test.TestReportMsg(test_textentry->text_entry_->GetText() == "”", "”");
00381   test.ViewSendCtrlA();
00382   test.ViewSendDelete();
00383   nux::SleepForMilliseconds(100);
00384 
00385   //DOUBLE LOW-9 QUOTATION MARK
00386   test.ViewSendCompositionKeys("\",");
00387   test.TestReportMsg(test_textentry->text_entry_->GetText() == "„", "„");
00388   test.ViewSendCtrlA();
00389   test.ViewSendDelete();
00390   nux::SleepForMilliseconds(100);
00391 
00392   //PER MILLE SIGN
00393   test.ViewSendCompositionKeys("%o");
00394   test.TestReportMsg(test_textentry->text_entry_->GetText() == "‰", "‰");
00395   test.ViewSendCtrlA();
00396   test.ViewSendDelete();
00397   nux::SleepForMilliseconds(100);
00398 
00399   //SINGLE RIGHT-POINTING ANGLE QUOTATION MARK
00400   test.ViewSendCompositionKeys(".>");
00401   test.TestReportMsg(test_textentry->text_entry_->GetText() == "›", "›");
00402   test.ViewSendCtrlA();
00403   test.ViewSendDelete();
00404   nux::SleepForMilliseconds(100);
00405 
00406   //EuroSign # EURO SIGN
00407   test.ViewSendCompositionKeys("=E");
00408   test.TestReportMsg(test_textentry->text_entry_->GetText() == "€", "€");
00409   test.ViewSendCtrlA();
00410   test.ViewSendDelete();
00411   nux::SleepForMilliseconds(100);
00412 
00413   //REVERSED DOUBLE PRIME QUOTATION MARK
00414   test.ViewSendCompositionKeys("\"\\");
00415   test.TestReportMsg(test_textentry->text_entry_->GetText() == "〝", "〝");
00416   test.ViewSendCtrlA();
00417   test.ViewSendDelete();
00418   nux::SleepForMilliseconds(100);
00419 
00420   if (test.WhenDoneTerminateProgram())
00421   {
00422     wnd_thread->ExitMainLoop();
00423   }
00424   nuxDebugMsg("Exit testing thread");
00425 }
00426 
00427 int main(int argc, char** argv)
00428 {
00429   int xstatus = XInitThreads();
00430   nuxAssertMsg(xstatus > 0, "XInitThreads has failed");
00431 
00432   test_textentry = new TextTextEntry("Text Entry: Composition Characters", 600, 200, 40000);
00433   test_textentry->Startup();
00434   test_textentry->UserInterfaceSetup();
00435 
00436   nux::SystemThread* test_thread = nux::CreateSystemThread(NULL, &TestingThread, test_textentry->GetWindowThread());
00437 
00438   test_thread->Start(test_textentry);
00439 
00440   test_textentry->Run();
00441 
00442   delete test_thread;
00443   delete test_textentry;
00444 
00445   return 0;
00446 }
00447