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

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

Issue 1779733003: Fix bug in net::RequestPriority -> HTTP/2 dependency conversion. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Make bi-directional stream unittests enable priority->dependency setting. Created 4 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 unified diff | Download patch
« no previous file with comments | « net/spdy/http2_priority_dependencies.cc ('k') | net/spdy/spdy_http_stream_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "net/spdy/http2_priority_dependencies.h"
6
7 #include "testing/platform_test.h"
8
9 namespace net {
10
11 class HttpPriorityDependencyTest : public PlatformTest {
12 public:
13 HttpPriorityDependencyTest() : next_id_(0u) {}
14
15 // Fixed priority values to use for testing.
16 enum { HIGHEST = 0, MEDIUM = 2, LOW = 4, LOWEST = 5 };
17
18 SpdyStreamId GetId() { return ++next_id_; }
19
20 void TestStreamCreation(SpdyStreamId new_id,
21 SpdyPriority priority,
22 SpdyStreamId expected_dependent_id) {
23 SpdyStreamId dependent_id = 999u;
24 bool exclusive = false;
25 dependency_state.OnStreamSynSent(new_id, priority, &dependent_id,
26 &exclusive);
27 EXPECT_EQ(expected_dependent_id, dependent_id);
28 EXPECT_TRUE(exclusive);
29 }
30
31 void OnStreamDestruction(SpdyStreamId id) {
32 dependency_state.OnStreamDestruction(id);
33 }
34
35 private:
36 SpdyStreamId next_id_;
37 Http2PriorityDependencies dependency_state;
38 };
39
40 // Confirm dependencies correct for entries at the same priority.
41 TEST_F(HttpPriorityDependencyTest, SamePriority) {
42 Http2PriorityDependencies dependency_state;
43
44 const SpdyStreamId first_id = GetId();
45 const SpdyStreamId second_id = GetId();
46 const SpdyStreamId third_id = GetId();
47
48 TestStreamCreation(first_id, MEDIUM, 0u);
49 TestStreamCreation(second_id, MEDIUM, first_id);
50 TestStreamCreation(third_id, MEDIUM, second_id);
51 }
52
53 // Confirm dependencies correct for entries at different priorities, increasing.
54 TEST_F(HttpPriorityDependencyTest, DifferentPriorityIncreasing) {
55 Http2PriorityDependencies dependency_state;
56
57 const SpdyStreamId first_id = GetId();
58 const SpdyStreamId second_id = GetId();
59 const SpdyStreamId third_id = GetId();
60
61 TestStreamCreation(first_id, LOWEST, 0u);
62 TestStreamCreation(second_id, MEDIUM, 0u);
63 TestStreamCreation(third_id, HIGHEST, 0u);
64 }
65
66 // Confirm dependencies correct for entries at different priorities, increasing.
67 TEST_F(HttpPriorityDependencyTest, DifferentPriorityDecreasing) {
68 Http2PriorityDependencies dependency_state;
69
70 const SpdyStreamId first_id = GetId();
71 const SpdyStreamId second_id = GetId();
72 const SpdyStreamId third_id = GetId();
73
74 TestStreamCreation(first_id, HIGHEST, 0u);
75 TestStreamCreation(second_id, MEDIUM, first_id);
76 TestStreamCreation(third_id, LOWEST, second_id);
77 }
78
79 // Confirm dependencies correct if requests are completed between before
80 // next creation.
81 TEST_F(HttpPriorityDependencyTest, CompletionBeforeIssue) {
82 Http2PriorityDependencies dependency_state;
83
84 const SpdyStreamId first_id = GetId();
85 const SpdyStreamId second_id = GetId();
86 const SpdyStreamId third_id = GetId();
87
88 TestStreamCreation(first_id, HIGHEST, 0u);
89 OnStreamDestruction(first_id);
90 TestStreamCreation(second_id, MEDIUM, 0u);
91 OnStreamDestruction(second_id);
92 TestStreamCreation(third_id, LOWEST, 0u);
93 }
94
95 // Confirm dependencies correct if some requests are completed between before
96 // next creation.
97 TEST_F(HttpPriorityDependencyTest, SomeCompletions) {
98 Http2PriorityDependencies dependency_state;
99
100 const SpdyStreamId first_id = GetId();
101 const SpdyStreamId second_id = GetId();
102 const SpdyStreamId third_id = GetId();
103
104 TestStreamCreation(first_id, HIGHEST, 0u);
105 TestStreamCreation(second_id, MEDIUM, first_id);
106 OnStreamDestruction(second_id);
107 TestStreamCreation(third_id, LOWEST, first_id);
108 }
109
110 // A more complex example parallel to a simple web page.
111 TEST_F(HttpPriorityDependencyTest, Complex) {
112 Http2PriorityDependencies dependency_state;
113
114 const SpdyStreamId first_id = GetId();
115 const SpdyStreamId second_id = GetId();
116 const SpdyStreamId third_id = GetId();
117 const SpdyStreamId fourth_id = GetId();
118 const SpdyStreamId fifth_id = GetId();
119 const SpdyStreamId sixth_id = GetId();
120 const SpdyStreamId seventh_id = GetId();
121 const SpdyStreamId eighth_id = GetId();
122 const SpdyStreamId nineth_id = GetId();
123 const SpdyStreamId tenth_id = GetId();
124
125 TestStreamCreation(first_id, HIGHEST, 0u);
126 TestStreamCreation(second_id, MEDIUM, first_id);
127 TestStreamCreation(third_id, MEDIUM, second_id);
128 OnStreamDestruction(first_id);
129 TestStreamCreation(fourth_id, MEDIUM, third_id);
130 TestStreamCreation(fifth_id, LOWEST, fourth_id);
131 TestStreamCreation(sixth_id, MEDIUM, fourth_id);
132 OnStreamDestruction(third_id);
133 TestStreamCreation(seventh_id, MEDIUM, sixth_id);
134 TestStreamCreation(eighth_id, LOW, seventh_id);
135 OnStreamDestruction(second_id);
136 OnStreamDestruction(fourth_id);
137 OnStreamDestruction(fifth_id);
138 OnStreamDestruction(sixth_id);
139 OnStreamDestruction(seventh_id);
140 TestStreamCreation(nineth_id, MEDIUM, 0u);
141 TestStreamCreation(tenth_id, HIGHEST, 0u);
142 }
143
144 } // namespace net
OLDNEW
« no previous file with comments | « net/spdy/http2_priority_dependencies.cc ('k') | net/spdy/spdy_http_stream_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698