~unity-team/thumbnailer/trunk

« back to all changes in this revision

Viewing changes to tests/basic.cpp

  • Committer: CI bot
  • Author(s): Jussi Pakkanen
  • Date: 2014-03-07 15:41:09 UTC
  • mfrom: (71.2.2 thumbnailer)
  • Revision ID: ps-jenkins@lists.canonical.com-20140307154109-g1e7li9nra4571n8
Reorient images manually to work around a bug in GdkPixbuf. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
#include<gdk-pixbuf/gdk-pixbuf.h>
24
24
 
25
25
#define TESTIMAGE TESTDATADIR "/testimage.jpg"
 
26
#define ROTTESTIMAGE TESTDATADIR "/testrotate.jpg"
26
27
#define TESTVIDEO TESTDATADIR "/testvideo.ogg"
27
28
 
28
29
using namespace std;
79
80
    file_test(tn, imfile);
80
81
}
81
82
 
 
83
void rotate_test() {
 
84
    Thumbnailer tn;
 
85
    string imfile(ROTTESTIMAGE);
 
86
    int w, h;
 
87
    assert(file_exists(imfile));
 
88
    string thumbfile = tn.get_thumbnail(imfile, TN_SIZE_LARGE);
 
89
    unlink(thumbfile.c_str());
 
90
    assert(!file_exists(thumbfile));
 
91
    string thumbfile2 = tn.get_thumbnail(imfile, TN_SIZE_LARGE);
 
92
    assert(thumbfile == thumbfile2);
 
93
    assert(file_exists(thumbfile));
 
94
    assert(gdk_pixbuf_get_file_info(imfile.c_str(), &w, &h));
 
95
    assert(w > h); // gdk_pixbuf does not reorient images automatically.
 
96
    assert(gdk_pixbuf_get_file_info(thumbfile.c_str(), &w, &h));
 
97
    assert(h > w); // Has the orientation been straightened during scaling?
 
98
}
 
99
 
82
100
void video_test() {
83
101
    Thumbnailer tn;
84
102
    string videofile(TESTVIDEO);
155
173
#else
156
174
    trivial_test();
157
175
    image_test();
 
176
    rotate_test();
158
177
    video_test();
159
178
    video_original_test();
160
179
    size_test();