2 * This file is part of QMAFW
4 * Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). All rights
7 * Contact: Visa Smolander <visa.smolander@nokia.com>
9 * This software, including documentation, is protected by copyright controlled
10 * by Nokia Corporation. All rights are reserved. Copying, including
11 * reproducing, storing, adapting or translating, any or all of this material
12 * requires the prior written consent of Nokia Corporation. This material also
13 * contains confidential information which may not be disclosed to others
14 * without the prior written consent of Nokia.
24 #include "ut_Others.h"
25 #include "mafw-gst-renderer-utils.h"
26 #include "mafw-gst-renderer-worker.h"
28 #define UNUSED(x) (void)(x)
30 /* START OF STUB DEFINITIONS */
31 gboolean g_utf8_validate(const gchar *str,
39 if (g_str_equal("valid", str))
50 gchar* g_locale_to_utf8(const gchar *opsysstring,
59 UNUSED(bytes_written);
61 if (g_str_equal("non-valid", opsysstring))
63 return g_strdup(opsysstring);
68 g_quark_from_string("test"),
70 "%s", "SIMULATED ERROR");
76 /* END OF STUB DEFINITIONS */
78 void ut_Others::testUtils()
80 QVERIFY(uri_is_stream("file:///file.m3u") == FALSE);
81 QVERIFY(uri_is_stream("http:///joojoo.com") == TRUE);
82 QVERIFY(uri_is_stream(NULL) == FALSE);
85 QVERIFY(convert_utf8(NULL, NULL) == FALSE);
86 QVERIFY(convert_utf8("valid", NULL) == FALSE);
87 QVERIFY(convert_utf8(NULL, &dst) == FALSE);
88 QVERIFY(convert_utf8("valid", &dst) == TRUE);
90 QVERIFY(convert_utf8("non-valid", &dst) == TRUE);
92 QVERIFY(g_str_equal(dst, "non-valid") == TRUE);
94 QVERIFY(convert_utf8("error", &dst) == FALSE);
98 void ut_Others::testGstErrorRemapping()
101 GQuark domain = g_quark_from_string("test_error_domain");
103 GError* error = g_error_new_literal(domain, 999, "error_message");
104 QVERIFY(remap_gst_error_code(error) == 999);
106 error->domain = GST_RESOURCE_ERROR;
107 error->code = GST_RESOURCE_ERROR_READ;
108 QVERIFY(remap_gst_error_code(error) == WORKER_ERROR_STREAM_DISCONNECTED);
109 error->code = GST_RESOURCE_ERROR_NOT_FOUND;
110 QVERIFY(remap_gst_error_code(error) == WORKER_ERROR_MEDIA_NOT_FOUND);
111 error->code = GST_RESOURCE_ERROR_OPEN_READ_WRITE;
112 QVERIFY(remap_gst_error_code(error) == WORKER_ERROR_MEDIA_NOT_FOUND);
113 error->code = GST_RESOURCE_ERROR_NO_SPACE_LEFT;
114 QVERIFY(remap_gst_error_code(error) == WORKER_ERROR_UNABLE_TO_PERFORM);
115 error->code = GST_RESOURCE_ERROR_WRITE;
116 QVERIFY(remap_gst_error_code(error) == WORKER_ERROR_CORRUPTED_FILE);
117 error->code = GST_RESOURCE_ERROR_SEEK;
118 QVERIFY(remap_gst_error_code(error) == WORKER_ERROR_CANNOT_SET_POSITION);
119 error->code = 999999;
120 QVERIFY(remap_gst_error_code(error) == WORKER_ERROR_UNABLE_TO_PERFORM);
122 error->domain = GST_STREAM_ERROR;
123 error->code = GST_STREAM_ERROR_TYPE_NOT_FOUND;
124 QVERIFY(remap_gst_error_code(error) == WORKER_ERROR_TYPE_NOT_AVAILABLE);
125 error->code = GST_STREAM_ERROR_FORMAT;
126 QVERIFY(remap_gst_error_code(error) == WORKER_ERROR_UNSUPPORTED_TYPE);
127 error->code = GST_STREAM_ERROR_DECODE;
128 QVERIFY(remap_gst_error_code(error) == WORKER_ERROR_CORRUPTED_FILE);
129 error->code = GST_STREAM_ERROR_CODEC_NOT_FOUND;
130 QVERIFY(remap_gst_error_code(error) == WORKER_ERROR_CODEC_NOT_FOUND);
131 error->code = GST_STREAM_ERROR_DECRYPT;
132 QVERIFY(remap_gst_error_code(error) == WORKER_ERROR_DRM_NOT_ALLOWED);
133 error->code = 999999;
134 QVERIFY(remap_gst_error_code(error) == WORKER_ERROR_UNABLE_TO_PERFORM);
140 void ut_Others::init()
145 void ut_Others::cleanup()
150 QTEST_APPLESS_MAIN(ut_Others)