| 1 | /* |
| 2 | * %injeqt copyright begin% |
| 3 | * Copyright 2014 Rafał Malinowski ([email protected]) |
| 4 | * %injeqt copyright end% |
| 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Lesser General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2.1 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Lesser General Public License for more details. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
| 17 | * License along with this library; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
| 20 | |
| 21 | #include "expect.h"cxx . . $ `<file>/test/unit/expect.h`/ |
| 22 | #include "utils.h"cxx . . $ `<file>/test/unit/utils.h`/ |
| 23 | |
| 24 | #include <injeqt/exception/invalid-action.h>cxx . . $ `<file>/include/injeqt/exception/invalid-action.h`/ |
| 25 | |
| 26 | #include "internal/action-method.h"cxx . . $ `<file>/src/internal/action-method.h`/ |
| 27 | |
| 28 | #include <QtTest/QtTest> |
| 29 | |
| 30 | #ifndef Q_MOC_RUN |
| 31 | # define INVALID_ACTION_TAGcxx . . $ `test/unit/action-method-test.cpp:31:11`! |
| 32 | #endif |
| 33 | |
| 34 | using namespace injeqtcxx . . $ injeqt/::internal; |
| 35 | using namespace injeqtcxx . . $ injeqt/::v1; |
| 36 | |
| 37 | class test_typecxx . . $ test_type# : public QObjectcxx . . $ QObject# |
| 38 | { |
| 39 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 40 | |
| 41 | public: |
| 42 | int vcxx . . $ test_type#v. = 0; |
| 43 | |
| 44 | test_typecxx . . $ test_type#test_type(49f6e7a06ebc5aa8).() {} |
| 45 | |
| 46 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! test_typecxx . . $ test_type#test_type(d4f767463ce0a6b3).(int) {} |
| 47 | |
| 48 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! INJEQT_INITcxx . . $ `include/injeqt/injeqt.h:32:11`! void tagged_init_action_methodcxx . . $ test_type#tagged_init_action_method(49f6e7a06ebc5aa8).() { } |
| 49 | Q_INVOKABLEcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:124:9`! INJEQT_DONEcxx . . $ `include/injeqt/injeqt.h:33:11`! void tagged_done_action_methodcxx . . $ test_type#tagged_done_action_method(49f6e7a06ebc5aa8).() { } |
| 50 | |
| 51 | public slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 52 | INJEQT_INITcxx . . $ `include/injeqt/injeqt.h:32:11`! void tagged_init_action_slotcxx . . $ test_type#tagged_init_action_slot(49f6e7a06ebc5aa8).() { vcxx . . $ test_type#v. = 1; } |
| 53 | INJEQT_DONEcxx . . $ `include/injeqt/injeqt.h:33:11`! void tagged_done_action_slotcxx . . $ test_type#tagged_done_action_slot(49f6e7a06ebc5aa8).() { } |
| 54 | INJEQT_INITcxx . . $ `include/injeqt/injeqt.h:32:11`! void invalid_init_action_argumentscxx . . $ test_type#invalid_init_action_arguments(d4f767463ce0a6b3).(int) { } |
| 55 | INJEQT_DONEcxx . . $ `include/injeqt/injeqt.h:33:11`! void invalid_done_action_argumentscxx . . $ test_type#invalid_done_action_arguments(d4f767463ce0a6b3).(int) { } |
| 56 | INVALID_ACTION_TAGcxx . . $ `test/unit/action-method-test.cpp:31:11`! void invalid_action_invalid_tagcxx . . $ test_type#invalid_action_invalid_tag(49f6e7a06ebc5aa8).() { } |
| 57 | void invalid_action_no_tagcxx . . $ test_type#invalid_action_no_tag(49f6e7a06ebc5aa8).() { } |
| 58 | |
| 59 | signalscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:89:14`!: |
| 60 | INJEQT_INITcxx . . $ `include/injeqt/injeqt.h:32:11`! void invalid_init_action_signalcxx . . $ test_type#invalid_init_action_signal(49f6e7a06ebc5aa8).(); |
| 61 | INJEQT_DONEcxx . . $ `include/injeqt/injeqt.h:33:11`! void invalid_done_action_signalcxx . . $ test_type#invalid_done_action_signal(49f6e7a06ebc5aa8).(); |
| 62 | |
| 63 | }; |
| 64 | |
| 65 | class action_method_testcxx . . $ action_method_test# : public QObjectcxx . . $ QObject# |
| 66 | { |
| 67 | Q_OBJECTcxx . . $ `<external>/1208926524888476972/qobjectdefs.h:170:9`! |
| 68 | |
| 69 | private slotscxx . . $ `<external>/1208926524888476972/qobjectdefs.h:88:14`!: |
| 70 | void should_create_emptycxx . . $ action_method_test#should_create_empty(49f6e7a06ebc5aa8).(); |
| 71 | void should_create_valid_from_tagged_action_methodcxx . . $ action_method_test#should_create_valid_from_tagged_action_method(49f6e7a06ebc5aa8).(); |
| 72 | void should_create_valid_from_tagged_action_slotcxx . . $ action_method_test#should_create_valid_from_tagged_action_slot(49f6e7a06ebc5aa8).(); |
| 73 | void should_invoke_have_resultscxx . . $ action_method_test#should_invoke_have_results(49f6e7a06ebc5aa8).(); |
| 74 | void should_throw_when_empty_methodcxx . . $ action_method_test#should_throw_when_empty_method(49f6e7a06ebc5aa8).(); |
| 75 | void should_throw_when_argumentscxx . . $ action_method_test#should_throw_when_arguments(49f6e7a06ebc5aa8).(); |
| 76 | void should_throw_when_invalid_tagcxx . . $ action_method_test#should_throw_when_invalid_tag(49f6e7a06ebc5aa8).(); |
| 77 | void should_throw_when_no_tagcxx . . $ action_method_test#should_throw_when_no_tag(49f6e7a06ebc5aa8).(); |
| 78 | void should_throw_when_signalcxx . . $ action_method_test#should_throw_when_signal(49f6e7a06ebc5aa8).(); |
| 79 | void should_throw_when_constructorcxx . . $ action_method_test#should_throw_when_constructor(49f6e7a06ebc5aa8).(); |
| 80 | |
| 81 | }; |
| 82 | |
| 83 | void action_method_testcxx . . $ action_method_test#::should_create_emptycxx . . $ action_method_test#should_create_empty(49f6e7a06ebc5aa8).() |
| 84 | { |
| 85 | auto action = action_methodcxx . . $ injeqt/internal/action_method#action_method(49f6e7a06ebc5aa8).{}; |
| 86 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(action.is_empty()); |
| 87 | } |
| 88 | |
| 89 | void action_method_testcxx . . $ action_method_test#::should_create_valid_from_tagged_action_methodcxx . . $ action_method_test#should_create_valid_from_tagged_action_method(49f6e7a06ebc5aa8).() |
| 90 | { |
| 91 | auto action = make_action_methodcxx . . $ injeqt/internal/make_action_method(91c31e8fb4d6933).(get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("tagged_init_action_method()"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 92 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(!action.is_empty()); |
| 93 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(action.object_type(), make_type<test_type>()); |
| 94 | |
| 95 | ;action =cxx . . $ injeqt/internal/action_method#`operator=`(5e0e331ff9f7f8b3). make_action_methodcxx . . $ injeqt/internal/make_action_method(91c31e8fb4d6933).(get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("tagged_done_action_method()"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 96 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(!action.is_empty()); |
| 97 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(action.object_type(), make_type<test_type>()); |
| 98 | } |
| 99 | |
| 100 | void action_method_testcxx . . $ action_method_test#::should_create_valid_from_tagged_action_slotcxx . . $ action_method_test#should_create_valid_from_tagged_action_slot(49f6e7a06ebc5aa8).() |
| 101 | { |
| 102 | auto action = make_action_methodcxx . . $ injeqt/internal/make_action_method(91c31e8fb4d6933).(get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("tagged_init_action_slot()"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 103 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(!action.is_empty()); |
| 104 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(action.object_type(), make_type<test_type>()); |
| 105 | |
| 106 | make_action_methodcxx . . $ injeqt/internal/make_action_method(91c31e8fb4d6933).(get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("tagged_done_action_slot()"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 107 | QVERIFYcxx . . $ `<external>/8602788698586413231/qtestcase.h:63:9`!(!action.is_empty()); |
| 108 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(action.object_type(), make_type<test_type>()); |
| 109 | } |
| 110 | |
| 111 | void action_method_testcxx . . $ action_method_test#::should_invoke_have_resultscxx . . $ action_method_test#should_invoke_have_results(49f6e7a06ebc5aa8).() |
| 112 | { |
| 113 | auto action = make_action_methodcxx . . $ injeqt/internal/make_action_method(91c31e8fb4d6933).(get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("tagged_init_action_slot()"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 114 | auto on = make_objectcxx . . $ std/unique_ptr#unique_ptr(d6762fce684538e4).<test_typecxx . . $ test_type#>(); |
| 115 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(0, static_cast<test_type *>(on.get())->v); |
| 116 | |
| 117 | action.invokecxx . . $ injeqt/internal/action_method#invoke(a7755beb02b388f3).(on.getcxx . . $ std/unique_ptr#get(ca399b2b6292c808).()); |
| 118 | QCOMPAREcxx . . $ `<external>/8602788698586413231/qtestcase.h:86:9`!(1, static_cast<test_type *>(on.get())->v); |
| 119 | } |
| 120 | |
| 121 | void action_method_testcxx . . $ action_method_test#::should_throw_when_empty_methodcxx . . $ action_method_test#should_throw_when_empty_method(49f6e7a06ebc5aa8).() |
| 122 | { |
| 123 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::invalid_actioncxx . . $ injeqt/v1/exception/invalid_action#>({cxx . . $ std/vector#vector(9619226211e5a241)."action does not have enclosing meta object"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 124 | make_action_methodcxx . . $ injeqt/internal/make_action_method(91c31e8fb4d6933).(QMetaMethodcxx . . $ QMetaMethod#QMetaMethod(49f6e7a06ebc5aa8).{}); |
| 125 | }); |
| 126 | } |
| 127 | |
| 128 | void action_method_testcxx . . $ action_method_test#::should_throw_when_argumentscxx . . $ action_method_test#should_throw_when_arguments(49f6e7a06ebc5aa8).() |
| 129 | { |
| 130 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::invalid_actioncxx . . $ injeqt/v1/exception/invalid_action#>({cxx . . $ std/vector#vector(9619226211e5a241)."invalid parameter count"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 131 | make_action_methodcxx . . $ injeqt/internal/make_action_method(91c31e8fb4d6933).(get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("invalid_init_action_arguments(int)"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 132 | }); |
| 133 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::invalid_actioncxx . . $ injeqt/v1/exception/invalid_action#>({cxx . . $ std/vector#vector(9619226211e5a241)."invalid parameter count"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 134 | make_action_methodcxx . . $ injeqt/internal/make_action_method(91c31e8fb4d6933).(get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("invalid_done_action_arguments(int)"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 135 | }); |
| 136 | } |
| 137 | |
| 138 | void action_method_testcxx . . $ action_method_test#::should_throw_when_invalid_tagcxx . . $ action_method_test#should_throw_when_invalid_tag(49f6e7a06ebc5aa8).() |
| 139 | { |
| 140 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::invalid_actioncxx . . $ injeqt/v1/exception/invalid_action#>({cxx . . $ std/vector#vector(9619226211e5a241)."action does not have valid tag"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 141 | make_action_methodcxx . . $ injeqt/internal/make_action_method(91c31e8fb4d6933).(get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("invalid_action_invalid_tag()"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 142 | }); |
| 143 | } |
| 144 | |
| 145 | void action_method_testcxx . . $ action_method_test#::should_throw_when_no_tagcxx . . $ action_method_test#should_throw_when_no_tag(49f6e7a06ebc5aa8).() |
| 146 | { |
| 147 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::invalid_actioncxx . . $ injeqt/v1/exception/invalid_action#>({cxx . . $ std/vector#vector(9619226211e5a241)."action does not have valid tag"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 148 | make_action_methodcxx . . $ injeqt/internal/make_action_method(91c31e8fb4d6933).(get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("invalid_action_no_tag()"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 149 | }); |
| 150 | } |
| 151 | |
| 152 | void action_method_testcxx . . $ action_method_test#::should_throw_when_signalcxx . . $ action_method_test#should_throw_when_signal(49f6e7a06ebc5aa8).() |
| 153 | { |
| 154 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::invalid_actioncxx . . $ injeqt/v1/exception/invalid_action#>({cxx . . $ std/vector#vector(9619226211e5a241)."action is signal"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 155 | make_action_methodcxx . . $ injeqt/internal/make_action_method(91c31e8fb4d6933).(get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("invalid_init_action_signal()"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 156 | }); |
| 157 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::invalid_actioncxx . . $ injeqt/v1/exception/invalid_action#>({cxx . . $ std/vector#vector(9619226211e5a241)."action is signal"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 158 | make_action_methodcxx . . $ injeqt/internal/make_action_method(91c31e8fb4d6933).(get_methodcxx . . $ injeqt/v1/get_method(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("invalid_done_action_signal()"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 159 | }); |
| 160 | } |
| 161 | |
| 162 | void action_method_testcxx . . $ action_method_test#::should_throw_when_constructorcxx . . $ action_method_test#should_throw_when_constructor(49f6e7a06ebc5aa8).() |
| 163 | { |
| 164 | expectcxx . . $ expect(d99b926da2bbc072).<exceptioncxx . . $ injeqt/v1/exception/::invalid_actioncxx . . $ injeqt/v1/exception/invalid_action#>({cxx . . $ std/vector#vector(9619226211e5a241)."action is constructor"}, [cxx . . $ std/function#function(a4b4b0c4acad1616).&]{ |
| 165 | make_action_methodcxx . . $ injeqt/internal/make_action_method(91c31e8fb4d6933).(get_constructorcxx . . $ injeqt/v1/get_constructor(cd3527b7bfe5b271).<test_typecxx . . $ test_type#>("test_type(int)"cxx . . $ std/__cxx11/basic_string#basic_string(e36662616dba894d).)); |
| 166 | }); |
| 167 | } |
| 168 | |
| 169 | QTEST_APPLESS_MAINcxx . . $ `<external>/4204159469433502174/qtest.h:442:9`!(action_method_test) |
| 170 | #include "action-method-test.moc"cxx . . $ `<file>/build/test/action-method-test_autogen/include/action-method-test.moc`/ |