Welcome to mirror list, hosted at ThFree Co, Russian Federation.

yandex_tests.cpp « partners_api_tests « partners_api - github.com/mapsme/omim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 1152fb9af28dac9c04a5235d9928eed8e03fda4b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include "testing/testing.hpp"

#include "partners_api/yandex_api.hpp"

#include "geometry/latlon.hpp"

#include "platform/platform.hpp"

namespace
{
UNIT_TEST(Yandex_GetTaxiInfo)
{
  ms::LatLon const from(55.796918, 37.537859);
  ms::LatLon const to(55.758213, 37.616093);
  string result;

  taxi::yandex::RawApi::GetTaxiInfo(from, to, result);

  TEST(!result.empty(), ());
}

UNIT_TEST(Yandex_GetAvailableProducts)
{
  taxi::yandex::Api api("http://localhost:34568/partners");
  ms::LatLon const from(55.796918, 37.537859);
  ms::LatLon const to(55.758213, 37.616093);

  std::vector<taxi::Product> resultProducts;

  api.GetAvailableProducts(from, to,
                           [&resultProducts](std::vector<taxi::Product> const & products) {
                             resultProducts = products;
                             GetPlatform().RunOnGuiThread([] { testing::StopEventLoop(); });
                           },
                           [](taxi::ErrorCode const code) {
                             TEST(false, (code));
                             GetPlatform().RunOnGuiThread([] { testing::StopEventLoop(); });
                           });

  testing::RunEventLoop();

  TEST(!resultProducts.empty(), ());

  taxi::ErrorCode errorCode = taxi::ErrorCode::RemoteError;
  ms::LatLon const farPos(56.838197, 35.908507);
  api.GetAvailableProducts(from, farPos,
                           [](std::vector<taxi::Product> const & products) {
                             TEST(false, ());
                             GetPlatform().RunOnGuiThread([] { testing::StopEventLoop(); });
                           },
                           [&errorCode](taxi::ErrorCode const code) {
                             errorCode = code;
                             GetPlatform().RunOnGuiThread([] { testing::StopEventLoop(); });
                           });

  TEST_EQUAL(errorCode, taxi::ErrorCode::NoProducts, ());

  testing::RunEventLoop();
}
}  // namespace