| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #include "core/fetch/ClientHintsPreferences.h" | |
| 6 | |
| 7 #include "testing/gtest/include/gtest/gtest.h" | |
| 8 | |
| 9 namespace blink { | |
| 10 | |
| 11 class ClientHintsPreferencesTest : public ::testing::Test {}; | |
| 12 | |
| 13 TEST_F(ClientHintsPreferencesTest, Basic) { | |
| 14 struct TestCase { | |
| 15 const char* headerValue; | |
| 16 bool expectationResourceWidth; | |
| 17 bool expectationDPR; | |
| 18 bool expectationViewportWidth; | |
| 19 } cases[] = { | |
| 20 {"width, dpr, viewportWidth", true, true, false}, | |
| 21 {"WiDtH, dPr, viewport-width", true, true, true}, | |
| 22 {"WIDTH, DPR, VIWEPROT-Width", true, true, false}, | |
| 23 {"VIewporT-Width, wutwut, width", true, false, true}, | |
| 24 {"dprw", false, false, false}, | |
| 25 {"DPRW", false, false, false}, | |
| 26 }; | |
| 27 | |
| 28 for (const auto& testCase : cases) { | |
| 29 ClientHintsPreferences preferences; | |
| 30 const char* value = testCase.headerValue; | |
| 31 | |
| 32 preferences.updateFromAcceptClientHintsHeader(value, nullptr); | |
| 33 EXPECT_EQ(testCase.expectationResourceWidth, | |
| 34 preferences.shouldSendResourceWidth()); | |
| 35 EXPECT_EQ(testCase.expectationDPR, preferences.shouldSendDPR()); | |
| 36 EXPECT_EQ(testCase.expectationViewportWidth, | |
| 37 preferences.shouldSendViewportWidth()); | |
| 38 } | |
| 39 } | |
| 40 | |
| 41 } // namespace blink | |
| OLD | NEW |