File indexing completed on 2024-05-19 16:18:13
0001 /*************************************************************************** 0002 * SPDX-FileCopyrightText: 2022 S. MANKOWSKI stephane@mankowski.fr 0003 * SPDX-FileCopyrightText: 2022 G. DE BURE support@mankowski.fr 0004 * SPDX-License-Identifier: GPL-3.0-or-later 0005 ***************************************************************************/ 0006 /** @file 0007 * This file is a test for actions. 0008 * 0009 * @author Stephane MANKOWSKI / Guillaume DE BURE 0010 */ 0011 #include "skgtestactions.h" 0012 #include "skgboardwidget.h" 0013 #include "skgdocumentbank.h" 0014 #include "skgmainpanel.h" 0015 #include "skgtestmacro.h" 0016 #include "skgtraces.h" 0017 0018 void SKGTESTActions::Test() 0019 { 0020 KLocalizedString::setApplicationDomain("skrooge"); 0021 0022 // Initialize document 0023 SKGDocumentBank doc; 0024 0025 // Create main panel 0026 SKGMainPanel mainpanel(nullptr, &doc); 0027 mainpanel.show(); 0028 0029 QVERIFY2(!doc.load(SKGTest::getTestPath(QStringLiteral("IN")) % "/advice.skg"), "Load document failed"); 0030 0031 { 0032 SKGError err; 0033 SKGBEGINTRANSACTION(doc, QStringLiteral("DELETE"), err) 0034 doc.executeSqliteOrder(QStringLiteral("DELETE FROM operation WHERE d_date<'") + SKGServices::dateToSqlString(QDate::currentDate().addMonths(-2)) + '\''); 0035 } 0036 0037 // Scenario 0038 QStringList actionsToExecute; 0039 actionsToExecute 0040 // Reinitialize document 0041 << QStringLiteral("tab_closeall") << QStringLiteral("fullscreen") << QStringLiteral("fullscreen") << QStringLiteral("fullscreen") << QStringLiteral("edit_undolastsave") << QStringLiteral("view_unlock") << QStringLiteral("view_unlock") << QStringLiteral("options_show_menubar") << QStringLiteral("options_show_menubar") 0042 // Bank page 0043 << QStringLiteral("page_Skrooge bank plugin") << QStringLiteral("enable_editor") << QStringLiteral("edit_select_all") << QStringLiteral("edit_copy") << QStringLiteral("edit_switch_highlight") << QStringLiteral("edit_select_all") << QStringLiteral("edit_delete") 0044 // Undo 0045 << QStringLiteral("edit_undo") << QStringLiteral("edit_redo") << QStringLiteral("edit_undolastsave") << QStringLiteral("edit_clear_history") 0046 // Clean 0047 << QStringLiteral("edit_select_all") << QStringLiteral("open_report") << QStringLiteral("edit_find") 0048 << QStringLiteral("page_Skrooge bank plugin") << QStringLiteral("edit_select_all") << QStringLiteral("edit_reconcile") 0049 << QStringLiteral("page_Skrooge bank plugin") << QStringLiteral("edit_select_all") << QStringLiteral("edit_find") 0050 0051 // Transaction 0052 << QStringLiteral("page_Skrooge operation plugin") << QStringLiteral("enable_editor") << QStringLiteral("fast_edition") << QStringLiteral("edit_select_all") << QStringLiteral("edit_switch_highlight") << QStringLiteral("edit_mark_selected_operation") 0053 << QStringLiteral("merge_sub_operations") 0054 // Too long << "edit_select_all" << "edit_duplicate_operation" 0055 << QStringLiteral("edit_select_all") << QStringLiteral("edit_group_operation") << QStringLiteral("merge_imported_operation") 0056 << QStringLiteral("edit_select_all") << QStringLiteral("open_report") 0057 << QStringLiteral("page_Skrooge operation plugin") << QStringLiteral("edit_select_all") << QStringLiteral("edit_find") 0058 0059 // Category 0060 << QStringLiteral("page_Skrooge categories plugin") << QStringLiteral("edit_expandall") << QStringLiteral("edit_collapseal") 0061 << QStringLiteral("edit_select_all") << QStringLiteral("open_report") 0062 << QStringLiteral("page_Skrooge categories plugin") << QStringLiteral("edit_select_all") << QStringLiteral("edit_find") 0063 0064 // Search page 0065 << QStringLiteral("page_Skrooge search plugin") << QStringLiteral("edit_select_all") 0066 << QStringLiteral("execute_all") << QStringLiteral("execute_notchecked") << QStringLiteral("execute_imported") << QStringLiteral("execute_not_validated") 0067 << QStringLiteral("open_report") 0068 0069 // All other pages 0070 << QStringLiteral("page_Dashboard plugin") << QStringLiteral("500") 0071 << QStringLiteral("page_Skrooge budget plugin") << QStringLiteral("tool_process_budget_rules") << QStringLiteral("edit_select_all") << QStringLiteral("open_report") 0072 << QStringLiteral("page_Skrooge budget plugin") << QStringLiteral("edit_select_all") << QStringLiteral("edit_find") 0073 << QStringLiteral("page_Skrooge calculator plugin") 0074 << QStringLiteral("page_Skrooge payee plugin") << QStringLiteral("edit_select_all") << QStringLiteral("open_report") 0075 << QStringLiteral("page_Skrooge payee plugin") << QStringLiteral("edit_select_all") << QStringLiteral("edit_find") 0076 << QStringLiteral("page_Skrooge report plugin") 0077 << QStringLiteral("page_Skrooge scheduled plugin") << QStringLiteral("edit_select_all") << QStringLiteral("open_report") 0078 << QStringLiteral("page_Skrooge scheduled plugin") << QStringLiteral("edit_select_all") << QStringLiteral("edit_find") 0079 << QStringLiteral("page_Skrooge tracker plugin") << QStringLiteral("edit_select_all") << QStringLiteral("open_report") 0080 << QStringLiteral("page_Skrooge tracker plugin") << QStringLiteral("edit_select_all") << QStringLiteral("edit_find") 0081 << QStringLiteral("page_Skrooge unit plugin") << QStringLiteral("edit_select_all") << QStringLiteral("open_report") 0082 << QStringLiteral("page_Skrooge unit plugin") << QStringLiteral("edit_select_all") << QStringLiteral("edit_find") 0083 0084 // Go 0085 << QStringLiteral("page_Monthly plugin") << QStringLiteral("go_previous") << QStringLiteral("go_next") << QStringLiteral("go_home") << QStringLiteral("new_tab") 0086 0087 // imports 0088 << QStringLiteral("import") << QStringLiteral("import_backends") << QStringLiteral("import_standard_bookmarks") << QStringLiteral("import_standard_categories") 0089 0090 // Processing 0091 << QStringLiteral("align_comment") << QStringLiteral("clean_delete_unused_categories") << QStringLiteral("clean_delete_unused_payees") << QStringLiteral("clean_delete_unused_units") << QStringLiteral("clean_remove_group_with_one_operation") 0092 << QStringLiteral("process_banks") << QStringLiteral("process_foundtransfer") << QStringLiteral("process_validate") << QStringLiteral("processing") << QStringLiteral("switch_validation_imported_operation") 0093 0094 // Views 0095 << QStringLiteral("view_bookmarks") << QStringLiteral("view_context") << QStringLiteral("view_contextmenu") << QStringLiteral("view_lock") << QStringLiteral("view_menu") << QStringLiteral("view_open_duplicates") << QStringLiteral("view_open_highlight") 0096 << QStringLiteral("view_open_last_modified") << QStringLiteral("view_open_not_validated") << QStringLiteral("view_open_operation_in_group_of_one") << QStringLiteral("view_open_operation_with_comment_not_aligned") 0097 << QStringLiteral("view_open_operation_without_category") << QStringLiteral("view_open_operation_without_mode") << QStringLiteral("view_open_operation_without_payee") << QStringLiteral("view_open_suboperations") 0098 << QStringLiteral("view_open_transfers_without_category") << QStringLiteral("view_open_transfers_without_payee") << QStringLiteral("view_open_very_old_operations") << QStringLiteral("view_properties") << QStringLiteral("view_transactions") 0099 // Close 0100 << QStringLiteral("tab_close") << QStringLiteral("tab_closeallother") << QStringLiteral("tab_closeall") 0101 // Tabs 0102 << QStringLiteral("tab_reopenlastclosed") << QStringLiteral("tab_resetdefaultstate") << QStringLiteral("tab_savedefaultstate") << QStringLiteral("tab_switchpin") << QStringLiteral("tab_overwritebookmark") 0103 0104 // File 0105 << QStringLiteral("file_save") << QStringLiteral("file_new"); 0106 0107 // Dump actions 0108 QMap< QString, QPointer<QAction> > actions = mainpanel.getGlobalActions(); 0109 QStringList keys = actions.keys(); 0110 for (const auto& key : qAsConst(keys)) { 0111 if (!actionsToExecute.contains(key)) { 0112 SKGTRACE << " [" << key << "]" << SKGENDL; 0113 } 0114 } 0115 0116 // Trigger actions 0117 for (const auto& key : qAsConst(actionsToExecute)) { 0118 if (key == QStringLiteral("edit_select_all")) { 0119 SKGTRACE << " Wait" << SKGENDL; 0120 QTest::qWait(10); 0121 } 0122 SKGTRACE << QDateTime::currentDateTime().toString(QStringLiteral("yyyy-MM-dd hh:mm:ss")) << " [" << key << "]: "; 0123 QAction* act = mainpanel.getGlobalAction(key); 0124 if (act != nullptr) { 0125 act->trigger(); 0126 SKGTRACESUITE << "DONE" << SKGENDL; 0127 } else { 0128 SKGTRACESUITE << "UNKNOWN" << SKGENDL; 0129 } 0130 0131 if (key == QStringLiteral("edit_select_all")) { 0132 SKGTabPage* page = mainpanel.currentPage(); 0133 if (page != nullptr) { 0134 SKGTRACE << " Current page:" << page->objectName() << SKGENDL; 0135 } 0136 SKGTRACE << " Nb objects selected:" << mainpanel.getNbSelectedObjects() << SKGENDL; 0137 } 0138 } 0139 } 0140 0141 QTEST_MAIN(SKGTESTActions) 0142