~thomas-voss/location-service/fix-1347887

« back to all changes in this revision

Viewing changes to tests/velocity_test.cpp

This MP consolidates multiple related changes together, with the goal of:

(1.) Make the service instance accessible via a cli. Useful for testing scenarios.
(2.) To cut down time-to-first-fix (ttff) by:
  (2.1) Leveraging SUPL and other supplementary data downloaded over ordinary data connections.
  (2.2) Enabling network-based positioning providers to acquire fast position estimates.

In more detail:

* Added tests for daemon and cli.
* Unified daemon and cli header and implementation files.
* Add a command-line interface to the service.
* Split up provider selection policy to rely on an interface ProviderEnumerator to ease in testing.
* Trimmed down on types.
* Removed connectivity API draft to prepare for simpler approach.
* Refactored includes.
* Added a configuration option to handle cell and wifi ID reporting.
* Add a mock for a connectivity API exposed to providers and reporters.
* Add units for connectivity api.
* Refactor cell class into namespace radio. Fixes: 1226204, 1248973, 1281817

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright © 2012-2013 Canonical Ltd.
3
 
 *
4
 
 * This program is free software: you can redistribute it and/or modify it
5
 
 * under the terms of the GNU Lesser General Public License version 3,
6
 
 * as published by the Free Software Foundation.
7
 
 *
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.
12
 
 *
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/>.
15
 
 *
16
 
 * Authored by: Thomas Voß <thomas.voss@canonical.com>
17
 
 */
18
 
#include "com/ubuntu/location/velocity.h"
19
 
 
20
 
#include <gtest/gtest.h>
21
 
 
22
 
TEST(Velocity, constructing_a_velocity_with_invalid_value_throws)
23
 
{
24
 
    std::default_random_engine rng;
25
 
    std::uniform_real_distribution<double> dist(
26
 
        -std::numeric_limits<double>::max(),
27
 
        com::ubuntu::location::Velocity::min().value() - std::numeric_limits<double>::min());
28
 
    double d = dist(rng);
29
 
    EXPECT_ANY_THROW(com::ubuntu::location::Velocity v {d*com::ubuntu::location::units::MetersPerSecond};);
30
 
    dist = std::uniform_real_distribution<double>(
31
 
        com::ubuntu::location::Velocity::max().value() + std::numeric_limits<double>::min(),
32
 
        std::numeric_limits<double>::max());
33
 
    d = dist(rng);
34
 
    EXPECT_NO_THROW(com::ubuntu::location::Velocity v {d*com::ubuntu::location::units::MetersPerSecond};);
35
 
}
36
 
 
37
 
TEST(Velocity, constructing_a_velocity_with_a_valid_value_does_not_throw)
38
 
{
39
 
    std::default_random_engine rng;
40
 
    std::uniform_real_distribution<double> dist(com::ubuntu::location::Velocity::min().value(),
41
 
            com::ubuntu::location::Velocity::max().value());
42
 
 
43
 
    EXPECT_NO_THROW(com::ubuntu::location::Velocity v {dist(rng)*com::ubuntu::location::units::MetersPerSecond};);
44
 
}
45
 
 
46
 
TEST(Velocity, a_velocity_contains_value_passed_at_construction)
47
 
{
48
 
    std::default_random_engine rng;
49
 
    std::uniform_real_distribution<double> dist(com::ubuntu::location::Velocity::min().value(),
50
 
            com::ubuntu::location::Velocity::max().value());
51
 
    double d = dist(rng);
52
 
    com::ubuntu::location::Velocity v {d* com::ubuntu::location::units::MetersPerSecond};
53
 
    EXPECT_DOUBLE_EQ(d, v.value.value());
54
 
}