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

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

Issue 11970002: Added Client-Hints. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Made float literals explicit in tests Created 7 years, 9 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 (c) 2012 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(int width, int height, float pixel_ratio) {
14 ClientHints::ScreenInfo info;
15 info.width = width;
16 info.height = height;
17 info.pixel_ratio = pixel_ratio;
18 client_hints_.UpdateScreenInfo(&info);
19 };
20
21 protected:
22 ClientHints client_hints_;
23 };
24
25 TEST_F(ClientHintsTest, HintsWellFormatted) {
26 UpdateScreenInfo(100, 200, 1.567f);
27 std::string hint = client_hints_.GetScreenInfoHints();
28 EXPECT_EQ("dh=200, dw=100, dpr=1.57", hint);
29 }
30
31 TEST_F(ClientHintsTest, HintsHaveNonbogusValues) {
32 UpdateScreenInfo(-100, -200, -1.567f);
33 std::string hint = client_hints_.GetScreenInfoHints();
34 EXPECT_EQ("", hint);
35
36 UpdateScreenInfo(100, 200, 1.567f);
37 hint = client_hints_.GetScreenInfoHints();
38 EXPECT_EQ("dh=200, dw=100, dpr=1.57", hint);
39
40 UpdateScreenInfo(100, 200, 0.0f);
41 hint = client_hints_.GetScreenInfoHints();
42 // Hints should be last known good values.
43 EXPECT_EQ("dh=200, dw=100, dpr=1.57", hint);
44 }
45
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