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

Side by Side Diff: components/cloud_devices/common/printer_description_unittest.cc

Issue 1131113004: Convert JsonWriter::Write to taking a const ref for the in-param (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: another rebase Created 5 years, 7 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 "components/cloud_devices/common/printer_description.h" 5 #include "components/cloud_devices/common/printer_description.h"
6 6
7 #include "base/json/json_reader.h" 7 #include "base/json/json_reader.h"
8 #include "base/json/json_writer.h" 8 #include "base/json/json_writer.h"
9 #include "base/strings/string_util.h" 9 #include "base/strings/string_util.h"
10 #include "base/values.h" 10 #include "base/values.h"
11 #include "testing/gtest/include/gtest/gtest.h" 11 #include "testing/gtest/include/gtest/gtest.h"
12 12
13 namespace cloud_devices { 13 namespace cloud_devices {
14 14
15 namespace printer { 15 namespace printer {
16 16
17 // Replaces ' with " to allow readable json constants in tests. 17 // Replaces ' with " to allow readable json constants in tests.
18 // Makes sure that same json value represented by same strings to simplify 18 // Makes sure that same json value represented by same strings to simplify
19 // comparison. 19 // comparison.
20 std::string NormalizeJson(const std::string& json) { 20 std::string NormalizeJson(const std::string& json) {
21 std::string result = json; 21 std::string result = json;
22 base::ReplaceChars(result, "'", "\"", &result); 22 base::ReplaceChars(result, "'", "\"", &result);
23 scoped_ptr<base::Value> value(base::JSONReader::Read(result)); 23 scoped_ptr<base::Value> value(base::JSONReader::Read(result));
24 DCHECK(value); 24 DCHECK(value);
25 base::JSONWriter::Write(value.get(), &result); 25 base::JSONWriter::Write(*value, &result);
26 return result; 26 return result;
27 } 27 }
28 28
29 const char kCdd[] = 29 const char kCdd[] =
30 "{" 30 "{"
31 " 'version': '1.0'," 31 " 'version': '1.0',"
32 " 'printer': {" 32 " 'printer': {"
33 " 'supported_content_type': [ {" 33 " 'supported_content_type': [ {"
34 " 'content_type': 'image/pwg-raster'" 34 " 'content_type': 'image/pwg-raster'"
35 " }, {" 35 " }, {"
(...skipping 574 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 EXPECT_EQ(media.value(), Media(ISO_C7C6, 4261, 334)); 610 EXPECT_EQ(media.value(), Media(ISO_C7C6, 4261, 334));
611 EXPECT_FALSE(collate.value()); 611 EXPECT_FALSE(collate.value());
612 EXPECT_TRUE(reverse.value()); 612 EXPECT_TRUE(reverse.value());
613 613
614 EXPECT_EQ(NormalizeJson(kCjt), NormalizeJson(description.ToString())); 614 EXPECT_EQ(NormalizeJson(kCjt), NormalizeJson(description.ToString()));
615 } 615 }
616 616
617 } // namespace printer 617 } // namespace printer
618 618
619 } // namespace cloud_devices 619 } // namespace cloud_devices
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698