OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/public/browser/web_ui_message_handler.h" | 5 #include "content/public/browser/web_ui_message_handler.h" |
6 | 6 |
7 #include "base/strings/string16.h" | 7 #include "base/strings/string16.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 | 11 |
12 namespace content { | 12 namespace content { |
13 | 13 |
14 TEST(WebUIMessageHandlerTest, ExtractIntegerValue) { | 14 TEST(WebUIMessageHandlerTest, ExtractIntegerValue) { |
15 ListValue list; | 15 base::ListValue list; |
16 int value, zero_value = 0, neg_value = -1234, pos_value = 1234; | 16 int value, zero_value = 0, neg_value = -1234, pos_value = 1234; |
17 base::string16 zero_string(UTF8ToUTF16("0")); | 17 base::string16 zero_string(UTF8ToUTF16("0")); |
18 base::string16 neg_string(UTF8ToUTF16("-1234")); | 18 base::string16 neg_string(UTF8ToUTF16("-1234")); |
19 base::string16 pos_string(UTF8ToUTF16("1234")); | 19 base::string16 pos_string(UTF8ToUTF16("1234")); |
20 | 20 |
21 list.Append(new base::FundamentalValue(zero_value)); | 21 list.Append(new base::FundamentalValue(zero_value)); |
22 EXPECT_TRUE(WebUIMessageHandler::ExtractIntegerValue(&list, &value)); | 22 EXPECT_TRUE(WebUIMessageHandler::ExtractIntegerValue(&list, &value)); |
23 EXPECT_EQ(value, zero_value); | 23 EXPECT_EQ(value, zero_value); |
24 list.Clear(); | 24 list.Clear(); |
25 | 25 |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 TEST(WebUIMessageHandlerTest, ExtractStringValue) { | 88 TEST(WebUIMessageHandlerTest, ExtractStringValue) { |
89 base::ListValue list; | 89 base::ListValue list; |
90 base::string16 in_string(UTF8ToUTF16( | 90 base::string16 in_string(UTF8ToUTF16( |
91 "The facts, though interesting, are irrelevant.")); | 91 "The facts, though interesting, are irrelevant.")); |
92 list.Append(new base::StringValue(in_string)); | 92 list.Append(new base::StringValue(in_string)); |
93 base::string16 out_string = WebUIMessageHandler::ExtractStringValue(&list); | 93 base::string16 out_string = WebUIMessageHandler::ExtractStringValue(&list); |
94 EXPECT_EQ(in_string, out_string); | 94 EXPECT_EQ(in_string, out_string); |
95 } | 95 } |
96 | 96 |
97 } // namespace content | 97 } // namespace content |
OLD | NEW |