| 27 | namespace |
| 28 | { |
| 29 | void TransferLocation(Reporter & reporter, TestSocket & testSocket, double timestamp, double latidute, |
| 30 | double longtitude) |
| 31 | { |
| 32 | location::GpsInfo gpsInfo; |
| 33 | gpsInfo.m_timestamp = timestamp; |
| 34 | gpsInfo.m_latitude = latidute; |
| 35 | gpsInfo.m_longitude = longtitude; |
| 36 | gpsInfo.m_horizontalAccuracy = 1.0; |
| 37 | reporter.AddLocation(gpsInfo, traffic::SpeedGroup::Unknown); |
| 38 | |
| 39 | using Packet = tracking::Protocol::PacketType; |
| 40 | vector<uint8_t> buffer; |
| 41 | size_t readSize = 0; |
| 42 | size_t attempts = 3; |
| 43 | do |
| 44 | { |
| 45 | readSize = testSocket.ReadServer(buffer); |
| 46 | if (attempts-- && readSize == 0) |
| 47 | continue; |
| 48 | switch (Packet(buffer[0])) |
| 49 | { |
| 50 | case Packet::CurrentAuth: |
| 51 | { |
| 52 | buffer.clear(); |
| 53 | testSocket.WriteServer(tracking::Protocol::kOk); |
| 54 | break; |
| 55 | } |
| 56 | case Packet::Error: |
| 57 | case Packet::DataV0: |
| 58 | case Packet::DataV1: |
| 59 | { |
| 60 | readSize = 0; |
| 61 | break; |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | while (readSize); |
| 66 | |
| 67 | TEST(!buffer.empty(), ()); |
| 68 | vector<coding::TrafficGPSEncoder::DataPoint> points; |
| 69 | MemReader memReader(buffer.data(), buffer.size()); |
| 70 | ReaderSource<MemReader> src(memReader); |
| 71 | src.Skip(sizeof(uint32_t /* header */)); |
| 72 | coding::TrafficGPSEncoder::DeserializeDataPoints(coding::TrafficGPSEncoder::kLatestVersion, src, points); |
| 73 | |
| 74 | TEST_EQUAL(points.size(), 1, ()); |
| 75 | auto const & point = points[0]; |
| 76 | TEST_EQUAL(point.m_timestamp, timestamp, ()); |
| 77 | TEST(AlmostEqualAbs(point.m_latLon.m_lat, latidute, 0.001), ()); |
| 78 | TEST(AlmostEqualAbs(point.m_latLon.m_lon, longtitude, 0.001), ()); |
| 79 | } |
| 80 | } // namespace |
| 81 | |
| 82 | UNIT_TEST(Reporter_Smoke) |
no test coverage detected