private void VerifyAssignedKeyValueAndGridColor(AT keyGridNeedToBeAssigned, AT reassignDialog, string pressedKey, bool blAssignKey) { var gridColorValue = KeyMappingGridColor.Purple; try { var assignedValue = reassignDialog.GetElementFromDescendants(MPObj.AssignedValue, returnNullWhenException: true); DifferentFlowForDifferentPressedKey(pressedKey, () => { gridColorValue = KeyMappingGridColor.Red; if (assignedValue != null && !assignedValue.GetElementInfo().IsOffscreen()) { _r.RecordActionFailedDuringCaseRunning($"The Key is not disabled, the reassignable textbox is still there.", "ReassignTextboxStillThere"); } }, () => { gridColorValue = KeyMappingGridColor.Green; var reassignTitleValue = reassignDialog.GetElementFromDescendants(MPObj.ReassignTitleValue); if (assignedValue.GetElementInfo().FullDescription() != reassignTitleValue.GetElementInfo().FullDescription()) { _r.RecordActionFailedDuringCaseRunning($"The assigned key is not restored to {reassignTitleValue.GetElementInfo().FullDescription()} when enabling it.", "assignedValueNotRestored"); } }, () => { gridColorValue = KeyMappingGridColor.Purple; var value = assignedValue.GetElementInfo().FullDescription(); if (!value.Equals(pressedKey)) { _r.RecordActionFailedDuringCaseRunning($"Input {pressedKey}, but got {value}.", "assignedValueWrong"); } if (keyGridNeedToBeAssigned.GetElementInfo().Name().Equals(pressedKey)) { gridColorValue = KeyMappingGridColor.Green; } }); } catch (Exception e) { throw new Exception(e.Message); } finally { var saveOrCloseButton = reassignDialog.GetElementFromDescendants(blAssignKey ? MPObj.ReassignSaveButton : MPObj.ReassignCloseButton); saveOrCloseButton.DoClickPoint(0.4); } if (!keyGridNeedToBeAssigned.GetElementInfo().FullDescription().Equals(gridColorValue)) { _r.RecordActionFailedDuringCaseRunning($"Key {pressedKey} in not in {KeyMappingGridColor.GetVarName(gridColorValue)} color.", "WrongColor"); } }
public TestIt() { _MpCases = new MasterPlusTestCases(); KeysSpy = new KeysSpyOp(_MpCases.MpActions.KeySpyRelativePath); _portalTestFlows = new PortalTestFlows(); //AssembleTopMenu(); GetKeyboardKeysFromKeyMapTabFile(); GetMatrixFromFile(); UtilKeys.SetPhysicalKeyStatus(KbKeys.SC_KEY_NUM_LOCK.KeyValue, UtilKeys.Status.On); UtilKeys.SetPhysicalKeyStatus(KbKeys.SC_KEY_CAP.KeyValue, UtilKeys.Status.Off); //UtilLoop.testA(); //_MpCases.Case_AssignInLoop(blAssignKey: true, blVerifyKeyWork: false, blScanCodeInput: true); _MpCases.Case_AssignInLoop(true, false, true); this.Suit_KeyMappingBaseTest("SK652"); UtilProcess.KillAllProcessesByName("wmplayer"); UtilTime.WaitTime(1); var p = UtilWmp.StartWmpWithMedias(Path.Combine(_MpCases.MpActions.MediaFolderPath, "1.mp3"), Path.Combine(_MpCases.MpActions.MediaFolderPath, "2.mp3"), Path.Combine(_MpCases.MpActions.MediaFolderPath, "3.mp3")); var wmpWindow = new AT().GetElementFromHwndAndWaitAppears(p); var sliderbar = wmpWindow.GetElementFromDescendants(new ATElementStruct() { ControlType = AT.ControlType.Slider }); var barValue1 = sliderbar.DoGetValue(); UtilTime.WaitTime(0.5); var barValue2 = sliderbar.DoGetValue(); _MpCases.Case_CheckAllKeysOnRelayController(); }