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

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: Address comments 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..76901ca43ae3fb22a20e2366adf3f59cb6f71305
--- /dev/null
+++ b/net/http/http_cache_transaction_unittest.cc
@@ -0,0 +1,54 @@
+// 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/http/http_cache.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:
+ typedef HttpCache::Transaction HttpCacheTransaction;
+
+ scoped_ptr<HttpCacheTransaction> MakeCacheTransaction() {
+ scoped_ptr<HttpTransaction> trans;
+ int rv = cache_.http_cache()->CreateTransaction(&trans, NULL);
+ EXPECT_EQ(OK, rv);
+ return scoped_ptr<HttpCacheTransaction>(
+ static_cast<HttpCacheTransaction*>(trans.release()));
+ }
+
+ MockNetworkTransaction* InjectMockTransaction(
+ HttpCacheTransaction* cache_trans) {
+ MockNetworkTransaction* mock_trans = new MockNetworkTransaction(&network_);
+ cache_trans->network_trans_.reset(mock_trans);
+ return mock_trans;
+ }
+
+ MockNetworkLayer network_;
+ MockHttpCache cache_;
+};
+
+// Make sure that calling HttpCache::Transaction passes on its
+// priority updates to its underlying network transaction.
+TEST_F(HttpCacheTransactionTest, SetPriority) {
mmenke 2013/03/13 15:24:38 I believe the HttpCache unittests have all the nec
akalin 2013/03/13 16:06:45 I can't see how; the name HttpCache::Transaction i
mmenke 2013/03/13 16:16:11 They create the MockTransaction before the HttpCac
mmenke 2013/03/13 16:27:28 The same thing I suggested in the other case will
akalin 2013/03/13 16:57:14 Okay that works. Since more than one thing now wan
+ scoped_ptr<HttpCacheTransaction> trans = MakeCacheTransaction();
+
+ trans->SetPriority(LOW);
+
+ MockNetworkTransaction* mock_trans = InjectMockTransaction(trans.get());
+
+ EXPECT_EQ(IDLE, mock_trans->priority());
+
+ trans->SetPriority(MEDIUM);
+
+ EXPECT_EQ(MEDIUM, mock_trans->priority());
+}
+
+} // namespace net
+

Powered by Google App Engine
This is Rietveld 408576698