summaryrefslogtreecommitdiffstats
blob: 98653efc9f869d118bc03a0ee7ee5d29355d4cdc (plain)
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
/*
 * Copyright (c) 2010 Isode Limited.
 * All rights reserved.
 * See the COPYING file for more information.
 */

#include <cppunit/extensions/HelperMacros.h>
#include <cppunit/extensions/TestFactoryRegistry.h>

#include <Swiften/Parser/PayloadParsers/StatusShowParser.h>
#include <Swiften/Parser/PayloadParsers/UnitTest/PayloadsParserTester.h>

using namespace Swift;

class StatusShowParserTest : public CppUnit::TestFixture
{
		CPPUNIT_TEST_SUITE(StatusShowParserTest);
		CPPUNIT_TEST(testParse_Invalid);
		CPPUNIT_TEST(testParse_Away);
		CPPUNIT_TEST(testParse_FFC);
		CPPUNIT_TEST(testParse_XA);
		CPPUNIT_TEST(testParse_DND);
		CPPUNIT_TEST_SUITE_END();

	public:
		StatusShowParserTest() {}

		void testParse_Invalid() {
			PayloadsParserTester parser;
			
			CPPUNIT_ASSERT(parser.parse("<show>invalid</show>"));

			StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
			CPPUNIT_ASSERT(StatusShow::Online == payload->getType());
		}

		void testParse_Away() {
			PayloadsParserTester parser;
			
			CPPUNIT_ASSERT(parser.parse("<show>away</show>"));

			StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
			CPPUNIT_ASSERT(StatusShow::Away == payload->getType());
		}

		void testParse_FFC() {
			PayloadsParserTester parser;
			
			CPPUNIT_ASSERT(parser.parse("<show>chat</show>"));

			StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
			CPPUNIT_ASSERT(StatusShow::FFC == payload->getType());
		}

		void testParse_XA() {
			PayloadsParserTester parser;
			
			CPPUNIT_ASSERT(parser.parse("<show>xa</show>"));

			StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
			CPPUNIT_ASSERT(StatusShow::XA == payload->getType());
		}

		void testParse_DND() {
			PayloadsParserTester parser;
			
			CPPUNIT_ASSERT(parser.parse("<show>dnd</show>"));

			StatusShow* payload = dynamic_cast<StatusShow*>(parser.getPayload().get());
			CPPUNIT_ASSERT(StatusShow::DND == payload->getType());
		}
};

CPPUNIT_TEST_SUITE_REGISTRATION(StatusShowParserTest);