~xavi-garcia-mena/storage-provider-webdav/base-url-host-fix

« back to all changes in this revision

Viewing changes to tests/davprovider/davprovider_test.cpp

  • Committer: Tarmac
  • Author(s): James Henstridge
  • Date: 2016-09-23 05:03:11 UTC
  • mfrom: (7.1.13 provider-test-fixture)
  • Revision ID: tarmac-20160923050311-bb3m6zal58cpccqu
Add test infrastructure for testing DavProvider.

Approved by Michi Henning, unity-api-1-bot.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "../../src/DavProvider.h"
 
2
#include <utils/DBusEnvironment.h>
 
3
#include <utils/DavEnvironment.h>
 
4
#include <utils/ProviderEnvironment.h>
 
5
 
 
6
#include <QCoreApplication>
 
7
 
 
8
#include <gtest/gtest.h>
 
9
 
 
10
using namespace std;
 
11
using namespace unity::storage::provider;
 
12
 
 
13
class TestDavProvider : public DavProvider
 
14
{
 
15
public:
 
16
    TestDavProvider(QUrl const& base_url)
 
17
        : base_url_(base_url)
 
18
    {
 
19
    }
 
20
 
 
21
protected:
 
22
    QUrl base_url(Context const& ctx) const override
 
23
    {
 
24
        Q_UNUSED(ctx);
 
25
        return base_url_;
 
26
    }
 
27
 
 
28
    void add_credentials(QNetworkRequest* request, Context const& ctx) const override
 
29
    {
 
30
        Q_UNUSED(request);
 
31
        Q_UNUSED(ctx);
 
32
    }
 
33
 
 
34
private:
 
35
    QUrl const base_url_;
 
36
};
 
37
 
 
38
class DavProviderTests : public ::testing::Test
 
39
{
 
40
protected:
 
41
    void SetUp() override
 
42
    {
 
43
        dbus_env_.reset(new DBusEnvironment);
 
44
        dbus_env_->start_services();
 
45
        dav_env_.reset(new DavEnvironment("/tmp"));
 
46
        provider_env_.reset(new ProviderEnvironment(
 
47
                                unique_ptr<ProviderBase>(new TestDavProvider(dav_env_->base_url())),
 
48
                                2, *dbus_env_));
 
49
    }
 
50
 
 
51
    void TearDown() override
 
52
    {
 
53
        provider_env_.reset();
 
54
        dav_env_.reset();
 
55
        dbus_env_.reset();
 
56
    }
 
57
 
 
58
private:
 
59
    std::unique_ptr<DBusEnvironment> dbus_env_;
 
60
    std::unique_ptr<DavEnvironment> dav_env_;
 
61
    std::unique_ptr<ProviderEnvironment> provider_env_;
 
62
};
 
63
 
 
64
TEST_F(DavProviderTests, roots)
 
65
{
 
66
}
 
67
 
 
68
int main(int argc, char**argv)
 
69
{
 
70
    QCoreApplication app(argc, argv);
 
71
    ::testing::InitGoogleTest(&argc, argv);
 
72
    return RUN_ALL_TESTS();
 
73
}