~thomas-voss/location-service/add_controller_and_service_configuration

« back to all changes in this revision

Viewing changes to tests/gps_provider_test.cpp

  • Committer: thomas-voss
  • Date: 2014-06-12 15:53:33 UTC
  • Revision ID: thomas.voss@canonical.com-20140612155333-i19namy4qpd7dptr
Make reporting to ichnaea from gps provider test cases opt-in.

Show diffs side-by-side

added added

removed removed

Lines of Context:
372
372
 
373
373
namespace
374
374
{
 
375
static constexpr const char* enable_harvesting_key
 
376
{
 
377
    "COM_UBUNTU_LOCATION_GPS_PROVIDER_ENABLE_HARVESTING_DURING_TESTS"
 
378
};
 
379
 
 
380
static constexpr const char* ichnaea_instance_url_key
 
381
{
 
382
    "COM_UBUNTU_LOCATION_GPS_PROVIDER_ICHNAEA_INSTANCE_URL"
 
383
};
 
384
 
 
385
static constexpr const char* ichnaea_api_key_key
 
386
{
 
387
    "COM_UBUNTU_LOCATION_GPS_PROVIDER_ICHNAEA_API_KEY"
 
388
};
 
389
 
375
390
location::service::Harvester& the_harvester()
376
391
{
377
392
    struct State
383
398
 
384
399
        location::service::ichnaea::Reporter::Configuration reporter_configuration
385
400
        {
386
 
            "https://162.213.35.107",
387
 
            "location_service_test_cases"
 
401
            core::posix::this_process::env::get(ichnaea_instance_url_key, "https://162.213.35.107"),
 
402
            core::posix::this_process::env::get(ichnaea_api_key_key, "location_service_test_cases")
388
403
        };
389
404
 
390
405
        std::shared_ptr<location::service::ichnaea::Reporter> reporter
465
480
    // We wire up our state to position updates from the hal.
466
481
    hal->position_updates().connect([&state](const location::Position& pos)
467
482
    {
468
 
        the_harvester().report_position_update(location::Update<location::Position>
469
 
        {
470
 
            pos, location::Clock::now()
471
 
        });
 
483
        try
 
484
        {
 
485
            // This will throw if the env variable is not set.
 
486
            core::posix::this_process::env::get(enable_harvesting_key);
 
487
 
 
488
            the_harvester().report_position_update(location::Update<location::Position>
 
489
            {
 
490
                pos, location::Clock::now()
 
491
            });
 
492
        } catch(...)
 
493
        {
 
494
        }
472
495
 
473
496
        state.on_position_updated(pos);
474
497
    });
593
616
    // We wire up our state to position updates from the hal.
594
617
    hal->position_updates().connect([&state](const location::Position& pos)
595
618
    {
596
 
        the_harvester().report_position_update(location::Update<location::Position>
597
 
        {
598
 
            pos, location::Clock::now()
599
 
        });
 
619
        try
 
620
        {
 
621
            // This will throw if the env variable is not set.
 
622
            core::posix::this_process::env::get(enable_harvesting_key);
 
623
 
 
624
            the_harvester().report_position_update(location::Update<location::Position>
 
625
            {
 
626
                pos, location::Clock::now()
 
627
            });
 
628
        } catch(...)
 
629
        {
 
630
        }
600
631
 
601
632
        state.on_position_updated(pos);
602
633
    });