aboutsummaryrefslogtreecommitdiff
path: root/tests/main.cpp
blob: 24cc74fb41fda2f85d554c1c9f54ec7768034a9e (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
#include "../include/DynamicImage.hpp"
#include "../include/ChatMessage.hpp"
#include <stdio.h>
#include <vector>
#include <string.h>
#include <gtkmm/application.h>
#include <gtkmm/window.h>
#include <gtkmm/grid.h>
#include <gtkmm/textview.h>
#include <assert.h>

#define REQUIRE(expr) do { if(!(expr)) { fprintf(stderr, "%s:%d: Assert failed: %s\n", __FILE__, __LINE__, #expr); exit(EXIT_FAILURE); } } while(0)
static void requireEqualValues(int a, int b, const char *file, int line)
{
    if(a != b)
    {
        fprintf(stderr, "%s:%d: Assert failed: %d == %d\n", file, line, a, b);
        exit(EXIT_FAILURE);
    }
}
#define REQUIRE_EQUAL(a, b) do { requireEqualValues((a), (b), __FILE__, __LINE__); } while(0)

static int testVisual(int argc, char **argv)
{
    auto app = Gtk::Application::create(argc, argv, "dec05eba.dchat", Gio::APPLICATION_NON_UNIQUE);
    Gtk::Window window;
    window.set_border_width(0);
    window.set_size_request(640, 480);

    auto grid = Gtk::manage(new Gtk::Grid());
    grid->set_vexpand(true);
    grid->set_hexpand(true);
    window.add(*grid);

    auto textView = Gtk::manage(new Gtk::TextView());
    textView->set_size_request(640, 480);
    textView->set_wrap_mode(Gtk::WRAP_WORD_CHAR);
    dchat::applyRichText(textView, "Hello world [emoji](https://discordemoji.com/assets/emoji/PeepoHide.png)[emoji](https://discordemoji.com/assets/emoji/PeepoHide.png)");
    grid->attach(*textView, 0, 0, 1, 1);

    window.show_all();
    return app->run(window);
}

int main(int argc, char **argv)
{
    return testVisual(argc, argv);
}