2
* Copyright (C) 2016 Canonical Ltd
4
* This program is free software: you can redistribute it and/or modify
5
* it under the terms of the GNU Lesser General Public License version 3 as
6
* published by the Free Software Foundation.
8
* This program is distributed in the hope that it will be useful,
9
* but WITHOUT ANY WARRANTY; without even the implied warranty of
10
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11
* GNU Lesser General Public License for more details.
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program. If not, see <http://www.gnu.org/licenses/>.
16
* Authors: James Henstridge <james.henstridge@canonical.com>
19
#include "ProviderFixture.h"
21
#include <unity/storage/internal/dbus_error.h>
25
using namespace unity::storage::provider;
31
const auto SERVICE_CONNECTION_NAME = QStringLiteral("service-session-bus");
32
const auto BUS_PATH = QStringLiteral("/provider");
36
ProviderFixture::ProviderFixture()
38
dbus_.reset(new DBusEnvironment);
39
dbus_->start_services();
40
service_connection_.reset(new QDBusConnection(QDBusConnection::connectToBus(dbus_->busAddress(),
41
SERVICE_CONNECTION_NAME)));
42
account_manager_.reset(new OnlineAccounts::Manager("", *service_connection_));
45
ProviderFixture::~ProviderFixture()
48
service_connection_.reset();
49
QDBusConnection::disconnectFromBus(SERVICE_CONNECTION_NAME);
53
QDBusConnection const& ProviderFixture::connection() const
55
return dbus_->connection();
58
void ProviderFixture::set_provider(unique_ptr<ProviderBase>&& provider)
60
account_manager_->waitForReady();
61
OnlineAccounts::Account* account = account_manager_->account(2, "oauth2-service");
62
ASSERT_NE(nullptr, account);
65
new unity::storage::provider::testing::TestServer(move(provider), account,
66
*service_connection_, BUS_PATH.toStdString()));
69
void ProviderFixture::wait_for(QDBusPendingCall const& call)
71
QDBusPendingCallWatcher watcher(call);
72
QSignalSpy spy(&watcher, &QDBusPendingCallWatcher::finished);
73
ASSERT_TRUE(spy.wait());
76
QString ProviderFixture::bus_path() const