~ubuntu-branches/ubuntu/trusty/kdepimlibs/trusty

« back to all changes in this revision

Viewing changes to kcalcore/tests/testalarm.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg, Rohan Garg, Philip Muškovac
  • Date: 2013-11-23 17:36:44 UTC
  • mfrom: (1.1.102)
  • Revision ID: package-import@ubuntu.com-20131123173644-p5ow94192ezsny8g
Tags: 4:4.11.80-0ubuntu1
[ Rohan Garg ]
* New upstream beta release
  - Bump akonadi requirement to 1.10.45
  - Update install files
  - Update symbols

[ Philip Muškovac ]
* kdepimlibs-dev/-dbg breaks/replaces kdepim-runtime/-dbg (<< 4:4.11.80)

Show diffs side-by-side

added added

removed removed

Lines of Context:
42
42
  Alarm alarm1( &inc1 ), alarm2( &inc2 );
43
43
  alarm1.setType( Alarm::Email );
44
44
  alarm2.setType( Alarm::Email );
 
45
 
 
46
  alarm1.setMailAddress(Person::Ptr(new Person("name", "email@foo.com")));
 
47
  alarm2.setMailAddress(Person::Ptr(new Person("name", "email@foo.com")));
 
48
 
45
49
  QVERIFY( alarm1 == alarm2 );
 
50
 
 
51
  alarm2.setMailAddress(Person::Ptr(new Person("name", "email@foo.pt")));
 
52
  QVERIFY( alarm1 != alarm2 );
 
53
 
46
54
  alarm2.setType( Alarm::Display );
47
55
  QVERIFY( alarm1 != alarm2 );
48
56
}
56
64
  Alarm *alarm3 = new Alarm( alarm1 );
57
65
  QVERIFY( alarm2 == *alarm3 );
58
66
}
 
67
 
 
68
 
 
69
void AlarmTest::testSerializer_data()
 
70
{
 
71
  QTest::addColumn<KCalCore::Alarm::Ptr>( "alarm" );
 
72
  Alarm::Ptr a1 = Alarm::Ptr( new Alarm( 0 ) );
 
73
  Alarm::Ptr a2 = Alarm::Ptr( new Alarm( 0 ) );
 
74
  Alarm::Ptr a3 = Alarm::Ptr( new Alarm( 0 ) );
 
75
  Alarm::Ptr a4 = Alarm::Ptr( new Alarm( 0 ) );
 
76
 
 
77
 
 
78
  a1->setType( Alarm::Email );
 
79
  a2->setType( Alarm::Procedure );
 
80
  a3->setType( Alarm::Display );
 
81
  a4->setType( Alarm::Audio );
 
82
 
 
83
  a3->setDisplayAlarm("foo");
 
84
  a3->setText("foo bar");
 
85
  a4->setAudioFile("file.mp3");
 
86
  a2->setProgramFile("/usr/bin/foo");
 
87
  a2->setProgramArguments("--play");
 
88
 
 
89
  a1->setMailSubject("empty subject");
 
90
 
 
91
  Person::List persons;
 
92
  persons << Person::Ptr(new Person("a", "a@a.pt")) << Person::Ptr(new Person("b", "b@b.pt"));
 
93
  a1->setMailAddresses(persons);
 
94
  a1->setMailAttachment("foo attachment");
 
95
  a1->setMailText("mail body");
 
96
 
 
97
  a1->setTime(KDateTime( QDate( 2006, 8, 3 ), QTime( 8, 0, 0 ), KDateTime::UTC ));
 
98
  a2->setStartOffset(Duration( 7, Duration::Days ));
 
99
  a3->setEndOffset(Duration( 1, Duration::Days ));
 
100
 
 
101
  a1->setSnoozeTime(Duration( 1, Duration::Seconds ));
 
102
  a1->setRepeatCount(50);
 
103
  a1->setEnabled(true);
 
104
  a2->setEnabled(true);
 
105
  a3->setHasLocationRadius(false);
 
106
  a3->setLocationRadius(100);
 
107
 
 
108
  QTest::newRow( "alarm1" ) << a1;
 
109
  QTest::newRow( "alarm2" ) << a2;
 
110
  QTest::newRow( "alarm3" ) << a3;
 
111
  QTest::newRow( "alarm4" ) << a4;
 
112
}
 
113
 
 
114
void AlarmTest::testSerializer()
 
115
{
 
116
  QFETCH( KCalCore::Alarm::Ptr, alarm );
 
117
 
 
118
  QByteArray array;
 
119
  QDataStream stream(&array, QIODevice::WriteOnly);
 
120
  stream << alarm; // Serialize
 
121
 
 
122
  Alarm::Ptr alarm2 = Alarm::Ptr( new Alarm(0) );
 
123
  //QVERIFY(*alarm != *alarm2);
 
124
  QDataStream stream2(&array, QIODevice::ReadOnly);
 
125
  stream2 >> alarm2; // deserialize
 
126
  QVERIFY(*alarm == *alarm2);
 
127
}
 
128