Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: chrome/browser/safe_json_parser_browsertest.cc

Issue 1214903010: Make JSONParser a pure interface. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: review Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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::Parse(json, success_callback, error_callback);
58 new SafeJsonParser(json, success_callback, error_callback);
59 parser->Start();
60 58
61 message_loop_runner_->Run(); 59 message_loop_runner_->Run();
62 message_loop_runner_ = nullptr; 60 message_loop_runner_ = nullptr;
63 } 61 }
64 62
65 private: 63 private:
66 void ExpectValue(scoped_ptr<base::Value> expected_value, 64 void ExpectValue(scoped_ptr<base::Value> expected_value,
67 scoped_ptr<base::Value> actual_value) { 65 scoped_ptr<base::Value> actual_value) {
68 EXPECT_TRUE(base::Value::Equals(actual_value.get(), expected_value.get())) 66 EXPECT_TRUE(base::Value::Equals(actual_value.get(), expected_value.get()))
69 << "Expected: " << MaybeToJson(expected_value.get()) 67 << "Expected: " << MaybeToJson(expected_value.get())
(...skipping 27 matching lines...) Expand all
97 TestParse("\"laser\""); 95 TestParse("\"laser\"");
98 TestParse("false"); 96 TestParse("false");
99 TestParse("null"); 97 TestParse("null");
100 TestParse("3.14"); 98 TestParse("3.14");
101 TestParse("["); 99 TestParse("[");
102 TestParse("\""); 100 TestParse("\"");
103 TestParse(std::string()); 101 TestParse(std::string());
104 TestParse("☃"); 102 TestParse("☃");
105 TestParse("\"☃\""); 103 TestParse("\"☃\"");
106 } 104 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698