2
* Copyright 2013 Canonical Ltd.
4
* This program is free software: you can redistribute it and/or modify it
5
* under the terms of the GNU General Public License version 3, as published
6
* by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranties of
10
* MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
11
* PURPOSE. See the GNU General Public License for more details.
13
* You should have received a copy of the GNU General Public License along
14
* with this program. If not, see <http://www.gnu.org/licenses/>.
17
* Ted Gould <ted.gould@canonical.com>
20
#include <gtest/gtest.h>
22
#include <libdbustest/dbus-test.h>
24
TEST(ZGEvent, OpenTest)
26
DbusTestService * service = dbus_test_service_new(NULL);
28
DbusTestDbusMock * mock = dbus_test_dbus_mock_new("org.gnome.zeitgeist.Engine");
29
DbusTestDbusMockObject * obj = dbus_test_dbus_mock_get_object(mock, "/org/gnome/zeitgeist/log/activity", "org.gnome.zeitgeist.Log", NULL);
31
dbus_test_dbus_mock_object_add_method(mock, obj,
33
G_VARIANT_TYPE("a(asaasay)"),
38
dbus_test_service_add_task(service, DBUS_TEST_TASK(mock));
40
DbusTestProcess * zgevent = dbus_test_process_new(ZG_EVENT_TOOL);
41
dbus_test_process_append_param(zgevent, "open");
42
g_setenv("APP_ID", "foo", 1);
43
dbus_test_task_set_wait_for(DBUS_TEST_TASK(zgevent), "org.gnome.zeitgeist.Engine");
44
dbus_test_task_set_name(DBUS_TEST_TASK(zgevent), "ZGEvent");
46
dbus_test_service_add_task(service, DBUS_TEST_TASK(zgevent));
48
dbus_test_service_start_tasks(service);
50
/* Give it time to send the event and exit */
52
while (g_main_pending()) {
53
g_main_iteration(TRUE);
56
ASSERT_EQ(dbus_test_task_get_state(DBUS_TEST_TASK(zgevent)), DBUS_TEST_TASK_STATE_FINISHED);
57
ASSERT_TRUE(dbus_test_task_passed(DBUS_TEST_TASK(zgevent)));
60
const DbusTestDbusMockCall * calls = dbus_test_dbus_mock_object_get_method_calls(mock, obj, "InsertEvents", &numcalls, NULL);
62
ASSERT_NE(calls, nullptr);
63
ASSERT_EQ(numcalls, 1);
65
g_object_unref(zgevent);
67
g_object_unref(service);