1*635a8641SAndroid Build Coastguard Worker // Copyright (c) 2012 The Chromium Authors. All rights reserved. 2*635a8641SAndroid Build Coastguard Worker // Use of this source code is governed by a BSD-style license that can be 3*635a8641SAndroid Build Coastguard Worker // found in the LICENSE file. 4*635a8641SAndroid Build Coastguard Worker 5*635a8641SAndroid Build Coastguard Worker #ifndef BASE_TEST_VALUES_TEST_UTIL_H_ 6*635a8641SAndroid Build Coastguard Worker #define BASE_TEST_VALUES_TEST_UTIL_H_ 7*635a8641SAndroid Build Coastguard Worker 8*635a8641SAndroid Build Coastguard Worker #include <memory> 9*635a8641SAndroid Build Coastguard Worker #include <string> 10*635a8641SAndroid Build Coastguard Worker 11*635a8641SAndroid Build Coastguard Worker #include "base/strings/string_piece.h" 12*635a8641SAndroid Build Coastguard Worker 13*635a8641SAndroid Build Coastguard Worker namespace base { 14*635a8641SAndroid Build Coastguard Worker class DictionaryValue; 15*635a8641SAndroid Build Coastguard Worker class ListValue; 16*635a8641SAndroid Build Coastguard Worker class Value; 17*635a8641SAndroid Build Coastguard Worker 18*635a8641SAndroid Build Coastguard Worker // All the functions below expect that the value for the given key in 19*635a8641SAndroid Build Coastguard Worker // the given dictionary equals the given expected value. 20*635a8641SAndroid Build Coastguard Worker 21*635a8641SAndroid Build Coastguard Worker void ExpectDictBooleanValue(bool expected_value, 22*635a8641SAndroid Build Coastguard Worker const DictionaryValue& value, 23*635a8641SAndroid Build Coastguard Worker const std::string& key); 24*635a8641SAndroid Build Coastguard Worker 25*635a8641SAndroid Build Coastguard Worker void ExpectDictDictionaryValue(const DictionaryValue& expected_value, 26*635a8641SAndroid Build Coastguard Worker const DictionaryValue& value, 27*635a8641SAndroid Build Coastguard Worker const std::string& key); 28*635a8641SAndroid Build Coastguard Worker 29*635a8641SAndroid Build Coastguard Worker void ExpectDictIntegerValue(int expected_value, 30*635a8641SAndroid Build Coastguard Worker const DictionaryValue& value, 31*635a8641SAndroid Build Coastguard Worker const std::string& key); 32*635a8641SAndroid Build Coastguard Worker 33*635a8641SAndroid Build Coastguard Worker void ExpectDictListValue(const ListValue& expected_value, 34*635a8641SAndroid Build Coastguard Worker const DictionaryValue& value, 35*635a8641SAndroid Build Coastguard Worker const std::string& key); 36*635a8641SAndroid Build Coastguard Worker 37*635a8641SAndroid Build Coastguard Worker void ExpectDictStringValue(const std::string& expected_value, 38*635a8641SAndroid Build Coastguard Worker const DictionaryValue& value, 39*635a8641SAndroid Build Coastguard Worker const std::string& key); 40*635a8641SAndroid Build Coastguard Worker 41*635a8641SAndroid Build Coastguard Worker void ExpectStringValue(const std::string& expected_str, const Value& actual); 42*635a8641SAndroid Build Coastguard Worker 43*635a8641SAndroid Build Coastguard Worker namespace test { 44*635a8641SAndroid Build Coastguard Worker 45*635a8641SAndroid Build Coastguard Worker // Parses |json| as JSON, allowing trailing commas, and returns the 46*635a8641SAndroid Build Coastguard Worker // resulting value. If the json fails to parse, causes an EXPECT 47*635a8641SAndroid Build Coastguard Worker // failure and returns the Null Value (but never a NULL pointer). 48*635a8641SAndroid Build Coastguard Worker std::unique_ptr<Value> ParseJson(base::StringPiece json); 49*635a8641SAndroid Build Coastguard Worker 50*635a8641SAndroid Build Coastguard Worker } // namespace test 51*635a8641SAndroid Build Coastguard Worker } // namespace base 52*635a8641SAndroid Build Coastguard Worker 53*635a8641SAndroid Build Coastguard Worker #endif // BASE_TEST_VALUES_TEST_UTIL_H_ 54