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

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: Added unit tests Created 7 years, 11 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
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
Ryan Sleevi 2013/01/17 01:57:56 nit: unnecessary newline
bengr (incorrect) 2013/01/18 02:12:00 Done.
12 class ClientHintsTest : public testing::Test {
13 protected:
14 ClientHintsTest() {}
15
16 virtual void SetUp() OVERRIDE {
17 client_hints_ = new ClientHints();
18 client_hints_->UpdateScreenInfo(1, 2, 100, 200, 2.5);
19 client_hints_->UpdateScreenInfo(1, 3, 50, 150, 1.567);
20 }
21
22 virtual void TearDown() OVERRIDE {
23 client_hints_ = NULL;
24 }
25
26 bool IsScreenInfoAvailable(int process_id, int render_view_id) {
27 return client_hints_->IsScreenInfoAvailable(process_id, render_view_id);
28 }
29
30 scoped_refptr<ClientHints> client_hints_;
31 };
32
33 TEST_F(ClientHintsTest, HintsAvailable) {
34 EXPECT_TRUE(IsScreenInfoAvailable(1,2));
35 EXPECT_TRUE(IsScreenInfoAvailable(1,3));
36 EXPECT_FALSE(IsScreenInfoAvailable(0,2));
37
38 }
39 TEST_F(ClientHintsTest, HintsWellFormatted) {
40 std::string hint = client_hints_->GetScreenInfoHints(1, 2);
41 std::string hint2 = client_hints_->GetScreenInfoHints(1, 3);
42 #if defined(OS_POSIX) || defined(USE_AURA)
43 EXPECT_EQ("vh=200, vw=100, dpr=2.5", hint);
44 EXPECT_EQ("vh=150, vw=50, dpr=1.57", hint2);
45 #else
46 EXPECT_EQ("vh=200, vw=100", hint);
47 EXPECT_EQ("vh=150, vw=50", hint2);
48 #endif
49 }
50
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698