Index: net/url_request/url_request_http_job_unittest.cc |
diff --git a/net/url_request/url_request_http_job_unittest.cc b/net/url_request/url_request_http_job_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d3f4dc254ec952e21fa9346da71650c6349b5e5c |
--- /dev/null |
+++ b/net/url_request/url_request_http_job_unittest.cc |
@@ -0,0 +1,43 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
mmenke
2013/03/12 18:40:22
nit: 2013
akalin
2013/03/12 22:08:28
Done.
|
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "net/url_request/url_request_http_job.h" |
+ |
+#include "base/memory/ref_counted.h" |
+#include "net/http/http_transaction_unittest.h" |
+#include "net/url_request/url_request_test_util.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+namespace net { |
+ |
+// Make sure that URLRequestHttpJob passes on its priority updates to |
+// its transaction. |
+TEST(URLRequestHttpJob, Priority) { |
+ MockNetworkLayer network_layer; |
+ net::TestURLRequestContext context; |
+ context.set_http_transaction_factory(&network_layer); |
+ |
+ net::TestDelegate d; |
+ net::TestURLRequest req(GURL("http://www.example.com"), &d, &context, NULL); |
+ scoped_refptr<URLRequestHttpJob> job( |
+ static_cast<URLRequestHttpJob*>( |
+ URLRequestHttpJob::Factory(&req, NULL, "http"))); |
+ EXPECT_TRUE(!job->transaction_); |
mmenke
2013/03/12 18:40:22
EXPECT_FALSE(job->transaction_);?
akalin
2013/03/12 22:08:28
Done.
|
+ |
+ req.SetPriority(MEDIUM); |
+ // |req| doesn't know about |job|, so propagate the SetPriority call |
+ // manually. |
+ job->SetPriority(MEDIUM); |
+ |
+ job->Start(); |
+ EXPECT_TRUE(job->transaction_ != NULL); |
mmenke
2013/03/12 18:40:22
EXPECT_TRUE(job->transaction_);?
Think it's a lit
akalin
2013/03/12 22:08:28
I think I'm just paranoid of how various compilers
|
+ MockNetworkTransaction* transaction = |
+ static_cast<MockNetworkTransaction*>(job->transaction_.get()); |
+ EXPECT_EQ(MEDIUM, transaction->priority()); |
+ |
+ job->SetPriority(HIGHEST); |
+ EXPECT_EQ(HIGHEST, transaction->priority()); |
+} |
+ |
+} // namespace net |