1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
/* This file is part of lomiri-action-api
* Copyright 2013 Canonical Ltd.
*
* lomiri-action-api is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* lomiri-action-api is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranties of
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "tst_previewaction.h"
#include <lomiri/action/PreviewAction>
#include <lomiri/action/PreviewRangeParameter>
#include <QtTest/QtTest>
using namespace lomiri::action;
void
TestPreviewAction::setCommitLabel()
{
PreviewAction action;
QSignalSpy spy(&action, SIGNAL(commitLabelChanged(QString)));
action.setCommitLabel("Crop");
QVERIFY(action.commitLabel() == "Crop");
QCOMPARE(spy.count(), 1);
QList<QVariant> arguments = spy.takeFirst();
QVERIFY(arguments.at(0).toString() == "Crop");
spy.clear();
action.setCommitLabel("Crop");
QCOMPARE(spy.count(), 0);
}
void
TestPreviewAction::parameterOperations()
{
PreviewAction action;
PreviewRangeParameter param1;
PreviewRangeParameter param2;
QSignalSpy spy(&action, SIGNAL(parametersChanged()));
QVERIFY(action.parameters().isEmpty());
action.addParameter(¶m1);
QCOMPARE(spy.count(), 1);
action.addParameter(¶m2);
QCOMPARE(spy.count(), 2);
QVERIFY(action.parameters().contains(¶m1));
QVERIFY(action.parameters().contains(¶m2));
spy.clear();
action.addParameter(¶m1);
action.addParameter(¶m2);
QCOMPARE(spy.count(), 0);
QCOMPARE(action.parameters().count(), 2);
spy.clear();
action.removeParameter(¶m1);
QCOMPARE(spy.count(), 1);
QCOMPARE(action.parameters().count(), 1);
QVERIFY(!action.parameters().contains(¶m1));
spy.clear();
action.removeParameter(¶m1);
QCOMPARE(spy.count(), 0);
QVERIFY(action.parameters().contains(¶m2));
action.removeParameter(¶m2);
QCOMPARE(spy.count(), 1);
QVERIFY(action.parameters().isEmpty());
}
void
TestPreviewAction::deletedParameter()
{
// if parameter is deleted we must detect this and not crash
PreviewAction action;
PreviewRangeParameter *param1 = new PreviewRangeParameter();
PreviewRangeParameter *param2 = new PreviewRangeParameter();
action.addParameter(param1);
action.addParameter(param2);
QSignalSpy spy(&action, SIGNAL(parametersChanged()));
delete param1;
QCOMPARE(spy.count(), 1);
QVERIFY(!action.parameters().contains(param1));
param1 = 0;
delete param2;
QCOMPARE(spy.count(), 2);
QVERIFY(!action.parameters().contains(param2));
param2 = 0;
QVERIFY(action.parameters().isEmpty());
}
|