1 // Copyright 2014 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.
6 #include "core/fetch/ClientHintsPreferences.h"
8 #include <gtest/gtest.h>
12 class ClientHintsPreferencesTest
: public ::testing::Test
{
15 TEST_F(ClientHintsPreferencesTest
, Basic
)
18 const char* headerValue
;
19 bool expectationResourceWidth
;
21 bool expectationViewportWidth
;
23 {"width, dpr, viewportWidth", true, true, false},
24 {"WiDtH, dPr, viewport-width", true, true, true},
25 {"WIDTH, DPR, VIWEPROT-Width", true, true, false},
26 {"VIewporT-Width, wutwut, width", true, false, true},
27 {"dprw", false, false, false},
28 {"DPRW", false, false, false},
31 for (const auto& testCase
: cases
) {
32 ClientHintsPreferences preferences
;
33 const char* value
= testCase
.headerValue
;
35 preferences
.updateFromAcceptClientHintsHeader(value
, nullptr);
36 EXPECT_EQ(testCase
.expectationResourceWidth
, preferences
.shouldSendResourceWidth());
37 EXPECT_EQ(testCase
.expectationDPR
, preferences
.shouldSendDPR());
38 EXPECT_EQ(testCase
.expectationViewportWidth
, preferences
.shouldSendViewportWidth());