OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "net/url_request/url_request_http_job.h" | 5 #include "net/url_request/url_request_http_job.h" |
6 | 6 |
7 #include <cstddef> | 7 #include <cstddef> |
8 | 8 |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 job->SetPriority(MEDIUM); | 68 job->SetPriority(MEDIUM); |
69 EXPECT_EQ(MEDIUM, job->priority()); | 69 EXPECT_EQ(MEDIUM, job->priority()); |
70 } | 70 } |
71 | 71 |
72 // Make sure that URLRequestHttpJob passes on its priority to its | 72 // Make sure that URLRequestHttpJob passes on its priority to its |
73 // transaction on start. | 73 // transaction on start. |
74 TEST_F(URLRequestHttpJobTest, SetTransactionPriorityOnStart) { | 74 TEST_F(URLRequestHttpJobTest, SetTransactionPriorityOnStart) { |
75 scoped_refptr<TestURLRequestHttpJob> job(new TestURLRequestHttpJob(&req_)); | 75 scoped_refptr<TestURLRequestHttpJob> job(new TestURLRequestHttpJob(&req_)); |
76 job->SetPriority(LOW); | 76 job->SetPriority(LOW); |
77 | 77 |
78 EXPECT_FALSE(network_layer_.last_transaction()); | 78 EXPECT_FALSE(network_layer_.last_transaction().get()); |
79 | 79 |
80 job->Start(); | 80 job->Start(); |
81 | 81 |
82 ASSERT_TRUE(network_layer_.last_transaction()); | 82 ASSERT_TRUE(network_layer_.last_transaction().get()); |
83 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); | 83 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); |
84 } | 84 } |
85 | 85 |
86 // Make sure that URLRequestHttpJob passes on its priority updates to | 86 // Make sure that URLRequestHttpJob passes on its priority updates to |
87 // its transaction. | 87 // its transaction. |
88 TEST_F(URLRequestHttpJobTest, SetTransactionPriority) { | 88 TEST_F(URLRequestHttpJobTest, SetTransactionPriority) { |
89 scoped_refptr<TestURLRequestHttpJob> job(new TestURLRequestHttpJob(&req_)); | 89 scoped_refptr<TestURLRequestHttpJob> job(new TestURLRequestHttpJob(&req_)); |
90 job->SetPriority(LOW); | 90 job->SetPriority(LOW); |
91 job->Start(); | 91 job->Start(); |
92 ASSERT_TRUE(network_layer_.last_transaction()); | 92 ASSERT_TRUE(network_layer_.last_transaction().get()); |
93 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); | 93 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); |
94 | 94 |
95 job->SetPriority(HIGHEST); | 95 job->SetPriority(HIGHEST); |
96 EXPECT_EQ(HIGHEST, network_layer_.last_transaction()->priority()); | 96 EXPECT_EQ(HIGHEST, network_layer_.last_transaction()->priority()); |
97 } | 97 } |
98 | 98 |
99 // Make sure that URLRequestHttpJob passes on its priority updates to | 99 // Make sure that URLRequestHttpJob passes on its priority updates to |
100 // newly-created transactions after the first one. | 100 // newly-created transactions after the first one. |
101 TEST_F(URLRequestHttpJobTest, SetSubsequentTransactionPriority) { | 101 TEST_F(URLRequestHttpJobTest, SetSubsequentTransactionPriority) { |
102 scoped_refptr<TestURLRequestHttpJob> job(new TestURLRequestHttpJob(&req_)); | 102 scoped_refptr<TestURLRequestHttpJob> job(new TestURLRequestHttpJob(&req_)); |
103 job->Start(); | 103 job->Start(); |
104 | 104 |
105 job->SetPriority(LOW); | 105 job->SetPriority(LOW); |
106 ASSERT_TRUE(network_layer_.last_transaction()); | 106 ASSERT_TRUE(network_layer_.last_transaction().get()); |
107 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); | 107 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); |
108 | 108 |
109 job->Kill(); | 109 job->Kill(); |
110 network_layer_.ClearLastTransaction(); | 110 network_layer_.ClearLastTransaction(); |
111 | 111 |
112 // Creates a second transaction. | 112 // Creates a second transaction. |
113 job->Start(); | 113 job->Start(); |
114 ASSERT_TRUE(network_layer_.last_transaction()); | 114 ASSERT_TRUE(network_layer_.last_transaction().get()); |
115 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); | 115 EXPECT_EQ(LOW, network_layer_.last_transaction()->priority()); |
116 } | 116 } |
117 | 117 |
118 } // namespace | 118 } // namespace |
119 | 119 |
120 } // namespace net | 120 } // namespace net |
OLD | NEW |