1 // Copyright 2019 The Chromium Authors
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/http/alternative_service.h"
6
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace net {
10 namespace {
11
TEST(AlternativeServicesTest,IsProtocolEnabledHttp11)12 TEST(AlternativeServicesTest, IsProtocolEnabledHttp11) {
13 EXPECT_TRUE(IsProtocolEnabled(kProtoHTTP11, /*is_http2_enabled=*/false,
14 /*is_quic_enabled=*/false));
15 EXPECT_TRUE(IsProtocolEnabled(kProtoHTTP11, /*is_http2_enabled=*/false,
16 /*is_quic_enabled=*/true));
17 EXPECT_TRUE(IsProtocolEnabled(kProtoHTTP11, /*is_http2_enabled=*/true,
18 /*is_quic_enabled=*/false));
19 EXPECT_TRUE(IsProtocolEnabled(kProtoHTTP11, /*is_http2_enabled=*/true,
20 /*is_quic_enabled=*/true));
21 }
22
TEST(AlternativeServicesTest,IsProtocolEnabledHttp2)23 TEST(AlternativeServicesTest, IsProtocolEnabledHttp2) {
24 EXPECT_FALSE(IsProtocolEnabled(kProtoHTTP2, /*is_http2_enabled=*/false,
25 /*is_quic_enabled=*/false));
26 EXPECT_FALSE(IsProtocolEnabled(kProtoHTTP2, /*is_http2_enabled=*/false,
27 /*is_quic_enabled=*/true));
28 EXPECT_TRUE(IsProtocolEnabled(kProtoHTTP2, /*is_http2_enabled=*/true,
29 /*is_quic_enabled=*/false));
30 EXPECT_TRUE(IsProtocolEnabled(kProtoHTTP2, /*is_http2_enabled=*/true,
31 /*is_quic_enabled=*/true));
32 }
33
TEST(AlternativeServicesTest,IsProtocolEnabledQuic)34 TEST(AlternativeServicesTest, IsProtocolEnabledQuic) {
35 EXPECT_FALSE(IsProtocolEnabled(kProtoQUIC, /*is_http2_enabled=*/false,
36 /*is_quic_enabled=*/false));
37 EXPECT_TRUE(IsProtocolEnabled(kProtoQUIC, /*is_http2_enabled=*/false,
38 /*is_quic_enabled=*/true));
39 EXPECT_FALSE(IsProtocolEnabled(kProtoQUIC, /*is_http2_enabled=*/true,
40 /*is_quic_enabled=*/false));
41 EXPECT_TRUE(IsProtocolEnabled(kProtoQUIC, /*is_http2_enabled=*/true,
42 /*is_quic_enabled=*/true));
43 }
44
45 } // namespace
46 } // namespace net
47