| OLD | NEW |
| (Empty) | |
| 1 // Copyright 2017 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 "core/timing/PerformanceResourceTiming.h" |
| 6 |
| 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 |
| 9 namespace blink { |
| 10 |
| 11 class PerformanceResourceTimingTest : public ::testing::Test { |
| 12 protected: |
| 13 AtomicString getNextHopProtocol( |
| 14 const AtomicString& alpnNegotiatedProtocol, |
| 15 const AtomicString& connectionInfo) { |
| 16 return PerformanceResourceTiming::getNextHopProtocol( |
| 17 alpnNegotiatedProtocol, connectionInfo); |
| 18 } |
| 19 }; |
| 20 |
| 21 TEST_F(PerformanceResourceTimingTest, |
| 22 TestFallbackToConnectionInfoWhenALPNUnknown) { |
| 23 AtomicString connectionInfo = "http/1.1"; |
| 24 AtomicString alpnNegotiatedProtocol = "unknown"; |
| 25 EXPECT_EQ(getNextHopProtocol(alpnNegotiatedProtocol, connectionInfo), |
| 26 connectionInfo); |
| 27 } |
| 28 |
| 29 TEST_F(PerformanceResourceTimingTest, |
| 30 TestFallbackToHTTPInfoWhenALPNAndConnectionInfoUnknown) { |
| 31 AtomicString connectionInfo = "unknown"; |
| 32 AtomicString alpnNegotiatedProtocol = "unknown"; |
| 33 EXPECT_EQ(getNextHopProtocol(alpnNegotiatedProtocol, connectionInfo), |
| 34 "http/1.1"); |
| 35 } |
| 36 |
| 37 TEST_F(PerformanceResourceTimingTest, TestFallbackToHQWhenContainsQuic) { |
| 38 AtomicString connectionInfo = "http/1.1"; |
| 39 AtomicString alpnNegotiatedProtocol = "quic/1+spdy/3"; |
| 40 EXPECT_EQ(getNextHopProtocol(alpnNegotiatedProtocol, connectionInfo), |
| 41 "hq"); |
| 42 } |
| 43 |
| 44 TEST_F(PerformanceResourceTimingTest, TestNoChangeWhenOtherwise) { |
| 45 AtomicString connectionInfo = "http/1.1"; |
| 46 AtomicString alpnNegotiatedProtocol = "RandomProtocol"; |
| 47 EXPECT_EQ(getNextHopProtocol(alpnNegotiatedProtocol, connectionInfo), |
| 48 alpnNegotiatedProtocol); |
| 49 } |
| 50 } |
| OLD | NEW |