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

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: Removed entire locale test on Android and iOS 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 #if !defined(OS_ANDROID) && !defined(OS_IOS)
11 #include "base/test/scoped_locale.h"
12 #endif
13 #include "testing/gtest/include/gtest/gtest.h"
14
15 class ClientHintsTest : public testing::Test {
16 public:
17 void UpdateScreenInfo(float pixel_ratio) {
18 client_hints_.UpdateScreenInfo(pixel_ratio);
19 };
20
21 protected:
22 ClientHints client_hints_;
23 };
24
25 TEST_F(ClientHintsTest, HintsWellFormatted) {
26 UpdateScreenInfo(1.567f);
27 std::string hint = client_hints_.GetDevicePixelRatioHeader();
28 EXPECT_EQ("1.57", hint);
29 }
30
31 #if !defined(OS_ANDROID) && !defined(OS_IOS)
32 TEST_F(ClientHintsTest, HintsWellFormattedWithNonEnLocale) {
33 // Android and iOS do not support setLocal.
Avi (use Gerrit) 2013/09/30 18:16:16 Move the comment above the #if. And it's "setloca
bengr 2013/10/04 21:27:23 Done.
34 base::ScopedLocale locale("fr_FR.UTF-8");
35 UpdateScreenInfo(1.567f);
36 std::string hint = client_hints_.GetDevicePixelRatioHeader();
37 EXPECT_EQ("1.57", hint);
38 }
39 #endif // !defined(OS_ANDROID) && !defined(OS_IOS)
40
41 TEST_F(ClientHintsTest, HintsHaveNonbogusValues) {
42 UpdateScreenInfo(-1.567f);
43 std::string hint = client_hints_.GetDevicePixelRatioHeader();
44 EXPECT_EQ("", hint);
45
46 UpdateScreenInfo(1.567f);
47 hint = client_hints_.GetDevicePixelRatioHeader();
48 EXPECT_EQ("1.57", hint);
49
50 UpdateScreenInfo(0.0f);
51 hint = client_hints_.GetDevicePixelRatioHeader();
52 // Hints should be last known good values.
53 EXPECT_EQ("1.57", hint);
54 }
55
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