|
| 1 | +/************************************************************************** |
| 2 | + * This file is part of QXmlEdit * |
| 3 | + * Copyright (C) 2022 by Luca Bellonda and individual contributors * |
| 4 | + * as indicated in the AUTHORS file * |
| 5 | + * lbellonda _at_ gmail.com * |
| 6 | + * * |
| 7 | + * This library is free software; you can redistribute it and/or * |
| 8 | + * modify it under the terms of the GNU Library General Public * |
| 9 | + * License as published by the Free Software Foundation; either * |
| 10 | + * version 2 of the License, or (at your option) any later version. * |
| 11 | + * * |
| 12 | + * This library is distributed in the hope that it will be useful, * |
| 13 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of * |
| 14 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * |
| 15 | + * Library General Public License for more details. * |
| 16 | + * * |
| 17 | + * You should have received a copy of the GNU Library General Public * |
| 18 | + * License along with this library; if not, write to the * |
| 19 | + * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, * |
| 20 | + * Boston, MA 02110-1301 USA * |
| 21 | + **************************************************************************/ |
| 22 | + |
| 23 | +#include "testabout.h" |
| 24 | +#include "licensedialog.h" |
| 25 | + |
| 26 | +TestAbout::TestAbout() |
| 27 | +{ |
| 28 | + Config::setBackend(&_configBackend); |
| 29 | +} |
| 30 | + |
| 31 | +TestAbout::~TestAbout() |
| 32 | +{ |
| 33 | + Config::setBackend(NULL); |
| 34 | +} |
| 35 | + |
| 36 | +bool TestAbout::testFast() |
| 37 | +{ |
| 38 | + return testLicense(); |
| 39 | +} |
| 40 | + |
| 41 | +bool TestAbout::testUnit() { |
| 42 | + _testName = "testUnit"; |
| 43 | + if(!testLicense()) { |
| 44 | + return false; |
| 45 | + } |
| 46 | + return true ; |
| 47 | +} |
| 48 | + |
| 49 | +bool TestAbout::testLicense() |
| 50 | +{ |
| 51 | + _subTestName = "testLicense"; |
| 52 | + if(!testLicenseStart()) { |
| 53 | + return false; |
| 54 | + } |
| 55 | + if(!testLicenseStarted()) { |
| 56 | + return false; |
| 57 | + } |
| 58 | + return true; |
| 59 | +} |
| 60 | + |
| 61 | +bool TestAbout::testLicenseStart() { |
| 62 | + _subTestName = "testLicense/Start"; |
| 63 | + Config::setBackend(&_configBackend); |
| 64 | + LicenseDialog::testLicenseValid = false; |
| 65 | + Config::saveBool(Config::KEY_GENERAL_LICENSE_AGREED, false); |
| 66 | + // |
| 67 | + LicenseDialog::licenseAgreement(); |
| 68 | + // |
| 69 | + if(!Config::getBool(Config::KEY_GENERAL_LICENSE_AGREED, false)) { |
| 70 | + return error("After dialog, no settings"); |
| 71 | + } |
| 72 | + if(!LicenseDialog::testLicenseValid) { |
| 73 | + return error("After dialog, no settings"); |
| 74 | + } |
| 75 | + return true; |
| 76 | +} |
| 77 | + |
| 78 | +bool TestAbout::testLicenseStarted() { |
| 79 | + _subTestName = "testLicense/Started"; |
| 80 | + Config::setBackend(&_configBackend); |
| 81 | + LicenseDialog::testLicenseValid = false; |
| 82 | + Config::saveBool(Config::KEY_GENERAL_LICENSE_AGREED, true); |
| 83 | + // |
| 84 | + LicenseDialog::licenseAgreement(); |
| 85 | + // |
| 86 | + if(!Config::getBool(Config::KEY_GENERAL_LICENSE_AGREED, false)) { |
| 87 | + return error("After dialog, no settings"); |
| 88 | + } |
| 89 | + if(LicenseDialog::testLicenseValid) { |
| 90 | + return error("After dialog, no settings"); |
| 91 | + } |
| 92 | + return true; |
| 93 | +} |
0 commit comments