summaryrefslogtreecommitdiff
path: root/auto_tests
diff options
context:
space:
mode:
Diffstat (limited to 'auto_tests')
-rw-r--r--auto_tests/Makefile.inc12
-rw-r--r--auto_tests/self_conference_title_change_test.c86
2 files changed, 96 insertions, 2 deletions
diff --git a/auto_tests/Makefile.inc b/auto_tests/Makefile.inc
index b27fcc5d..244737d9 100644
--- a/auto_tests/Makefile.inc
+++ b/auto_tests/Makefile.inc
@@ -75,13 +75,21 @@ dht_autotest_CFLAGS = $(AUTOTEST_CFLAGS)
75dht_autotest_LDADD = $(AUTOTEST_LDADD) 75dht_autotest_LDADD = $(AUTOTEST_LDADD)
76 76
77 77
78# TODO(iphydf): This test is broken. The code needs to be fixed, as the test 78# TODO(iphydf): These tests are broken. The code needs to be fixed, as the
79# itself is correct. 79# tests themselves are correct.
80#selfname_change_conference_SOURCE = ../auto_tests/selfname_change_conference_test.c 80#selfname_change_conference_SOURCE = ../auto_tests/selfname_change_conference_test.c
81# 81#
82#selfname_change_conference_CFLAGS = $(AUTOTEST_CFLAGS) 82#selfname_change_conference_CFLAGS = $(AUTOTEST_CFLAGS)
83# 83#
84#selfname_change_conference_LDADD = $(AUTOTEST_LDADD) 84#selfname_change_conference_LDADD = $(AUTOTEST_LDADD)
85#
86#
87#self_conference_title_change_SOURCE = ../auto_tests/self_conference_title_change_test.c
88#
89#self_conference_title_change_CFLAGS = $(AUTOTEST_CFLAGS)
90#
91#self_conference_title_change_LDADD = $(AUTOTEST_LDADD)
92
85 93
86if BUILD_AV 94if BUILD_AV
87toxav_basic_test_SOURCES = ../auto_tests/toxav_basic_test.c 95toxav_basic_test_SOURCES = ../auto_tests/toxav_basic_test.c
diff --git a/auto_tests/self_conference_title_change_test.c b/auto_tests/self_conference_title_change_test.c
new file mode 100644
index 00000000..f0896101
--- /dev/null
+++ b/auto_tests/self_conference_title_change_test.c
@@ -0,0 +1,86 @@
1/* self_conference_title_change.c
2 *
3 * Small test for checking if obtaining savedata, saving it to disk and using
4 * works correctly.
5 *
6 * Copyright (C) 2017 Tox project All Rights Reserved.
7 *
8 * This file is part of Tox.
9 *
10 * Tox is free software: you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation, either version 3 of the License, or
13 * (at your option) any later version.
14 *
15 * Tox is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with Tox. If not, see <http://www.gnu.org/licenses/>.
22 *
23 */
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <string.h>
28#include <time.h>
29
30#include "../toxcore/tox.h"
31#include "../toxencryptsave/toxencryptsave.h"
32
33static const char *newtitle = "kitten over darknet";
34
35static void cbtitlechange(Tox *tox, uint32_t conference_number, uint32_t peer_number, const uint8_t *title,
36 size_t length, void *user_data)
37{
38 if (!memcmp(title, newtitle, tox_conference_get_title_size(tox, conference_number, NULL))) {
39 printf("success: title was changed and updated in the conference");
40 exit(0);
41 }
42}
43
44int main(void)
45{
46 uint32_t conference_number;
47 struct timespec sleeptime;
48 struct Tox_Options to;
49 Tox *t;
50 TOX_ERR_CONFERENCE_NEW conference_err;
51 TOX_ERR_CONFERENCE_TITLE title_err;
52
53 tox_options_default(&to);
54 t = tox_new(&to, NULL);
55
56 tox_callback_conference_title(t, &cbtitlechange);
57
58 if ((conference_number = tox_conference_new(t, &conference_err)) == UINT32_MAX) {
59 tox_kill(t);
60 fprintf(stderr, "error: could not create new conference, error code %d\n", conference_err);
61 return 2;
62 }
63
64 tox_iterate(t, NULL);
65
66 sleeptime.tv_sec = 0;
67 sleeptime.tv_nsec = tox_iteration_interval(t) * 1E6;
68
69 nanosleep(&sleeptime, NULL);
70
71 if (!tox_conference_set_title(t, conference_number, (const uint8_t *)newtitle, strlen(newtitle), &title_err)) {
72 tox_kill(t);
73 fprintf(stderr, "error: could not set conference title, error code %d\n", title_err);
74 return 3;
75 }
76
77 tox_iterate(t, NULL);
78 nanosleep(&sleeptime, NULL);
79 tox_iterate(t, NULL);
80
81 fprintf(stderr, "error: title was not changed in callback. exiting.\n");
82
83 tox_kill(t);
84
85 return 1;
86}