| 1 | /* |
| 2 | * Copyright (C) 2021 Damir Porobic <[email protected]> |
| 3 | * |
| 4 | * This program is free software; you can redistribute it and/or modify |
| 5 | * it under the terms of the GNU General Public License as published by |
| 6 | * the Free Software Foundation; either version 2 of the License, or |
| 7 | * (at your option) any later version. |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 17 | * Boston, MA 02110-1301, USA. |
| 18 | */ |
| 19 | |
| 20 | #include "ActionTests.h" |
| 21 | |
| 22 | #include "src/gui/actions/Action.h" |
| 23 | |
| 24 | #include "tests/utils/TestRunner.h" |
| 25 | |
| 26 | void ActionTests::EqualsOperator_Should_ReturnTrue_When_AllValuesMatch() |
| 27 | { |
| 28 | // arrange |
| 29 | Action action1; |
| 30 | action1.setName("Name"); |
| 31 | action1.setShortcut(Qt::CTRL + Qt::Key_A); |
| 32 | action1.setIsCaptureEnabled(true); |
| 33 | action1.setIncludeCursor(true); |
| 34 | action1.setCaptureDelay(2000); |
| 35 | action1.setCaptureMode(CaptureModes::FullScreen); |
| 36 | action1.setIsSaveEnabled(true); |
| 37 | action1.setIsCopyToClipboardEnabled(true); |
| 38 | action1.setIsUploadEnabled(true); |
| 39 | action1.setIsOpenDirectoryEnabled(true); |
| 40 | action1.setIsPinImageEnabled(true); |
| 41 | action1.setIsHideMainWindowEnabled(true); |
| 42 | action1.setIsGlobalShortcut(true); |
| 43 | |
| 44 | Action action2; |
| 45 | action2.setName(action1.name()); |
| 46 | action2.setShortcut(action1.shortcut()); |
| 47 | action2.setIsCaptureEnabled(action1.isCaptureEnabled()); |
| 48 | action2.setIncludeCursor(action1.includeCursor()); |
| 49 | action2.setCaptureDelay(action1.captureDelay()); |
| 50 | action2.setCaptureMode(action1.captureMode()); |
| 51 | action2.setIsSaveEnabled(action1.isSaveEnabled()); |
| 52 | action2.setIsCopyToClipboardEnabled(action1.isCopyToClipboardEnabled()); |
| 53 | action2.setIsUploadEnabled(action1.isUploadEnabled()); |
| 54 | action2.setIsOpenDirectoryEnabled(action1.isOpenDirectoryEnabled()); |
| 55 | action2.setIsPinImageEnabled(action1.isPinImageEnabled()); |
| 56 | action2.setIsHideMainWindowEnabled(action1.isHideMainWindowEnabled()); |
| 57 | action2.setIsGlobalShortcut(action1.isGlobalShortcut()); |
| 58 | |
| 59 | // act |
| 60 | auto result = action1 == action2; |
| 61 | |
| 62 | // assert |
| 63 | QCOMPARE(result, true); |
| 64 | } |
| 65 | |
| 66 | void ActionTests::EqualsOperator_Should_ReturnFalse_When_NameIsDifferent() |
| 67 | { |
| 68 | // arrange |
| 69 | Action action1; |
| 70 | action1.setName("Name"); |
| 71 | action1.setShortcut(Qt::CTRL + Qt::Key_A); |
| 72 | action1.setIsCaptureEnabled(true); |
| 73 | action1.setIncludeCursor(true); |
| 74 | action1.setCaptureDelay(2000); |
| 75 | action1.setCaptureMode(CaptureModes::FullScreen); |
| 76 | action1.setIsSaveEnabled(true); |
| 77 | action1.setIsCopyToClipboardEnabled(true); |
| 78 | action1.setIsUploadEnabled(true); |
| 79 | action1.setIsOpenDirectoryEnabled(true); |
| 80 | action1.setIsPinImageEnabled(true); |
| 81 | action1.setIsHideMainWindowEnabled(true); |
| 82 | action1.setIsGlobalShortcut(true); |
| 83 | |
| 84 | Action action2; |
| 85 | action2.setName("Other"); |
| 86 | action2.setShortcut(action1.shortcut()); |
| 87 | action2.setIsCaptureEnabled(action1.isCaptureEnabled()); |
| 88 | action2.setIncludeCursor(action1.includeCursor()); |
| 89 | action2.setCaptureDelay(action1.captureDelay()); |
| 90 | action2.setCaptureMode(action1.captureMode()); |
| 91 | action2.setIsSaveEnabled(action1.isSaveEnabled()); |
| 92 | action2.setIsCopyToClipboardEnabled(action1.isCopyToClipboardEnabled()); |
| 93 | action2.setIsUploadEnabled(action1.isUploadEnabled()); |
| 94 | action2.setIsOpenDirectoryEnabled(action1.isOpenDirectoryEnabled()); |
| 95 | action2.setIsPinImageEnabled(action1.isPinImageEnabled()); |
| 96 | action2.setIsHideMainWindowEnabled(action1.isHideMainWindowEnabled()); |
| 97 | action2.setIsGlobalShortcut(action1.isGlobalShortcut()); |
| 98 | |
| 99 | // act |
| 100 | auto result = action1 == action2; |
| 101 | |
| 102 | // assert |
| 103 | QCOMPARE(result, false); |
| 104 | } |
| 105 | |
| 106 | void ActionTests::EqualsOperator_Should_ReturnFalse_When_ShortcutDifferent() |
| 107 | { |
| 108 | // arrange |
| 109 | Action action1; |
| 110 | action1.setName("Name"); |
| 111 | action1.setShortcut(Qt::CTRL + Qt::Key_A); |
| 112 | action1.setIsCaptureEnabled(true); |
| 113 | action1.setIncludeCursor(true); |
| 114 | action1.setCaptureDelay(2000); |
| 115 | action1.setCaptureMode(CaptureModes::FullScreen); |
| 116 | action1.setIsSaveEnabled(true); |
| 117 | action1.setIsCopyToClipboardEnabled(true); |
| 118 | action1.setIsUploadEnabled(true); |
| 119 | action1.setIsOpenDirectoryEnabled(true); |
| 120 | action1.setIsPinImageEnabled(true); |
| 121 | action1.setIsHideMainWindowEnabled(true); |
| 122 | action1.setIsGlobalShortcut(true); |
| 123 | |
| 124 | Action action2; |
| 125 | action2.setName(action1.name()); |
| 126 | action2.setShortcut(QKeySequence(Qt::CTRL + Qt::Key_B)); |
| 127 | action2.setIsCaptureEnabled(action1.isCaptureEnabled()); |
| 128 | action2.setIncludeCursor(action1.includeCursor()); |
| 129 | action2.setCaptureDelay(action1.captureDelay()); |
| 130 | action2.setCaptureMode(action1.captureMode()); |
| 131 | action2.setIsSaveEnabled(action1.isSaveEnabled()); |
| 132 | action2.setIsCopyToClipboardEnabled(action1.isCopyToClipboardEnabled()); |
| 133 | action2.setIsUploadEnabled(action1.isUploadEnabled()); |
| 134 | action2.setIsOpenDirectoryEnabled(action1.isOpenDirectoryEnabled()); |
| 135 | action2.setIsPinImageEnabled(action1.isPinImageEnabled()); |
| 136 | action2.setIsHideMainWindowEnabled(action1.isHideMainWindowEnabled()); |
| 137 | action2.setIsGlobalShortcut(action1.isGlobalShortcut()); |
| 138 | |
| 139 | // act |
| 140 | auto result = action1 == action2; |
| 141 | |
| 142 | // assert |
| 143 | QCOMPARE(result, false); |
| 144 | } |
| 145 | |
| 146 | void ActionTests::EqualsOperator_Should_ReturnFalse_When_IsCaptureEnabledDifferent() |
| 147 | { |
| 148 | // arrange |
| 149 | Action action1; |
| 150 | action1.setName("Name"); |
| 151 | action1.setShortcut(Qt::CTRL + Qt::Key_A); |
| 152 | action1.setIsCaptureEnabled(true); |
| 153 | action1.setIncludeCursor(true); |
| 154 | action1.setCaptureDelay(2000); |
| 155 | action1.setCaptureMode(CaptureModes::FullScreen); |
| 156 | action1.setIsSaveEnabled(true); |
| 157 | action1.setIsCopyToClipboardEnabled(true); |
| 158 | action1.setIsUploadEnabled(true); |
| 159 | action1.setIsOpenDirectoryEnabled(true); |
| 160 | action1.setIsPinImageEnabled(true); |
| 161 | action1.setIsHideMainWindowEnabled(true); |
| 162 | action1.setIsGlobalShortcut(true); |
| 163 | |
| 164 | Action action2; |
| 165 | action2.setName(action1.name()); |
| 166 | action2.setShortcut(action1.shortcut()); |
| 167 | action2.setIsCaptureEnabled(false); |
| 168 | action2.setIncludeCursor(action1.includeCursor()); |
| 169 | action2.setCaptureDelay(action1.captureDelay()); |
| 170 | action2.setCaptureMode(action1.captureMode()); |
| 171 | action2.setIsSaveEnabled(action1.isSaveEnabled()); |
| 172 | action2.setIsCopyToClipboardEnabled(action1.isCopyToClipboardEnabled()); |
| 173 | action2.setIsUploadEnabled(action1.isUploadEnabled()); |
| 174 | action2.setIsOpenDirectoryEnabled(action1.isOpenDirectoryEnabled()); |
| 175 | action2.setIsPinImageEnabled(action1.isPinImageEnabled()); |
| 176 | action2.setIsHideMainWindowEnabled(action1.isHideMainWindowEnabled()); |
| 177 | action2.setIsGlobalShortcut(action1.isGlobalShortcut()); |
| 178 | |
| 179 | // act |
| 180 | auto result = action1 == action2; |
| 181 | |
| 182 | // assert |
| 183 | QCOMPARE(result, false); |
| 184 | } |
| 185 | |
| 186 | void ActionTests::EqualsOperator_Should_ReturnFalse_When_IncludeCursorDifferent() |
| 187 | { |
| 188 | // arrange |
| 189 | Action action1; |
| 190 | action1.setName("Name"); |
| 191 | action1.setShortcut(Qt::CTRL + Qt::Key_A); |
| 192 | action1.setIsCaptureEnabled(true); |
| 193 | action1.setIncludeCursor(true); |
| 194 | action1.setCaptureDelay(2000); |
| 195 | action1.setCaptureMode(CaptureModes::FullScreen); |
| 196 | action1.setIsSaveEnabled(true); |
| 197 | action1.setIsCopyToClipboardEnabled(true); |
| 198 | action1.setIsUploadEnabled(true); |
| 199 | action1.setIsOpenDirectoryEnabled(true); |
| 200 | action1.setIsPinImageEnabled(true); |
| 201 | action1.setIsHideMainWindowEnabled(true); |
| 202 | action1.setIsGlobalShortcut(true); |
| 203 | |
| 204 | Action action2; |
| 205 | action2.setName(action1.name()); |
| 206 | action2.setShortcut(action1.shortcut()); |
| 207 | action2.setIsCaptureEnabled(action1.isCaptureEnabled()); |
| 208 | action2.setIncludeCursor(false); |
| 209 | action2.setCaptureDelay(action1.captureDelay()); |
| 210 | action2.setCaptureMode(action1.captureMode()); |
| 211 | action2.setIsSaveEnabled(action1.isSaveEnabled()); |
| 212 | action2.setIsCopyToClipboardEnabled(action1.isCopyToClipboardEnabled()); |
| 213 | action2.setIsUploadEnabled(action1.isUploadEnabled()); |
| 214 | action2.setIsOpenDirectoryEnabled(action1.isOpenDirectoryEnabled()); |
| 215 | action2.setIsPinImageEnabled(action1.isPinImageEnabled()); |
| 216 | action2.setIsHideMainWindowEnabled(action1.isHideMainWindowEnabled()); |
| 217 | action2.setIsGlobalShortcut(action1.isGlobalShortcut()); |
| 218 | |
| 219 | // act |
| 220 | auto result = action1 == action2; |
| 221 | |
| 222 | // assert |
| 223 | QCOMPARE(result, false); |
| 224 | } |
| 225 | |
| 226 | void ActionTests::EqualsOperator_Should_ReturnFalse_When_CaptureDelayDifferent() |
| 227 | { |
| 228 | // arrange |
| 229 | Action action1; |
| 230 | action1.setName("Name"); |
| 231 | action1.setShortcut(Qt::CTRL + Qt::Key_A); |
| 232 | action1.setIsCaptureEnabled(true); |
| 233 | action1.setIncludeCursor(true); |
| 234 | action1.setCaptureDelay(2000); |
| 235 | action1.setCaptureMode(CaptureModes::FullScreen); |
| 236 | action1.setIsSaveEnabled(true); |
| 237 | action1.setIsCopyToClipboardEnabled(true); |
| 238 | action1.setIsUploadEnabled(true); |
| 239 | action1.setIsOpenDirectoryEnabled(true); |
| 240 | action1.setIsPinImageEnabled(true); |
| 241 | action1.setIsHideMainWindowEnabled(true); |
| 242 | action1.setIsGlobalShortcut(true); |
| 243 | |
| 244 | Action action2; |
| 245 | action2.setName(action1.name()); |
| 246 | action2.setShortcut(action1.shortcut()); |
| 247 | action2.setIsCaptureEnabled(action1.isCaptureEnabled()); |
| 248 | action2.setIncludeCursor(action1.includeCursor()); |
| 249 | action2.setCaptureDelay(5000); |
| 250 | action2.setCaptureMode(action1.captureMode()); |
| 251 | action2.setIsSaveEnabled(action1.isSaveEnabled()); |
| 252 | action2.setIsCopyToClipboardEnabled(action1.isCopyToClipboardEnabled()); |
| 253 | action2.setIsUploadEnabled(action1.isUploadEnabled()); |
| 254 | action2.setIsOpenDirectoryEnabled(action1.isOpenDirectoryEnabled()); |
| 255 | action2.setIsPinImageEnabled(action1.isPinImageEnabled()); |
| 256 | action2.setIsHideMainWindowEnabled(action1.isHideMainWindowEnabled()); |
| 257 | action2.setIsGlobalShortcut(action1.isGlobalShortcut()); |
| 258 | |
| 259 | // act |
| 260 | auto result = action1 == action2; |
| 261 | |
| 262 | // assert |
| 263 | QCOMPARE(result, false); |
| 264 | } |
| 265 | |
| 266 | void ActionTests::EqualsOperator_Should_ReturnFalse_When_CaptureModeDifferent() |
| 267 | { |
| 268 | // arrange |
| 269 | Action action1; |
| 270 | action1.setName("Name"); |
| 271 | action1.setShortcut(Qt::CTRL + Qt::Key_A); |
| 272 | action1.setIsCaptureEnabled(true); |
| 273 | action1.setIncludeCursor(true); |
| 274 | action1.setCaptureDelay(2000); |
| 275 | action1.setCaptureMode(CaptureModes::FullScreen); |
| 276 | action1.setIsSaveEnabled(true); |
| 277 | action1.setIsCopyToClipboardEnabled(true); |
| 278 | action1.setIsUploadEnabled(true); |
| 279 | action1.setIsOpenDirectoryEnabled(true); |
| 280 | action1.setIsPinImageEnabled(true); |
| 281 | action1.setIsHideMainWindowEnabled(true); |
| 282 | action1.setIsGlobalShortcut(true); |
| 283 | |
| 284 | Action action2; |
| 285 | action2.setName(action1.name()); |
| 286 | action2.setShortcut(action1.shortcut()); |
| 287 | action2.setIsCaptureEnabled(action1.isCaptureEnabled()); |
| 288 | action2.setIncludeCursor(action1.includeCursor()); |
| 289 | action2.setCaptureDelay(action1.captureDelay()); |
| 290 | action2.setCaptureMode(CaptureModes::RectArea); |
| 291 | action2.setIsSaveEnabled(action1.isSaveEnabled()); |
| 292 | action2.setIsCopyToClipboardEnabled(action1.isCopyToClipboardEnabled()); |
| 293 | action2.setIsUploadEnabled(action1.isUploadEnabled()); |
| 294 | action2.setIsOpenDirectoryEnabled(action1.isOpenDirectoryEnabled()); |
| 295 | action2.setIsPinImageEnabled(action1.isPinImageEnabled()); |
| 296 | action2.setIsHideMainWindowEnabled(action1.isHideMainWindowEnabled()); |
| 297 | action2.setIsGlobalShortcut(action1.isGlobalShortcut()); |
| 298 | |
| 299 | // act |
| 300 | auto result = action1 == action2; |
| 301 | |
| 302 | // assert |
| 303 | QCOMPARE(result, false); |
| 304 | } |
| 305 | |
| 306 | void ActionTests::EqualsOperator_Should_ReturnFalse_When_IsSaveEnabledDifferent() |
| 307 | { |
| 308 | // arrange |
| 309 | Action action1; |
| 310 | action1.setName("Name"); |
| 311 | action1.setShortcut(Qt::CTRL + Qt::Key_A); |
| 312 | action1.setIsCaptureEnabled(true); |
| 313 | action1.setIncludeCursor(true); |
| 314 | action1.setCaptureDelay(2000); |
| 315 | action1.setCaptureMode(CaptureModes::FullScreen); |
| 316 | action1.setIsSaveEnabled(true); |
| 317 | action1.setIsCopyToClipboardEnabled(true); |
| 318 | action1.setIsUploadEnabled(true); |
| 319 | action1.setIsOpenDirectoryEnabled(true); |
| 320 | action1.setIsPinImageEnabled(true); |
| 321 | action1.setIsHideMainWindowEnabled(true); |
| 322 | action1.setIsGlobalShortcut(true); |
| 323 | |
| 324 | Action action2; |
| 325 | action2.setName(action1.name()); |
| 326 | action2.setShortcut(action1.shortcut()); |
| 327 | action2.setIsCaptureEnabled(action1.isCaptureEnabled()); |
| 328 | action2.setIncludeCursor(action1.includeCursor()); |
| 329 | action2.setCaptureDelay(action1.captureDelay()); |
| 330 | action2.setCaptureMode(action1.captureMode()); |
| 331 | action2.setIsSaveEnabled(false); |
| 332 | action2.setIsCopyToClipboardEnabled(action1.isCopyToClipboardEnabled()); |
| 333 | action2.setIsUploadEnabled(action1.isUploadEnabled()); |
| 334 | action2.setIsOpenDirectoryEnabled(action1.isOpenDirectoryEnabled()); |
| 335 | action2.setIsPinImageEnabled(action1.isPinImageEnabled()); |
| 336 | action2.setIsHideMainWindowEnabled(action1.isHideMainWindowEnabled()); |
| 337 | action2.setIsGlobalShortcut(action1.isGlobalShortcut()); |
| 338 | |
| 339 | // act |
| 340 | auto result = action1 == action2; |
| 341 | |
| 342 | // assert |
| 343 | QCOMPARE(result, false); |
| 344 | } |
| 345 | |
| 346 | void ActionTests::EqualsOperator_Should_ReturnFalse_When_IsCopyToClipboardEnabledDifferent() |
| 347 | { |
| 348 | // arrange |
| 349 | Action action1; |
| 350 | action1.setName("Name"); |
| 351 | action1.setShortcut(Qt::CTRL + Qt::Key_A); |
| 352 | action1.setIsCaptureEnabled(true); |
| 353 | action1.setIncludeCursor(true); |
| 354 | action1.setCaptureDelay(2000); |
| 355 | action1.setCaptureMode(CaptureModes::FullScreen); |
| 356 | action1.setIsSaveEnabled(true); |
| 357 | action1.setIsCopyToClipboardEnabled(true); |
| 358 | action1.setIsUploadEnabled(true); |
| 359 | action1.setIsOpenDirectoryEnabled(true); |
| 360 | action1.setIsPinImageEnabled(true); |
| 361 | action1.setIsHideMainWindowEnabled(true); |
| 362 | action1.setIsGlobalShortcut(true); |
| 363 | |
| 364 | Action action2; |
| 365 | action2.setName(action1.name()); |
| 366 | action2.setShortcut(action1.shortcut()); |
| 367 | action2.setIsCaptureEnabled(action1.isCaptureEnabled()); |
| 368 | action2.setIncludeCursor(action1.includeCursor()); |
| 369 | action2.setCaptureDelay(action1.captureDelay()); |
| 370 | action2.setCaptureMode(action1.captureMode()); |
| 371 | action2.setIsSaveEnabled(action1.isSaveEnabled()); |
| 372 | action2.setIsCopyToClipboardEnabled(false); |
| 373 | action2.setIsUploadEnabled(action1.isUploadEnabled()); |
| 374 | action2.setIsOpenDirectoryEnabled(action1.isOpenDirectoryEnabled()); |
| 375 | action2.setIsPinImageEnabled(action1.isPinImageEnabled()); |
| 376 | action2.setIsHideMainWindowEnabled(action1.isHideMainWindowEnabled()); |
| 377 | action2.setIsGlobalShortcut(action1.isGlobalShortcut()); |
| 378 | |
| 379 | // act |
| 380 | auto result = action1 == action2; |
| 381 | |
| 382 | // assert |
| 383 | QCOMPARE(result, false); |
| 384 | } |
| 385 | |
| 386 | void ActionTests::EqualsOperator_Should_ReturnFalse_When_IsUploadEnabledDifferent() |
| 387 | { |
| 388 | // arrange |
| 389 | Action action1; |
| 390 | action1.setName("Name"); |
| 391 | action1.setShortcut(Qt::CTRL + Qt::Key_A); |
| 392 | action1.setIsCaptureEnabled(true); |
| 393 | action1.setIncludeCursor(true); |
| 394 | action1.setCaptureDelay(2000); |
| 395 | action1.setCaptureMode(CaptureModes::FullScreen); |
| 396 | action1.setIsSaveEnabled(true); |
| 397 | action1.setIsCopyToClipboardEnabled(true); |
| 398 | action1.setIsUploadEnabled(true); |
| 399 | action1.setIsOpenDirectoryEnabled(true); |
| 400 | action1.setIsPinImageEnabled(true); |
| 401 | action1.setIsHideMainWindowEnabled(true); |
| 402 | action1.setIsGlobalShortcut(true); |
| 403 | |
| 404 | Action action2; |
| 405 | action2.setName(action1.name()); |
| 406 | action2.setShortcut(action1.shortcut()); |
| 407 | action2.setIsCaptureEnabled(action1.isCaptureEnabled()); |
| 408 | action2.setIncludeCursor(action1.includeCursor()); |
| 409 | action2.setCaptureDelay(action1.captureDelay()); |
| 410 | action2.setCaptureMode(action1.captureMode()); |
| 411 | action2.setIsSaveEnabled(action1.isSaveEnabled()); |
| 412 | action2.setIsCopyToClipboardEnabled(action1.isCopyToClipboardEnabled()); |
| 413 | action2.setIsUploadEnabled(false); |
| 414 | action2.setIsOpenDirectoryEnabled(action1.isOpenDirectoryEnabled()); |
| 415 | action2.setIsPinImageEnabled(action1.isPinImageEnabled()); |
| 416 | action2.setIsHideMainWindowEnabled(action1.isHideMainWindowEnabled()); |
| 417 | action2.setIsGlobalShortcut(action1.isGlobalShortcut()); |
| 418 | |
| 419 | // act |
| 420 | auto result = action1 == action2; |
| 421 | |
| 422 | // assert |
| 423 | QCOMPARE(result, false); |
| 424 | } |
| 425 | |
| 426 | void ActionTests::EqualsOperator_Should_ReturnFalse_When_IsOpenDirectoryEnabledDifferent() |
| 427 | { |
| 428 | // arrange |
| 429 | Action action1; |
| 430 | action1.setName("Name"); |
| 431 | action1.setShortcut(Qt::CTRL + Qt::Key_A); |
| 432 | action1.setIsCaptureEnabled(true); |
| 433 | action1.setIncludeCursor(true); |
| 434 | action1.setCaptureDelay(2000); |
| 435 | action1.setCaptureMode(CaptureModes::FullScreen); |
| 436 | action1.setIsSaveEnabled(true); |
| 437 | action1.setIsCopyToClipboardEnabled(true); |
| 438 | action1.setIsUploadEnabled(true); |
| 439 | action1.setIsOpenDirectoryEnabled(true); |
| 440 | action1.setIsPinImageEnabled(true); |
| 441 | action1.setIsHideMainWindowEnabled(true); |
| 442 | action1.setIsGlobalShortcut(true); |
| 443 | |
| 444 | Action action2; |
| 445 | action2.setName(action1.name()); |
| 446 | action2.setShortcut(action1.shortcut()); |
| 447 | action2.setIsCaptureEnabled(action1.isCaptureEnabled()); |
| 448 | action2.setIncludeCursor(action1.includeCursor()); |
| 449 | action2.setCaptureDelay(action1.captureDelay()); |
| 450 | action2.setCaptureMode(action1.captureMode()); |
| 451 | action2.setIsSaveEnabled(action1.isSaveEnabled()); |
| 452 | action2.setIsCopyToClipboardEnabled(action1.isCopyToClipboardEnabled()); |
| 453 | action2.setIsUploadEnabled(action1.isUploadEnabled()); |
| 454 | action2.setIsOpenDirectoryEnabled(false); |
| 455 | action2.setIsPinImageEnabled(action1.isPinImageEnabled()); |
| 456 | action2.setIsHideMainWindowEnabled(action1.isHideMainWindowEnabled()); |
| 457 | action2.setIsGlobalShortcut(action1.isGlobalShortcut()); |
| 458 | |
| 459 | // act |
| 460 | auto result = action1 == action2; |
| 461 | |
| 462 | // assert |
| 463 | QCOMPARE(result, false); |
| 464 | } |
| 465 | |
| 466 | void ActionTests::EqualsOperator_Should_ReturnFalse_When_IsPinScreenshotEnabledDifferent() |
| 467 | { |
| 468 | // arrange |
| 469 | Action action1; |
| 470 | action1.setName("Name"); |
| 471 | action1.setShortcut(Qt::CTRL + Qt::Key_A); |
| 472 | action1.setIsCaptureEnabled(true); |
| 473 | action1.setIncludeCursor(true); |
| 474 | action1.setCaptureDelay(2000); |
| 475 | action1.setCaptureMode(CaptureModes::FullScreen); |
| 476 | action1.setIsSaveEnabled(true); |
| 477 | action1.setIsCopyToClipboardEnabled(true); |
| 478 | action1.setIsUploadEnabled(true); |
| 479 | action1.setIsOpenDirectoryEnabled(true); |
| 480 | action1.setIsPinImageEnabled(true); |
| 481 | action1.setIsHideMainWindowEnabled(true); |
| 482 | action1.setIsGlobalShortcut(true); |
| 483 | |
| 484 | Action action2; |
| 485 | action2.setName(action1.name()); |
| 486 | action2.setShortcut(action1.shortcut()); |
| 487 | action2.setIsCaptureEnabled(action1.isCaptureEnabled()); |
| 488 | action2.setIncludeCursor(action1.includeCursor()); |
| 489 | action2.setCaptureDelay(action1.captureDelay()); |
| 490 | action2.setCaptureMode(action1.captureMode()); |
| 491 | action2.setIsSaveEnabled(action1.isSaveEnabled()); |
| 492 | action2.setIsCopyToClipboardEnabled(action1.isCopyToClipboardEnabled()); |
| 493 | action2.setIsUploadEnabled(action1.isUploadEnabled()); |
| 494 | action2.setIsOpenDirectoryEnabled(action1.isOpenDirectoryEnabled()); |
| 495 | action2.setIsPinImageEnabled(false); |
| 496 | action2.setIsHideMainWindowEnabled(action1.isHideMainWindowEnabled()); |
| 497 | action2.setIsGlobalShortcut(action1.isGlobalShortcut()); |
| 498 | |
| 499 | // act |
| 500 | auto result = action1 == action2; |
| 501 | |
| 502 | // assert |
| 503 | QCOMPARE(result, false); |
| 504 | } |
| 505 | |
| 506 | void ActionTests::EqualsOperator_Should_ReturnFalse_When_IsHideMainWindowEnabledDifferent() |
| 507 | { |
| 508 | // arrange |
| 509 | Action action1; |
| 510 | action1.setName("Name"); |
| 511 | action1.setShortcut(Qt::CTRL + Qt::Key_A); |
| 512 | action1.setIsCaptureEnabled(true); |
| 513 | action1.setIncludeCursor(true); |
| 514 | action1.setCaptureDelay(2000); |
| 515 | action1.setCaptureMode(CaptureModes::FullScreen); |
| 516 | action1.setIsSaveEnabled(true); |
| 517 | action1.setIsCopyToClipboardEnabled(true); |
| 518 | action1.setIsUploadEnabled(true); |
| 519 | action1.setIsOpenDirectoryEnabled(true); |
| 520 | action1.setIsPinImageEnabled(true); |
| 521 | action1.setIsHideMainWindowEnabled(true); |
| 522 | action1.setIsGlobalShortcut(true); |
| 523 | |
| 524 | Action action2; |
| 525 | action2.setName(action1.name()); |
| 526 | action2.setShortcut(action1.shortcut()); |
| 527 | action2.setIsCaptureEnabled(action1.isCaptureEnabled()); |
| 528 | action2.setIncludeCursor(action1.includeCursor()); |
| 529 | action2.setCaptureDelay(action1.captureDelay()); |
| 530 | action2.setCaptureMode(action1.captureMode()); |
| 531 | action2.setIsSaveEnabled(action1.isSaveEnabled()); |
| 532 | action2.setIsCopyToClipboardEnabled(action1.isCopyToClipboardEnabled()); |
| 533 | action2.setIsUploadEnabled(action1.isUploadEnabled()); |
| 534 | action2.setIsOpenDirectoryEnabled(action1.isOpenDirectoryEnabled()); |
| 535 | action2.setIsPinImageEnabled(action1.isPinImageEnabled()); |
| 536 | action2.setIsHideMainWindowEnabled(false); |
| 537 | action2.setIsGlobalShortcut(action1.isGlobalShortcut()); |
| 538 | |
| 539 | // act |
| 540 | auto result = action1 == action2; |
| 541 | |
| 542 | // assert |
| 543 | QCOMPARE(result, false); |
| 544 | } |
| 545 | |
| 546 | void ActionTests::EqualsOperator_Should_ReturnFalse_When_IsGlobalShortcutDifferent() |
| 547 | { |
| 548 | // arrange |
| 549 | Action action1; |
| 550 | action1.setName("Name"); |
| 551 | action1.setShortcut(Qt::CTRL + Qt::Key_A); |
| 552 | action1.setIsCaptureEnabled(true); |
| 553 | action1.setIncludeCursor(true); |
| 554 | action1.setCaptureDelay(2000); |
| 555 | action1.setCaptureMode(CaptureModes::FullScreen); |
| 556 | action1.setIsSaveEnabled(true); |
| 557 | action1.setIsCopyToClipboardEnabled(true); |
| 558 | action1.setIsUploadEnabled(true); |
| 559 | action1.setIsOpenDirectoryEnabled(true); |
| 560 | action1.setIsPinImageEnabled(true); |
| 561 | action1.setIsHideMainWindowEnabled(true); |
| 562 | action1.setIsGlobalShortcut(true); |
| 563 | |
| 564 | Action action2; |
| 565 | action2.setName(action1.name()); |
| 566 | action2.setShortcut(action1.shortcut()); |
| 567 | action2.setIsCaptureEnabled(action1.isCaptureEnabled()); |
| 568 | action2.setIncludeCursor(action1.includeCursor()); |
| 569 | action2.setCaptureDelay(action1.captureDelay()); |
| 570 | action2.setCaptureMode(action1.captureMode()); |
| 571 | action2.setIsSaveEnabled(action1.isSaveEnabled()); |
| 572 | action2.setIsCopyToClipboardEnabled(action1.isCopyToClipboardEnabled()); |
| 573 | action2.setIsUploadEnabled(action1.isUploadEnabled()); |
| 574 | action2.setIsOpenDirectoryEnabled(action1.isOpenDirectoryEnabled()); |
| 575 | action2.setIsPinImageEnabled(action1.isPinImageEnabled()); |
| 576 | action2.setIsHideMainWindowEnabled(action1.isHideMainWindowEnabled()); |
| 577 | action2.setIsGlobalShortcut(false); |
| 578 | |
| 579 | // act |
| 580 | auto result = action1 == action2; |
| 581 | |
| 582 | // assert |
| 583 | QCOMPARE(result, false); |
| 584 | } |
| 585 | |
| 586 | TEST_MAIN(ActionTests) |