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 111
|
#!/usr/bin/perl
package HelpContextSensitiveHelpTest;
use strict;
use warnings;
use QtCore4;
use QtGui4;
use QtTest4 qw( QVERIFY );
use WateringConfigDialog;
use QtCore4::isa qw(Qt::Object);
use QtCore4::slots
private => 1,
testFocusSwitch => [],
initTestCase => [];
use Test::More;
sub NEW {
my ($class, $parent) = @_;
$class->SUPER::NEW();
}
sub testFocusSwitch {
my $dialog = this->{dialog};
my $filterCheckBox = $dialog->{m_ui}->filterCheckBox();
my @widgets = (
$dialog->{m_ui}->plantComboBox(),
$dialog->{m_ui}->temperatureCheckBox(),
$dialog->{m_ui}->temperatureSpinBox(),
$dialog->{m_ui}->rainCheckBox(),
$dialog->{m_ui}->rainSpinBox(),
$dialog->{m_ui}->startTimeEdit(),
$dialog->{m_ui}->amountSpinBox(),
$dialog->{m_ui}->sourceComboBox(),
$dialog->{m_ui}->filterCheckBox(),
);
my %msgHash = (
$widgets[0] => 'Different kind of plants need different amounts of water. Here\'s a short overview over the most common grown plants and their avarage need of water:
Kind
Amount
Squash
2000
Bean
1500
Carrot
1200
Strawberry
1300
Raspberry
1000
Blueberry
1100
Warning: Watering them too much or too little will cause irreversible damage! ',
$widgets[1] => 'Depending on the temperature, the plants need more or less water. The higher the temperature the higher the need for water. If the temperature does not reach a certain level, maybe no automatic watering should be done at all.
Before setting this parameter for good, you should also take the amount of rain into account. ',
$widgets[2] => 'Depending on the temperature, the plants need more or less water. The higher the temperature the higher the need for water. If the temperature does not reach a certain level, maybe no automatic watering should be done at all.
Before setting this parameter for good, you should also take the amount of rain into account. ',
$widgets[3] => 'Depending on the rain fall, the automated watering system should not be switched on at all. Also, the temperature should be considered. ',
$widgets[4] => 'Depending on the rain fall, the automated watering system should not be switched on at all. Also, the temperature should be considered. ',
$widgets[5] => 'Starting the watering too early may be ineffective since most water will evaporate. ',
$widgets[6] => 'Depending on the plant, temperature and rain fall the amount needs to be larger or smaller. On a really hot day without rain, the suggested amount can be increased by about 10%. ',
$widgets[7] => 'The current pipe system connects to four different sources. Be aware that only a limited amount of water can be taken from some sources.
Source
Amount
Fountain
4000
River
6000
Lake
10000
Public Water System
unlimited
',
$widgets[8] => 'Depending on the source of water, it needs to be filtered or not. Filtering is strongly recommened for the river and lake. ',
);
foreach my $widget ( @widgets ) {
my $msg = $msgHash{$widget};
Qt::Test::mouseClick( $widget, Qt::LeftButton() );
is( $dialog->{m_ui}->helpBrowser->toPlainText(), $msg, 'Help message update ' . $widget->objectName() );
Qt::Test::qWait(10);
}
}
sub initTestCase {
my $dialog = WateringConfigDialog();
$dialog->show();
Qt::Test::qWaitForWindowShown( $dialog );
this->{dialog} = $dialog;
pass( 'Window shown' );
}
package main;
use strict;
use warnings;
use QtCore4;
use QtGui4;
use QtTest4 qw(QTEST_MAIN);
use HelpContextSensitiveHelpTest;
use Test::More tests => 10;
exit QTEST_MAIN('HelpContextSensitiveHelpTest');
|