~thomas-voss/location-service/flatten

« back to all changes in this revision

Viewing changes to tests/session_test.cpp

  • Committer: thomas-voss
  • Date: 2015-02-03 12:21:33 UTC
  • Revision ID: thomas.voss@canonical.com-20150203122133-660kjot28cz7dx6m
Adjust namespace to core::location for all classes not in com::ubuntu::location::connectivity.

Show diffs side-by-side

added added

removed removed

Lines of Context:
23
23
 
24
24
namespace
25
25
{
26
 
struct MockProvider : public com::ubuntu::location::Provider
 
26
struct MockProvider : public core::location::Provider
27
27
{
28
28
    MOCK_METHOD1(subscribe_to_position_updates,
29
 
                 com::ubuntu::location::ChannelConnection(std::function<void(const com::ubuntu::location::Update<com::ubuntu::location::Position>&)>));
 
29
                 core::location::ChannelConnection(std::function<void(const core::location::Update<core::location::Position>&)>));
30
30
 
31
31
    MOCK_METHOD1(subscribe_to_heading_updates,
32
 
                 com::ubuntu::location::ChannelConnection(std::function<void(const com::ubuntu::location::Update<com::ubuntu::location::Heading>&)>));
 
32
                 core::location::ChannelConnection(std::function<void(const core::location::Update<core::location::Heading>&)>));
33
33
 
34
34
    MOCK_METHOD1(subscribe_to_velocity_updates,
35
 
                 com::ubuntu::location::ChannelConnection(std::function<void(const com::ubuntu::location::Update<com::ubuntu::location::Velocity>&)>));
 
35
                 core::location::ChannelConnection(std::function<void(const core::location::Update<core::location::Velocity>&)>));
36
36
};
37
37
}
38
38
 
39
39
TEST(LocationSession, constructing_with_a_null_provider_throws)
40
40
{
41
 
    EXPECT_ANY_THROW(com::ubuntu::location::Session session(com::ubuntu::location::Provider::Ptr {}));
 
41
    EXPECT_ANY_THROW(core::location::Session session(core::location::Provider::Ptr {}));
42
42
}
43
43
 
44
44
TEST(LocationSession, changing_provider_association_of_session_results_in_connections_to_new_provider)
46
46
    using namespace ::testing;
47
47
    NiceMock<MockProvider> mock_provider1;
48
48
    ON_CALL(mock_provider1, subscribe_to_position_updates(_))
49
 
    .WillByDefault(Return(com::ubuntu::location::ChannelConnection()));
 
49
    .WillByDefault(Return(core::location::ChannelConnection()));
50
50
    ON_CALL(mock_provider1, subscribe_to_heading_updates(_))
51
 
    .WillByDefault(Return(com::ubuntu::location::ChannelConnection()));
 
51
    .WillByDefault(Return(core::location::ChannelConnection()));
52
52
    ON_CALL(mock_provider1, subscribe_to_velocity_updates(_))
53
 
    .WillByDefault(Return(com::ubuntu::location::ChannelConnection()));
 
53
    .WillByDefault(Return(core::location::ChannelConnection()));
54
54
 
55
55
    NiceMock<MockProvider> mock_provider2;
56
56
    EXPECT_CALL(mock_provider2, subscribe_to_position_updates(_))
57
 
    .WillRepeatedly(Return(com::ubuntu::location::ChannelConnection()));
 
57
    .WillRepeatedly(Return(core::location::ChannelConnection()));
58
58
    EXPECT_CALL(mock_provider2, subscribe_to_heading_updates(_))
59
 
    .WillRepeatedly(Return(com::ubuntu::location::ChannelConnection()));
 
59
    .WillRepeatedly(Return(core::location::ChannelConnection()));
60
60
    EXPECT_CALL(mock_provider2, subscribe_to_velocity_updates(_))
61
 
    .WillRepeatedly(Return(com::ubuntu::location::ChannelConnection()));
 
61
    .WillRepeatedly(Return(core::location::ChannelConnection()));
62
62
 
63
 
    com::ubuntu::location::Session session(com::ubuntu::location::Provider::Ptr {&mock_provider1, [](com::ubuntu::location::Provider*) {}});
64
 
    session.change_provider_assocation_to(com::ubuntu::location::Provider::Ptr {&mock_provider2, [](com::ubuntu::location::Provider*) {}});
 
63
    core::location::Session session(core::location::Provider::Ptr {&mock_provider1, [](core::location::Provider*) {}});
 
64
    session.change_provider_assocation_to(core::location::Provider::Ptr {&mock_provider2, [](core::location::Provider*) {}});
65
65
}
66
66
 
67
67
TEST(LocationSession, installing_updates_handlers_connects_them_to_the_provider_associated_to_the_session)
72
72
 
73
73
    EXPECT_CALL(mock_provider, subscribe_to_position_updates(_))
74
74
    .Times(1)
75
 
    .WillRepeatedly(Return(com::ubuntu::location::ChannelConnection()));
 
75
    .WillRepeatedly(Return(core::location::ChannelConnection()));
76
76
    EXPECT_CALL(mock_provider, subscribe_to_heading_updates(_))
77
77
    .Times(1)
78
 
    .WillRepeatedly(Return(com::ubuntu::location::ChannelConnection()));
 
78
    .WillRepeatedly(Return(core::location::ChannelConnection()));
79
79
    EXPECT_CALL(mock_provider, subscribe_to_velocity_updates(_))
80
80
    .Times(1)
81
 
    .WillRepeatedly(Return(com::ubuntu::location::ChannelConnection()));
82
 
 
83
 
    com::ubuntu::location::Session session(com::ubuntu::location::Provider::Ptr {&mock_provider, [](com::ubuntu::location::Provider*) {}});
84
 
 
85
 
    session.install_position_updates_handler([](const com::ubuntu::location::Update<com::ubuntu::location::Position>&)
86
 
    {
87
 
    });
88
 
    session.install_heading_updates_handler([](const com::ubuntu::location::Update<com::ubuntu::location::Heading>&)
89
 
    {
90
 
    });
91
 
    session.install_velocity_updates_handler([](const com::ubuntu::location::Update<com::ubuntu::location::Velocity>&)
 
81
    .WillRepeatedly(Return(core::location::ChannelConnection()));
 
82
 
 
83
    core::location::Session session(core::location::Provider::Ptr {&mock_provider, [](core::location::Provider*) {}});
 
84
 
 
85
    session.install_position_updates_handler([](const core::location::Update<core::location::Position>&)
 
86
    {
 
87
    });
 
88
    session.install_heading_updates_handler([](const core::location::Update<core::location::Heading>&)
 
89
    {
 
90
    });
 
91
    session.install_velocity_updates_handler([](const core::location::Update<core::location::Velocity>&)
92
92
    {
93
93
    });
94
94
}