OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/safe_json/testing_json_parser.h" | 5 #include "components/safe_json/testing_json_parser.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 22 matching lines...) Expand all Loading... |
33 bool did_success() { return did_success_; } | 33 bool did_success() { return did_success_; } |
34 bool did_error() { return did_error_; } | 34 bool did_error() { return did_error_; } |
35 | 35 |
36 private: | 36 private: |
37 static void SuccessCallback(TestingJsonParserTest* test, | 37 static void SuccessCallback(TestingJsonParserTest* test, |
38 base::Closure quit_closure, | 38 base::Closure quit_closure, |
39 std::unique_ptr<base::Value> value) { | 39 std::unique_ptr<base::Value> value) { |
40 test->did_success_ = true; | 40 test->did_success_ = true; |
41 quit_closure.Run(); | 41 quit_closure.Run(); |
42 | 42 |
43 ASSERT_TRUE(value->IsType(base::Value::TYPE_DICTIONARY)); | 43 ASSERT_TRUE(value->IsType(base::Value::Type::DICTIONARY)); |
44 base::DictionaryValue* dict; | 44 base::DictionaryValue* dict; |
45 ASSERT_TRUE(value->GetAsDictionary(&dict)); | 45 ASSERT_TRUE(value->GetAsDictionary(&dict)); |
46 int key_value = 0; | 46 int key_value = 0; |
47 EXPECT_TRUE(dict->GetInteger("key", &key_value)); | 47 EXPECT_TRUE(dict->GetInteger("key", &key_value)); |
48 EXPECT_EQ(2, key_value); | 48 EXPECT_EQ(2, key_value); |
49 } | 49 } |
50 | 50 |
51 static void ErrorCallback(TestingJsonParserTest* test, | 51 static void ErrorCallback(TestingJsonParserTest* test, |
52 base::Closure quit_closure, | 52 base::Closure quit_closure, |
53 const std::string& error) { | 53 const std::string& error) { |
(...skipping 16 matching lines...) Expand all Loading... |
70 } | 70 } |
71 | 71 |
72 TEST_F(TestingJsonParserTest, QuitLoopInErrorCallback) { | 72 TEST_F(TestingJsonParserTest, QuitLoopInErrorCallback) { |
73 Parse(&kTestJson[1]); | 73 Parse(&kTestJson[1]); |
74 EXPECT_FALSE(did_success()); | 74 EXPECT_FALSE(did_success()); |
75 EXPECT_TRUE(did_error()); | 75 EXPECT_TRUE(did_error()); |
76 } | 76 } |
77 | 77 |
78 } // namespace | 78 } // namespace |
79 } // namespace safe_json | 79 } // namespace safe_json |
OLD | NEW |