Alex Vakulenko | 6201d2d | 2014-07-16 14:46:48 -0700 | [diff] [blame] | 1 | // Copyright 2014 The Chromium OS 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 BUFFET_COMMANDS_UNITTEST_UTILS_H_ |
| 6 | #define BUFFET_COMMANDS_UNITTEST_UTILS_H_ |
| 7 | |
| 8 | #include <memory> |
| 9 | #include <string> |
| 10 | |
| 11 | #include <base/values.h> |
| 12 | |
| 13 | namespace buffet { |
| 14 | namespace unittests { |
| 15 | |
| 16 | // Helper method to create base::Value from a string as a smart pointer. |
| 17 | // For ease of definition in C++ code, double-quotes in the source definition |
| 18 | // are replaced with apostrophes. |
Alex Vakulenko | 7c36b67 | 2014-07-16 14:50:58 -0700 | [diff] [blame] | 19 | std::unique_ptr<base::Value> CreateValue(const char* json); |
Alex Vakulenko | 6201d2d | 2014-07-16 14:46:48 -0700 | [diff] [blame] | 20 | |
| 21 | // Helper method to create a JSON dictionary object from a string. |
| 22 | std::unique_ptr<base::DictionaryValue> CreateDictionaryValue(const char* json); |
| 23 | |
| 24 | // Converts a JSON value to a string. It also converts double-quotes to |
| 25 | // apostrophes for easy comparisons in C++ source code. |
| 26 | std::string ValueToString(const base::Value* value); |
| 27 | |
| 28 | } // namespace unittests |
| 29 | } // namespace buffet |
| 30 | |
| 31 | #endif // BUFFET_COMMANDS_UNITTEST_UTILS_H_ |