Index: chrome/browser/net/client_hints_unittest.cc |
diff --git a/chrome/browser/net/client_hints_unittest.cc b/chrome/browser/net/client_hints_unittest.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..adc5b61221d5e1c552f263d99622744962e4dc43 |
--- /dev/null |
+++ b/chrome/browser/net/client_hints_unittest.cc |
@@ -0,0 +1,50 @@ |
+// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "chrome/browser/net/client_hints.h" |
+ |
+#include "base/logging.h" |
+#include "base/memory/scoped_ptr.h" |
+#include "testing/gtest/include/gtest/gtest.h" |
+ |
+ |
Ryan Sleevi
2013/01/17 01:57:56
nit: unnecessary newline
bengr (incorrect)
2013/01/18 02:12:00
Done.
|
+class ClientHintsTest : public testing::Test { |
+ protected: |
+ ClientHintsTest() {} |
+ |
+ virtual void SetUp() OVERRIDE { |
+ client_hints_ = new ClientHints(); |
+ client_hints_->UpdateScreenInfo(1, 2, 100, 200, 2.5); |
+ client_hints_->UpdateScreenInfo(1, 3, 50, 150, 1.567); |
+ } |
+ |
+ virtual void TearDown() OVERRIDE { |
+ client_hints_ = NULL; |
+ } |
+ |
+ bool IsScreenInfoAvailable(int process_id, int render_view_id) { |
+ return client_hints_->IsScreenInfoAvailable(process_id, render_view_id); |
+ } |
+ |
+ scoped_refptr<ClientHints> client_hints_; |
+}; |
+ |
+TEST_F(ClientHintsTest, HintsAvailable) { |
+ EXPECT_TRUE(IsScreenInfoAvailable(1,2)); |
+ EXPECT_TRUE(IsScreenInfoAvailable(1,3)); |
+ EXPECT_FALSE(IsScreenInfoAvailable(0,2)); |
+ |
+} |
+TEST_F(ClientHintsTest, HintsWellFormatted) { |
+ std::string hint = client_hints_->GetScreenInfoHints(1, 2); |
+ std::string hint2 = client_hints_->GetScreenInfoHints(1, 3); |
+#if defined(OS_POSIX) || defined(USE_AURA) |
+ EXPECT_EQ("vh=200, vw=100, dpr=2.5", hint); |
+ EXPECT_EQ("vh=150, vw=50, dpr=1.57", hint2); |
+#else |
+ EXPECT_EQ("vh=200, vw=100", hint); |
+ EXPECT_EQ("vh=150, vw=50", hint2); |
+#endif |
+} |
+ |