| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
| 8 #include "base/test/values_test_util.h" | 8 #include "base/test/values_test_util.h" |
| 9 #include "base/values.h" | 9 #include "base/values.h" |
| 10 #include "chromeos/printing/printer_configuration.h" | 10 #include "chromeos/printing/printer_configuration.h" |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 97 // Make sure we don't serialize empty fields. | 97 // Make sure we don't serialize empty fields. |
| 98 TEST(PrinterTranslatorTest, PrinterToPrefPpdReferenceLazy) { | 98 TEST(PrinterTranslatorTest, PrinterToPrefPpdReferenceLazy) { |
| 99 Printer printer("UNIQUE_ID"); | 99 Printer printer("UNIQUE_ID"); |
| 100 std::unique_ptr<base::DictionaryValue> actual = PrinterToPref(printer); | 100 std::unique_ptr<base::DictionaryValue> actual = PrinterToPref(printer); |
| 101 | 101 |
| 102 EXPECT_FALSE(actual->HasKey("ppd_reference.user_supplied_ppd_url")); | 102 EXPECT_FALSE(actual->HasKey("ppd_reference.user_supplied_ppd_url")); |
| 103 EXPECT_FALSE(actual->HasKey("ppd_reference.effective_manufacturer")); | 103 EXPECT_FALSE(actual->HasKey("ppd_reference.effective_manufacturer")); |
| 104 EXPECT_FALSE(actual->HasKey("ppd_reference.effective_model")); | 104 EXPECT_FALSE(actual->HasKey("ppd_reference.effective_model")); |
| 105 } | 105 } |
| 106 | 106 |
| 107 // FIXME add a test that we don't set fields that are empty. | |
| 108 | |
| 109 TEST(PrinterTranslatorTest, PrefToPrinterRoundTrip) { | 107 TEST(PrinterTranslatorTest, PrefToPrinterRoundTrip) { |
| 110 base::DictionaryValue preference; | 108 base::DictionaryValue preference; |
| 111 preference.SetString("id", kGUID); | 109 preference.SetString("id", kGUID); |
| 112 preference.SetString("display_name", kName); | 110 preference.SetString("display_name", kName); |
| 113 preference.SetString("description", kDescription); | 111 preference.SetString("description", kDescription); |
| 114 preference.SetString("manufacturer", kMake); | 112 preference.SetString("manufacturer", kMake); |
| 115 preference.SetString("model", kModel); | 113 preference.SetString("model", kModel); |
| 116 preference.SetString("uri", kUri); | 114 preference.SetString("uri", kUri); |
| 117 preference.SetString("uuid", kUUID); | 115 preference.SetString("uuid", kUUID); |
| 118 | 116 |
| 119 preference.SetString("ppd_reference.user_supplied_ppd_url", | 117 preference.SetString("ppd_reference.user_supplied_ppd_url", |
| 120 kUserSuppliedPpdUrl); | 118 kUserSuppliedPpdUrl); |
| 121 preference.SetString("ppd_reference.effective_manufacturer", | 119 preference.SetString("ppd_reference.effective_manufacturer", |
| 122 kEffectiveManufacturer); | 120 kEffectiveManufacturer); |
| 123 preference.SetString("ppd_reference.effective_model", kEffectiveModel); | 121 preference.SetString("ppd_reference.effective_model", kEffectiveModel); |
| 124 | 122 |
| 125 std::unique_ptr<Printer> printer = PrefToPrinter(preference); | 123 std::unique_ptr<Printer> printer = PrefToPrinter(preference); |
| 126 std::unique_ptr<base::DictionaryValue> pref_copy = PrinterToPref(*printer); | 124 std::unique_ptr<base::DictionaryValue> pref_copy = PrinterToPref(*printer); |
| 127 | 125 |
| 128 EXPECT_TRUE(preference.Equals(pref_copy.get())); | 126 EXPECT_TRUE(preference.Equals(pref_copy.get())); |
| 129 } | 127 } |
| 130 | 128 |
| 131 } // namespace printing | 129 } // namespace printing |
| 132 } // namespace chromeos | 130 } // namespace chromeos |
| OLD | NEW |