UI data is stored on GObjects and automatically destroyed, so this isn't
really needed as a UI op for *our* UIs. There will be a replacement soon
if needed by other UIs.
/*
* purple - Sametime Protocol Plugin Tests
*
* Purple is the legal property of its developers, whose names are too numerous
* to list here. Please refer to the COPYRIGHT file distributed with this
* source distribution.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
*
*/
#include<glib.h>
#include<gmime/gmime.h>
#include<string.h>
#include"image.h"
#include"image-store.h"
#include"util.h"
#include"protocols/sametime/im_mime.h"
typedefstruct_TestData{
/* Name of the test case. */
constgchar*name;
/* HTML version of the message. */
constgchar*html;
/* MIME-encoded version of the message. */
constgchar*mime;
/* Whether to load an image and substitute %u for its imagestore id. */
gbooleanwith_image;
}TestData;
constTestDataTEST_CASES[]={
#include"data/mime-basic.h"
#include"data/mime-multiline.h"
#include"data/mime-image.h"
#include"data/mime-utf8.h"
};
// Image data to use for tests:
#include"data/image-data.h"
staticvoid
test_sametime_im_mime_parse(gconstpointer_data)
{
constTestData*data=(constTestData*)_data;
gchar*result,*ncr;
/* This decoding is normally done in im_recv_html, but it's not used here. */
ncr=im_mime_parse(data->mime);
result=purple_utf8_ncr_decode(ncr);
g_free(ncr);
if(data->with_image){
gchar**expected;
gchar**got;
gchar*suffix_expected,*suffix_got;
expected=g_strsplit(data->html,"<img src=\"",2);
g_assert_nonnull(expected);
got=g_strsplit(result,"<img src=\"",2);
g_assert_nonnull(got);
/* The image will be in the image store with some random id, so
* assert it's starting with the same prefix. */
g_assert_cmpstr(got[0],==,expected[0]);
/* Then assert it's ending with the same suffix. */
g_assert_nonnull(suffix_expected=expected[1]);
g_assert_nonnull(suffix_got=got[1]);
if(suffix_expected&&suffix_got){
/* First trim off the src attribute which will differ