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

Unified Diff: chrome/browser/chromeos/printing/specifics_translation_unittest.cc

Issue 2884863002: Add an autoconf field to printer objects. (Closed)
Patch Set: more comments Created 3 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/printing/specifics_translation_unittest.cc
diff --git a/chrome/browser/chromeos/printing/specifics_translation_unittest.cc b/chrome/browser/chromeos/printing/specifics_translation_unittest.cc
index 23740c164f8cc6e37e373c750806c6c1887ab8fa..30d9738de85453fdbeb88c0a0f24a0bfba53f370 100644
--- a/chrome/browser/chromeos/printing/specifics_translation_unittest.cc
+++ b/chrome/browser/chromeos/printing/specifics_translation_unittest.cc
@@ -22,6 +22,7 @@ const char uri[] = "ipps://notaprinter.chromium.org/ipp/print";
const char uuid[] = "UUIDUUIDUUID";
const base::Time kUpdateTime = base::Time::FromInternalValue(22114455660000);
+const char kUserSuppliedPPD[] = "file://foo/bar/baz/eeaaaffccdd00";
const char effective_make_and_model[] = "Manufacturer Model T1000";
} // namespace
@@ -56,6 +57,7 @@ TEST(SpecificsTranslationTest, SpecificsToPrinter) {
EXPECT_EQ(effective_make_and_model,
result->ppd_reference().effective_make_and_model);
+ EXPECT_FALSE(result->IsIppEverywhere());
}
TEST(SpecificsTranslationTest, PrinterToSpecifics) {
@@ -97,7 +99,7 @@ TEST(SpecificsTranslationTest, SpecificsToPrinterRoundTrip) {
printer.set_uuid(uuid);
Printer::PpdReference ppd;
- ppd.effective_make_and_model = effective_make_and_model;
+ ppd.autoconf = true;
*printer.mutable_ppd_reference() = ppd;
std::unique_ptr<sync_pb::PrinterSpecifics> temp = PrinterToSpecifics(printer);
@@ -111,8 +113,58 @@ TEST(SpecificsTranslationTest, SpecificsToPrinterRoundTrip) {
EXPECT_EQ(uri, result->uri());
EXPECT_EQ(uuid, result->uuid());
+ EXPECT_TRUE(result->ppd_reference().effective_make_and_model.empty());
+ EXPECT_TRUE(result->ppd_reference().autoconf);
+}
+
+TEST(SpecificsTranslationTest, MergePrinterToSpecifics) {
+ sync_pb::PrinterSpecifics original;
+ original.set_id(id);
+ original.mutable_ppd_reference()->set_autoconf(true);
+
+ Printer printer(id);
+ printer.mutable_ppd_reference()->effective_make_and_model =
+ effective_make_and_model;
+
+ MergePrinterToSpecifics(printer, &original);
+
+ EXPECT_EQ(id, original.id());
EXPECT_EQ(effective_make_and_model,
- result->ppd_reference().effective_make_and_model);
+ original.ppd_reference().effective_make_and_model());
+
+ // Verify that autoconf is cleared.
+ EXPECT_FALSE(original.ppd_reference().autoconf());
+}
+
+// Tests that the autoconf value overwrites other PpdReference fields.
Carlson 2017/05/23 17:03:00 overrides is probably a little better word.
skau 2017/05/23 17:50:46 Done.
+TEST(SpecificsTranslationTest, AutoconfOverrides) {
+ sync_pb::PrinterSpecifics original;
+ original.set_id(id);
+ auto* ppd_reference = original.mutable_ppd_reference();
+ ppd_reference->set_autoconf(true);
+ ppd_reference->set_user_supplied_ppd_url(kUserSuppliedPPD);
+
+ auto printer = SpecificsToPrinter(original);
+
+ EXPECT_TRUE(printer->ppd_reference().autoconf);
+ EXPECT_TRUE(printer->ppd_reference().user_supplied_ppd_url.empty());
+ EXPECT_TRUE(printer->ppd_reference().effective_make_and_model.empty());
+}
+
+// Tests that user_supplied_ppd_url overwrites other PpdReference fields if
+// autoconf is false.
+TEST(SpecificsTranslationTest, UserSuppliedOverrides) {
+ sync_pb::PrinterSpecifics original;
+ original.set_id(id);
+ auto* ppd_reference = original.mutable_ppd_reference();
+ ppd_reference->set_user_supplied_ppd_url(kUserSuppliedPPD);
+ ppd_reference->set_effective_make_and_model(effective_make_and_model);
+
+ auto printer = SpecificsToPrinter(original);
+
+ EXPECT_FALSE(printer->ppd_reference().autoconf);
+ EXPECT_FALSE(printer->ppd_reference().user_supplied_ppd_url.empty());
+ EXPECT_TRUE(printer->ppd_reference().effective_make_and_model.empty());
}
} // namespace printing
« no previous file with comments | « chrome/browser/chromeos/printing/specifics_translation.cc ('k') | chromeos/printing/printer_configuration.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698