~ci-train-bot/thumbnailer/thumbnailer-ubuntu-yakkety-landing-072

« back to all changes in this revision

Viewing changes to tests/vs-thumb/vs-thumb_test.cpp

  • Committer: CI Train Bot
  • Author(s): Michi Henning
  • Date: 2015-09-15 11:04:11 UTC
  • mfrom: (125.1.2 landing150915)
  • Revision ID: ci-train-bot@canonical.com-20150915110411-233xw0fljaq7p2o0
Landing changes on devel to trunk.
Approved by: James Henstridge

Show diffs side-by-side

added added

removed removed

Lines of Context:
28
28
#pragma GCC diagnostic ignored "-Wcast-align"
29
29
#include <gdk-pixbuf/gdk-pixbuf.h>
30
30
#include <gio/gio.h>
 
31
#ifdef __clang__
 
32
#pragma clang diagnostic push
 
33
#pragma clang diagnostic ignored "-Wparentheses-equality"
 
34
#endif
31
35
#include <gst/gst.h>
 
36
#ifdef __clang__
 
37
#pragma clang diagnostic pop
 
38
#endif
32
39
#pragma GCC diagnostic pop
33
40
#include <gtest/gtest.h>
34
41
 
35
42
#include <testsetup.h>
36
43
#include <internal/gobj_memory.h>
 
44
#include <utils/supports_decoder.h>
37
45
#include "../src/vs-thumb/thumbnailextractor.h"
38
46
 
39
47
using namespace unity::thumbnailer::internal;
99
107
    return std::move(image);
100
108
}
101
109
 
102
 
bool supports_decoder(const std::string& format)
103
 
{
104
 
    static std::set<std::string> formats;
105
 
 
106
 
    if (formats.empty())
107
 
    {
108
 
        std::unique_ptr<GList, decltype(&gst_plugin_feature_list_free)> decoders(
109
 
            gst_element_factory_list_get_elements(GST_ELEMENT_FACTORY_TYPE_DECODER, GST_RANK_NONE),
110
 
            gst_plugin_feature_list_free);
111
 
        for (const GList* l = decoders.get(); l != nullptr; l = l->next)
112
 
        {
113
 
            const auto factory = static_cast<GstElementFactory*>(l->data);
114
 
 
115
 
            const GList* templates = gst_element_factory_get_static_pad_templates(factory);
116
 
            for (const GList* l = templates; l != nullptr; l = l->next)
117
 
            {
118
 
                const auto t = static_cast<GstStaticPadTemplate*>(l->data);
119
 
                if (t->direction != GST_PAD_SINK)
120
 
                {
121
 
                    continue;
122
 
                }
123
 
 
124
 
                std::unique_ptr<GstCaps, decltype(&gst_caps_unref)> caps(gst_static_caps_get(&t->static_caps),
125
 
                                                                         gst_caps_unref);
126
 
                for (unsigned int i = 0; i < gst_caps_get_size(caps.get()); i++)
127
 
                {
128
 
                    const auto structure = gst_caps_get_structure(caps.get(), i);
129
 
                    formats.emplace(gst_structure_get_name(structure));
130
 
                }
131
 
            }
132
 
        }
133
 
    }
134
 
 
135
 
    return formats.find(format) != formats.end();
136
 
}
137
 
 
138
110
TEST_F(ExtractorTest, extract_theora)
139
111
{
140
112
    if (!supports_decoder("video/x-theora"))