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

Side by Side Diff: net/spdy/spdy_session_spdy3_unittest.cc

Issue 10185007: [net] Change order of RequestPriority to natural: higher > lower (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Removed left-over comment Created 8 years, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « net/spdy/spdy_session_spdy2_unittest.cc ('k') | net/spdy/spdy_stream.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/spdy/spdy_session.h" 5 #include "net/spdy/spdy_session.h"
6 6
7 #include "net/base/host_cache.h" 7 #include "net/base/host_cache.h"
8 #include "net/base/ip_endpoint.h" 8 #include "net/base/ip_endpoint.h"
9 #include "net/base/net_log_unittest.h" 9 #include "net/base/net_log_unittest.h"
10 #include "net/spdy/spdy_io_buffer.h" 10 #include "net/spdy/spdy_io_buffer.h"
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 private: 68 private:
69 CompletionCallback callback_; 69 CompletionCallback callback_;
70 }; 70 };
71 71
72 // Test the SpdyIOBuffer class. 72 // Test the SpdyIOBuffer class.
73 TEST_F(SpdySessionSpdy3Test, SpdyIOBuffer) { 73 TEST_F(SpdySessionSpdy3Test, SpdyIOBuffer) {
74 std::priority_queue<SpdyIOBuffer> queue_; 74 std::priority_queue<SpdyIOBuffer> queue_;
75 const size_t kQueueSize = 100; 75 const size_t kQueueSize = 100;
76 76
77 // Insert 100 items; pri 100 to 1. 77 // Insert items with random priority and increasing buffer size
78 for (size_t index = 0; index < kQueueSize; ++index) { 78 for (size_t index = 0; index < kQueueSize; ++index) {
79 SpdyIOBuffer buffer(new IOBuffer(), 0, kQueueSize - index, NULL); 79 queue_.push(SpdyIOBuffer(
80 queue_.push(buffer); 80 new IOBufferWithSize(index + 1),
81 index + 1,
82 static_cast<RequestPriority>(rand() % NUM_PRIORITIES),
83 NULL));
81 } 84 }
82 85
83 // Insert several priority 0 items last. 86 EXPECT_EQ(kQueueSize, queue_.size());
84 const size_t kNumDuplicates = 12;
85 IOBufferWithSize* buffers[kNumDuplicates];
86 for (size_t index = 0; index < kNumDuplicates; ++index) {
87 buffers[index] = new IOBufferWithSize(index+1);
88 queue_.push(SpdyIOBuffer(buffers[index], buffers[index]->size(), 0, NULL));
89 }
90 87
91 EXPECT_EQ(kQueueSize + kNumDuplicates, queue_.size()); 88 // Verify items come out with decreasing priority or FIFO order.
92 89 RequestPriority last_priority = NUM_PRIORITIES;
93 // Verify the P0 items come out in FIFO order. 90 size_t last_size = 0;
94 for (size_t index = 0; index < kNumDuplicates; ++index) { 91 for (size_t index = 0; index < kQueueSize; ++index) {
95 SpdyIOBuffer buffer = queue_.top(); 92 SpdyIOBuffer buffer = queue_.top();
96 EXPECT_EQ(0, buffer.priority()); 93 EXPECT_LE(buffer.priority(), last_priority);
97 EXPECT_EQ(index + 1, buffer.size()); 94 if (buffer.priority() < last_priority)
95 last_size = 0;
96 EXPECT_LT(last_size, buffer.size());
97 last_priority = buffer.priority();
98 last_size = buffer.size();
98 queue_.pop(); 99 queue_.pop();
99 } 100 }
100 101
101 int priority = 1; 102 EXPECT_EQ(0u, queue_.size());
102 while (queue_.size()) {
103 SpdyIOBuffer buffer = queue_.top();
104 EXPECT_EQ(priority++, buffer.priority());
105 queue_.pop();
106 }
107 } 103 }
108 104
109 TEST_F(SpdySessionSpdy3Test, GoAway) { 105 TEST_F(SpdySessionSpdy3Test, GoAway) {
110 SpdySessionDependencies session_deps; 106 SpdySessionDependencies session_deps;
111 session_deps.host_resolver->set_synchronous_mode(true); 107 session_deps.host_resolver->set_synchronous_mode(true);
112 108
113 MockConnect connect_data(SYNCHRONOUS, OK); 109 MockConnect connect_data(SYNCHRONOUS, OK);
114 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway()); 110 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway());
115 MockRead reads[] = { 111 MockRead reads[] = {
116 CreateMockRead(*goaway), 112 CreateMockRead(*goaway),
(...skipping 1080 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 &spdy_stream2, 1193 &spdy_stream2,
1198 BoundNetLog(), 1194 BoundNetLog(),
1199 callback1.callback())); 1195 callback1.callback()));
1200 1196
1201 EXPECT_EQ(spdy_stream2->send_window_size(), window_size); 1197 EXPECT_EQ(spdy_stream2->send_window_size(), window_size);
1202 spdy_stream2->Cancel(); 1198 spdy_stream2->Cancel();
1203 spdy_stream2 = NULL; 1199 spdy_stream2 = NULL;
1204 } 1200 }
1205 1201
1206 } // namespace net 1202 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/spdy_session_spdy2_unittest.cc ('k') | net/spdy/spdy_stream.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698