Debian Codegraph @

tests/service-mocks/accounts-mock/main.cpp

raw
1 /*
2 * Copyright (C) 2015 Canonical Ltd.
3 *
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.
7 *
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.
12 *
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/>.
15 *
16 * Author: Xavi Garcia <[email protected]>
17 */
18 #include <QtDBus/QDBusConnection>
19 #include <QtDBus/QDBusConnectionInterface>
20
21 #include <string>
22
23 #include "AccountsDefs.h"
24 #include "AccountsServiceSoundMock.h"
25 #include "AccountsServiceSoundMockAdaptor.h"
26 #include "AccountsMock.h"
27 #include "AccountsMockAdaptor.h"
28
29 using namespace ayatana::indicators::testing;
30
31 int main(int argc, char *argv[])
32 {
33 QCoreApplication app(argc, argv);
34 QDBusConnection connection = QDBusConnection::systemBus();
35 if (!connection.interface()->isServiceRegistered(ACCOUNTS_SERVICE))
36 {
37 auto service = new AccountsServiceSoundMock(&app);
38 new SoundAdaptor(service);
39
40 auto accounts_service = new AccountsMock(&app);
41 new AccountsAdaptor(accounts_service);
42
43 if (!connection.registerService(ACCOUNTS_SERVICE))
44 {
45 qFatal("Could not register AccountsService Volume service.");
46 }
47
48 if (!connection.registerObject(USER_PATH, service))
49 {
50 qFatal("Could not register AccountsService Volume object.");
51 }
52
53 if (!connection.registerObject(ACCOUNTS_PATH, accounts_service))
54 {
55 qFatal("Could not register Accounts object.");
56 }
57 }
58 else
59 {
60 qDebug() << "Service is already registered!.";
61 }
62 return app.exec();
63 }