summaryrefslogtreecommitdiff
path: root/common/http_fetcher_unittest.cc
diff options
context:
space:
mode:
Diffstat (limited to 'common/http_fetcher_unittest.cc')
-rw-r--r--common/http_fetcher_unittest.cc23
1 files changed, 19 insertions, 4 deletions
diff --git a/common/http_fetcher_unittest.cc b/common/http_fetcher_unittest.cc
index 237ea209..99ea99bd 100644
--- a/common/http_fetcher_unittest.cc
+++ b/common/http_fetcher_unittest.cc
@@ -28,15 +28,25 @@
#include <base/bind.h>
#include <base/location.h>
#include <base/logging.h>
+#if BASE_VER < 780000 // Android
#include <base/message_loop/message_loop.h>
+#endif // BASE_VER < 780000
+#include <base/stl_util.h>
#include <base/strings/string_number_conversions.h>
#include <base/strings/string_util.h>
#include <base/strings/stringprintf.h>
+#if BASE_VER >= 780000 // CrOS
+#include <base/task/single_thread_task_executor.h>
+#endif // BASE_VER >= 780000
#include <base/time/time.h>
#include <brillo/message_loops/base_message_loop.h>
#include <brillo/message_loops/message_loop.h>
#include <brillo/message_loops/message_loop_utils.h>
+#ifdef __CHROMEOS__
+#include <brillo/process/process.h>
+#else
#include <brillo/process.h>
+#endif // __CHROMEOS__
#include <brillo/streams/file_stream.h>
#include <brillo/streams/stream.h>
#include <gtest/gtest.h>
@@ -359,7 +369,7 @@ class FileFetcherTest : public AnyHttpFetcherTest {
HttpServer* CreateServer() override { return new NullHttpServer; }
private:
- test_utils::ScopedTempFile temp_file_{"ue_file_fetcher.XXXXXX"};
+ ScopedTempFile temp_file_{"ue_file_fetcher.XXXXXX"};
};
class MultiRangeHttpFetcherOverFileFetcherTest : public FileFetcherTest {
@@ -398,8 +408,13 @@ class MultiRangeHttpFetcherOverFileFetcherTest : public FileFetcherTest {
template <typename T>
class HttpFetcherTest : public ::testing::Test {
public:
+#if BASE_VER < 780000 // Android
base::MessageLoopForIO base_loop_;
brillo::BaseMessageLoop loop_{&base_loop_};
+#else // Chrome OS
+ base::SingleThreadTaskExecutor base_loop_{base::MessagePumpType::IO};
+ brillo::BaseMessageLoop loop_{base_loop_.task_runner()};
+#endif // BASE_VER < 780000
T test_;
@@ -1049,7 +1064,7 @@ TYPED_TEST(HttpFetcherTest, SimpleRedirectTest) {
unique_ptr<HttpServer> server(this->test_.CreateServer());
ASSERT_TRUE(server->started_);
- for (size_t c = 0; c < arraysize(kRedirectCodes); ++c) {
+ for (size_t c = 0; c < base::size(kRedirectCodes); ++c) {
const string url = base::StringPrintf(
"/redirect/%d/download/%d", kRedirectCodes[c], kMediumLength);
RedirectTest(server.get(), true, url, this->test_.NewLargeFetcher());
@@ -1066,7 +1081,7 @@ TYPED_TEST(HttpFetcherTest, MaxRedirectTest) {
string url;
for (int r = 0; r < kDownloadMaxRedirects; r++) {
url += base::StringPrintf("/redirect/%d",
- kRedirectCodes[r % arraysize(kRedirectCodes)]);
+ kRedirectCodes[r % base::size(kRedirectCodes)]);
}
url += base::StringPrintf("/download/%d", kMediumLength);
RedirectTest(server.get(), true, url, this->test_.NewLargeFetcher());
@@ -1082,7 +1097,7 @@ TYPED_TEST(HttpFetcherTest, BeyondMaxRedirectTest) {
string url;
for (int r = 0; r < kDownloadMaxRedirects + 1; r++) {
url += base::StringPrintf("/redirect/%d",
- kRedirectCodes[r % arraysize(kRedirectCodes)]);
+ kRedirectCodes[r % base::size(kRedirectCodes)]);
}
url += base::StringPrintf("/download/%d", kMediumLength);
RedirectTest(server.get(), false, url, this->test_.NewLargeFetcher());