@@ -0,0 +1,112 @@
2+ * Copyright (C) 2011, 2013 Canonical, Ltd.
4+ * This program is free software; you can redistribute it and/or modify
5+ * it under the terms of the GNU General Public License as published by
6+ * the Free Software Foundation; version 3.
8+ * This program is distributed in the hope that it will be useful,
9+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
10+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+ * GNU General Public License for more details.
13+ * You should have received a copy of the GNU General Public License
14+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
17+#include "previewbindingstest.h"
22+#include <UnityCore/GenericPreview.h>
23+#include <UnityCore/GLibWrapper.h>
24+#include <unity-protocol.h>
27+#include "applicationpreview.h"
28+#include "moviepreview.h"
29+#include "musicpreview.h"
31+void PreviewBindingsTest::initTestCase()
35+void PreviewBindingsTest::testGenericPreview()
37+ auto raw_preview = (GObject *)unity_protocol_generic_preview_new();
38+ unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(raw_preview), "Metallica");
39+ unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(raw_preview), "Ride The Lightning");
40+ unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(raw_preview), "Lorem ipsum dolor sit amet");
41+ unity::glib::Object<GObject> gen_prv(raw_preview);
43+ auto core_prv = unity::dash::Preview::PreviewForProtocolObject(gen_prv);
44+ auto prv = Preview::newFromUnityPreview(core_prv);
46+ QCOMPARE(prv != nullptr, true);
47+ QCOMPARE(prv->title(), QString("Metallica"));
48+ QCOMPARE(prv->subtitle(), QString("Ride The Lightning"));
49+ QCOMPARE(prv->description(), QString("Lorem ipsum dolor sit amet"));
52+void PreviewBindingsTest::testApplicationPreview()
54+ auto raw_preview = (GObject *)unity_protocol_application_preview_new();
55+ unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(raw_preview), "Firefox");
56+ unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(raw_preview), "Web Browser");
57+ unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(raw_preview), "Lorem ipsum dolor sit amet");
58+ unity_protocol_application_preview_set_license(UNITY_PROTOCOL_APPLICATION_PREVIEW(raw_preview), "GPL");
59+ unity::glib::Object<GObject> gen_prv(raw_preview);
61+ auto core_prv = unity::dash::Preview::PreviewForProtocolObject(gen_prv);
62+ auto prv = Preview::newFromUnityPreview(core_prv);
63+ auto app_prv = dynamic_cast<ApplicationPreview*>(prv);
65+ QCOMPARE(app_prv != nullptr, true);
66+ QCOMPARE(app_prv->title(), QString("Firefox"));
67+ QCOMPARE(app_prv->subtitle(), QString("Web Browser"));
68+ QCOMPARE(app_prv->description(), QString("Lorem ipsum dolor sit amet"));
69+ QCOMPARE(app_prv->license(), QString("GPL"));
72+void PreviewBindingsTest::testMoviePreview()
74+ auto raw_preview = (GObject *)unity_protocol_movie_preview_new();
75+ unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(raw_preview), "Blade Runner");
76+ unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(raw_preview), "Ridley Scott");
77+ unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(raw_preview), "Lorem ipsum dolor sit amet");
78+ unity_protocol_movie_preview_set_year(UNITY_PROTOCOL_MOVIE_PREVIEW(raw_preview), "1982");
79+ unity::glib::Object<GObject> gen_prv(raw_preview);
81+ auto core_prv = unity::dash::Preview::PreviewForProtocolObject(gen_prv);
82+ auto prv = Preview::newFromUnityPreview(core_prv);
83+ auto movie_prv = dynamic_cast<MoviePreview*>(prv);
85+ QCOMPARE(movie_prv != nullptr, true);
86+ QCOMPARE(movie_prv->title(), QString("Blade Runner"));
87+ QCOMPARE(movie_prv->subtitle(), QString("Ridley Scott"));
88+ QCOMPARE(movie_prv->description(), QString("Lorem ipsum dolor sit amet"));
89+ QCOMPARE(movie_prv->year(), QString("1982"));
92+void PreviewBindingsTest::testMusicPreview()
94+ auto raw_preview = (GObject *)unity_protocol_music_preview_new();
95+ unity_protocol_preview_set_title(UNITY_PROTOCOL_PREVIEW(raw_preview), "Metallica");
96+ unity_protocol_preview_set_subtitle(UNITY_PROTOCOL_PREVIEW(raw_preview), "Death Magnetic");
97+ unity_protocol_preview_set_description(UNITY_PROTOCOL_PREVIEW(raw_preview), "Lorem ipsum dolor sit amet");
98+ unity::glib::Object<GObject> gen_prv(raw_preview);
100+ auto core_prv = unity::dash::Preview::PreviewForProtocolObject(gen_prv);
101+ auto prv = Preview::newFromUnityPreview(core_prv);
102+ auto music_prv = dynamic_cast<MusicPreview*>(prv);
104+ QCOMPARE(music_prv != nullptr, true);
105+ QCOMPARE(music_prv->title(), QString("Metallica"));
106+ QCOMPARE(music_prv->subtitle(), QString("Death Magnetic"));
107+ QCOMPARE(music_prv->description(), QString("Lorem ipsum dolor sit amet"));
110+QTEST_MAIN(PreviewBindingsTest)
112+#include "previewbindingstest.moc"