summaryrefslogtreecommitdiffstats
path: root/testfiles/src/drag-and-drop-svgz.cpp
blob: faa3e0f1663013e4ef6edea8d0806a888f9cfedd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
// SPDX-License-Identifier: GPL-2.0-or-later OR MIT
/**
 * @file
 * Test that svgz (= compressed SVG) import/drag-and-drop
 * is working: https://gitlab.com/inkscape/inkscape/-/issues/906 .
 *
 */
/*
 * Authors:
 *      Shlomi Fish
 *
 * Copyright (C) 2020 Authors
 */

#include "doc-per-case-test.h"
#include <glibmm.h>

#include "extension/init.h"
#include "extension/db.h"
#include "extension/find_extension_by_mime.h"
#include "extension/internal/svgz.h"
#include "io/resource.h"
#include "path-prefix.h"
#include "preferences.h"

#include "gtest/gtest.h"

#include <iostream>
class SvgzImportTest : public DocPerCaseTest {
  public:
    void TestBody() override
    {
        Inkscape::Extension::init();
        ASSERT_TRUE(_doc != nullptr);
        ASSERT_TRUE(_doc->getRoot() != nullptr);
        Inkscape::Preferences *prefs = Inkscape::Preferences::get();
        prefs->setBool("/dialogs/import/ask_svg", true);
        prefs->setBool("/options/onimport", true);
        auto ext = Inkscape::Extension::find_by_mime("image/svg+xml-compressed");
        if (!ext) {
            std::cerr << "SvgzImportTest: Failed to find mime type!" << std::endl;
        }
        ext->set_gui(true);

        using namespace Inkscape::IO::Resource;
        auto fn = get_path_string(SYSTEM, EXAMPLES, "tiger.svgz");

        auto imod = dynamic_cast<Inkscape::Extension::Input *>(ext);
        auto svg_mod = (new Inkscape::Extension::Internal::Svg);
        ASSERT_TRUE(svg_mod->open(imod, fn.c_str()) != nullptr);
    }
    ~SvgzImportTest() override {}
};

TEST_F(SvgzImportTest, Eq)
{
    SvgzImportTest foo;
    foo.TestBody();
}

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :