BufferValidationTests.cpp
1 #include "pch.h" 2 3 // Suppressing 26466 - Don't use static_cast downcasts - in CppUnitTest.h 4 #pragma warning(push) 5 #pragma warning(disable : 26466) 6 #include "CppUnitTest.h" 7 #pragma warning(pop) 8 9 #include <keyboardmanager/KeyboardManagerEditorLibrary/BufferValidationHelpers.h> 10 #include <common/interop/keyboard_layout.h> 11 #include <common/interop/shared_constants.h> 12 #include <functional> 13 #include <keyboardmanager/KeyboardManagerEditorLibrary/ShortcutErrorType.h> 14 15 using namespace Microsoft::VisualStudio::CppUnitTestFramework; 16 17 namespace RemappingUITests 18 { 19 // Tests for methods in the BufferValidationHelpers namespace 20 TEST_CLASS (BufferValidationTests) 21 { 22 std::wstring testApp1 = L"testprocess1.exe"; 23 std::wstring testApp2 = L"testprocess2.exe"; 24 LayoutMap keyboardLayout; 25 26 struct ValidateAndUpdateKeyBufferElementArgs 27 { 28 int elementRowIndex; 29 int elementColIndex; 30 int selectedCodeFromDropDown; 31 }; 32 33 struct ValidateShortcutBufferElementArgs 34 { 35 int elementRowIndex; 36 int elementColIndex; 37 uint32_t indexOfDropDownLastModified; 38 std::vector<int32_t> selectedCodesOnDropDowns; 39 std::wstring targetAppNameInTextBox; 40 bool isHybridColumn; 41 RemapBufferRow bufferRow; 42 }; 43 44 void RunTestCases(const std::vector<ValidateShortcutBufferElementArgs>& testCases, std::function<void(const ValidateShortcutBufferElementArgs&)> testMethod) 45 { 46 for (int i = 0; i < testCases.size(); i++) 47 { 48 testMethod(testCases[i]); 49 } 50 } 51 52 public: 53 TEST_METHOD_INITIALIZE(InitializeTestEnv) 54 { 55 } 56 57 // Test if the ValidateAndUpdateKeyBufferElement method is successful when setting a key to null in a new row 58 TEST_METHOD (ValidateAndUpdateKeyBufferElement_ShouldUpdateAndReturnNoError_OnSettingKeyToNullInANewRow) 59 { 60 RemapBuffer remapBuffer; 61 62 // Add 2 empty rows 63 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ (DWORD)0, (DWORD)0 }, std::wstring() }); 64 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ (DWORD)0, (DWORD)0 }, std::wstring() }); 65 66 // Validate and update the element when -1 i.e. null selection is made on an empty row. 67 ValidateAndUpdateKeyBufferElementArgs args = { 0, 0, -1 }; 68 ShortcutErrorType error = BufferValidationHelpers::ValidateAndUpdateKeyBufferElement(args.elementRowIndex, args.elementColIndex, args.selectedCodeFromDropDown, remapBuffer); 69 70 // Assert that the element is validated and buffer is updated 71 Assert::AreEqual(true, error == ShortcutErrorType::NoError); 72 Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[0].mapping[0])); 73 Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[0].mapping[1])); 74 Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].mapping[0])); 75 Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].mapping[1])); 76 } 77 78 // Test if the ValidateAndUpdateKeyBufferElement method is successful when setting a key to non-null in a new row 79 TEST_METHOD (ValidateAndUpdateKeyBufferElement_ShouldUpdateAndReturnNoError_OnSettingKeyToNonNullInANewRow) 80 { 81 RemapBuffer remapBuffer; 82 83 // Add an empty row 84 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ (DWORD)0, (DWORD)0 }, std::wstring() }); 85 86 // Validate and update the element when selecting B on an empty row 87 ValidateAndUpdateKeyBufferElementArgs args = { 0, 0, 0x42 }; 88 ShortcutErrorType error = BufferValidationHelpers::ValidateAndUpdateKeyBufferElement(args.elementRowIndex, args.elementColIndex, args.selectedCodeFromDropDown, remapBuffer); 89 90 // Assert that the element is validated and buffer is updated 91 Assert::AreEqual(true, error == ShortcutErrorType::NoError); 92 Assert::AreEqual((DWORD)0x42, std::get<DWORD>(remapBuffer[0].mapping[0])); 93 Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[0].mapping[1])); 94 } 95 96 // Test if the ValidateAndUpdateKeyBufferElement method is successful when setting a key to non-null in a valid key to key 97 TEST_METHOD (ValidateAndUpdateKeyBufferElement_ShouldUpdateAndReturnNoError_OnSettingKeyToNonNullInAValidKeyToKeyRow) 98 { 99 RemapBuffer remapBuffer; 100 101 // Add a row with A as the target 102 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ (DWORD)0, (DWORD)0x41 }, std::wstring() }); 103 104 // Validate and update the element when selecting B on a row 105 ValidateAndUpdateKeyBufferElementArgs args = { 0, 0, 0x42 }; 106 ShortcutErrorType error = BufferValidationHelpers::ValidateAndUpdateKeyBufferElement(args.elementRowIndex, args.elementColIndex, args.selectedCodeFromDropDown, remapBuffer); 107 108 // Assert that the element is validated and buffer is updated 109 Assert::AreEqual(true, error == ShortcutErrorType::NoError); 110 Assert::AreEqual((DWORD)0x42, std::get<DWORD>(remapBuffer[0].mapping[0])); 111 Assert::AreEqual((DWORD)0x41, std::get<DWORD>(remapBuffer[0].mapping[1])); 112 } 113 114 // Test if the ValidateAndUpdateKeyBufferElement method is successful when setting a key to non-null in a valid key to shortcut 115 TEST_METHOD (ValidateAndUpdateKeyBufferElement_ShouldUpdateAndReturnNoError_OnSettingKeyToNonNullInAValidKeyToShortcutRow) 116 { 117 RemapBuffer remapBuffer; 118 119 // Add a row with Ctrl+A as the target 120 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ (DWORD)0, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) }, std::wstring() }); 121 122 // Validate and update the element when selecting B on a row 123 ValidateAndUpdateKeyBufferElementArgs args = { 0, 0, 0x42 }; 124 ShortcutErrorType error = BufferValidationHelpers::ValidateAndUpdateKeyBufferElement(args.elementRowIndex, args.elementColIndex, args.selectedCodeFromDropDown, remapBuffer); 125 126 // Assert that the element is validated and buffer is updated 127 Assert::AreEqual(true, error == ShortcutErrorType::NoError); 128 Assert::AreEqual((DWORD)0x42, std::get<DWORD>(remapBuffer[0].mapping[0])); 129 Assert::AreEqual(true, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) == std::get<Shortcut>(remapBuffer[0].mapping[1])); 130 } 131 132 // Test if the ValidateAndUpdateKeyBufferElement method is unsuccessful when setting first column to the same value as the right column 133 TEST_METHOD (ValidateAndUpdateKeyBufferElement_ShouldReturnMapToSameKeyError_OnSettingFirstColumnToSameValueAsRightColumn) 134 { 135 RemapBuffer remapBuffer; 136 137 // Add a row with A as the target 138 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ (DWORD)0, (DWORD)0x41 }, std::wstring() }); 139 140 // Validate and update the element when selecting A on a row 141 ValidateAndUpdateKeyBufferElementArgs args = { 0, 0, 0x41 }; 142 ShortcutErrorType error = BufferValidationHelpers::ValidateAndUpdateKeyBufferElement(args.elementRowIndex, args.elementColIndex, args.selectedCodeFromDropDown, remapBuffer); 143 144 // Assert that the element is invalid and buffer is not updated 145 Assert::AreEqual(true, error == ShortcutErrorType::MapToSameKey); 146 Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[0].mapping[0])); 147 Assert::AreEqual((DWORD)0x41, std::get<DWORD>(remapBuffer[0].mapping[1])); 148 } 149 150 // Test if the ValidateAndUpdateKeyBufferElement method is unsuccessful when setting first column of a key to key row to the same value as in another row 151 TEST_METHOD (ValidateAndUpdateKeyBufferElement_ShouldReturnSameKeyPreviouslyMappedError_OnSettingFirstColumnOfAKeyToKeyRowToSameValueAsInAnotherRow) 152 { 153 RemapBuffer remapBuffer; 154 155 // Add a row from A->B and a row with C as target 156 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ (DWORD)0x41, (DWORD)0x42 }, std::wstring() }); 157 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ (DWORD)0, (DWORD)0x43 }, std::wstring() }); 158 159 // Validate and update the element when selecting A on second row 160 ValidateAndUpdateKeyBufferElementArgs args = { 1, 0, 0x41 }; 161 ShortcutErrorType error = BufferValidationHelpers::ValidateAndUpdateKeyBufferElement(args.elementRowIndex, args.elementColIndex, args.selectedCodeFromDropDown, remapBuffer); 162 163 // Assert that the element is invalid and buffer is not updated 164 Assert::AreEqual(true, error == ShortcutErrorType::SameKeyPreviouslyMapped); 165 Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].mapping[0])); 166 Assert::AreEqual((DWORD)0x43, std::get<DWORD>(remapBuffer[1].mapping[1])); 167 } 168 169 // Test if the ValidateAndUpdateKeyBufferElement method is unsuccessful when setting first column of a key to shortcut row to the same value as in another row 170 TEST_METHOD (ValidateAndUpdateKeyBufferElement_ShouldReturnSameKeyPreviouslyMappedError_OnSettingFirstColumnOfAKeyToShortcutRowToSameValueAsInAnotherRow) 171 { 172 RemapBuffer remapBuffer; 173 174 // Add a row from A->B and a row with Ctrl+A as target 175 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ (DWORD)0x41, (DWORD)0x42 }, std::wstring() }); 176 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ (DWORD)0, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) }, std::wstring() }); 177 178 // Validate and update the element when selecting A on second row 179 ValidateAndUpdateKeyBufferElementArgs args = { 1, 0, 0x41 }; 180 ShortcutErrorType error = BufferValidationHelpers::ValidateAndUpdateKeyBufferElement(args.elementRowIndex, args.elementColIndex, args.selectedCodeFromDropDown, remapBuffer); 181 182 // Assert that the element is invalid and buffer is not updated 183 Assert::AreEqual(true, error == ShortcutErrorType::SameKeyPreviouslyMapped); 184 Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].mapping[0])); 185 Assert::AreEqual(true, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) == std::get<Shortcut>(remapBuffer[1].mapping[1])); 186 } 187 188 // Test if the ValidateAndUpdateKeyBufferElement method is unsuccessful when setting first column of a key to key row to a conflicting modifier with another row 189 TEST_METHOD (ValidateAndUpdateKeyBufferElement_ShouldReturnConflictingModifierKeyError_OnSettingFirstColumnOfAKeyToKeyRowToConflictingModifierWithAnotherRow) 190 { 191 RemapBuffer remapBuffer; 192 193 // Add a row from Ctrl->B and a row with C as target 194 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ (DWORD)VK_CONTROL, (DWORD)0x42 }, std::wstring() }); 195 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ (DWORD)0, (DWORD)0x43 }, std::wstring() }); 196 197 // Validate and update the element when selecting LCtrl on second row 198 ValidateAndUpdateKeyBufferElementArgs args = { 1, 0, VK_LCONTROL }; 199 ShortcutErrorType error = BufferValidationHelpers::ValidateAndUpdateKeyBufferElement(args.elementRowIndex, args.elementColIndex, args.selectedCodeFromDropDown, remapBuffer); 200 201 // Assert that the element is invalid and buffer is not updated 202 Assert::AreEqual(true, error == ShortcutErrorType::ConflictingModifierKey); 203 Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].mapping[0])); 204 Assert::AreEqual((DWORD)0x43, std::get<DWORD>(remapBuffer[1].mapping[1])); 205 } 206 207 // Test if the ValidateAndUpdateKeyBufferElement method is unsuccessful when setting first column of a key to shortcut row to a conflicting modifier with another row 208 TEST_METHOD (ValidateAndUpdateKeyBufferElement_ShouldReturnConflictingModifierKeyError_OnSettingFirstColumnOfAKeyToShortcutRowToConflictingModifierWithAnotherRow) 209 { 210 RemapBuffer remapBuffer; 211 212 // Add a row from Ctrl->B and a row with Ctrl+A as target 213 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ (DWORD)VK_CONTROL, (DWORD)0x42 }, std::wstring() }); 214 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ (DWORD)0, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) }, std::wstring() }); 215 216 // Validate and update the element when selecting LCtrl on second row 217 ValidateAndUpdateKeyBufferElementArgs args = { 1, 0, VK_LCONTROL }; 218 ShortcutErrorType error = BufferValidationHelpers::ValidateAndUpdateKeyBufferElement(args.elementRowIndex, args.elementColIndex, args.selectedCodeFromDropDown, remapBuffer); 219 220 // Assert that the element is invalid and buffer is not updated 221 Assert::AreEqual(true, error == ShortcutErrorType::ConflictingModifierKey); 222 Assert::AreEqual((DWORD)NULL, std::get<DWORD>(remapBuffer[1].mapping[0])); 223 Assert::AreEqual(true, Shortcut(std::vector<int32_t>{ VK_CONTROL, 0x41 }) == std::get<Shortcut>(remapBuffer[1].mapping[1])); 224 } 225 226 // Test if the ValidateShortcutBufferElement method is successful and no drop down action is required on setting a column to null in a new or valid row 227 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnNoErrorAndNoAction_OnSettingColumnToNullInANewOrValidRow) 228 { 229 std::vector<ValidateShortcutBufferElementArgs> testCases; 230 // Case 1: Validate the element when making null-selection (-1 index) on first column of empty shortcut to shortcut row 231 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 232 // Case 2: Validate the element when making null-selection (-1 index) on second column of empty shortcut to shortcut row 233 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 234 // Case 3: Validate the element when making null-selection (-1 index) on first column of empty shortcut to key row 235 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), (DWORD)0 }, std::wstring() } }); 236 // Case 4: Validate the element when making null-selection (-1 index) on second column of empty shortcut to key row 237 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ -1 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), (DWORD)0 }, std::wstring() } }); 238 // Case 5: Validate the element when making null-selection (-1 index) on first dropdown of first column of valid shortcut to shortcut row 239 testCases.push_back({ 0, 0, 0, std::vector<int32_t>({ -1, 0x43 }), std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring() } }); 240 // Case 6: Validate the element when making null-selection (-1 index) on first dropdown of second column of valid shortcut to shortcut row 241 testCases.push_back({ 0, 1, 0, std::vector<int32_t>({ -1, 0x41 }), std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring() } }); 242 // Case 7: Validate the element when making null-selection (-1 index) on first dropdown of second column of valid hybrid shortcut to shortcut row 243 testCases.push_back({ 0, 1, 0, std::vector<int32_t>({ -1, 0x41 }), std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring() } }); 244 // Case 8: Validate the element when making null-selection (-1 index) on second dropdown of first column of valid shortcut to shortcut row 245 testCases.push_back({ 0, 0, 1, std::vector<int32_t>({ VK_CONTROL, -1 }), std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring() } }); 246 // Case 9: Validate the element when making null-selection (-1 index) on second dropdown of second column of valid shortcut to shortcut row 247 testCases.push_back({ 0, 1, 1, std::vector<int32_t>({ VK_CONTROL, -1 }), std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring() } }); 248 // Case 10: Validate the element when making null-selection (-1 index) on second dropdown of second column of valid hybrid shortcut to shortcut row 249 testCases.push_back({ 0, 1, 1, std::vector<int32_t>({ VK_CONTROL, -1 }), std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring() } }); 250 // Case 11: Validate the element when making null-selection (-1 index) on first dropdown of first column of valid 3 key shortcut to shortcut row 251 testCases.push_back({ 0, 0, 0, std::vector<int32_t>({ -1, VK_SHIFT, 0x44 }), std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x44 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 } }, std::wstring() } }); 252 // Case 12: Validate the element when making null-selection (-1 index) on first dropdown of second column of valid 3 key shortcut to shortcut row 253 testCases.push_back({ 0, 1, 0, std::vector<int32_t>({ -1, VK_SHIFT, 0x42 }), std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x44 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 } }, std::wstring() } }); 254 // Case 13: Validate the element when making null-selection (-1 index) on first dropdown of second column of valid hybrid 3 key shortcut to shortcut row 255 testCases.push_back({ 0, 1, 0, std::vector<int32_t>({ -1, VK_SHIFT, 0x42 }), std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x44 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 } }, std::wstring() } }); 256 // Case 14: Validate the element when making null-selection (-1 index) on second dropdown of first column of valid 3 key shortcut to shortcut row 257 testCases.push_back({ 0, 0, 1, std::vector<int32_t>({ VK_CONTROL, -1, 0x44 }), std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x44 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 } }, std::wstring() } }); 258 // Case 15: Validate the element when making null-selection (-1 index) on second dropdown of second column of valid 3 key shortcut to shortcut row 259 testCases.push_back({ 0, 1, 1, std::vector<int32_t>({ VK_CONTROL, -1, 0x42 }), std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x44 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 } }, std::wstring() } }); 260 // Case 16: Validate the element when making null-selection (-1 index) on second dropdown of second column of valid hybrid 3 key shortcut to shortcut row 261 testCases.push_back({ 0, 1, 1, std::vector<int32_t>({ VK_CONTROL, -1, 0x42 }), std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x44 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 } }, std::wstring() } }); 262 // Case 17: Validate the element when making null-selection (-1 index) on third dropdown of first column of valid 3 key shortcut to shortcut row 263 testCases.push_back({ 0, 0, 2, std::vector<int32_t>({ VK_CONTROL, VK_SHIFT, -1 }), std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x44 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 } }, std::wstring() } }); 264 // Case 18: Validate the element when making null-selection (-1 index) on third dropdown of second column of valid 3 key shortcut to shortcut row 265 testCases.push_back({ 0, 1, 2, std::vector<int32_t>({ VK_CONTROL, VK_SHIFT, -1 }), std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x44 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 } }, std::wstring() } }); 266 // Case 19: Validate the element when making null-selection (-1 index) on third dropdown of second column of valid hybrid 3 key shortcut to shortcut row 267 testCases.push_back({ 0, 1, 2, std::vector<int32_t>({ VK_CONTROL, VK_SHIFT, -1 }), std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x44 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 } }, std::wstring() } }); 268 // Case 20: Validate the element when making null-selection (-1 index) on fourth dropdown of first column of valid 4 key shortcut to shortcut row 269 testCases.push_back({ 0, 0, 3, std::vector<int32_t>({ VK_CONTROL, VK_SHIFT, VK_MENU, -1 }), std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, VK_MENU, 0x44 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, VK_MENU, 0x42 } }, std::wstring() } }); 270 // Case 21: Validate the element when making null-selection (-1 index) on fourth dropdown of second column of valid 4 key shortcut to shortcut row 271 testCases.push_back({ 0, 1, 3, std::vector<int32_t>({ VK_CONTROL, VK_SHIFT, VK_MENU, -1 }), std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, VK_MENU, 0x44 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, VK_MENU, 0x42 } }, std::wstring() } }); 272 // Case 22: Validate the element when making null-selection (-1 index) on fourth dropdown of second column of valid hybrid 4 key shortcut to shortcut row 273 testCases.push_back({ 0, 1, 3, std::vector<int32_t>({ VK_CONTROL, VK_SHIFT, VK_MENU, -1 }), std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, VK_MENU, 0x44 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, VK_MENU, 0x42 } }, std::wstring() } }); 274 // Case 23: Validate the element when making null-selection (-1 index) on fifth dropdown of first column of valid 5 key shortcut to shortcut row 275 testCases.push_back({ 0, 0, 3, std::vector<int32_t>({ VK_CONTROL, VK_SHIFT, VK_MENU, VK_LWIN, -1 }), std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, VK_MENU, VK_LWIN, 0x44 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, VK_MENU, VK_LWIN, 0x42 } }, std::wstring() } }); 276 // Case 24: Validate the element when making null-selection (-1 index) on fifth dropdown of second column of valid 5 key shortcut to shortcut row 277 testCases.push_back({ 0, 1, 3, std::vector<int32_t>({ VK_CONTROL, VK_SHIFT, VK_MENU, VK_LWIN, -1 }), std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, VK_MENU, VK_LWIN, 0x44 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, VK_MENU, VK_LWIN, 0x42 } }, std::wstring() } }); 278 // Case 25: Validate the element when making null-selection (-1 index) on fifth dropdown of second column of valid hybrid 5 key shortcut to shortcut row 279 testCases.push_back({ 0, 1, 3, std::vector<int32_t>({ VK_CONTROL, VK_SHIFT, VK_MENU, VK_LWIN, -1 }), std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, VK_MENU, VK_LWIN, 0x44 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, VK_MENU, VK_LWIN, 0x42 } }, std::wstring() } }); 280 281 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 282 // Arrange 283 RemapBuffer remapBuffer; 284 remapBuffer.push_back(testCase.bufferRow); 285 286 // Act 287 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 288 289 // Assert that the element is valid and no drop down action is required 290 Assert::AreEqual(true, result.first == ShortcutErrorType::NoError); 291 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 292 }); 293 } 294 295 // Test if the ValidateShortcutBufferElement method returns ShortcutStartWithModifier error and no drop down action is required on setting first drop down to an action key on a non-hybrid control column 296 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnShortcutStartWithModifierErrorAndNoAction_OnSettingFirstDropDownToActionKeyOnANonHybridColumn) 297 { 298 std::vector<ValidateShortcutBufferElementArgs> testCases; 299 // Case 1: Validate the element when selecting A (0x41) on first dropdown of first column of empty shortcut to shortcut row 300 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ 0x41 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 301 // Case 2: Validate the element when selecting A (0x41) on first dropdown of second column of empty shortcut to shortcut row 302 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0x41 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 303 // Case 3: Validate the element when selecting A (0x41) on first dropdown of first column of empty shortcut to key row 304 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ 0x41 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), (DWORD)0 }, std::wstring() } }); 305 // Case 4: Validate the element when selecting A (0x41) on first dropdown of first column of valid shortcut to shortcut row 306 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ 0x41, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring() } }); 307 308 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 309 // Arrange 310 RemapBuffer remapBuffer; 311 remapBuffer.push_back(testCase.bufferRow); 312 313 // Act 314 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 315 316 // Assert that the element is invalid and no drop down action is required 317 Assert::AreEqual(true, result.first == ShortcutErrorType::ShortcutStartWithModifier); 318 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 319 }); 320 } 321 322 // Test if the ValidateShortcutBufferElement method returns no error and no drop down action is required on setting first drop down to an action key on an empty hybrid control column 323 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnNoErrorAndNoAction_OnSettingFirstDropDownToActionKeyOnAnEmptyHybridColumn) 324 { 325 std::vector<ValidateShortcutBufferElementArgs> testCases; 326 // Case 1: Validate the element when selecting A (0x41) on first dropdown of second column of empty shortcut to shortcut row 327 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0x41 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 328 // Case 2: Validate the element when selecting A (0x41) on first dropdown of second column of empty shortcut to key row 329 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0x41 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), (DWORD)0 }, std::wstring() } }); 330 331 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 332 // Arrange 333 RemapBuffer remapBuffer; 334 remapBuffer.push_back(testCase.bufferRow); 335 336 // Act 337 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 338 339 // Assert that the element is valid and no drop down action is required 340 Assert::AreEqual(true, result.first == ShortcutErrorType::NoError); 341 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 342 }); 343 } 344 345 // Test if the ValidateShortcutBufferElement method returns ShortcutNotMoreThanOneActionKey error and no drop down action is required on setting first drop down to an action key on a hybrid control column with full shortcut 346 // Changed because we can have more than one key here now that we allow key-chords 347 // old name: ValidateShortcutBufferElement_ShouldReturnShortcutNotMoreThanOneActionKeyAndNoAction_OnSettingNonLastDropDownToActionKeyOnAHybridColumnWithFullShortcut 348 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnNoErrorAndNoAction_OnSettingNonLastDropDownToActionKeyOnAHybridColumnWithFullShortcut) 349 { 350 std::vector<ValidateShortcutBufferElementArgs> testCases; 351 // Case 1: Validate the element when selecting A (0x41) on first dropdown of second column of hybrid shortcut to shortcut row 352 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0x41, 0x43 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ VK_CONTROL, 0x43 } }, std::wstring() } }); 353 // Case 2: Validate the element when selecting A (0x41) on second dropdown of second column of hybrid shortcut to shortcut row 354 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0x41, 0x42 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 } }, std::wstring() } }); 355 356 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 357 // Arrange 358 RemapBuffer remapBuffer; 359 remapBuffer.push_back(testCase.bufferRow); 360 361 // Act 362 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 363 364 // Assert that the element is invalid and no drop down action is required 365 Assert::AreEqual(true, result.first == ShortcutErrorType::NoError); 366 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 367 }); 368 } 369 370 // Test if the ValidateShortcutBufferElement method returns ShortcutNotMoreThanOneActionKey error and no drop down action is required on setting non first non last drop down to an action key on a non hybrid control column with full shortcut 371 // This test was changed since there is now NoError since more than one shortcut can have the same first key, since we now allow key-chords 372 // old name: ValidateShortcutBufferElement_ShouldReturnShortcutNotMoreThanOneActionKeyAndNoAction_OnSettingNonFirstNonLastDropDownToActionKeyOnANonHybridColumnWithFullShortcut 373 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnNoErrorAndNoAction_OnSettingNonFirstNonLastDropDownToActionKeyOnANonHybridColumnWithFullShortcut) 374 { 375 std::vector<ValidateShortcutBufferElementArgs> testCases; 376 // Case 1: Validate the element when selecting A (0x41) on second dropdown of first column of shortcut to shortcut row 377 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, 0x41, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 } }, std::wstring() } }); 378 // Case 2: Validate the element when selecting A (0x41)on second dropdown of second column of shortcut to shortcut row 379 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0x41, 0x42 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 } }, std::wstring() } }); 380 381 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 382 // Arrange 383 RemapBuffer remapBuffer; 384 remapBuffer.push_back(testCase.bufferRow); 385 386 // Act 387 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 388 389 // Assert that the element is invalid and no drop down action is required 390 Assert::AreEqual(true, result.first == ShortcutErrorType::NoError); 391 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 392 }); 393 } 394 395 // Test if the ValidateShortcutBufferElement method returns no error and no drop down action is required on setting last drop down to an action key on a column with at least two drop downs 396 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnNoErrorAndNoAction_OnSettingLastDropDownToActionKeyOnAColumnWithAtleastTwoDropDowns) 397 { 398 std::vector<ValidateShortcutBufferElementArgs> testCases; 399 // Case 1: Validate the element when selecting A (0x41) on last dropdown of first column of three key shortcut to shortcut row 400 testCases.push_back({ 0, 0, 2, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x41 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 } }, std::wstring() } }); 401 // Case 2: Validate the element when selecting A (0x41) on last dropdown of second column of three key shortcut to shortcut row 402 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x41 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 } }, std::wstring() } }); 403 // Case 3: Validate the element when selecting A (0x41) on last dropdown of hybrid second column of three key shortcut to shortcut row 404 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x41 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 } }, std::wstring() } }); 405 // Case 4: Validate the element when selecting A (0x41) on last dropdown of first column of two key shortcut to shortcut row 406 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, 0x41 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 407 // Case 5: Validate the element when selecting A (0x41) on last dropdown of second column of two key shortcut to shortcut row 408 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0x41 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 409 // Case 6: Validate the element when selecting A (0x41) on last dropdown of hybrid second column of two key shortcut to shortcut row 410 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0x41 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 411 412 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 413 // Arrange 414 RemapBuffer remapBuffer; 415 remapBuffer.push_back(testCase.bufferRow); 416 417 // Act 418 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 419 420 // Assert that the element is valid and no drop down action is required 421 Assert::AreEqual(true, result.first == ShortcutErrorType::NoError); 422 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 423 }); 424 } 425 426 // Test if the ValidateShortcutBufferElement method returns no error and ClearUnusedDropDowns action is required on setting non first drop down to an action key on a column if all the drop downs after it are empty 427 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnNoErrorAndClearUnusedDropDownsAction_OnSettingNonFirstDropDownToActionKeyOnAColumnIfAllTheDropDownsAfterItAreEmpty) 428 { 429 std::vector<ValidateShortcutBufferElementArgs> testCases; 430 // Case 1: Validate the element when selecting A (0x41) on second dropdown of first column of 3 dropdown shortcut to shortcut row 431 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, 0x41, -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 432 // Case 2: Validate the element when selecting A (0x41) on second dropdown of second column of 3 dropdown shortcut to shortcut row 433 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0x41, -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 434 // Case 3: Validate the element when selecting A (0x41) on second dropdown of second column of 3 dropdown hybrid shortcut to shortcut row 435 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0x41, -1 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 436 // Case 4: Validate the element when selecting A (0x41) on second dropdown of first column of empty 3 dropdown shortcut to shortcut row 437 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ -1, 0x41, -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 438 // Case 5: Validate the element when selecting A (0x41) on second dropdown of second column of empty 3 dropdown shortcut to shortcut row 439 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ -1, 0x41, -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 440 // Case 6: Validate the element when selecting A (0x41) on second dropdown of second column of empty 3 dropdown hybrid shortcut to shortcut row 441 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ -1, 0x41, -1 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 442 443 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 444 // Arrange 445 RemapBuffer remapBuffer; 446 remapBuffer.push_back(testCase.bufferRow); 447 448 // Act 449 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 450 451 // Assert that the element is valid and ClearUnusedDropDowns action is required 452 Assert::AreEqual(true, result.first == ShortcutErrorType::NoError); 453 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::ClearUnusedDropDowns); 454 }); 455 } 456 457 // Test if the ValidateShortcutBufferElement method returns no error and ClearUnusedDropDowns action is required on setting first drop down to an action key on a hybrid column if all the drop downs after it are empty 458 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnNoErrorAndClearUnusedDropDownsAction_OnSettingFirstDropDownToActionKeyOnAHybridColumnIfAllTheDropDownsAfterItAreEmpty) 459 { 460 std::vector<ValidateShortcutBufferElementArgs> testCases; 461 // Case 1: Validate the element when selecting A (0x41) on first dropdown of second column of empty 3 dropdown hybrid shortcut to shortcut row 462 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0x41, -1, -1 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 463 464 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 465 // Arrange 466 RemapBuffer remapBuffer; 467 remapBuffer.push_back(testCase.bufferRow); 468 469 // Act 470 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 471 472 // Assert that the element is valid and ClearUnusedDropDowns action is required 473 Assert::AreEqual(true, result.first == ShortcutErrorType::NoError); 474 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::ClearUnusedDropDowns); 475 }); 476 } 477 478 // Test if the ValidateShortcutBufferElement method returns no error and AddDropDown action is required on setting last drop down to a non-repeated modifier key on a column there are less than 3 drop downs 479 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnNoErrorAndAddDropDownAction_OnSettingLastDropDownToNonRepeatedModifierKeyOnAColumnIfThereAreLessThan3DropDowns) 480 { 481 std::vector<ValidateShortcutBufferElementArgs> testCases; 482 // Case 1: Validate the element when selecting Shift (VK_SHIFT) on second dropdown of first column of 2 dropdown shortcut to shortcut row 483 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 484 // Case 2: Validate the element when selecting Shift (VK_SHIFT) on second dropdown of second column of 2 dropdown shortcut to shortcut row 485 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 486 // Case 3: Validate the element when selecting Shift (VK_SHIFT) on second dropdown of second column of 2 dropdown hybrid shortcut to shortcut row 487 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 488 // Case 4: Validate the element when selecting Shift (VK_SHIFT) on first dropdown of first column of 1 dropdown shortcut to shortcut row 489 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ VK_SHIFT }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 490 // Case 5: Validate the element when selecting Shift (VK_SHIFT) on first dropdown of second column of 1 dropdown shortcut to shortcut row 491 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_SHIFT }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 492 // Case 6: Validate the element when selecting Shift (VK_SHIFT) on first dropdown of second column of 1 dropdown hybrid shortcut to shortcut row 493 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_SHIFT }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 494 // Case 7: Validate the element when selecting Shift (VK_SHIFT) on first dropdown of second column of 1 dropdown hybrid shortcut to key row with an action key selected 495 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_SHIFT }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), (DWORD)0x44 }, std::wstring() } }); 496 497 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 498 // Arrange 499 RemapBuffer remapBuffer; 500 remapBuffer.push_back(testCase.bufferRow); 501 502 // Act 503 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 504 505 // Assert that the element is valid and AddDropDown action is required 506 Assert::AreEqual(true, result.first == ShortcutErrorType::NoError); 507 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::AddDropDown); 508 }); 509 } 510 511 // Test if the ValidateShortcutBufferElement method returns ShortcutCannotHaveRepeatedModifier error and no action is required on setting last drop down to a repeated modifier key on a column there are less than 3 drop downs 512 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnShortcutCannotHaveRepeatedModifierErrorAndNoAction_OnSettingLastDropDownToRepeatedModifierKeyOnAColumnIfThereAreLessThan3DropDowns) 513 { 514 std::vector<ValidateShortcutBufferElementArgs> testCases; 515 // Case 1: Validate the element when selecting LCtrl (VK_LCONTROL) on second dropdown of first column of 2 dropdown shortcut to shortcut row 516 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, VK_LCONTROL }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 517 // Case 2: Validate the element when selecting LCtrl (VK_LCONTROL) on second dropdown of second column of 2 dropdown hybrid shortcut to shortcut row 518 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, VK_LCONTROL }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 519 // Case 3: Validate the element when selecting LCtrl (VK_LCONTROL) on second dropdown of second column of 2 dropdown hybrid shortcut to shortcut row 520 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, VK_LCONTROL }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 521 522 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 523 // Arrange 524 RemapBuffer remapBuffer; 525 remapBuffer.push_back(testCase.bufferRow); 526 527 // Act 528 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 529 530 // Assert that the element is invalid and no action is required 531 Assert::AreEqual(true, result.first == ShortcutErrorType::ShortcutCannotHaveRepeatedModifier); 532 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 533 }); 534 } 535 536 // Test if the ValidateShortcutBufferElement method returns ShortcutMaxShortcutSizeOneActionKey error and no action is required on setting last drop down to a non repeated modifier key on a column there 3 or more drop downs 537 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnShortcutMaxShortcutSizeOneActionKeyErrorAndNoAction_OnSettingLastDropDownToNonRepeatedModifierKeyOnAColumnIfThereAre3OrMoreDropDowns) 538 { 539 std::vector<ValidateShortcutBufferElementArgs> testCases; 540 // Case 1: Validate the element when selecting Shift (VK_SHIFT) on last dropdown of first column of 5 dropdown shortcut to shortcut row with middle empty 541 testCases.push_back({ 0, 0, 4, std::vector<int32_t>{ VK_CONTROL, -1, -1, -1, VK_SHIFT }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 542 // Case 2: Validate the element when selecting Shift (VK_SHIFT) on last dropdown of second column of 5 dropdown shortcut to shortcut row with middle empty 543 testCases.push_back({ 0, 1, 4, std::vector<int32_t>{ VK_CONTROL, -1, -1, -1, VK_SHIFT }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 544 // Case 3: Validate the element when selecting Shift (VK_SHIFT) on last dropdown of second column of 5 dropdown hybrid shortcut to shortcut row with middle empty 545 testCases.push_back({ 0, 1, 4, std::vector<int32_t>{ VK_CONTROL, -1, -1, -1, VK_SHIFT }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 546 // Case 4: Validate the element when selecting Shift (VK_SHIFT) on last dropdown of first column of 5 dropdown shortcut to shortcut row with first four empty 547 testCases.push_back({ 0, 0, 4, std::vector<int32_t>{ -1, -1, -1, -1, VK_SHIFT }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 548 // Case 5: Validate the element when selecting Shift (VK_SHIFT) on last dropdown of second column of 5 dropdown shortcut to shortcut row with first four empty 549 testCases.push_back({ 0, 1, 4, std::vector<int32_t>{ -1, -1, -1, -1, VK_SHIFT }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 550 // Case 6: Validate the element when selecting Shift (VK_SHIFT) on last dropdown of second column of 5 dropdown hybrid shortcut to shortcut row with first four empty 551 testCases.push_back({ 0, 1, 4, std::vector<int32_t>{ -1, -1, -1, -1, VK_SHIFT }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 552 // Case 7: Validate the element when selecting Shift (VK_SHIFT) on last dropdown of first column of 5 dropdown shortcut to shortcut row 553 testCases.push_back({ 0, 0, 4, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN, VK_SHIFT }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN, 0x42 } }, std::wstring() } }); 554 // Case 8: Validate the element when selecting Shift (VK_SHIFT) on last dropdown of second column of 5 dropdown shortcut to shortcut row 555 testCases.push_back({ 0, 1, 4, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN, VK_SHIFT }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN, 0x42 } }, std::wstring() } }); 556 // Case 9: Validate the element when selecting Shift (VK_SHIFT) on last dropdown of second column of 5 dropdown hybrid shortcut to shortcut row 557 testCases.push_back({ 0, 1, 4, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN, VK_SHIFT }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_RWIN, 0x42 } }, std::wstring() } }); 558 559 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 560 // Arrange 561 RemapBuffer remapBuffer; 562 remapBuffer.push_back(testCase.bufferRow); 563 564 // Act 565 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 566 567 // Assert that the element is invalid and no action is required 568 Assert::AreEqual(true, result.first == ShortcutErrorType::ShortcutMaxShortcutSizeOneActionKey); 569 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 570 }); 571 } 572 573 // Test if the ValidateShortcutBufferElement method returns ShortcutMaxShortcutSizeOneActionKey error and no action is required on setting last drop down to a repeated modifier key on a column there 3 or more drop downs 574 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnShortcutMaxShortcutSizeOneActionKeyErrorAndNoAction_OnSettingLastDropDownToRepeatedModifierKeyOnAColumnIfThereAre3OrMoreDropDowns) 575 { 576 std::vector<ValidateShortcutBufferElementArgs> testCases; 577 // Case 1: Validate the element when selecting Ctrl (VK_CONTROL) on last dropdown of first column of 5 dropdown shortcut to shortcut row with middle empty 578 testCases.push_back({ 0, 0, 4, std::vector<int32_t>{ VK_CONTROL, -1, -1, -1, VK_CONTROL }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 579 // Case 2: Validate the element when selecting Ctrl (VK_CONTROL) on last dropdown of second column of 5 dropdown shortcut to shortcut row with middle empty 580 testCases.push_back({ 0, 1, 4, std::vector<int32_t>{ VK_CONTROL, -1, -1, -1, VK_CONTROL }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 581 // Case 3: Validate the element when selecting Ctrl (VK_CONTROL) on last dropdown of second column of 5 dropdown hybrid shortcut to shortcut row with middle empty 582 testCases.push_back({ 0, 1, 4, std::vector<int32_t>{ VK_CONTROL, -1, -1, -1, VK_CONTROL }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 583 // Case 4: Validate the element when selecting Ctrl (VK_CONTROL) on last dropdown of first column of 5 dropdown shortcut to shortcut row 584 testCases.push_back({ 0, 0, 4, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_SHIFT, VK_CONTROL }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_SHIFT, 0x42 } }, std::wstring() } }); 585 // Case 5: Validate the element when selecting Ctrl (VK_CONTROL) on last dropdown of second column of 5 dropdown shortcut to shortcut row 586 testCases.push_back({ 0, 1, 4, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_SHIFT, VK_CONTROL }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_SHIFT, 0x42 } }, std::wstring() } }); 587 // Case 6: Validate the element when selecting Ctrl (VK_CONTROL) on last dropdown of second column of 5 dropdown hybrid shortcut to shortcut row 588 testCases.push_back({ 0, 1, 4, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_SHIFT, VK_CONTROL }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_LWIN, VK_SHIFT, 0x42 } }, std::wstring() } }); 589 590 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 591 // Arrange 592 RemapBuffer remapBuffer; 593 remapBuffer.push_back(testCase.bufferRow); 594 595 // Act 596 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 597 598 // Assert that the element is invalid and no action is required 599 Assert::AreEqual(true, result.first == ShortcutErrorType::ShortcutMaxShortcutSizeOneActionKey); 600 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 601 }); 602 } 603 604 // Test if the ValidateShortcutBufferElement method returns no error and no action is required on setting non-last drop down to a non repeated modifier key on a column 605 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnNoErrorAndNoAction_OnSettingNonLastDropDownToNonRepeatedModifierKeyOnAColumn) 606 { 607 std::vector<ValidateShortcutBufferElementArgs> testCases; 608 // Case 1: Validate the element when selecting Shift (VK_SHIFT) on first dropdown of first column of 2 dropdown shortcut to shortcut row 609 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 610 // Case 2: Validate the element when selecting Shift (VK_SHIFT) on first dropdown of second column of 2 dropdown shortcut to shortcut row 611 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 612 // Case 3: Validate the element when selecting Shift (VK_SHIFT) on first dropdown of second column of 2 dropdown hybrid shortcut to shortcut row 613 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 614 // Case 4: Validate the element when selecting Shift (VK_SHIFT) on first dropdown of first column of 3 dropdown shortcut to shortcut row 615 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ VK_SHIFT, VK_MENU, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 616 // Case 5: Validate the element when selecting Shift (VK_SHIFT) on first dropdown of second column of 3 dropdown shortcut to shortcut row 617 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_SHIFT, VK_MENU, 0x42 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 618 // Case 6: Validate the element when selecting Shift (VK_SHIFT) on first dropdown of second column of 3 dropdown hybrid shortcut to shortcut row 619 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_SHIFT, VK_MENU, 0x42 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 620 // Case 7: Validate the element when selecting Shift (VK_SHIFT) on second dropdown of first column of 3 dropdown shortcut to shortcut row 621 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 622 // Case 8: Validate the element when selecting Shift (VK_SHIFT) on second dropdown of second column of 3 dropdown shortcut to shortcut row 623 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 624 // Case 9: Validate the element when selecting Shift (VK_SHIFT) on second dropdown of second column of 3 dropdown hybrid shortcut to shortcut row 625 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x42 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 626 627 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 628 // Arrange 629 RemapBuffer remapBuffer; 630 remapBuffer.push_back(testCase.bufferRow); 631 632 // Act 633 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 634 635 // Assert that the element is valid and no action is required 636 Assert::AreEqual(true, result.first == ShortcutErrorType::NoError); 637 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 638 }); 639 } 640 641 // Test if the ValidateShortcutBufferElement method returns ShortcutCannotHaveRepeatedModifier error and no action is required on setting non-last drop down to a repeated modifier key on a column 642 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnShortcutCannotHaveRepeatedModifierErrorAndNoAction_OnSettingNonLastDropDownToRepeatedModifierKeyOnAColumn) 643 { 644 std::vector<ValidateShortcutBufferElementArgs> testCases; 645 // Case 1: Validate the element when selecting Ctrl (VK_CONTROL) on first dropdown of first column of 3 dropdown shortcut to shortcut row with first empty 646 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ VK_CONTROL, VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 647 // Case 2: Validate the element when selecting Ctrl (VK_CONTROL) on first dropdown of second column of 3 dropdown shortcut to shortcut row with first empty 648 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_CONTROL, VK_CONTROL, 0x42 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 649 // Case 3: Validate the element when selecting Ctrl (VK_CONTROL) on first dropdown of second column of 3 dropdown hybrid shortcut to shortcut row with first empty 650 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_CONTROL, VK_CONTROL, 0x42 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 651 // Case 4: Validate the element when selecting Alt (VK_MENU) on first dropdown of first column of 3 dropdown shortcut to shortcut row 652 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ VK_MENU, VK_MENU, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 653 // Case 5: Validate the element when selecting Alt (VK_MENU) on first dropdown of second column of 3 dropdown shortcut to shortcut row 654 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_MENU, VK_MENU, 0x42 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 655 // Case 6: Validate the element when selecting Alt (VK_MENU) on first dropdown of second column of 3 dropdown hybrid shortcut to shortcut row 656 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_MENU, VK_MENU, 0x42 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 657 // Case 7: Validate the element when selecting Ctrl (VK_CONTROL) on second dropdown of first column of 3 dropdown shortcut to shortcut row 658 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 659 // Case 8: Validate the element when selecting Ctrl (VK_CONTROL) on second dropdown of second column of 3 dropdown shortcut to shortcut row 660 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, VK_CONTROL, 0x42 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 661 // Case 9: Validate the element when selecting Ctrl (VK_CONTROL) on second dropdown of second column of 3 dropdown hybrid shortcut to shortcut row 662 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, VK_CONTROL, 0x42 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 663 664 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 665 // Arrange 666 RemapBuffer remapBuffer; 667 remapBuffer.push_back(testCase.bufferRow); 668 669 // Act 670 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 671 672 // Assert that the element is invalid and no action is required 673 Assert::AreEqual(true, result.first == ShortcutErrorType::ShortcutCannotHaveRepeatedModifier); 674 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 675 }); 676 } 677 678 // Test if the ValidateShortcutBufferElement method returns ShortcutStartWithModifier error and no action is required on setting first drop down to None on a non-hybrid column with one drop down 679 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnShortcutStartWithModifierErrorAndNoAction_OnSettingFirstDropDownToNoneOnNonHybridColumnWithOneDropDown) 680 { 681 std::vector<ValidateShortcutBufferElementArgs> testCases; 682 // Case 1: Validate the element when selecting None (0) on first dropdown of first column of 1 dropdown shortcut to shortcut row 683 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ 0 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 684 // Case 2: Validate the element when selecting None (0) on first dropdown of second column of 1 dropdown shortcut to shortcut row 685 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 686 687 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 688 // Arrange 689 RemapBuffer remapBuffer; 690 remapBuffer.push_back(testCase.bufferRow); 691 692 // Act 693 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 694 695 // Assert that the element is invalid and no action is required 696 Assert::AreEqual(true, result.first == ShortcutErrorType::ShortcutStartWithModifier); 697 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 698 }); 699 } 700 701 // Test if the ValidateShortcutBufferElement method returns ShortcutOneActionKey error and no action is required on setting first drop down to None on a hybrid column with one drop down 702 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnShortcutOneActionKeyErrorAndNoAction_OnSettingFirstDropDownToNoneOnHybridColumnWithOneDropDown) 703 { 704 std::vector<ValidateShortcutBufferElementArgs> testCases; 705 // Case 1: Validate the element when selecting None (0) on first dropdown of first column of 1 dropdown hybrid shortcut to shortcut row 706 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 707 708 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 709 // Arrange 710 RemapBuffer remapBuffer; 711 remapBuffer.push_back(testCase.bufferRow); 712 713 // Act 714 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 715 716 // Assert that the element is invalid and no action is required 717 Assert::AreEqual(true, result.first == ShortcutErrorType::ShortcutOneActionKey); 718 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 719 }); 720 } 721 722 // Test if the ValidateShortcutBufferElement method returns ShortcutAtleast2Keys error and no action is required on setting first drop down to None on a non-hybrid column with two drop down 723 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnShortcutAtleast2KeysAndNoAction_OnSettingFirstDropDownToNoneOnNonHybridColumnWithTwoDropDowns) 724 { 725 std::vector<ValidateShortcutBufferElementArgs> testCases; 726 // Case 1: Validate the element when selecting None (0) on first dropdown of first column of 2 dropdown empty shortcut to shortcut row 727 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ 0, -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 728 // Case 2: Validate the element when selecting None (0) on first dropdown of second column of 2 dropdown empty shortcut to shortcut row 729 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0, -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 730 // Case 3: Validate the element when selecting None (0) on first dropdown of second column of 2 dropdown valid shortcut to shortcut row 731 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ 0, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 732 // Case 4: Validate the element when selecting None (0) on first dropdown of second column of 2 dropdown valid shortcut to shortcut row 733 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0, 0x42 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 734 735 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 736 // Arrange 737 RemapBuffer remapBuffer; 738 remapBuffer.push_back(testCase.bufferRow); 739 740 // Act 741 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 742 743 // Assert that the element is invalid and no action is required 744 Assert::AreEqual(true, result.first == ShortcutErrorType::ShortcutAtleast2Keys); 745 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 746 }); 747 } 748 749 // Test if the ValidateShortcutBufferElement method returns ShortcutOneActionKey error and no action is required on setting second drop down to None on a non-hybrid column with two drop down 750 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnShortcutOneActionKeyAndNoAction_OnSettingSecondDropDownToNoneOnNonHybridColumnWithTwoDropDowns) 751 { 752 std::vector<ValidateShortcutBufferElementArgs> testCases; 753 // Case 1: Validate the element when selecting None (0) on second dropdown of first column of 2 dropdown empty shortcut to shortcut row 754 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ -1, 0 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 755 // Case 2: Validate the element when selecting None (0) on second dropdown of second column of 2 dropdown empty shortcut to shortcut row 756 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ -1, 0 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 757 // Case 3: Validate the element when selecting None (0) on second dropdown of second column of 2 dropdown valid shortcut to shortcut row 758 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, 0 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 759 // Case 4: Validate the element when selecting None (0) on second dropdown of second column of 2 dropdown valid shortcut to shortcut row 760 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 761 762 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 763 // Arrange 764 RemapBuffer remapBuffer; 765 remapBuffer.push_back(testCase.bufferRow); 766 767 // Act 768 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 769 770 // Assert that the element is invalid and no action is required 771 Assert::AreEqual(true, result.first == ShortcutErrorType::ShortcutOneActionKey); 772 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 773 }); 774 } 775 776 // Test if the ValidateShortcutBufferElement method returns no error and DeleteDropDown action is required on setting drop down to None on a hybrid column with two drop down 777 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnNoErrorAndDeleteDropDownAction_OnSettingDropDownToNoneOnHybridColumnWithTwoDropDowns) 778 { 779 std::vector<ValidateShortcutBufferElementArgs> testCases; 780 // Case 1: Validate the element when selecting None (0) on first dropdown of second column of 2 dropdown empty hybrid shortcut to shortcut row 781 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0, -1 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 782 // Case 2: Validate the element when selecting None (0) on second dropdown of second column of 2 dropdown empty hybrid shortcut to shortcut row 783 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ -1, 0 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 784 // Case 3: Validate the element when selecting None (0) on first dropdown of second column of 2 dropdown valid hybrid shortcut to shortcut row 785 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0, VK_CONTROL }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 786 // Case 4: Validate the element when selecting None (0) on second dropdown of second column of 2 dropdown valid hybrid shortcut to shortcut row 787 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x42 } }, std::wstring() } }); 788 789 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 790 // Arrange 791 RemapBuffer remapBuffer; 792 remapBuffer.push_back(testCase.bufferRow); 793 794 // Act 795 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 796 797 // Assert that the element is valid and DeleteDropDown action is required 798 Assert::AreEqual(true, result.first == ShortcutErrorType::NoError); 799 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::DeleteDropDown); 800 }); 801 } 802 803 // Test if the ValidateShortcutBufferElement method returns no error and DeleteDropDown action is required on setting non last drop down to None on a column with three drop down 804 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnNoErrorAndDeleteDropDownAction_OnSettingNonLastDropDownToNoneOnColumnWithThreeDropDowns) 805 { 806 std::vector<ValidateShortcutBufferElementArgs> testCases; 807 // Case 1: Validate the element when selecting None (0) on first dropdown of first column of 3 dropdown empty shortcut to shortcut row 808 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ 0, -1, -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 809 // Case 2: Validate the element when selecting None (0) on first dropdown of second column of 3 dropdown empty shortcut to shortcut row 810 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0, -1, -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 811 // Case 3: Validate the element when selecting None (0) on first dropdown of second column of 3 dropdown empty hybrid shortcut to shortcut row 812 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0, -1, -1 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 813 // Case 4: Validate the element when selecting None (0) on second dropdown of first column of 3 dropdown empty shortcut to shortcut row 814 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ -1, 0, -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 815 // Case 5: Validate the element when selecting None (0) on second dropdown of second column of 3 dropdown empty shortcut to shortcut row 816 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ -1, 0, -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 817 // Case 6: Validate the element when selecting None (0) on second dropdown of second column of 3 dropdown empty hybrid shortcut to shortcut row 818 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ -1, 0, -1 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 819 // Case 7: Validate the element when selecting None (0) on first dropdown of first column of 3 dropdown valid shortcut to shortcut row 820 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ 0, VK_MENU, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 821 // Case 8: Validate the element when selecting None (0) on first dropdown of second column of 3 dropdown valid shortcut to shortcut row 822 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0, VK_MENU, 0x42 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 823 // Case 9: Validate the element when selecting None (0) on first dropdown of second column of 3 dropdown valid hybrid shortcut to shortcut row 824 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0, VK_MENU, 0x42 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 825 // Case 10: Validate the element when selecting None (0) on first dropdown of first column of 3 dropdown valid shortcut to shortcut row 826 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, 0, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 827 // Case 11: Validate the element when selecting None (0) on first dropdown of second column of 3 dropdown valid shortcut to shortcut row 828 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0, 0x42 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 829 // Case 12: Validate the element when selecting None (0) on first dropdown of second column of 3 dropdown valid hybrid shortcut to shortcut row 830 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0, 0x42 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 831 832 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 833 // Arrange 834 RemapBuffer remapBuffer; 835 remapBuffer.push_back(testCase.bufferRow); 836 837 // Act 838 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 839 840 // Assert that the element is valid and DeleteDropDown action is required 841 Assert::AreEqual(true, result.first == ShortcutErrorType::NoError); 842 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::DeleteDropDown); 843 }); 844 } 845 846 // Test if the ValidateShortcutBufferElement method returns ShortcutOneActionKey error and no action is required on setting last drop down to None on a column with three drop down 847 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnShortcutOneActionKeyErrorAndNoAction_OnSettingLastDropDownToNoneOnColumnWithThreeDropDowns) 848 { 849 std::vector<ValidateShortcutBufferElementArgs> testCases; 850 // Case 1: Validate the element when selecting None (0) on first dropdown of first column of 3 dropdown empty shortcut to shortcut row 851 testCases.push_back({ 0, 0, 2, std::vector<int32_t>{ -1, -1, 0 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 852 // Case 2: Validate the element when selecting None (0) on first dropdown of second column of 3 dropdown empty shortcut to shortcut row 853 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ -1, -1, 0 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 854 // Case 3: Validate the element when selecting None (0) on first dropdown of second column of 3 dropdown empty hybrid shortcut to shortcut row 855 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ -1, -1, 0 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), Shortcut() }, std::wstring() } }); 856 // Case 4: Validate the element when selecting None (0) on first dropdown of first column of 3 dropdown valid shortcut to shortcut row 857 testCases.push_back({ 0, 0, 2, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 858 // Case 5: Validate the element when selecting None (0) on first dropdown of second column of 3 dropdown valid shortcut to shortcut row 859 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 860 // Case 6: Validate the element when selecting None (0) on first dropdown of second column of 3 dropdown valid hybrid shortcut to shortcut row 861 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_MENU, 0x42 } }, std::wstring() } }); 862 863 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 864 // Arrange 865 RemapBuffer remapBuffer; 866 remapBuffer.push_back(testCase.bufferRow); 867 868 // Act 869 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 870 871 // Assert that the element is invalid and no action is required 872 Assert::AreEqual(true, result.first == ShortcutErrorType::ShortcutOneActionKey); 873 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 874 }); 875 } 876 877 // Test if the ValidateShortcutBufferElement method returns WinL error on setting a drop down to Win or L on a column resulting in Win+L 878 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnWinLError_OnSettingDropDownToWinOrLOnColumnResultingInWinL) 879 { 880 std::vector<ValidateShortcutBufferElementArgs> testCases; 881 // Case 1: Validate the element when selecting L (0x4C) on second dropdown of first column of LWin+Empty shortcut 882 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_LWIN, 0x4C }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LWIN }, Shortcut() }, std::wstring() } }); 883 // Case 2: Validate the element when selecting L (0x4C) on second dropdown of second column of LWin+Empty shortcut 884 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_LWIN, 0x4C }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ VK_LWIN } }, std::wstring() } }); 885 // Case 3: Validate the element when selecting L (0x4C) on second dropdown of second column of hybrid LWin+Empty shortcut 886 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_LWIN, 0x4C }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ VK_LWIN } }, std::wstring() } }); 887 // Case 4: Validate the element when selecting L (0x4C) on second dropdown of first column of Win+Empty shortcut 888 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ CommonSharedConstants::VK_WIN_BOTH, 0x4C }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ CommonSharedConstants::VK_WIN_BOTH }, Shortcut() }, std::wstring() } }); 889 // Case 5: Validate the element when selecting L (0x4C) on second dropdown of second column of Win+Empty shortcut 890 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ CommonSharedConstants::VK_WIN_BOTH, 0x4C }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ CommonSharedConstants::VK_WIN_BOTH } }, std::wstring() } }); 891 // Case 6: Validate the element when selecting L (0x4C) on second dropdown of second column of hybrid Win+Empty shortcut 892 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ CommonSharedConstants::VK_WIN_BOTH, 0x4C }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ CommonSharedConstants::VK_WIN_BOTH } }, std::wstring() } }); 893 // Case 7: Validate the element when selecting LWin (VK_LWIN) on first dropdown of first column of Empty+L shortcut 894 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ VK_LWIN, 0x4C }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ 0x4C }, Shortcut() }, std::wstring() } }); 895 // Case 8: Validate the element when selecting LWin (VK_LWIN) on first dropdown of second column of Empty+L shortcut 896 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_LWIN, 0x4C }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ 0x4C } }, std::wstring() } }); 897 // Case 9: Validate the element when selecting LWin (VK_LWIN) on first dropdown of second column of hybrid Empty+L shortcut 898 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_LWIN, 0x4C }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ 0x4C } }, std::wstring() } }); 899 900 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 901 // Arrange 902 RemapBuffer remapBuffer; 903 remapBuffer.push_back(testCase.bufferRow); 904 905 // Act 906 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 907 908 // Assert that the element is invalid 909 Assert::AreEqual(true, result.first == ShortcutErrorType::WinL); 910 }); 911 } 912 913 // Test if the ValidateShortcutBufferElement method returns WinL error on setting a drop down to null or none on a column resulting in Win+L 914 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnWinLError_OnSettingDropDownToNullOrNoneOnColumnResultingInWinL) 915 { 916 std::vector<ValidateShortcutBufferElementArgs> testCases; 917 // Case 1: Validate the element when selecting Null (-1) on second dropdown of first column of LWin + Ctrl + L shortcut 918 testCases.push_back({ 0, 0, 2, std::vector<int32_t>{ VK_LWIN, -1, 0x4C }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LWIN, VK_CONTROL, 0x4C }, Shortcut() }, std::wstring() } }); 919 // Case 2: Validate the element when selecting Null (-1) on second dropdown of second column of LWin + Ctrl + L shortcut 920 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ VK_LWIN, -1, 0x4C }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ VK_LWIN, VK_CONTROL, 0x4C } }, std::wstring() } }); 921 // Case 3: Validate the element when selecting Null (-1) on second dropdown of second column of hybrid LWin + Ctrl + L shortcut 922 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ VK_LWIN, -1, 0x4C }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ VK_LWIN, VK_CONTROL, 0x4C } }, std::wstring() } }); 923 // Case 4: Validate the element when selecting None (0) on second dropdown of first column of LWin + Ctrl + L shortcut 924 testCases.push_back({ 0, 0, 2, std::vector<int32_t>{ VK_LWIN, 0, 0x4C }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LWIN, VK_CONTROL, 0x4C }, Shortcut() }, std::wstring() } }); 925 // Case 5: Validate the element when selecting None (0) on second dropdown of second column of LWin + Ctrl + L shortcut 926 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ VK_LWIN, 0, 0x4C }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ VK_LWIN, VK_CONTROL, 0x4C } }, std::wstring() } }); 927 // Case 6: Validate the element when selecting None (0) on second dropdown of second column of hybrid LWin + Ctrl + L shortcut 928 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ VK_LWIN, 0, 0x4C }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ VK_LWIN, VK_CONTROL, 0x4C } }, std::wstring() } }); 929 930 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 931 // Arrange 932 RemapBuffer remapBuffer; 933 remapBuffer.push_back(testCase.bufferRow); 934 935 // Act 936 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 937 938 // Assert that the element is invalid 939 Assert::AreEqual(true, result.first == ShortcutErrorType::WinL); 940 }); 941 } 942 943 // Test if the ValidateShortcutBufferElement method returns CtrlAltDel error on setting a drop down to Ctrl, Alt or Del on a column resulting in Ctrl+Alt+Del 944 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnCtrlAltDelError_OnSettingDropDownToCtrlAltOrDelOnColumnResultingInCtrlAltDel) 945 { 946 std::vector<ValidateShortcutBufferElementArgs> testCases; 947 // Case 1: Validate the element when selecting Del (VK_DELETE) on third dropdown of first column of Ctrl+Alt+Empty shortcut 948 testCases.push_back({ 0, 0, 2, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_DELETE }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_MENU }, Shortcut() }, std::wstring() } }); 949 // Case 2: Validate the element when selecting Del (VK_DELETE) on third dropdown of second column of Ctrl+Alt+Empty shortcut 950 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_DELETE }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ VK_CONTROL, VK_MENU } }, std::wstring() } }); 951 // Case 3: Validate the element when selecting Del (VK_DELETE) on third dropdown of second column of hybrid Ctrl+Alt+Empty shortcut 952 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_DELETE }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ VK_CONTROL, VK_MENU } }, std::wstring() } }); 953 // Case 4: Validate the element when selecting Alt (VK_MENU) on second dropdown of first column of Ctrl+Empty+Del shortcut 954 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_DELETE }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_DELETE }, Shortcut() }, std::wstring() } }); 955 // Case 5: Validate the element when selecting Alt (VK_MENU) on second dropdown of second column of Ctrl+Empty+Del shortcut 956 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_DELETE }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ VK_CONTROL, VK_DELETE } }, std::wstring() } }); 957 // Case 6: Validate the element when selecting Alt (VK_MENU) on second dropdown of second column of hybrid Ctrl+Empty+Del shortcut 958 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, VK_MENU, VK_DELETE }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ Shortcut(), std::vector<int32_t>{ VK_CONTROL, VK_DELETE } }, std::wstring() } }); 959 960 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 961 // Arrange 962 RemapBuffer remapBuffer; 963 remapBuffer.push_back(testCase.bufferRow); 964 965 // Act 966 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 967 968 // Assert that the element is invalid 969 Assert::AreEqual(true, result.first == ShortcutErrorType::CtrlAltDel); 970 }); 971 } 972 973 // Test if the ValidateShortcutBufferElement method returns MapToSameKey error on setting hybrid second column to match first column in a remap keys table 974 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnMapToSameKeyError_OnSettingHybridSecondColumnToFirstColumnInKeyTable) 975 { 976 std::vector<ValidateShortcutBufferElementArgs> testCases; 977 // Case 1: Validate the element when selecting A (0x41) on first dropdown of empty hybrid second column 978 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0x41, -1, -1 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ (DWORD)0x41, (DWORD)0 }, std::wstring() } }); 979 // Case 2: Validate the element when selecting A (0x41) on second dropdown of empty hybrid second column 980 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ -1, 0x41, -1 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ (DWORD)0x41, (DWORD)0 }, std::wstring() } }); 981 // Case 3: Validate the element when selecting A (0x41) on third dropdown of empty hybrid second column 982 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ -1, -1, 0x41 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ (DWORD)0x41, (DWORD)0 }, std::wstring() } }); 983 // Case 4: Validate the element when selecting A (0x41) on first dropdown of hybrid second column with key 984 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0x41 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ (DWORD)0x41, (DWORD)0x43 }, std::wstring() } }); 985 // Case 5: Validate the element when selecting Null (-1) on first dropdown of hybrid second column with shortcut 986 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ -1, 0x41 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ (DWORD)0x41, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring() } }); 987 // Case 6: Validate the element when selecting None (0) on first dropdown of hybrid second column with shortcut 988 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0, 0x41 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ (DWORD)0x41, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring() } }); 989 // Case 7: Validate the element when selecting Null (-1) on second dropdown of hybrid second column with shortcut 990 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ -1, VK_CONTROL }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ (DWORD)VK_CONTROL, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring() } }); 991 // Case 8: Validate the element when selecting None (0) on second dropdown of hybrid second column with shortcut 992 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ 0, VK_CONTROL }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ (DWORD)VK_CONTROL, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring() } }); 993 994 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 995 // Arrange 996 RemapBuffer remapBuffer; 997 remapBuffer.push_back(testCase.bufferRow); 998 999 // Act 1000 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 1001 1002 // Assert that the element is invalid 1003 Assert::AreEqual(true, result.first == ShortcutErrorType::MapToSameKey); 1004 }); 1005 } 1006 1007 // Test if the ValidateShortcutBufferElement method returns MapToSameShortcut error on setting one column to match the other and both are valid 3 key shortcuts 1008 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnMapToSameShortcutError_OnSettingOneColumnToTheOtherAndBothAreValid3KeyShortcuts) 1009 { 1010 std::vector<ValidateShortcutBufferElementArgs> testCases; 1011 // Case 1 : Validate the element when selecting C (0x43) on third dropdown of first column with Ctrl+Shift+Empty 1012 testCases.push_back({ 0, 0, 2, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 } }, std::wstring() } }); 1013 // Case 2 : Validate the element when selecting C (0x43) on third dropdown of second column with Ctrl+Shift+Empty 1014 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT } }, std::wstring() } }); 1015 // Case 3 : Validate the element when selecting C (0x43) on third dropdown of second column with hybrid Ctrl+Shift+Empty 1016 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT } }, std::wstring() } }); 1017 // Case 4 : Validate the element when selecting Shift (VK_SHIFT) on second dropdown of first column with Ctrl+Empty+C 1018 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 } }, std::wstring() } }); 1019 // Case 5 : Validate the element when selecting Shift (VK_SHIFT) on second dropdown of second column with Ctrl+Empty+C 1020 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x43 } }, std::wstring() } }); 1021 // Case 6 : Validate the element when selecting Shift (VK_SHIFT) on second dropdown of second column with hybrid Ctrl+Empty+C 1022 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x43 } }, std::wstring() } }); 1023 // Case 7 : Validate the element when selecting Shift (VK_SHIFT) on first dropdown of first column with Empty+Ctrl+C 1024 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ VK_SHIFT, VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 } }, std::wstring() } }); 1025 // Case 8 : Validate the element when selecting Shift (VK_SHIFT) on first dropdown of second column with Empty+Ctrl+C 1026 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_SHIFT, VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x43 } }, std::wstring() } }); 1027 // Case 9 : Validate the element when selecting Shift (VK_SHIFT) on first dropdown of second column with hybrid Empty+Ctrl+C 1028 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_SHIFT, VK_CONTROL, 0x43 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x43 } }, std::wstring() } }); 1029 1030 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 1031 // Arrange 1032 RemapBuffer remapBuffer; 1033 remapBuffer.push_back(testCase.bufferRow); 1034 1035 // Act 1036 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 1037 1038 // Assert that the element is invalid 1039 Assert::AreEqual(true, result.first == ShortcutErrorType::MapToSameShortcut); 1040 }); 1041 } 1042 1043 // Test if the ValidateShortcutBufferElement method returns MapToSameShortcut error on setting one column to match the other and both are valid 2 key shortcuts 1044 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnMapToSameShortcutError_OnSettingOneColumnToTheOtherAndBothAreValid2KeyShortcuts) 1045 { 1046 std::vector<ValidateShortcutBufferElementArgs> testCases; 1047 // Case 1 : Validate the element when selecting C (0x43) on third dropdown of first column with Ctrl+Empty+Empty 1048 testCases.push_back({ 0, 0, 2, std::vector<int32_t>{ VK_CONTROL, -1, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL }, std::vector<int32_t>{ VK_CONTROL, 0x43 } }, std::wstring() } }); 1049 // Case 2 : Validate the element when selecting C (0x43) on third dropdown of second column with Ctrl+Empty+Empty 1050 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ VK_CONTROL, -1, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL } }, std::wstring() } }); 1051 // Case 3 : Validate the element when selecting C (0x43) on third dropdown of second column with hybrid Ctrl+Empty+Empty 1052 testCases.push_back({ 0, 1, 2, std::vector<int32_t>{ VK_CONTROL, -1, 0x43 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL } }, std::wstring() } }); 1053 // Case 4 : Validate the element when selecting C (0x43) on second dropdown of first column with Ctrl+Empty+Empty 1054 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, 0x43, -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL }, std::vector<int32_t>{ VK_CONTROL, 0x43 } }, std::wstring() } }); 1055 // Case 5 : Validate the element when selecting C (0x43) on second dropdown of second column with Ctrl+Empty+Empty 1056 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0x43, -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL } }, std::wstring() } }); 1057 // Case 6 : Validate the element when selecting C (0x43) on second dropdown of second column with hybrid Ctrl+Empty+Empty 1058 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0x43, -1 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL } }, std::wstring() } }); 1059 // Case 7 : Validate the element when selecting Ctrl (VK_CONTROL) on first dropdown of first column with Empty+Empty+C 1060 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ VK_CONTROL, -1, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x43 } }, std::wstring() } }); 1061 // Case 8 : Validate the element when selecting Ctrl (VK_CONTROL) on first dropdown of second column with Empty+Empty+C 1062 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_CONTROL, -1, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ 0x43 } }, std::wstring() } }); 1063 // Case 9 : Validate the element when selecting Ctrl (VK_CONTROL) on first dropdown of second column with hybrid Empty+Empty+C 1064 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ VK_CONTROL, -1, 0x43 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ 0x43 } }, std::wstring() } }); 1065 // Case 10 : Validate the element when selecting Ctrl (VK_CONTROL) on second dropdown of first column with Empty+Empty+C 1066 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ -1, VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x43 } }, std::wstring() } }); 1067 // Case 11 : Validate the element when selecting Ctrl (VK_CONTROL) on second dropdown of second column with Empty+Empty+C 1068 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ -1, VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ 0x43 } }, std::wstring() } }); 1069 // Case 12 : Validate the element when selecting Ctrl (VK_CONTROL) on second dropdown of second column with hybrid Empty+Empty+C 1070 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ -1, VK_CONTROL, 0x43 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ 0x43 } }, std::wstring() } }); 1071 // Case 13 : Validate the element when selecting C (0x43) on second dropdown of first column with Ctrl+A 1072 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x41 }, std::vector<int32_t>{ VK_CONTROL, 0x43 } }, std::wstring() } }); 1073 // Case 14 : Validate the element when selecting C (0x43) on second dropdown of second column with Ctrl+A 1074 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring() } }); 1075 // Case 15 : Validate the element when selecting C (0x43) on second dropdown of second column with hybrid Ctrl+A 1076 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x41 } }, std::wstring() } }); 1077 // Case 16 : Validate the element when selecting Ctrl (VK_CONTROL) on first dropdown of first column with Alt+C 1078 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_MENU, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x43 } }, std::wstring() } }); 1079 // Case 17 : Validate the element when selecting Ctrl (VK_CONTROL) on first dropdown of second column with Alt+C 1080 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_MENU, 0x43 } }, std::wstring() } }); 1081 // Case 18 : Validate the element when selecting Ctrl (VK_CONTROL) on first dropdown of second column with hybrid Alt+C 1082 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_MENU, 0x43 } }, std::wstring() } }); 1083 // Case 19 : Validate the element when selecting Null (-1) on second dropdown of first column with Ctrl+Shift+C 1084 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, -1, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x43 } }, std::wstring() } }); 1085 // Case 20 : Validate the element when selecting Null (-1) on second dropdown of second column with Ctrl+Shift+C 1086 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, -1, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 } }, std::wstring() } }); 1087 // Case 21 : Validate the element when selecting Null (-1) on second dropdown of second column with hybrid Ctrl+Shift+C 1088 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, -1, 0x43 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 } }, std::wstring() } }); 1089 // Case 22 : Validate the element when selecting None (0) on second dropdown of first column with Ctrl+Shift+C 1090 testCases.push_back({ 0, 0, 1, std::vector<int32_t>{ VK_CONTROL, 0, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x43 } }, std::wstring() } }); 1091 // Case 23 : Validate the element when selecting None (0) on second dropdown of second column with Ctrl+Shift+C 1092 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 } }, std::wstring() } }); 1093 // Case 24 : Validate the element when selecting None (0) on second dropdown of second column with hybrid Ctrl+Shift+C 1094 testCases.push_back({ 0, 1, 1, std::vector<int32_t>{ VK_CONTROL, 0, 0x43 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 } }, std::wstring() } }); 1095 // Case 25 : Validate the element when selecting Null (-1) on first dropdown of first column with Shift+Ctrl+C 1096 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ -1, VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_SHIFT, VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x43 } }, std::wstring() } }); 1097 // Case 26 : Validate the element when selecting Null (-1) on first dropdown of second column with Shift+Ctrl+C 1098 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ -1, VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_SHIFT, VK_CONTROL, 0x43 } }, std::wstring() } }); 1099 // Case 27 : Validate the element when selecting Null (-1) on first dropdown of second column with hybrid Shift+Ctrl+C 1100 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ -1, VK_CONTROL, 0x43 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_SHIFT, VK_CONTROL, 0x43 } }, std::wstring() } }); 1101 // Case 28 : Validate the element when selecting None (0) on first dropdown of first column with Shift+Ctrl+C 1102 testCases.push_back({ 0, 0, 0, std::vector<int32_t>{ 0, VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_SHIFT, VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_CONTROL, 0x43 } }, std::wstring() } }); 1103 // Case 29 : Validate the element when selecting None (0) on first dropdown of second column with Shift+Ctrl+C 1104 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0, VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_SHIFT, VK_CONTROL, 0x43 } }, std::wstring() } }); 1105 // Case 30 : Validate the element when selecting None (0) on first dropdown of second column with hybrid Shift+Ctrl+C 1106 testCases.push_back({ 0, 1, 0, std::vector<int32_t>{ 0, VK_CONTROL, 0x43 }, std::wstring(), true, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::vector<int32_t>{ VK_SHIFT, VK_CONTROL, 0x43 } }, std::wstring() } }); 1107 1108 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 1109 // Arrange 1110 RemapBuffer remapBuffer; 1111 remapBuffer.push_back(testCase.bufferRow); 1112 1113 // Act 1114 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 1115 1116 // Assert that the element is invalid 1117 Assert::AreEqual(true, result.first == ShortcutErrorType::MapToSameShortcut); 1118 }); 1119 } 1120 1121 // Test if the ValidateShortcutBufferElement method returns SameShortcutPreviouslyMapped error on setting first column to match first column in another row with same target app and both are valid 3 key shortcuts 1122 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnSameShortcutPreviouslyMappedError_OnSettingFirstColumnToFirstColumnInAnotherRowWithSameTargetAppAndBothAreValid3KeyShortcuts) 1123 { 1124 std::vector<ValidateShortcutBufferElementArgs> testCases; 1125 // Case 1 : Validate the element when selecting C (0x43) on third dropdown of first column with Ctrl+Shift+Empty 1126 testCases.push_back({ 1, 0, 2, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT }, Shortcut() }, std::wstring() } }); 1127 // Case 2 : Validate the element when selecting Shift (VK_SHIFT) on second dropdown of first column with Ctrl+Empty+C 1128 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, Shortcut() }, std::wstring() } }); 1129 // Case 3 : Validate the element when selecting Shift (VK_SHIFT) on first dropdown of first column with Empty+Ctrl+C 1130 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ VK_SHIFT, VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, Shortcut() }, std::wstring() } }); 1131 1132 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 1133 // Arrange 1134 RemapBuffer remapBuffer; 1135 // Ctrl+Shift+C remapped 1136 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, Shortcut() }, std::wstring() }); 1137 remapBuffer.push_back(testCase.bufferRow); 1138 1139 // Act 1140 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 1141 1142 // Assert that the element is invalid 1143 Assert::AreEqual(true, result.first == ShortcutErrorType::SameShortcutPreviouslyMapped); 1144 }); 1145 } 1146 1147 // Test if the ValidateShortcutBufferElement method returns no error on setting first column to match first column in another row with different target app and both are valid 3 key shortcuts 1148 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnNoError_OnSettingFirstColumnToFirstColumnInAnotherRowWithDifferentTargetAppAndBothAreValid3KeyShortcuts) 1149 { 1150 std::vector<ValidateShortcutBufferElementArgs> testCases; 1151 // Case 1 : Validate the element when selecting C (0x43) on third dropdown of first column with Ctrl+Shift+Empty for testApp2 1152 testCases.push_back({ 1, 0, 2, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT }, Shortcut() }, testApp2 } }); 1153 // Case 2 : Validate the element when selecting Shift (VK_SHIFT) on second dropdown of first column with Ctrl+Empty+C for testApp2 1154 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, Shortcut() }, testApp2 } }); 1155 // Case 3 : Validate the element when selecting Shift (VK_SHIFT) on first dropdown of first column with Empty+Ctrl+C for testApp2 1156 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ VK_SHIFT, VK_CONTROL, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, Shortcut() }, testApp2 } }); 1157 1158 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 1159 // Arrange 1160 RemapBuffer remapBuffer; 1161 // Ctrl+Shift+C remapped for testApp1 1162 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, Shortcut() }, testApp1 }); 1163 remapBuffer.push_back(testCase.bufferRow); 1164 1165 // Act 1166 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 1167 1168 // Assert that the element is valid 1169 Assert::AreEqual(true, result.first == ShortcutErrorType::NoError); 1170 }); 1171 } 1172 1173 // Test if the ValidateShortcutBufferElement method returns ConflictingModifierShortcut error on setting first column to conflict with first column in another row with same target app and both are valid 3 key shortcuts 1174 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnConflictingModifierShortcutError_OnSettingFirstColumnToConflictWithFirstColumnInAnotherRowWithSameTargetAppAndBothAreValid3KeyShortcuts) 1175 { 1176 std::vector<ValidateShortcutBufferElementArgs> testCases; 1177 // Case 1 : Validate the element when selecting C (0x43) on third dropdown of first column with LCtrl+Shift+Empty 1178 testCases.push_back({ 1, 0, 2, std::vector<int32_t>{ VK_LCONTROL, VK_SHIFT, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LCONTROL, VK_SHIFT }, Shortcut() }, std::wstring() } }); 1179 // Case 2 : Validate the element when selecting Shift (VK_SHIFT) on second dropdown of first column with LCtrl+Empty+C 1180 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_LCONTROL, VK_SHIFT, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LCONTROL, 0x43 }, Shortcut() }, std::wstring() } }); 1181 // Case 3 : Validate the element when selecting LShift (VK_LSHIFT) on first dropdown of first column with Empty+Ctrl+C 1182 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ VK_LSHIFT, VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, Shortcut() }, std::wstring() } }); 1183 1184 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 1185 // Arrange 1186 RemapBuffer remapBuffer; 1187 // Ctrl+Shift+C remapped 1188 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, Shortcut() }, std::wstring() }); 1189 remapBuffer.push_back(testCase.bufferRow); 1190 1191 // Act 1192 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 1193 1194 // Assert that the element is invalid 1195 Assert::AreEqual(true, result.first == ShortcutErrorType::ConflictingModifierShortcut); 1196 }); 1197 } 1198 1199 // Test if the ValidateShortcutBufferElement method returns no error on setting first column to conflict with first column in another row with different target app and both are valid 3 key shortcuts 1200 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnNoError_OnSettingFirstColumnToConflictWithFirstColumnInAnotherRowWithDifferentTargetAppAndBothAreValid3KeyShortcuts) 1201 { 1202 std::vector<ValidateShortcutBufferElementArgs> testCases; 1203 // Case 1 : Validate the element when selecting C (0x43) on third dropdown of first column with LCtrl+Shift+Empty for testApp2 1204 testCases.push_back({ 1, 0, 2, std::vector<int32_t>{ VK_LCONTROL, VK_SHIFT, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LCONTROL, VK_SHIFT }, Shortcut() }, testApp2 } }); 1205 // Case 2 : Validate the element when selecting Shift (VK_SHIFT) on second dropdown of first column with LCtrl+Empty+C for testApp2 1206 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_LCONTROL, VK_SHIFT, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LCONTROL, 0x43 }, Shortcut() }, testApp2 } }); 1207 // Case 3 : Validate the element when selecting LShift (VK_LSHIFT) on first dropdown of first column with Empty+Ctrl+C for testApp2 1208 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ VK_LSHIFT, VK_CONTROL, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, Shortcut() }, testApp2 } }); 1209 1210 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 1211 // Arrange 1212 RemapBuffer remapBuffer; 1213 // Ctrl+Shift+C remapped for testApp1 1214 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, Shortcut() }, testApp1 }); 1215 remapBuffer.push_back(testCase.bufferRow); 1216 1217 // Act 1218 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 1219 1220 // Assert that the element is valid 1221 Assert::AreEqual(true, result.first == ShortcutErrorType::NoError); 1222 }); 1223 } 1224 1225 // Test if the ValidateShortcutBufferElement method returns SameShortcutPreviouslyMapped error on setting first column to match first column in another row with same target app and both are valid 2 key shortcuts 1226 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnSameShortcutPreviouslyMappedError_OnSettingFirstColumnToFirstColumnInAnotherRowWithSameTargetAppAndBothAreValid2KeyShortcuts) 1227 { 1228 std::vector<ValidateShortcutBufferElementArgs> testCases; 1229 // Case 1 : Validate the element when selecting C (0x43) on second dropdown of first column with Ctrl+Empty 1230 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL }, Shortcut() }, std::wstring() } }); 1231 // Case 2 : Validate the element when selecting C (0x43) on third dropdown of first column with Ctrl+Empty+Empty 1232 testCases.push_back({ 1, 0, 2, std::vector<int32_t>{ VK_CONTROL, -1, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL }, Shortcut() }, std::wstring() } }); 1233 // Case 3 : Validate the element when selecting C (0x43) on second dropdown of first column with Ctrl+Empty+Empty 1234 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_CONTROL, 0x43, -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL }, Shortcut() }, std::wstring() } }); 1235 // Case 4 : Validate the element when selecting Ctrl (VK_CONTROL) on first dropdown of first column with Empty+C 1236 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ 0x43 }, Shortcut() }, std::wstring() } }); 1237 // Case 5 : Validate the element when selecting Ctrl (VK_CONTROL) on first dropdown of first column with Empty+Empty+C 1238 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ VK_CONTROL, -1, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ 0x43 }, Shortcut() }, std::wstring() } }); 1239 // Case 6 : Validate the element when selecting Ctrl (VK_CONTROL) on second dropdown of first column with Empty+Empty+C 1240 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ -1, VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ 0x43 }, Shortcut() }, std::wstring() } }); 1241 // Case 7 : Validate the element when selecting Null (-1) on second dropdown of first column with Ctrl+Shift+C 1242 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_CONTROL, -1, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, Shortcut() }, std::wstring() } }); 1243 // Case 8 : Validate the element when selecting Null (-1) on first dropdown of first column with Shift+Ctrl+C 1244 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ -1, VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_SHIFT, VK_CONTROL, 0x43 }, Shortcut() }, std::wstring() } }); 1245 // Case 9 : Validate the element when selecting None (0) on second dropdown of first column with Ctrl+Shift+C 1246 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_CONTROL, 0, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, Shortcut() }, std::wstring() } }); 1247 // Case 10 : Validate the element when selecting None (0) on first dropdown of first column with Shift+Ctrl+C 1248 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ 0, VK_CONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_SHIFT, VK_CONTROL, 0x43 }, Shortcut() }, std::wstring() } }); 1249 1250 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 1251 // Arrange 1252 RemapBuffer remapBuffer; 1253 // Ctrl+C remapped 1254 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, Shortcut() }, std::wstring() }); 1255 remapBuffer.push_back(testCase.bufferRow); 1256 1257 // Act 1258 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 1259 1260 // Assert that the element is invalid 1261 Assert::AreEqual(true, result.first == ShortcutErrorType::SameShortcutPreviouslyMapped); 1262 }); 1263 } 1264 1265 // Test if the ValidateShortcutBufferElement method returns no error on setting first column to match first column in another row with different target app and both are valid 2 key shortcuts 1266 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnNoError_OnSettingFirstColumnToFirstColumnInAnotherRowWithDifferentTargetAppAndBothAreValid2KeyShortcuts) 1267 { 1268 std::vector<ValidateShortcutBufferElementArgs> testCases; 1269 // Case 1 : Validate the element when selecting C (0x43) on second dropdown of first column with Ctrl+Empty for testApp2 1270 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_CONTROL, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL }, Shortcut() }, testApp2 } }); 1271 // Case 2 : Validate the element when selecting C (0x43) on third dropdown of first column with Ctrl+Empty+Empty for testApp2 1272 testCases.push_back({ 1, 0, 2, std::vector<int32_t>{ VK_CONTROL, -1, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL }, Shortcut() }, testApp2 } }); 1273 // Case 3 : Validate the element when selecting C (0x43) on second dropdown of first column with Ctrl+Empty+Empty for testApp2 1274 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_CONTROL, 0x43, -1 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL }, Shortcut() }, testApp2 } }); 1275 // Case 4 : Validate the element when selecting Ctrl (VK_CONTROL) on first dropdown of first column with Empty+C for testApp2 1276 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ VK_CONTROL, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ 0x43 }, Shortcut() }, testApp2 } }); 1277 // Case 5 : Validate the element when selecting Ctrl (VK_CONTROL) on first dropdown of first column with Empty+Empty+C for testApp2 1278 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ VK_CONTROL, -1, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ 0x43 }, Shortcut() }, testApp2 } }); 1279 // Case 6 : Validate the element when selecting Ctrl (VK_CONTROL) on second dropdown of first column with Empty+Empty+C for testApp2 1280 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ -1, VK_CONTROL, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ 0x43 }, Shortcut() }, testApp2 } }); 1281 // Case 7 : Validate the element when selecting Null (-1) on second dropdown of first column with Ctrl+Shift+C for testApp2 1282 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_CONTROL, -1, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, Shortcut() }, testApp2 } }); 1283 // Case 8 : Validate the element when selecting Null (-1) on first dropdown of first column with Shift+Ctrl+C for testApp2 1284 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ -1, VK_CONTROL, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_SHIFT, VK_CONTROL, 0x43 }, Shortcut() }, testApp2 } }); 1285 // Case 9 : Validate the element when selecting None (0) on second dropdown of first column with Ctrl+Shift+C for testApp2 1286 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_CONTROL, 0, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, VK_SHIFT, 0x43 }, Shortcut() }, testApp2 } }); 1287 // Case 10 : Validate the element when selecting None (0) on first dropdown of first column with Shift+Ctrl+C for testApp2 1288 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ 0, VK_CONTROL, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_SHIFT, VK_CONTROL, 0x43 }, Shortcut() }, testApp2 } }); 1289 1290 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 1291 // Arrange 1292 RemapBuffer remapBuffer; 1293 // Ctrl+C remapped for testApp1 1294 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, Shortcut() }, testApp1 }); 1295 remapBuffer.push_back(testCase.bufferRow); 1296 1297 // Act 1298 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 1299 1300 // Assert that the element is valid 1301 Assert::AreEqual(true, result.first == ShortcutErrorType::NoError); 1302 }); 1303 } 1304 1305 // Test if the ValidateShortcutBufferElement method returns ConflictingModifierShortcut error on setting first column to conflict with first column in another row with same target app and both are valid 2 key shortcuts 1306 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnConflictingModifierShortcutError_OnSettingFirstColumnToConflictWithFirstColumnInAnotherRowWithSameTargetAppAndBothAreValid2KeyShortcuts) 1307 { 1308 std::vector<ValidateShortcutBufferElementArgs> testCases; 1309 // Case 1 : Validate the element when selecting C (0x43) on second dropdown of first column with LCtrl+Empty 1310 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_LCONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LCONTROL }, Shortcut() }, std::wstring() } }); 1311 // Case 2 : Validate the element when selecting C (0x43) on third dropdown of first column with LCtrl+Empty+Empty 1312 testCases.push_back({ 1, 0, 2, std::vector<int32_t>{ VK_LCONTROL, -1, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LCONTROL }, Shortcut() }, std::wstring() } }); 1313 // Case 3 : Validate the element when selecting C (0x43) on second dropdown of first column with LCtrl+Empty+Empty 1314 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_LCONTROL, 0x43, -1 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LCONTROL }, Shortcut() }, std::wstring() } }); 1315 // Case 4 : Validate the element when selecting LCtrl (VK_LCONTROL) on first dropdown of first column with Empty+C 1316 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ VK_LCONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ 0x43 }, Shortcut() }, std::wstring() } }); 1317 // Case 5 : Validate the element when selecting LCtrl (VK_LCONTROL) on first dropdown of first column with Empty+Empty+C 1318 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ VK_LCONTROL, -1, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ 0x43 }, Shortcut() }, std::wstring() } }); 1319 // Case 6 : Validate the element when selecting LCtrl (VK_LCONTROL) on second dropdown of first column with Empty+Empty+C 1320 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ -1, VK_LCONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ 0x43 }, Shortcut() }, std::wstring() } }); 1321 // Case 7 : Validate the element when selecting Null (-1) on second dropdown of first column with LCtrl+Shift+C 1322 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_LCONTROL, -1, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LCONTROL, VK_SHIFT, 0x43 }, Shortcut() }, std::wstring() } }); 1323 // Case 8 : Validate the element when selecting Null (-1) on first dropdown of first column with Shift+LCtrl+C 1324 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ -1, VK_LCONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_SHIFT, VK_LCONTROL, 0x43 }, Shortcut() }, std::wstring() } }); 1325 // Case 9 : Validate the element when selecting None (0) on second dropdown of first column with LCtrl+Shift+C 1326 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_LCONTROL, 0, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LCONTROL, VK_SHIFT, 0x43 }, Shortcut() }, std::wstring() } }); 1327 // Case 10 : Validate the element when selecting None (0) on first dropdown of first column with Shift+LCtrl+C 1328 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ 0, VK_LCONTROL, 0x43 }, std::wstring(), false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_SHIFT, VK_LCONTROL, 0x43 }, Shortcut() }, std::wstring() } }); 1329 1330 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 1331 // Arrange 1332 RemapBuffer remapBuffer; 1333 // Ctrl+C remapped 1334 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, Shortcut() }, std::wstring() }); 1335 remapBuffer.push_back(testCase.bufferRow); 1336 1337 // Act 1338 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 1339 1340 // Assert that the element is invalid 1341 Assert::AreEqual(true, result.first == ShortcutErrorType::ConflictingModifierShortcut); 1342 }); 1343 } 1344 1345 // Test if the ValidateShortcutBufferElement method returns no error on setting first column to conflict with first column in another row with different target app and both are valid 2 key shortcuts 1346 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnNoError_OnSettingFirstColumnToConflictWithFirstColumnInAnotherRowWithDifferentTargetAppAndBothAreValid2KeyShortcuts) 1347 { 1348 std::vector<ValidateShortcutBufferElementArgs> testCases; 1349 // Case 1 : Validate the element when selecting C (0x43) on second dropdown of first column with LCtrl+Empty for testApp2 1350 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_LCONTROL, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LCONTROL }, Shortcut() }, testApp2 } }); 1351 // Case 2 : Validate the element when selecting C (0x43) on third dropdown of first column with LCtrl+Empty+Empty for testApp2 1352 testCases.push_back({ 1, 0, 2, std::vector<int32_t>{ VK_LCONTROL, -1, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LCONTROL }, Shortcut() }, testApp2 } }); 1353 // Case 3 : Validate the element when selecting C (0x43) on second dropdown of first column with LCtrl+Empty+Empty for testApp2 1354 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_LCONTROL, 0x43, -1 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LCONTROL }, Shortcut() }, testApp2 } }); 1355 // Case 4 : Validate the element when selecting LCtrl (VK_LCONTROL) on first dropdown of first column with Empty+C for testApp2 1356 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ VK_LCONTROL, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ 0x43 }, Shortcut() }, testApp2 } }); 1357 // Case 5 : Validate the element when selecting LCtrl (VK_LCONTROL) on first dropdown of first column with Empty+Empty+C for testApp2 1358 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ VK_LCONTROL, -1, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ 0x43 }, Shortcut() }, testApp2 } }); 1359 // Case 6 : Validate the element when selecting LCtrl (VK_LCONTROL) on second dropdown of first column with Empty+Empty+C for testApp2 1360 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ -1, VK_LCONTROL, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ 0x43 }, Shortcut() }, testApp2 } }); 1361 // Case 7 : Validate the element when selecting Null (-1) on second dropdown of first column with LCtrl+Shift+C for testApp2 1362 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_LCONTROL, -1, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LCONTROL, VK_SHIFT, 0x43 }, Shortcut() }, testApp2 } }); 1363 // Case 8 : Validate the element when selecting Null (-1) on first dropdown of first column with Shift+LCtrl+C for testApp2 1364 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ -1, VK_LCONTROL, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_SHIFT, VK_LCONTROL, 0x43 }, Shortcut() }, testApp2 } }); 1365 // Case 9 : Validate the element when selecting None (0) on second dropdown of first column with LCtrl+Shift+C for testApp2 1366 testCases.push_back({ 1, 0, 1, std::vector<int32_t>{ VK_LCONTROL, 0, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_LCONTROL, VK_SHIFT, 0x43 }, Shortcut() }, testApp2 } }); 1367 // Case 10 : Validate the element when selecting None (0) on first dropdown of first column with Shift+LCtrl+C for testApp2 1368 testCases.push_back({ 1, 0, 0, std::vector<int32_t>{ 0, VK_LCONTROL, 0x43 }, testApp2, false, RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_SHIFT, VK_LCONTROL, 0x43 }, Shortcut() }, testApp2 } }); 1369 1370 RunTestCases(testCases, [this](const ValidateShortcutBufferElementArgs& testCase) { 1371 // Arrange 1372 RemapBuffer remapBuffer; 1373 // Ctrl+C remapped for testApp1 1374 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_CONTROL, 0x43 }, Shortcut() }, testApp1 }); 1375 remapBuffer.push_back(testCase.bufferRow); 1376 1377 // Act 1378 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(testCase.elementRowIndex, testCase.elementColIndex, testCase.indexOfDropDownLastModified, testCase.selectedCodesOnDropDowns, testCase.targetAppNameInTextBox, testCase.isHybridColumn, remapBuffer, true); 1379 1380 // Assert that the element is valid 1381 Assert::AreEqual(true, result.first == ShortcutErrorType::NoError); 1382 }); 1383 } 1384 1385 // Return error on Disable as second modifier key or action key 1386 TEST_METHOD (ValidateShortcutBufferElement_ShouldReturnDisableAsActionKeyError_OnSettingSecondDropdownAsDisable) 1387 { 1388 // Arrange 1389 RemapBuffer remapBuffer; 1390 remapBuffer.push_back(RemapBufferRow{ RemapBufferItem{ std::vector<int32_t>{ VK_SHIFT, CommonSharedConstants::VK_DISABLED }, Shortcut() }, testApp1 }); 1391 std::vector<int32_t> selectedCodes = { 1392 VK_SHIFT, 1393 CommonSharedConstants::VK_DISABLED 1394 }; 1395 1396 // Act 1397 std::pair<ShortcutErrorType, BufferValidationHelpers::DropDownAction> result = BufferValidationHelpers::ValidateShortcutBufferElement(0, 1, 1, selectedCodes, testApp1, true, remapBuffer, true); 1398 1399 // Assert 1400 Assert::AreEqual(true, result.first == ShortcutErrorType::ShortcutDisableAsActionKey); 1401 Assert::AreEqual(true, result.second == BufferValidationHelpers::DropDownAction::NoAction); 1402 } 1403 }; 1404 }