Fix P2PDownloadActionTest.

DownloadAction is now always using MultiRangeHttpFetcher, so had to
implement MultiRangeHttpFetcher::SetOffset() for unittest.

Bug: 73949420
Test: tests pass

Change-Id: I4ced2431e6a649402a318d601c384e998ef96b47
diff --git a/common/multi_range_http_fetcher.cc b/common/multi_range_http_fetcher.cc
index e696c36..1189fde 100644
--- a/common/multi_range_http_fetcher.cc
+++ b/common/multi_range_http_fetcher.cc
@@ -188,4 +188,27 @@
   return range_str;
 }
 
+void MultiRangeHttpFetcher::SetOffset(off_t offset) {
+  current_index_ = 0;
+  for (const Range& range : ranges_) {
+    if (!range.HasLength() || static_cast<size_t>(offset) < range.length()) {
+      bytes_received_this_range_ = offset;
+
+      base_fetcher_->SetOffset(range.offset() + offset);
+      if (range.HasLength())
+        base_fetcher_->SetLength(range.length());
+      else
+        base_fetcher_->UnsetLength();
+      if (delegate_)
+        delegate_->SeekToOffset(range.offset() + offset);
+      return;
+    }
+    current_index_++;
+    offset -= range.length();
+  }
+  if (offset > 0) {
+    LOG(ERROR) << "Offset too large.";
+  }
+}
+
 }  // namespace chromeos_update_engine
diff --git a/common/multi_range_http_fetcher.h b/common/multi_range_http_fetcher.h
index 8a91ead..54ddfbc 100644
--- a/common/multi_range_http_fetcher.h
+++ b/common/multi_range_http_fetcher.h
@@ -67,7 +67,7 @@
   }
 
   // HttpFetcher overrides.
-  void SetOffset(off_t offset) override {}  // for now, doesn't support this
+  void SetOffset(off_t offset) override;
 
   void SetLength(size_t length) override {}  // unsupported
   void UnsetLength() override {}
diff --git a/payload_consumer/download_action_unittest.cc b/payload_consumer/download_action_unittest.cc
index 21ce461..7ec7e0e 100644
--- a/payload_consumer/download_action_unittest.cc
+++ b/payload_consumer/download_action_unittest.cc
@@ -22,6 +22,7 @@
 #include <memory>
 #include <string>
 #include <utility>
+#include <vector>
 
 #include <base/bind.h>
 #include <base/files/file_path.h>
@@ -603,7 +604,7 @@
   // Callback used in StartDownload() method.
   void StartProcessorInRunLoopForP2P() {
     processor_.StartProcessing();
-    http_fetcher_->SetOffset(start_at_offset_);
+    download_action_->http_fetcher()->SetOffset(start_at_offset_);
   }
 
   // The requested starting offset passed to SetupDownload().