| 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 "components/cloud_devices/common/printer_description.h" | 5 #include "components/cloud_devices/common/printer_description.h" |
| 6 | 6 |
| 7 #include <memory> |
| 8 |
| 7 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
| 8 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| 9 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 10 #include "base/values.h" | 12 #include "base/values.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 12 | 14 |
| 13 namespace cloud_devices { | 15 namespace cloud_devices { |
| 14 | 16 |
| 15 namespace printer { | 17 namespace printer { |
| 16 | 18 |
| 17 // Replaces ' with " to allow readable json constants in tests. | 19 // Replaces ' with " to allow readable json constants in tests. |
| 18 // Makes sure that same json value represented by same strings to simplify | 20 // Makes sure that same json value represented by same strings to simplify |
| 19 // comparison. | 21 // comparison. |
| 20 std::string NormalizeJson(const std::string& json) { | 22 std::string NormalizeJson(const std::string& json) { |
| 21 std::string result = json; | 23 std::string result = json; |
| 22 base::ReplaceChars(result, "'", "\"", &result); | 24 base::ReplaceChars(result, "'", "\"", &result); |
| 23 scoped_ptr<base::Value> value = base::JSONReader::Read(result); | 25 std::unique_ptr<base::Value> value = base::JSONReader::Read(result); |
| 24 DCHECK(value); | 26 DCHECK(value); |
| 25 base::JSONWriter::Write(*value, &result); | 27 base::JSONWriter::Write(*value, &result); |
| 26 return result; | 28 return result; |
| 27 } | 29 } |
| 28 | 30 |
| 29 const char kCdd[] = | 31 const char kCdd[] = |
| 30 "{" | 32 "{" |
| 31 " 'version': '1.0'," | 33 " 'version': '1.0'," |
| 32 " 'printer': {" | 34 " 'printer': {" |
| 33 " 'supported_content_type': [ {" | 35 " 'supported_content_type': [ {" |
| (...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 610 EXPECT_EQ(media.value(), Media(ISO_C7C6, 4261, 334)); | 612 EXPECT_EQ(media.value(), Media(ISO_C7C6, 4261, 334)); |
| 611 EXPECT_FALSE(collate.value()); | 613 EXPECT_FALSE(collate.value()); |
| 612 EXPECT_TRUE(reverse.value()); | 614 EXPECT_TRUE(reverse.value()); |
| 613 | 615 |
| 614 EXPECT_EQ(NormalizeJson(kCjt), NormalizeJson(description.ToString())); | 616 EXPECT_EQ(NormalizeJson(kCjt), NormalizeJson(description.ToString())); |
| 615 } | 617 } |
| 616 | 618 |
| 617 } // namespace printer | 619 } // namespace printer |
| 618 | 620 |
| 619 } // namespace cloud_devices | 621 } // namespace cloud_devices |
| OLD | NEW |