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

Unified Diff: net/http/http_cache_transaction_unittest.cc

Issue 12701011: [Net] Propagate priority changes from URLRequest to HttpTransaction (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add more tests Created 7 years, 9 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: net/http/http_cache_transaction_unittest.cc
diff --git a/net/http/http_cache_transaction_unittest.cc b/net/http/http_cache_transaction_unittest.cc
new file mode 100644
index 0000000000000000000000000000000000000000..40fde35d75f4cf7230580b4251ef780ff3f9c77b
--- /dev/null
+++ b/net/http/http_cache_transaction_unittest.cc
@@ -0,0 +1,43 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "net/http/http_cache_transaction.h"
+
+#include "net/base/test_completion_callback.h"
+#include "net/http/http_cache.h"
+#include "net/http/http_request_info.h"
+#include "net/http/http_transaction_unittest.h"
+#include "net/http/mock_http_cache.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace net {
+
+class HttpCacheTransactionTest : public ::testing::Test {
+ protected:
+ MockHttpCache cache_;
+};
+
+// Make sure that calling HttpCache::Transaction passes on its
+// priority updates to its underlying network transaction.
+TEST_F(HttpCacheTransactionTest, SetPriority) {
+ scoped_ptr<HttpTransaction> trans;
+ ASSERT_EQ(OK, cache_.http_cache()->CreateTransaction(&trans, NULL));
+
+ // Shouldn't crash.
+ trans->SetPriority(LOW);
+
+ HttpRequestInfo info;
+ info.priority = MEDIUM;
+ TestCompletionCallback callback;
+ trans->Start(&info, callback.callback(), BoundNetLog());
+
+ ASSERT_TRUE(cache_.network_layer()->last_transaction());
+ EXPECT_EQ(MEDIUM, cache_.network_layer()->last_transaction()->priority());
+
+ trans->SetPriority(HIGHEST);
+ EXPECT_EQ(HIGHEST, cache_.network_layer()->last_transaction()->priority());
+}
+
+} // namespace net
+

Powered by Google App Engine
This is Rietveld 408576698