enable package builds
[osm/SO.git] / rwcal / test / rwcal_callback_gtest.cpp
1
2 /*
3 *
4 * Copyright 2016 RIFT.IO Inc
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20
21
22 #include <rwut.h>
23
24 #include "rwcal-api.h"
25
26 struct test_struct {
27 int accessed;
28 };
29
30 struct test_struct g_test_struct;
31
32 class RWCalCallbackTest : public ::testing::Test {
33 /*
34 * This is a tough one to test as we're really relying on the
35 * gobject introspection to do all the data marshalling for us
36 * correctly. At this point, all I can think of to do is to
37 * just create a closure and then call it the same way it would
38 * typically be called in C and make sure that everything
39 * executed as expected.
40 */
41 protected:
42 rwcal_module_ptr_t rwcal;
43
44 virtual void SetUp() {
45 rwcal = rwcal_module_alloc();
46 ASSERT_TRUE(rwcal);
47
48 g_test_struct.accessed = 0;
49 }
50
51 virtual void TearDown() {
52 rwcal_module_free(&rwcal);
53 }
54
55 virtual void TestSuccess() {
56 ASSERT_TRUE(rwcal);
57 #if 0
58 rwcal_closure_ptr_t closure;
59
60 closure = rwcal_closure_alloc(
61 rwcal,
62 &update_accessed,
63 (void *)&g_test_struct);
64 ASSERT_TRUE(closure);
65
66 ASSERT_EQ(g_test_struct.accessed, 0);
67 rw_cal_closure_callback(closure);
68 ASSERT_EQ(g_test_struct.accessed, 1);
69
70 rwcal_closure_free(&closure);
71 ASSERT_FALSE(closure);
72 #endif
73 }
74 };
75
76
77 TEST_F(RWCalCallbackTest, TestSuccess) {
78 TestSuccess();
79 }