blob: 43bf5728cc6e0942b9751bb4823651e4fcd6858f (
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
|
#include "context_tests.h"
#include "request.h"
void context_fixture_setup(ContextFixture *fixture,
gconstpointer test_data)
{
fixture->handle = webvi_context_initialize();
g_assert(fixture->handle != 0);
fixture->context = get_context_by_handle(fixture->handle);
g_assert(fixture->context != NULL);
}
void context_fixture_teardown(ContextFixture *fixture,
gconstpointer test_data)
{
g_assert(fixture->handle != 0);
g_assert(fixture->context != NULL);
webvi_context_cleanup(fixture->handle);
fixture->handle = 0;
fixture->context = NULL;
}
void test_context_create(void) {
WebviCtx ctx = webvi_initialize_context();
g_assert(ctx != 0);
WebviCtx ctx2 = webvi_initialize_context();
g_assert(ctx != ctx2);
webvi_context_cleanup(ctx2);
webvi_context_cleanup(ctx);
}
void test_context_template_path(ContextFixture *fixture,
gconstpointer test_data) {
const char *tpath = "testpath";
webvi_context_set_template_path(fixture->context, tpath);
const char *output_path = webvi_context_get_template_path(fixture->context);
g_assert_cmpstr(output_path, ==, tpath);
}
void test_context_request_processing(ContextFixture *fixture,
G_GNUC_UNUSED gconstpointer test_data) {
WebviRequest *mock_request = request_create("testuri", fixture->context);
WebviHandle h = webvi_context_add_request(fixture->context, mock_request);
g_assert(h != WEBVI_INVALID_HANDLE);
WebviRequest *req = webvi_context_get_request(fixture->context, h);
g_assert(req == mock_request);
webvi_context_remove_request(fixture->context, h);
req = webvi_context_get_request(fixture->context, h);
g_assert(req == NULL);
}
|