replay: fix qcam download error (#22777)

* fix qcam download error

* test loading qlog/qcamera
pull/22696/head
Dean Lee 4 years ago committed by GitHub
parent 09858f7f6f
commit 79651b6c49
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      selfdrive/ui/replay/filereader.cc
  2. 2
      selfdrive/ui/replay/route.h
  3. 5
      selfdrive/ui/replay/tests/test_replay.cc

@ -52,7 +52,7 @@ std::string FileReader::download(const std::string &url, std::atomic<bool> *abor
std::ostringstream oss;
result.resize(remote_file_size);
oss.rdbuf()->pubsetbuf(result.data(), result.size());
int chunks = chunk_size_ > 0 ? std::min(1, (int)std::nearbyint(remote_file_size / (float)chunk_size_)) : 1;
int chunks = chunk_size_ > 0 ? std::max(1, (int)std::nearbyint(remote_file_size / (float)chunk_size_)) : 1;
if (httpMultiPartDownload(url, oss, chunks, remote_file_size, abort)) {
return result;
}

@ -28,7 +28,7 @@ public:
inline const QString &name() const { return route_.str; }
inline const RouteIdentifier &identifier() const { return route_; }
inline const std::map<int, SegmentFile> &segments() const { return segments_; }
inline const SegmentFile &at(int n) { return segments_.at(n); }
inline SegmentFile &at(int n) { return segments_.at(n); }
static RouteIdentifier parseRoute(const QString &str);
protected:

@ -57,9 +57,14 @@ TEST_CASE("FileReader") {
}
TEST_CASE("Segment") {
auto test_qlog = GENERATE(false, true);
Route demo_route(DEMO_ROUTE);
REQUIRE(demo_route.load());
REQUIRE(demo_route.segments().size() == 11);
if (test_qlog) {
demo_route.at(0).road_cam = "";
demo_route.at(0).rlog = "";
}
QEventLoop loop;
Segment segment(0, demo_route.at(0), false, false, false);

Loading…
Cancel
Save