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

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: 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
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 SpdyStreamId GetId() { return ++next_id_; }
16
17 void TestStreamCreation(SpdyStreamId new_id,
18 RequestPriority priority,
19 SpdyStreamId expected_dependent_id) {
20 SpdyStreamId dependent_id = 999u;
21 bool exclusive = false;
22 dependency_state.OnStreamSynSent(new_id, priority, &dependent_id,
23 &exclusive);
24 EXPECT_EQ(expected_dependent_id, dependent_id);
25 EXPECT_TRUE(exclusive);
26 }
27
28 void OnStreamDestruction(SpdyStreamId id) {
29 dependency_state.OnStreamDestruction(id);
30 }
31
32 private:
33 SpdyStreamId next_id_;
34 Http2PriorityDependencies dependency_state;
35 };
36
37 // Confirm dependencies correct for entries at the same priority.
38 TEST_F(HttpPriorityDependencyTest, SamePriority) {
39 Http2PriorityDependencies dependency_state;
40
41 const SpdyStreamId first_id = GetId();
42 const SpdyStreamId second_id = GetId();
43 const SpdyStreamId third_id = GetId();
44
45 TestStreamCreation(first_id, MEDIUM, 0u);
46 TestStreamCreation(second_id, MEDIUM, first_id);
47 TestStreamCreation(third_id, MEDIUM, second_id);
48 }
49
50 // Confirm dependencies correct for entries at different priorities, increasing.
51 TEST_F(HttpPriorityDependencyTest, DifferentPriorityIncreasing) {
52 Http2PriorityDependencies dependency_state;
53
54 const SpdyStreamId first_id = GetId();
55 const SpdyStreamId second_id = GetId();
56 const SpdyStreamId third_id = GetId();
57
58 TestStreamCreation(first_id, LOWEST, 0u);
59 TestStreamCreation(second_id, MEDIUM, 0u);
60 TestStreamCreation(third_id, HIGHEST, 0u);
61 }
62
63 // Confirm dependencies correct for entries at different priorities, increasing.
64 TEST_F(HttpPriorityDependencyTest, DifferentPriorityDecreasing) {
65 Http2PriorityDependencies dependency_state;
66
67 const SpdyStreamId first_id = GetId();
68 const SpdyStreamId second_id = GetId();
69 const SpdyStreamId third_id = GetId();
70
71 TestStreamCreation(first_id, HIGHEST, 0u);
72 TestStreamCreation(second_id, MEDIUM, first_id);
73 TestStreamCreation(third_id, LOWEST, second_id);
74 }
75
76 // Confirm dependencies correct if requests are completed between before
77 // next creation.
78 TEST_F(HttpPriorityDependencyTest, CompletionBeforeIssue) {
79 Http2PriorityDependencies dependency_state;
80
81 const SpdyStreamId first_id = GetId();
82 const SpdyStreamId second_id = GetId();
83 const SpdyStreamId third_id = GetId();
84
85 TestStreamCreation(first_id, HIGHEST, 0u);
86 OnStreamDestruction(first_id);
87 TestStreamCreation(second_id, MEDIUM, 0u);
88 OnStreamDestruction(second_id);
89 TestStreamCreation(third_id, LOWEST, 0u);
90 }
91
92 // Confirm dependencies correct if some requests are completed between before
93 // next creation.
94 TEST_F(HttpPriorityDependencyTest, SomeCompletions) {
95 Http2PriorityDependencies dependency_state;
96
97 const SpdyStreamId first_id = GetId();
98 const SpdyStreamId second_id = GetId();
99 const SpdyStreamId third_id = GetId();
100
101 TestStreamCreation(first_id, HIGHEST, 0u);
102 TestStreamCreation(second_id, MEDIUM, first_id);
103 OnStreamDestruction(second_id);
104 TestStreamCreation(third_id, LOWEST, first_id);
105 }
106
107 // A more complex example parallel to a simple web page.
108 TEST_F(HttpPriorityDependencyTest, Complex) {
109 Http2PriorityDependencies dependency_state;
110
111 const SpdyStreamId first_id = GetId();
112 const SpdyStreamId second_id = GetId();
113 const SpdyStreamId third_id = GetId();
114 const SpdyStreamId fourth_id = GetId();
115 const SpdyStreamId fifth_id = GetId();
116 const SpdyStreamId sixth_id = GetId();
117 const SpdyStreamId seventh_id = GetId();
118 const SpdyStreamId eighth_id = GetId();
119 const SpdyStreamId nineth_id = GetId();
120 const SpdyStreamId tenth_id = GetId();
121
122 TestStreamCreation(first_id, HIGHEST, 0u);
123 TestStreamCreation(second_id, MEDIUM, first_id);
124 TestStreamCreation(third_id, MEDIUM, second_id);
125 OnStreamDestruction(first_id);
126 TestStreamCreation(fourth_id, MEDIUM, third_id);
127 TestStreamCreation(fifth_id, LOWEST, fourth_id);
128 TestStreamCreation(sixth_id, MEDIUM, fourth_id);
129 OnStreamDestruction(third_id);
130 TestStreamCreation(seventh_id, MEDIUM, sixth_id);
131 TestStreamCreation(eighth_id, LOW, seventh_id);
132 OnStreamDestruction(second_id);
133 OnStreamDestruction(fourth_id);
134 OnStreamDestruction(fifth_id);
135 OnStreamDestruction(sixth_id);
136 OnStreamDestruction(seventh_id);
137 TestStreamCreation(nineth_id, MEDIUM, 0u);
138 TestStreamCreation(tenth_id, HIGHEST, 0u);
139 }
140
141 } // namespace net
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698