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

Side by Side Diff: chrome/browser/net/client_hints_unittest.cc

Issue 23654014: Updated Client-Hints patch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed issues raised in review by mmenke and bengr Created 7 years, 3 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 | « chrome/browser/net/client_hints.cc ('k') | chrome/browser/profiles/profile_io_data.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2013 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 "chrome/browser/net/client_hints.h"
6
7 #include "base/logging.h"
8 #include "base/memory/scoped_ptr.h"
9 #include "testing/gtest/include/gtest/gtest.h"
10
11 class ClientHintsTest : public testing::Test {
12 public:
13 void UpdateScreenInfo(float pixel_ratio) {
14 client_hints_.UpdateScreenInfo(&pixel_ratio);
15 };
16
17 protected:
18 ClientHints client_hints_;
19 };
20
21 TEST_F(ClientHintsTest, HintsWellFormatted) {
22 UpdateScreenInfo(1.567f);
23 std::string hint = client_hints_.GetString();
24 EXPECT_EQ("dpr=1.57", hint);
25 }
26
27 TEST_F(ClientHintsTest, HintsWellFormattedWithNonEnLocale) {
28 std::setlocale(LC_ALL, "fr_FR.UTF-8");
29 UpdateScreenInfo(1.567f);
30 std::string hint = client_hints_.GetString();
31 EXPECT_EQ("dpr=1.57", hint);
32 }
33
34 TEST_F(ClientHintsTest, HintsHaveNonbogusValues) {
35 UpdateScreenInfo(-1.567f);
36 std::string hint = client_hints_.GetString();
37 EXPECT_EQ("", hint);
38
39 UpdateScreenInfo(1.567f);
40 hint = client_hints_.GetString();
41 EXPECT_EQ("dpr=1.57", hint);
42
43 UpdateScreenInfo(0.0f);
44 hint = client_hints_.GetString();
45 // Hints should be last known good values.
46 EXPECT_EQ("dpr=1.57", hint);
47 }
48
OLDNEW
« no previous file with comments | « chrome/browser/net/client_hints.cc ('k') | chrome/browser/profiles/profile_io_data.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698