Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
|
Robert Sesek
2015/05/14 20:12:33
Shouldn't this move to components_browsertests ?
Eran Messeri
2015/05/15 12:52:40
I've tried this, but that test requires that the h
| |
| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/json/json_reader.h" | 6 #include "base/json/json_reader.h" |
| 7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
| 8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chrome/browser/safe_json_parser.h" | |
| 11 #include "chrome/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| 11 #include "components/safe_json_parser/safe_json_parser.h" | |
| 12 #include "content/public/test/test_browser_thread_bundle.h" | 12 #include "content/public/test/test_browser_thread_bundle.h" |
| 13 #include "content/public/test/test_utils.h" | 13 #include "content/public/test/test_utils.h" |
| 14 | 14 |
| 15 namespace { | 15 namespace { |
| 16 | 16 |
| 17 using safe_json_parser::SafeJsonParser; | |
| 18 | |
| 17 std::string MaybeToJson(const base::Value* value) { | 19 std::string MaybeToJson(const base::Value* value) { |
| 18 if (!value) | 20 if (!value) |
| 19 return "(null)"; | 21 return "(null)"; |
| 20 | 22 |
| 21 std::string json; | 23 std::string json; |
| 22 if (!base::JSONWriter::Write(value, &json)) | 24 if (!base::JSONWriter::Write(value, &json)) |
| 23 return "(invalid value)"; | 25 return "(invalid value)"; |
| 24 | 26 |
| 25 return json; | 27 return json; |
| 26 } | 28 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 95 TestParse("\"laser\""); | 97 TestParse("\"laser\""); |
| 96 TestParse("false"); | 98 TestParse("false"); |
| 97 TestParse("null"); | 99 TestParse("null"); |
| 98 TestParse("3.14"); | 100 TestParse("3.14"); |
| 99 TestParse("["); | 101 TestParse("["); |
| 100 TestParse("\""); | 102 TestParse("\""); |
| 101 TestParse(std::string()); | 103 TestParse(std::string()); |
| 102 TestParse("☃"); | 104 TestParse("☃"); |
| 103 TestParse("\"☃\""); | 105 TestParse("\"☃\""); |
| 104 } | 106 } |
| OLD | NEW |