~ci-train-bot/thumbnailer/latestsnapshot-ubuntu-recup

« back to all changes in this revision

Viewing changes to tests/basic.cpp

  • Committer: Package Import Robot
  • Author(s): Ubuntu daily release, Jussi Pakkanen, Ubuntu daily release
  • Date: 2013-10-03 03:26:49 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20131003032649-dh4ryu2x1ng6zkve
Tags: 1.0+13.10.20131003-0ubuntu1
[ Jussi Pakkanen ]
* Run gstreamer video pipelines in an external process.
* Get helper path from config.h.
* Use helper binary from build dir when running tests.
* Adds support for full resolution thumbnails.

[ Ubuntu daily release ]
* Automatic snapshot from revision 48

Show diffs side-by-side

added added

removed removed

Lines of Context:
20
20
#include<testsetup.h>
21
21
#include<cassert>
22
22
#include<unistd.h>
 
23
#include<gdk-pixbuf/gdk-pixbuf.h>
23
24
 
24
25
#define TESTIMAGE TESTDATADIR "/testimage.jpg"
25
26
#define TESTVIDEO TESTDATADIR "/testvideo.ogg"
59
60
}
60
61
 
61
62
void file_test(Thumbnailer &tn, string &ifile) {
 
63
    int w, h;
62
64
    assert(file_exists(ifile));
63
65
    string thumbfile = tn.get_thumbnail(ifile, TN_SIZE_SMALL);
64
66
    unlink(thumbfile.c_str());
66
68
    string thumbfile2 = tn.get_thumbnail(ifile, TN_SIZE_SMALL);
67
69
    assert(thumbfile == thumbfile2);
68
70
    assert(file_exists(thumbfile));
69
 
 
 
71
    assert(gdk_pixbuf_get_file_info(thumbfile.c_str(), &w, &h));
 
72
    assert(w <= 128);
 
73
    assert(h <= 128);
70
74
}
71
75
 
72
76
void image_test() {
81
85
    file_test(tn, videofile);
82
86
}
83
87
 
 
88
void video_original_test() {
 
89
    Thumbnailer tn;
 
90
    int w, h;
 
91
    string videofile(TESTVIDEO);
 
92
    string origsize = tn.get_thumbnail(videofile, TN_SIZE_ORIGINAL);
 
93
    assert(file_exists(origsize));
 
94
    assert(gdk_pixbuf_get_file_info(origsize.c_str(), &w, &h));
 
95
    assert(w == 1920);
 
96
    assert(h == 1080);
 
97
}
 
98
 
 
99
 
84
100
void size_test() {
85
101
    Thumbnailer tn;
 
102
    int w, h;
86
103
    string imfile(TESTIMAGE);
87
104
    string thumbfile = tn.get_thumbnail(imfile, TN_SIZE_SMALL);
88
105
    string thumbfile2 = tn.get_thumbnail(imfile, TN_SIZE_LARGE);
89
106
    assert(!thumbfile.empty());
90
107
    assert(!thumbfile2.empty());
91
108
    assert(thumbfile != thumbfile2);
 
109
    assert(gdk_pixbuf_get_file_info(thumbfile.c_str(), &w, &h));
 
110
    assert(w == 128);
 
111
    assert(h <= 128);
 
112
    assert(gdk_pixbuf_get_file_info(thumbfile2.c_str(), &w, &h));
 
113
    assert(w == 256);
 
114
    assert(h <= 256);
92
115
}
93
116
 
94
117
void delete_test() {
108
131
    assert(!file_exists(thumbfile2));
109
132
}
110
133
 
 
134
void no_image_cache_test() {
 
135
    Thumbnailer tn;
 
136
    string srcimg(TESTIMAGE);
 
137
    string dstimg = tn.get_thumbnail(srcimg, TN_SIZE_ORIGINAL);
 
138
    assert(srcimg == dstimg);
 
139
}
 
140
 
111
141
int main() {
112
142
#ifdef NDEBUG
113
143
    fprintf(stderr, "NDEBUG defined, tests will not work.\n");
116
146
    trivial_test();
117
147
    image_test();
118
148
    video_test();
 
149
    video_original_test();
119
150
    size_test();
120
151
    delete_test();
 
152
    no_image_cache_test();
121
153
    return 0;
122
154
#endif
123
155
}