| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 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/test/base/in_process_browser_test.h" | 10 #include "chrome/test/base/in_process_browser_test.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 base::Bind(&SafeJsonParserTest::ExpectValue, base::Unretained(this), | 47 base::Bind(&SafeJsonParserTest::ExpectValue, base::Unretained(this), |
| 48 base::Passed(&value)); | 48 base::Passed(&value)); |
| 49 error_callback = base::Bind(&SafeJsonParserTest::FailWithError, | 49 error_callback = base::Bind(&SafeJsonParserTest::FailWithError, |
| 50 base::Unretained(this)); | 50 base::Unretained(this)); |
| 51 } else { | 51 } else { |
| 52 success_callback = base::Bind(&SafeJsonParserTest::FailWithValue, | 52 success_callback = base::Bind(&SafeJsonParserTest::FailWithValue, |
| 53 base::Unretained(this)); | 53 base::Unretained(this)); |
| 54 error_callback = base::Bind(&SafeJsonParserTest::ExpectError, | 54 error_callback = base::Bind(&SafeJsonParserTest::ExpectError, |
| 55 base::Unretained(this), error); | 55 base::Unretained(this), error); |
| 56 } | 56 } |
| 57 scoped_refptr<SafeJsonParser> parser = | 57 SafeJsonParser* parser = |
| 58 new SafeJsonParser(json, success_callback, error_callback); | 58 SafeJsonParser::Create(json, success_callback, error_callback); |
| 59 parser->Start(); | 59 parser->Start(); |
| 60 | 60 |
| 61 message_loop_runner_->Run(); | 61 message_loop_runner_->Run(); |
| 62 message_loop_runner_ = nullptr; | 62 message_loop_runner_ = nullptr; |
| 63 } | 63 } |
| 64 | 64 |
| 65 private: | 65 private: |
| 66 void ExpectValue(scoped_ptr<base::Value> expected_value, | 66 void ExpectValue(scoped_ptr<base::Value> expected_value, |
| 67 scoped_ptr<base::Value> actual_value) { | 67 scoped_ptr<base::Value> actual_value) { |
| 68 EXPECT_TRUE(base::Value::Equals(actual_value.get(), expected_value.get())) | 68 EXPECT_TRUE(base::Value::Equals(actual_value.get(), expected_value.get())) |
| (...skipping 28 matching lines...) Expand all Loading... |
| 97 TestParse("\"laser\""); | 97 TestParse("\"laser\""); |
| 98 TestParse("false"); | 98 TestParse("false"); |
| 99 TestParse("null"); | 99 TestParse("null"); |
| 100 TestParse("3.14"); | 100 TestParse("3.14"); |
| 101 TestParse("["); | 101 TestParse("["); |
| 102 TestParse("\""); | 102 TestParse("\""); |
| 103 TestParse(std::string()); | 103 TestParse(std::string()); |
| 104 TestParse("☃"); | 104 TestParse("☃"); |
| 105 TestParse("\"☃\""); | 105 TestParse("\"☃\""); |
| 106 } | 106 } |
| OLD | NEW |