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

Side by Side Diff: chrome/browser/chromeos/printing/specifics_translation_unittest.cc

Issue 2858353004: Track printer installations for each configuration. (Closed)
Patch Set: rebase 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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/time/time.h"
8 #include "chrome/browser/chromeos/printing/specifics_translation.h" 9 #include "chrome/browser/chromeos/printing/specifics_translation.h"
9 #include "chromeos/printing/printer_configuration.h" 10 #include "chromeos/printing/printer_configuration.h"
10 #include "components/sync/protocol/printer_specifics.pb.h" 11 #include "components/sync/protocol/printer_specifics.pb.h"
11 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
12 13
13 namespace { 14 namespace {
14 15
15 const char id[] = "UNIQUE_ID"; 16 const char id[] = "UNIQUE_ID";
16 const char display_name[] = "Best Printer Ever"; 17 const char display_name[] = "Best Printer Ever";
17 const char description[] = "The green one"; 18 const char description[] = "The green one";
18 const char manufacturer[] = "Manufacturer"; 19 const char manufacturer[] = "Manufacturer";
19 const char model[] = "MODEL"; 20 const char model[] = "MODEL";
20 const char uri[] = "ipps://notaprinter.chromium.org/ipp/print"; 21 const char uri[] = "ipps://notaprinter.chromium.org/ipp/print";
21 const char uuid[] = "UUIDUUIDUUID"; 22 const char uuid[] = "UUIDUUIDUUID";
23 const base::Time kUpdateTime = base::Time::FromInternalValue(22114455660000);
22 24
23 const char effective_make_and_model[] = "Manufacturer Model T1000"; 25 const char effective_make_and_model[] = "Manufacturer Model T1000";
24 26
25 } // namespace 27 } // namespace
26 28
27 namespace chromeos { 29 namespace chromeos {
28 namespace printing { 30 namespace printing {
29 31
30 TEST(SpecificsTranslationTest, SpecificsToPrinter) { 32 TEST(SpecificsTranslationTest, SpecificsToPrinter) {
31 sync_pb::PrinterSpecifics specifics; 33 sync_pb::PrinterSpecifics specifics;
32 specifics.set_id(id); 34 specifics.set_id(id);
33 specifics.set_display_name(display_name); 35 specifics.set_display_name(display_name);
34 specifics.set_description(description); 36 specifics.set_description(description);
35 specifics.set_manufacturer(manufacturer); 37 specifics.set_manufacturer(manufacturer);
36 specifics.set_model(model); 38 specifics.set_model(model);
37 specifics.set_uri(uri); 39 specifics.set_uri(uri);
38 specifics.set_uuid(uuid); 40 specifics.set_uuid(uuid);
41 specifics.set_updated_timestamp(kUpdateTime.ToJavaTime());
39 42
40 sync_pb::PrinterPPDReference ppd; 43 sync_pb::PrinterPPDReference ppd;
41 ppd.set_effective_make_and_model(effective_make_and_model); 44 ppd.set_effective_make_and_model(effective_make_and_model);
42 *specifics.mutable_ppd_reference() = ppd; 45 *specifics.mutable_ppd_reference() = ppd;
43 46
44 std::unique_ptr<Printer> result = SpecificsToPrinter(specifics); 47 std::unique_ptr<Printer> result = SpecificsToPrinter(specifics);
45 EXPECT_EQ(id, result->id()); 48 EXPECT_EQ(id, result->id());
46 EXPECT_EQ(display_name, result->display_name()); 49 EXPECT_EQ(display_name, result->display_name());
47 EXPECT_EQ(description, result->description()); 50 EXPECT_EQ(description, result->description());
48 EXPECT_EQ(manufacturer, result->manufacturer()); 51 EXPECT_EQ(manufacturer, result->manufacturer());
49 EXPECT_EQ(model, result->model()); 52 EXPECT_EQ(model, result->model());
50 EXPECT_EQ(uri, result->uri()); 53 EXPECT_EQ(uri, result->uri());
51 EXPECT_EQ(uuid, result->uuid()); 54 EXPECT_EQ(uuid, result->uuid());
55 EXPECT_EQ(kUpdateTime, result->last_updated());
52 56
53 EXPECT_EQ(effective_make_and_model, 57 EXPECT_EQ(effective_make_and_model,
54 result->ppd_reference().effective_make_and_model); 58 result->ppd_reference().effective_make_and_model);
55 } 59 }
56 60
57 TEST(SpecificsTranslationTest, PrinterToSpecifics) { 61 TEST(SpecificsTranslationTest, PrinterToSpecifics) {
58 Printer printer; 62 Printer printer;
59 printer.set_id(id); 63 printer.set_id(id);
60 printer.set_display_name(display_name); 64 printer.set_display_name(display_name);
61 printer.set_description(description); 65 printer.set_description(description);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
106 EXPECT_EQ(model, result->model()); 110 EXPECT_EQ(model, result->model());
107 EXPECT_EQ(uri, result->uri()); 111 EXPECT_EQ(uri, result->uri());
108 EXPECT_EQ(uuid, result->uuid()); 112 EXPECT_EQ(uuid, result->uuid());
109 113
110 EXPECT_EQ(effective_make_and_model, 114 EXPECT_EQ(effective_make_and_model,
111 result->ppd_reference().effective_make_and_model); 115 result->ppd_reference().effective_make_and_model);
112 } 116 }
113 117
114 } // namespace printing 118 } // namespace printing
115 } // namespace chromeos 119 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698