Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(302)

Unified Diff: http_fetcher_unittest.cc

Issue 4029002: AU: Don't use network on expensive connection types (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/update_engine.git
Patch Set: Created 10 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: http_fetcher_unittest.cc
diff --git a/http_fetcher_unittest.cc b/http_fetcher_unittest.cc
index 06cabacc15ce5f3a16d31741322361d3962f5d9f..bd167685c6bfa7d473460b273528961b36465fac 100644
--- a/http_fetcher_unittest.cc
+++ b/http_fetcher_unittest.cc
@@ -135,6 +135,7 @@ class HttpFetcherTest<LibcurlHttpFetcher> : public ::testing::Test {
// Speed up test execution.
ret->set_idle_seconds(1);
ret->set_retry_seconds(1);
+ ret->SetConnectionAsExpensive(false);
return ret;
}
HttpFetcher* NewSmallFetcher() {
@@ -696,4 +697,44 @@ TYPED_TEST(HttpFetcherTest, MultiHttpFetcherInsufficientTest) {
}
}
+namespace {
+class ExpensiveConnectionTestDelegate : public HttpFetcherDelegate {
+ public:
+ virtual void ReceivedBytes(HttpFetcher* fetcher,
+ const char* bytes, int length) {
+ ADD_FAILURE();
+ }
+ virtual void TransferComplete(HttpFetcher* fetcher, bool successful) {
+ EXPECT_FALSE(successful);
+ g_main_loop_quit(loop_);
+ }
+ GMainLoop* loop_;
+};
+
+} // namespace
+
+TYPED_TEST(HttpFetcherTest, ExpensiveConnectionTest) {
+ if (this->IsMock() || this->IsMulti())
+ return;
+ typename TestFixture::HttpServer server;
+
+ ASSERT_TRUE(server.started_);
+
+ GMainLoop* loop = g_main_loop_new(g_main_context_default(), FALSE);
+ ExpensiveConnectionTestDelegate delegate;
+ delegate.loop_ = loop;
+
+ scoped_ptr<HttpFetcher> fetcher(this->NewLargeFetcher());
+ dynamic_cast<LibcurlHttpFetcher*>(
+ fetcher.get())->SetConnectionAsExpensive(true);
+ fetcher->set_delegate(&delegate);
+
+ StartTransferArgs start_xfer_args =
+ { fetcher.get(), LocalServerUrlForPath(this->SmallUrl()) };
+
+ g_timeout_add(0, StartTransfer, &start_xfer_args);
+ g_main_loop_run(loop);
+ g_main_loop_unref(loop);
+}
+
} // namespace chromeos_update_engine

Powered by Google App Engine
This is Rietveld 408576698