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 #ifndef BASE_TEST_VALUES_TEST_UTIL_H_ 6 #define BASE_TEST_VALUES_TEST_UTIL_H_ 7 8 #include <memory> 9 #include <string> 10 11 #include "base/strings/string_piece.h" 12 13 namespace base { 14 class DictionaryValue; 15 class ListValue; 16 class Value; 17 18 // All the functions below expect that the value for the given key in 19 // the given dictionary equals the given expected value. 20 21 void ExpectDictBooleanValue(bool expected_value, 22 const DictionaryValue& value, 23 const std::string& key); 24 25 void ExpectDictDictionaryValue(const DictionaryValue& expected_value, 26 const DictionaryValue& value, 27 const std::string& key); 28 29 void ExpectDictIntegerValue(int expected_value, 30 const DictionaryValue& value, 31 const std::string& key); 32 33 void ExpectDictListValue(const ListValue& expected_value, 34 const DictionaryValue& value, 35 const std::string& key); 36 37 void ExpectDictStringValue(const std::string& expected_value, 38 const DictionaryValue& value, 39 const std::string& key); 40 41 void ExpectStringValue(const std::string& expected_str, const Value& actual); 42 43 namespace test { 44 45 // Parses |json| as JSON, allowing trailing commas, and returns the 46 // resulting value. If the json fails to parse, causes an EXPECT 47 // failure and returns the Null Value (but never a NULL pointer). 48 std::unique_ptr<Value> ParseJson(base::StringPiece json); 49 50 } // namespace test 51 } // namespace base 52 53 #endif // BASE_TEST_VALUES_TEST_UTIL_H_ 54