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

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

Issue 24451003: Client Hints (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed final comments Created 7 years, 2 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 <locale.h>
8
9 #include "base/logging.h"
10 #include "testing/gtest/include/gtest/gtest.h"
11
12 class ClientHintsTest : public testing::Test {
13 public:
14 void UpdateScreenInfo(float pixel_ratio) {
15 client_hints_.UpdateScreenInfo(pixel_ratio);
16 };
17
18 protected:
19 ClientHints client_hints_;
20 };
21
22 TEST_F(ClientHintsTest, HintsWellFormatted) {
23 UpdateScreenInfo(1.567f);
24 std::string hint = client_hints_.GetDevicePixelRatioHeader();
25 EXPECT_EQ("1.57", hint);
26 }
27
28 TEST_F(ClientHintsTest, HintsWellFormattedWithNonEnLocale) {
29 setlocale(LC_ALL, "fr_FR.UTF-8");
Avi (use Gerrit) 2013/09/26 19:21:26 Nooooo. Please don't set a locale and fail to rese
30 UpdateScreenInfo(1.567f);
31 std::string hint = client_hints_.GetDevicePixelRatioHeader();
32 EXPECT_EQ("1.57", hint);
33 }
34
35 TEST_F(ClientHintsTest, HintsHaveNonbogusValues) {
36 UpdateScreenInfo(-1.567f);
37 std::string hint = client_hints_.GetDevicePixelRatioHeader();
38 EXPECT_EQ("", hint);
39
40 UpdateScreenInfo(1.567f);
41 hint = client_hints_.GetDevicePixelRatioHeader();
42 EXPECT_EQ("1.57", hint);
43
44 UpdateScreenInfo(0.0f);
45 hint = client_hints_.GetDevicePixelRatioHeader();
46 // Hints should be last known good values.
47 EXPECT_EQ("1.57", hint);
48 }
49
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