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

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

Issue 2618313004: [CUPS] Implement the enterprise icon for printers in Print Preview Dialog. (Closed)
Patch Set: Address dpapad@'s comments. Created 3 years, 11 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 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 "chrome/browser/chromeos/printing/printer_pref_manager.h" 5 #include "chrome/browser/chromeos/printing/printer_pref_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 29 matching lines...) Expand all
40 content::TestBrowserThreadBundle thread_bundle; 40 content::TestBrowserThreadBundle thread_bundle;
41 auto profile = base::MakeUnique<TestingProfile>(); 41 auto profile = base::MakeUnique<TestingProfile>();
42 PrinterPrefManager* manager = 42 PrinterPrefManager* manager =
43 PrinterPrefManagerFactory::GetForBrowserContext(profile.get()); 43 PrinterPrefManagerFactory::GetForBrowserContext(profile.get());
44 44
45 manager->RegisterPrinter(base::MakeUnique<Printer>(kPrinterId)); 45 manager->RegisterPrinter(base::MakeUnique<Printer>(kPrinterId));
46 46
47 auto printers = manager->GetPrinters(); 47 auto printers = manager->GetPrinters();
48 ASSERT_EQ(1U, printers.size()); 48 ASSERT_EQ(1U, printers.size());
49 EXPECT_EQ(kPrinterId, printers[0]->id()); 49 EXPECT_EQ(kPrinterId, printers[0]->id());
50 EXPECT_EQ(Printer::Source::SRC_USER_PREFS, printers[0]->source());
50 } 51 }
51 52
52 TEST(PrinterPrefManagerTest, UpdatePrinterAssignsId) { 53 TEST(PrinterPrefManagerTest, UpdatePrinterAssignsId) {
53 content::TestBrowserThreadBundle thread_bundle; 54 content::TestBrowserThreadBundle thread_bundle;
54 auto profile = base::MakeUnique<TestingProfile>(); 55 auto profile = base::MakeUnique<TestingProfile>();
55 PrinterPrefManager* manager = 56 PrinterPrefManager* manager =
56 PrinterPrefManagerFactory::GetForBrowserContext(profile.get()); 57 PrinterPrefManagerFactory::GetForBrowserContext(profile.get());
57 58
58 manager->RegisterPrinter(base::MakeUnique<Printer>()); 59 manager->RegisterPrinter(base::MakeUnique<Printer>());
59 60
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 // TestingPrefSyncableService assumes ownership of |value|. 126 // TestingPrefSyncableService assumes ownership of |value|.
126 prefs->SetManagedPref(prefs::kRecommendedNativePrinters, value.release()); 127 prefs->SetManagedPref(prefs::kRecommendedNativePrinters, value.release());
127 128
128 PrinterPrefManager* manager = 129 PrinterPrefManager* manager =
129 PrinterPrefManagerFactory::GetForBrowserContext(&profile); 130 PrinterPrefManagerFactory::GetForBrowserContext(&profile);
130 131
131 auto printers = manager->GetRecommendedPrinters(); 132 auto printers = manager->GetRecommendedPrinters();
132 ASSERT_EQ(2U, printers.size()); 133 ASSERT_EQ(2U, printers.size());
133 EXPECT_EQ("Color Laser", printers[0]->display_name()); 134 EXPECT_EQ("Color Laser", printers[0]->display_name());
134 EXPECT_EQ("ipp://192.168.1.5", printers[1]->uri()); 135 EXPECT_EQ("ipp://192.168.1.5", printers[1]->uri());
136 EXPECT_EQ(Printer::Source::SRC_POLICY, printers[1]->source());
135 } 137 }
136 138
137 TEST(PrinterPrefManagerTest, GetRecommendedPrinter) { 139 TEST(PrinterPrefManagerTest, GetRecommendedPrinter) {
138 content::TestBrowserThreadBundle thread_bundle; 140 content::TestBrowserThreadBundle thread_bundle;
139 141
140 std::string printer = kLexJson; 142 std::string printer = kLexJson;
141 auto value = base::MakeUnique<base::ListValue>(); 143 auto value = base::MakeUnique<base::ListValue>();
142 value->AppendString(printer); 144 value->AppendString(printer);
143 145
144 TestingProfile profile; 146 TestingProfile profile;
145 sync_preferences::TestingPrefServiceSyncable* prefs = 147 sync_preferences::TestingPrefServiceSyncable* prefs =
146 profile.GetTestingPrefService(); 148 profile.GetTestingPrefService();
147 // TestingPrefSyncableService assumes ownership of |value|. 149 // TestingPrefSyncableService assumes ownership of |value|.
148 prefs->SetManagedPref(prefs::kRecommendedNativePrinters, value.release()); 150 prefs->SetManagedPref(prefs::kRecommendedNativePrinters, value.release());
149 151
150 PrinterPrefManager* manager = 152 PrinterPrefManager* manager =
151 PrinterPrefManagerFactory::GetForBrowserContext(&profile); 153 PrinterPrefManagerFactory::GetForBrowserContext(&profile);
152 154
153 auto printers = manager->GetRecommendedPrinters(); 155 auto printers = manager->GetRecommendedPrinters();
154 156
155 const Printer& from_list = *(printers.front()); 157 const Printer& from_list = *(printers.front());
156 std::unique_ptr<Printer> retrieved = manager->GetPrinter(from_list.id()); 158 std::unique_ptr<Printer> retrieved = manager->GetPrinter(from_list.id());
157 159
158 EXPECT_EQ(from_list.id(), retrieved->id()); 160 EXPECT_EQ(from_list.id(), retrieved->id());
159 EXPECT_EQ("LexaPrint", from_list.display_name()); 161 EXPECT_EQ("LexaPrint", from_list.display_name());
160 EXPECT_EQ(Printer::Source::SRC_POLICY, from_list.source()); 162 EXPECT_EQ(Printer::Source::SRC_POLICY, from_list.source());
161 } 163 }
162 164
163 } // namespace chromeos 165 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/browser_resources.grd ('k') | chrome/browser/resources/print_preview/data/destination.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698