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

Side by Side Diff: Source/core/fetch/ClientHintsPreferencesTest.cpp

Issue 1183233002: Split RW hint into Width and Viewport-Width (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed and added layout tests Created 5 years, 6 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
« no previous file with comments | « Source/core/fetch/ClientHintsPreferences.cpp ('k') | Source/core/frame/UseCounter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "config.h" 5 #include "config.h"
6 #include "core/fetch/ClientHintsPreferences.h" 6 #include "core/fetch/ClientHintsPreferences.h"
7 7
8 #include <gtest/gtest.h> 8 #include <gtest/gtest.h>
9 9
10 namespace blink { 10 namespace blink {
11 11
12 class ClientHintsPreferencesTest : public ::testing::Test { 12 class ClientHintsPreferencesTest : public ::testing::Test {
13 }; 13 };
14 14
15 TEST_F(ClientHintsPreferencesTest, Basic) 15 TEST_F(ClientHintsPreferencesTest, Basic)
16 { 16 {
17 struct TestCase { 17 struct TestCase {
18 const char* headerValue; 18 const char* headerValue;
19 bool expectationRW; 19 bool expectationResourceWidth;
20 bool expectationDPR; 20 bool expectationDPR;
21 bool expectationViewportWidth;
21 } cases[] = { 22 } cases[] = {
22 {"rw, dpr", true, true}, 23 {"width, dpr, viewportWidth", true, true, false},
23 {"Rw, dPr", true, true}, 24 {"WiDtH, dPr, viewport-width", true, true, true},
24 {"RW, DPR", true, true}, 25 {"WIDTH, DPR, VIWEPROT-Width", true, true, false},
25 {"dprw", false, false}, 26 {"VIewporT-Width, wutwut, width", true, false, true},
26 {"DPRW", false, false}, 27 {"dprw", false, false, false},
28 {"DPRW", false, false, false},
27 }; 29 };
28 30
29 for (auto testCase : cases) { 31 for (const auto& testCase : cases) {
30 ClientHintsPreferences preferences; 32 ClientHintsPreferences preferences;
31 const char* value = testCase.headerValue; 33 const char* value = testCase.headerValue;
32 bool expectationRW = testCase.expectationRW;
33 bool expectationDPR = testCase.expectationDPR;
34 34
35 handleAcceptClientHintsHeader(value, preferences); 35 handleAcceptClientHintsHeader(value, preferences);
36 EXPECT_EQ(expectationRW, preferences.shouldSendRW()); 36 EXPECT_EQ(testCase.expectationResourceWidth, preferences.shouldSendResou rceWidth());
37 EXPECT_EQ(expectationDPR, preferences.shouldSendDPR()); 37 EXPECT_EQ(testCase.expectationDPR, preferences.shouldSendDPR());
38 EXPECT_EQ(testCase.expectationViewportWidth, preferences.shouldSendViewp ortWidth());
38 } 39 }
39 } 40 }
40 41
41 } // namespace blink 42 } // namespace blink
OLDNEW
« no previous file with comments | « Source/core/fetch/ClientHintsPreferences.cpp ('k') | Source/core/frame/UseCounter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698