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

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: Use MINIMUM_PRIORITY instead of 0. 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
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 100 items; pri 0 to 99.
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 SpdyIOBuffer buffer(new IOBuffer(), 0, index, NULL);
80 queue_.push(buffer); 80 queue_.push(buffer);
81 } 81 }
82 82
83 // Insert several priority 0 items last. 83 // Insert several priority 100 items last.
84 const size_t kNumDuplicates = 12; 84 const size_t kNumDuplicates = 12;
85 IOBufferWithSize* buffers[kNumDuplicates]; 85 IOBufferWithSize* buffers[kNumDuplicates];
86 for (size_t index = 0; index < kNumDuplicates; ++index) { 86 for (size_t index = 0; index < kNumDuplicates; ++index) {
87 buffers[index] = new IOBufferWithSize(index+1); 87 buffers[index] = new IOBufferWithSize(index+1);
88 queue_.push(SpdyIOBuffer(buffers[index], buffers[index]->size(), 0, NULL)); 88 queue_.push(SpdyIOBuffer(buffers[index], buffers[index]->size(), 100,
89 NULL));
89 } 90 }
90 91
91 EXPECT_EQ(kQueueSize + kNumDuplicates, queue_.size()); 92 EXPECT_EQ(kQueueSize + kNumDuplicates, queue_.size());
92 93
93 // Verify the P0 items come out in FIFO order. 94 // Verify the P100 items come out in FIFO order.
94 for (size_t index = 0; index < kNumDuplicates; ++index) { 95 for (size_t index = 0; index < kNumDuplicates; ++index) {
95 SpdyIOBuffer buffer = queue_.top(); 96 SpdyIOBuffer buffer = queue_.top();
96 EXPECT_EQ(0, buffer.priority()); 97 EXPECT_EQ(100, buffer.priority());
97 EXPECT_EQ(index + 1, buffer.size()); 98 EXPECT_EQ(index + 1, buffer.size());
98 queue_.pop(); 99 queue_.pop();
99 } 100 }
100 101
101 int priority = 1; 102 int priority = 99;
102 while (queue_.size()) { 103 while (queue_.size()) {
103 SpdyIOBuffer buffer = queue_.top(); 104 SpdyIOBuffer buffer = queue_.top();
104 EXPECT_EQ(priority++, buffer.priority()); 105 EXPECT_EQ(priority--, buffer.priority());
105 queue_.pop(); 106 queue_.pop();
106 } 107 }
107 } 108 }
108 109
109 TEST_F(SpdySessionSpdy3Test, GoAway) { 110 TEST_F(SpdySessionSpdy3Test, GoAway) {
110 SpdySessionDependencies session_deps; 111 SpdySessionDependencies session_deps;
111 session_deps.host_resolver->set_synchronous_mode(true); 112 session_deps.host_resolver->set_synchronous_mode(true);
112 113
113 MockConnect connect_data(SYNCHRONOUS, OK); 114 MockConnect connect_data(SYNCHRONOUS, OK);
114 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway()); 115 scoped_ptr<SpdyFrame> goaway(ConstructSpdyGoAway());
(...skipping 1082 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 &spdy_stream2, 1198 &spdy_stream2,
1198 BoundNetLog(), 1199 BoundNetLog(),
1199 callback1.callback())); 1200 callback1.callback()));
1200 1201
1201 EXPECT_EQ(spdy_stream2->send_window_size(), window_size); 1202 EXPECT_EQ(spdy_stream2->send_window_size(), window_size);
1202 spdy_stream2->Cancel(); 1203 spdy_stream2->Cancel();
1203 spdy_stream2 = NULL; 1204 spdy_stream2 = NULL;
1204 } 1205 }
1205 1206
1206 } // namespace net 1207 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698