Bug 1309515 part.1 Add automated tests for Arabic - PC keyboard layout which can input 2 characters with a key press r=m_kato a=ritu
authorMasayuki Nakano <masayuki@d-toybox.com>
Fri, 14 Oct 2016 12:01:40 +0900
changeset 350727 5eb505aa477323a9e395c2fb6d86c019c1973615
parent 350726 2bcf7a0d6dd030237bb11532a5a9d7be0ecdbcef
child 350728 60d80f10cbadd3b2299701021bd9beab53a47ce8
push id1230
push userjlund@mozilla.com
push dateMon, 31 Oct 2016 18:13:35 +0000
treeherdermozilla-release@5e06e3766db2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato, ritu
bugs1309515
milestone50.0
Bug 1309515 part.1 Add automated tests for Arabic - PC keyboard layout which can input 2 characters with a key press r=m_kato a=ritu
testing/mochitest/tests/SimpleTest/EventUtils.js
widget/cocoa/TextInputHandler.mm
widget/tests/test_keycodes.xul
--- a/testing/mochitest/tests/SimpleTest/EventUtils.js
+++ b/testing/mochitest/tests/SimpleTest/EventUtils.js
@@ -839,38 +839,40 @@ function _parseNativeModifiers(aModifier
 // Mac: Any unused number is okay for adding new keyboard layout.
 //      When you add new keyboard layout here, you need to modify
 //      TISInputSourceWrapper::InitByLayoutID().
 // Win: These constants can be found by inspecting registry keys under
 //      HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Keyboard Layouts
 
 const KEYBOARD_LAYOUT_ARABIC =
   { name: "Arabic",             Mac: 6,    Win: 0x00000401 };
+const KEYBOARD_LAYOUT_ARABIC_PC =
+  { name: "Arabic - PC",        Mac: 7,    Win: null       };
 const KEYBOARD_LAYOUT_BRAZILIAN_ABNT =
   { name: "Brazilian ABNT",     Mac: null, Win: 0x00000416 };
 const KEYBOARD_LAYOUT_DVORAK_QWERTY =
   { name: "Dvorak-QWERTY",      Mac: 4,    Win: null       };
 const KEYBOARD_LAYOUT_EN_US =
   { name: "US",                 Mac: 0,    Win: 0x00000409 };
 const KEYBOARD_LAYOUT_FRENCH =
-  { name: "French",             Mac: 7,    Win: 0x0000040C };
+  { name: "French",             Mac: 8,    Win: 0x0000040C };
 const KEYBOARD_LAYOUT_GREEK =
   { name: "Greek",              Mac: 1,    Win: 0x00000408 };
 const KEYBOARD_LAYOUT_GERMAN =
   { name: "German",             Mac: 2,    Win: 0x00000407 };
 const KEYBOARD_LAYOUT_HEBREW =
-  { name: "Hebrew",             Mac: 8,    Win: 0x0000040D };
+  { name: "Hebrew",             Mac: 9,    Win: 0x0000040D };
 const KEYBOARD_LAYOUT_JAPANESE =
   { name: "Japanese",           Mac: null, Win: 0x00000411 };
 const KEYBOARD_LAYOUT_LITHUANIAN =
-  { name: "Lithuanian",         Mac: 9,    Win: 0x00010427 };
+  { name: "Lithuanian",         Mac: 10,   Win: 0x00010427 };
 const KEYBOARD_LAYOUT_NORWEGIAN =
-  { name: "Norwegian",          Mac: 10,   Win: 0x00000414 };
+  { name: "Norwegian",          Mac: 11,   Win: 0x00000414 };
 const KEYBOARD_LAYOUT_SPANISH =
-  { name: "Spanish",            Mac: 11,   Win: 0x0000040A };
+  { name: "Spanish",            Mac: 12,   Win: 0x0000040A };
 const KEYBOARD_LAYOUT_SWEDISH =
   { name: "Swedish",            Mac: 3,    Win: 0x0000041D };
 const KEYBOARD_LAYOUT_THAI =
   { name: "Thai",               Mac: 5,    Win: 0x0002041E };
 
 /**
  * synthesizeNativeKey() dispatches native key event on active window.
  * This is implemented only on Windows and Mac. Note that this function
--- a/widget/cocoa/TextInputHandler.mm
+++ b/widget/cocoa/TextInputHandler.mm
@@ -469,28 +469,31 @@ TISInputSourceWrapper::InitByLayoutID(SI
       break;
     case 5:
       InitByInputSourceID("com.apple.keylayout.Thai");
       break;
     case 6:
       InitByInputSourceID("com.apple.keylayout.Arabic");
       break;
     case 7:
-      InitByInputSourceID("com.apple.keylayout.French");
+      InitByInputSourceID("com.apple.keylayout.ArabicPC");
       break;
     case 8:
-      InitByInputSourceID("com.apple.keylayout.Hebrew");
+      InitByInputSourceID("com.apple.keylayout.French");
       break;
     case 9:
-      InitByInputSourceID("com.apple.keylayout.Lithuanian");
+      InitByInputSourceID("com.apple.keylayout.Hebrew");
       break;
     case 10:
+      InitByInputSourceID("com.apple.keylayout.Lithuanian");
+      break;
+    case 11:
       InitByInputSourceID("com.apple.keylayout.Norwegian");
       break;
-    case 11:
+    case 12:
       InitByInputSourceID("com.apple.keylayout.Spanish");
       break;
     default:
       Clear();
       break;
   }
   mOverrideKeyboard = aOverrideKeyboard;
 }
--- a/widget/tests/test_keycodes.xul
+++ b/widget/tests/test_keycodes.xul
@@ -3474,17 +3474,30 @@ function* runTextInputTests()
       var name = eventToString(aEvent);
 
       is(textbox.value, aExpectText, name + " does not input correct text.");
 
       continueTest();
     });
   }
 
-  if (IS_WIN) {
+  if (IS_MAC) {
+    yield testKey({layout:KEYBOARD_LAYOUT_ARABIC_PC, keyCode:MAC_VK_ANSI_G,
+                   modifiers:{shiftKey:1}, chars:"\u0644\u0623", unmodifiedChars:"\u0644\u0623"},
+                  "\u0644\u0623");
+    yield testKey({layout:KEYBOARD_LAYOUT_ARABIC_PC, keyCode:MAC_VK_ANSI_T,
+                   modifiers:{shiftKey:1}, chars:"\u0644\u0625", unmodifiedChars:"\u0644\u0625"},
+                  "\u0644\u0625");
+    yield testKey({layout:KEYBOARD_LAYOUT_ARABIC_PC, keyCode:MAC_VK_ANSI_B,
+                   modifiers:{shiftKey:1}, chars:"\u0644\u0622", unmodifiedChars:"\u0644\u0622"},
+                  "\u0644\u0622");
+    yield testKey({layout:KEYBOARD_LAYOUT_ARABIC_PC, keyCode:MAC_VK_ANSI_B,
+                   modifiers:{}, chars:"\u0644\u0627", unmodifiedChars:"\u0644\u0627"},
+                  "\u0644\u0627");
+  } else if (IS_WIN) {
     // Basic sanity checks
     yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A,
                    modifiers:{}, chars:"a"},
                   "a");
     yield testKey({layout:KEYBOARD_LAYOUT_EN_US, keyCode:WIN_VK_A,
                    modifiers:{shiftKey:1}, chars:"A"},
                   "A");
     // When Ctrl+Alt are pressed, any text should not be inputted.
@@ -3507,18 +3520,16 @@ function* runTextInputTests()
                   "8");
     yield testKey({layout:KEYBOARD_LAYOUT_LITHUANIAN, keyCode:WIN_VK_9,
                    modifiers:{ctrlKey:1, altKey:1}, chars:"9"},
                   "9");
     yield testKey({layout:KEYBOARD_LAYOUT_LITHUANIAN, keyCode:WIN_VK_0,
                    modifiers:{ctrlKey:1, altKey:1}, chars:"0"},
                   "0");
   }
-  else
-    todo(false, "runTextInputTests() checks Windows only");
 
   // XXX We need to move focus for canceling to search the autocomplete
   // result. If we don't do here, Fx will crash at end of this tests.
   document.getElementById("button").focus();
 }
 
 function* runAllTests() {
   yield* runKeyEventTests();