| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2011 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/test/values_test_util.h" | |
| 6 | |
| 7 #include "base/memory/scoped_ptr.h" | |
| 8 #include "base/string_number_conversions.h" | |
| 9 #include "base/values.h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | |
| 11 | |
| 12 namespace test { | |
| 13 | |
| 14 void ExpectDictBooleanValue(bool expected_value, | |
| 15 const DictionaryValue& value, | |
| 16 const std::string& key) { | |
| 17 bool boolean_value = false; | |
| 18 EXPECT_TRUE(value.GetBoolean(key, &boolean_value)) << key; | |
| 19 EXPECT_EQ(expected_value, boolean_value) << key; | |
| 20 } | |
| 21 | |
| 22 void ExpectDictDictionaryValue(const DictionaryValue& expected_value, | |
| 23 const DictionaryValue& value, | |
| 24 const std::string& key) { | |
| 25 DictionaryValue* dict_value = NULL; | |
| 26 EXPECT_TRUE(value.GetDictionary(key, &dict_value)) << key; | |
| 27 EXPECT_TRUE(Value::Equals(dict_value, &expected_value)) << key; | |
| 28 } | |
| 29 | |
| 30 void ExpectDictIntegerValue(int expected_value, | |
| 31 const DictionaryValue& value, | |
| 32 const std::string& key) { | |
| 33 int integer_value = 0; | |
| 34 EXPECT_TRUE(value.GetInteger(key, &integer_value)) << key; | |
| 35 EXPECT_EQ(expected_value, integer_value) << key; | |
| 36 } | |
| 37 | |
| 38 void ExpectDictListValue(const ListValue& expected_value, | |
| 39 const DictionaryValue& value, | |
| 40 const std::string& key) { | |
| 41 ListValue* list_value = NULL; | |
| 42 EXPECT_TRUE(value.GetList(key, &list_value)) << key; | |
| 43 EXPECT_TRUE(Value::Equals(list_value, &expected_value)) << key; | |
| 44 } | |
| 45 | |
| 46 void ExpectDictStringValue(const std::string& expected_value, | |
| 47 const DictionaryValue& value, | |
| 48 const std::string& key) { | |
| 49 std::string string_value; | |
| 50 EXPECT_TRUE(value.GetString(key, &string_value)) << key; | |
| 51 EXPECT_EQ(expected_value, string_value) << key; | |
| 52 } | |
| 53 | |
| 54 void ExpectStringValue(const std::string& expected_str, | |
| 55 StringValue* actual) { | |
| 56 scoped_ptr<StringValue> scoped_actual(actual); | |
| 57 std::string actual_str; | |
| 58 EXPECT_TRUE(scoped_actual->GetAsString(&actual_str)); | |
| 59 EXPECT_EQ(expected_str, actual_str); | |
| 60 } | |
| 61 | |
| 62 } // namespace test | |
| OLD | NEW |