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

Unified Diff: content/browser/webui/web_ui_unittest.cc

Issue 8528011: Page zoom improvements (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: One last(?) tweak. Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/webui/web_ui_unittest.cc
===================================================================
--- content/browser/webui/web_ui_unittest.cc (revision 0)
+++ content/browser/webui/web_ui_unittest.cc (revision 0)
@@ -0,0 +1,74 @@
+// Copyright (c) 2011 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 "content/browser/webui/web_ui.h"
+
+#include "base/string16.h"
+#include "base/values.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+class TestWebUIMessageHandler : public WebUIMessageHandler {
+ public:
+ TestWebUIMessageHandler() {}
+ virtual ~TestWebUIMessageHandler() {}
+
+ protected:
+ virtual void RegisterMessages() {}
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(TestWebUIMessageHandler);
+};
+
+TEST(WebUIMessageHandlerTest, ExtractIntegerValue) {
+ TestWebUIMessageHandler handler;
+
+ ListValue list;
+ int value, zero_value = 0, neg_value = -1234, pos_value = 1234;
+
+ list.Append(Value::CreateIntegerValue(zero_value));
+ EXPECT_TRUE(handler.ExtractIntegerValue(&list, &value));
+ EXPECT_EQ(value, zero_value);
+ list.Clear();
+
+ list.Append(Value::CreateIntegerValue(neg_value));
+ EXPECT_TRUE(handler.ExtractIntegerValue(&list, &value));
+ EXPECT_EQ(value, neg_value);
+ list.Clear();
+
+ list.Append(Value::CreateIntegerValue(pos_value));
+ EXPECT_TRUE(handler.ExtractIntegerValue(&list, &value));
+ EXPECT_EQ(value, pos_value);
+}
+
+TEST(WebUIMessageHandlerTest, ExtractDoubleValue) {
+ TestWebUIMessageHandler handler;
+
+ ListValue list;
+ double value, zero_value = 0.0, neg_value = -1234.5, pos_value = 1234.5;
+
+ list.Append(Value::CreateDoubleValue(zero_value));
+ EXPECT_TRUE(handler.ExtractDoubleValue(&list, &value));
+ EXPECT_EQ(value, zero_value);
+ list.Clear();
+
+ list.Append(Value::CreateDoubleValue(neg_value));
+ EXPECT_TRUE(handler.ExtractDoubleValue(&list, &value));
+ EXPECT_EQ(value, neg_value);
+ list.Clear();
+
+ list.Append(Value::CreateDoubleValue(pos_value));
+ EXPECT_TRUE(handler.ExtractDoubleValue(&list, &value));
+ EXPECT_EQ(value, pos_value);
+}
+
+TEST(WebUIMessageHandlerTest, ExtractStringValue) {
+ TestWebUIMessageHandler handler;
+
+ ListValue list;
+ string16 in_string = "The facts, though interesting, are irrelevant."
+ list.Append(Value::CreateStringValue(string));
+ string16 out_string = handler.ExtractStringValue(&list);
+ EXPECT_STREQ(in_string.c_str(), out_string.c_str());
+}
+
Property changes on: content/browser/webui/web_ui_unittest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF

Powered by Google App Engine
This is Rietveld 408576698