| 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 "../mocks/mocked-provider-configuration.h" |
| 22 | #include "expect.h" |
| 23 | #include "utils.h" |
| 24 | |
| 25 | #include "internal/module-impl.h" |
| 26 | |
| 27 | #include <QtTest/QtTest> |
| 28 | #include <string> |
| 29 | |
| 30 | using namespace injeqt::internal; |
| 31 | using namespace injeqt::v1; |
| 32 | |
| 33 | class type_1 : public QObject |
| 34 | { |
| 35 | Q_OBJECT |
| 36 | |
| 37 | public: |
| 38 | Q_INVOKABLE type_1() {} |
| 39 | |
| 40 | }; |
| 41 | |
| 42 | class factory_type_1 : public QObject |
| 43 | { |
| 44 | Q_OBJECT |
| 45 | |
| 46 | public: |
| 47 | Q_INVOKABLE type_1 * create_type_1() { return nullptr; } |
| 48 | |
| 49 | }; |
| 50 | |
| 51 | class module_impl_test : public QObject |
| 52 | { |
| 53 | Q_OBJECT |
| 54 | |
| 55 | private slots: |
| 56 | void should_properly_add_provider_configurations(); |
| 57 | |
| 58 | }; |
| 59 | |
| 60 | void module_impl_test::should_properly_add_provider_configurations() |
| 61 | { |
| 62 | auto m = module_impl{}; |
| 63 | QCOMPARE(m.provider_configurations().size(), size_t{0}); |
| 64 | |
| 65 | auto p1 = std::make_shared<mocked_provider_configuration>(); |
| 66 | m.add_provider_configuration(p1); |
| 67 | QCOMPARE(m.provider_configurations().size(), size_t{1}); |
| 68 | QCOMPARE(m.provider_configurations()[0].get(), p1.get()); |
| 69 | |
| 70 | auto p2 = std::make_shared<mocked_provider_configuration>(); |
| 71 | m.add_provider_configuration(p2); |
| 72 | QCOMPARE(m.provider_configurations().size(), size_t{2}); |
| 73 | QCOMPARE(m.provider_configurations()[0].get(), p1.get()); |
| 74 | QCOMPARE(m.provider_configurations()[1].get(), p2.get()); |
| 75 | |
| 76 | auto p3 = std::make_shared<mocked_provider_configuration>(); |
| 77 | m.add_provider_configuration(p3); |
| 78 | QCOMPARE(m.provider_configurations().size(), size_t{3}); |
| 79 | QCOMPARE(m.provider_configurations()[0].get(), p1.get()); |
| 80 | QCOMPARE(m.provider_configurations()[1].get(), p2.get()); |
| 81 | QCOMPARE(m.provider_configurations()[2].get(), p3.get()); |
| 82 | } |
| 83 | |
| 84 | QTEST_APPLESS_MAIN(module_impl_test) |
| 85 | #include "module-impl-test.moc" |