4 * Copyright 2016 RIFT.IO Inc
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
24 #include "rwcal-api.h"
30 struct test_struct g_test_struct
;
32 class RWCalCallbackTest
: public ::testing::Test
{
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.
42 rwcal_module_ptr_t rwcal
;
44 virtual void SetUp() {
45 rwcal
= rwcal_module_alloc();
48 g_test_struct
.accessed
= 0;
51 virtual void TearDown() {
52 rwcal_module_free(&rwcal
);
55 virtual void TestSuccess() {
58 rwcal_closure_ptr_t closure
;
60 closure
= rwcal_closure_alloc(
63 (void *)&g_test_struct
);
66 ASSERT_EQ(g_test_struct
.accessed
, 0);
67 rw_cal_closure_callback(closure
);
68 ASSERT_EQ(g_test_struct
.accessed
, 1);
70 rwcal_closure_free(&closure
);
71 ASSERT_FALSE(closure
);
77 TEST_F(RWCalCallbackTest
, TestSuccess
) {