Chromium Code Reviews| OLD | NEW |
|---|---|
| (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 }; | |
|
mmenke
2013/02/27 21:06:05
nit: Add line break.
bengr
2013/03/06 00:34:19
Done.
| |
| 20 protected: | |
| 21 ClientHints client_hints_; | |
| 22 }; | |
| 23 | |
| 24 TEST_F(ClientHintsTest, HintsWellFormatted) { | |
| 25 UpdateScreenInfo(100, 200, 1.567); | |
| 26 std::string hint = client_hints_.GetScreenInfoHints(); | |
| 27 EXPECT_EQ("dh=200, dw=100, dpr=1.57", hint); | |
| 28 } | |
| 29 | |
| 30 TEST_F(ClientHintsTest, HintsHaveNonbogusValues) { | |
| 31 UpdateScreenInfo(-100, -200, -1.567); | |
| 32 std::string hint = client_hints_.GetScreenInfoHints(); | |
| 33 EXPECT_EQ("", hint); | |
| 34 | |
| 35 UpdateScreenInfo(100, 200, 1.567); | |
| 36 hint = client_hints_.GetScreenInfoHints(); | |
| 37 EXPECT_EQ("dh=200, dw=100, dpr=1.57", hint); | |
| 38 | |
| 39 UpdateScreenInfo(100, 200, 0.0); | |
| 40 hint = client_hints_.GetScreenInfoHints(); | |
| 41 // Hints should be last known good values. | |
| 42 EXPECT_EQ("dh=200, dw=100, dpr=1.57", hint); | |
| 43 | |
|
mmenke
2013/02/27 21:06:05
nit: Remove blank line.
bengr
2013/03/06 00:34:19
Done.
| |
| 44 } | |
| 45 | |
| OLD | NEW |